Skip to content

Instantly share code, notes, and snippets.

View KhaledElshamy's full-sized avatar

Khaled Elshamy KhaledElshamy

View GitHub Profile
@KhaledElshamy
KhaledElshamy / B. Easter Eggs-codeforces
Created January 19, 2017 18:37
B. Easter Eggs-codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
string a="GBIV"; string b; int n;
cin>>n;
if (n<7)
cout<<"Wrong!";
else cout<<"ROYGBIV";
n=n-7;
@KhaledElshamy
KhaledElshamy / B. Effective Approach-codeforces
Created January 19, 2017 15:45
B. Effective Approach-codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, index1[100001];
cin>>n;
for (int i = 1; i <= n; ++i)
{
cin>>a;
index1[a] = i;
@KhaledElshamy
KhaledElshamy / B. Sum of Digits-codeforces
Created January 19, 2017 12:25
B. Sum of Digits-codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
char digits[100001];
cin>>digits;
int times=0;
if (digits[1] != 0)
{
int digitsum=0;
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m;
unsigned long long count1=0;
unsigned long long count2=0;
cin>>n>>m;
vector< vector<int> >container(m,vector<int>(2));
for(int i=0;i<m;i++)
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,in;
cin>>n>>in;
int a[n];
for (int i=1;i<=n;i++)
cin>>a[i];
int ans=0;
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
int num;
cin>>num;
char a[num];
for(int i=0;i<num;i++)
cin>>a[i];
int allin=count(a,a+num,'A');
@KhaledElshamy
KhaledElshamy / B. Petya and Countryside
Last active January 18, 2017 10:49
B. Petya and Countryside/codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main() {
int num,y=0,x,count1=0,count2=0;
cin>>num;
int a[num];
for(int i=0;i<num;i++)
cin>>a[i];
for(int i=0;i<num;i++)
@KhaledElshamy
KhaledElshamy / Noel's Labels
Created December 20, 2016 00:38
Noel's Labels problem (CONTEST DE NATAL 2016) at URI Online Judge
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int num1,num2;
string line1,line2;
cin>>num1;
vector<string>lang(num1), k1(num1);
for(int i=0;i<num1;i++)
@KhaledElshamy
KhaledElshamy / Check brackets in the code Check brackets in the code (Data Structures course at coursera)
Last active July 8, 2022 10:29
Problem: Check brackets in the code (Data Structures course at coursera)
#include <bits/stdc++.h>
using namespace std;
int main()
{
string str1;
int index=0,balance=true,a;
char top;
cin>>str1;
stack<char>s1;
while(index<str1.length())
@KhaledElshamy
KhaledElshamy / Take as much gold as possible (Dynamic programming)
Created November 28, 2016 15:46
Take as much gold as possible (Dynamic programming) algorithmic toolbox course at coursera
#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) { return (a > b)? a : b; }
int knapSack(int W, int wt[], int n)
{
int i, w;
int K[n+1][W+1];
for (i = 0; i <= n; i++)
{
for (w = 0; w <= W; w++)