akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
//#define int ll

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll btc = 30;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(1e9 + 239);
const int MOD = (int)(1e9 + 7); //998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937_64 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = (int)(1e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 18;
const int T = (1 << 20);
const int B = 500;
const int X = 5e5 + 239;

int n;
vector<pair<int, int>> v;

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    int ans = 0;
    pair<int, int> mxl = make_pair(-1, -1);
    pair<int, int> mnr = make_pair(BIG, BIG);
    for (int i = 0; i < n; i++)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        v.push_back(make_pair(l, r));
        ans = max(ans, r - l + 1);
        if (mxl.first < l)
            mxl = make_pair(l, r);
        if (mnr.second > r)
            mnr = make_pair(l, r);
    }
    if (mxl.first <= mnr.second)
    {
        int mx = 0;
        int cnt_mnr = 0;
        int cnt_mxl = 0;
        for (int i = 0; i < n; i++)
        {
            if (v[i] == mxl)
                cnt_mxl++;
            else if (v[i] == mnr)
                cnt_mnr++;
            else
                mx = max(mx, v[i].second - v[i].first + 1);
        }
        if (cnt_mxl > 1)
            mx = max(mx, mxl.second - mxl.first + 1);
        if (cnt_mnr > 1)
            mx = max(mx, mnr.second - mnr.first + 1);
        ans = max(ans, mnr.second - mxl.first + 1 + mx);
    }
    //cerr << mnr.first << " " << mnr.second << "??\n";
    //cerr << mxl.first << " " << mxl.second << "??\n";
    vector<pair<int, int>> s;
    for (int i = 0; i < n; i++)
        s.push_back(make_pair(max(0, mnr.second - v[i].first + 1), max(0, v[i].second - mxl.first + 1)));
    sort(s.begin(), s.end());
    //for (pair<int, int> t : s)
    //    cerr << t.first << " " << t.second << "\n";
    vector<int> mn(s.size() + 1);
    mn[0] = mxl.second - mxl.first + 1;
    for (int i = 0; i < n; i++)
        mn[i + 1] = min(mn[i], s[i].second);
    for (int i = 0; i < (int)s.size(); i++)
        ans = max(ans, s[i].first + mn[i]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int a,b,c,d;
    bool win=false;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c<= 0){
            win=true;
            break;
        }
        a -= d;
        if(a<=0) break;

    }
    if(win)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<cstdlib>
#define ll long long
using namespace std;
int read()
{
	int f=0,c=1;	char ch=getchar();
	while((ch<'0')||(ch>'9'))	{	if(ch=='-') c=-1;	ch=getchar();	}
	while((ch>='0')&&(ch<='9'))	{	f=f*10+ch-'0';	ch=getchar();	}
	return c*f;
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	char s=getchar();
	if(s<'a'||s>'z') return 0;
	++s;
	cout<<s;  
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

struct t_dict{
	string w;
	int c;
	t_dict(string ss, int cc){
		w = ss;
		c = cc;
	}
};

bool operator<( const t_dict &l, const t_dict &r ){
	if( l.c == r.c )
		return l.w < r.w;
	else
		return l.c > r.c;
}

t_dict makeDict(string s, int i){
	t_dict d(s,i);
	return d;
}

void split( string str, vector<string> &res ){
	int i=0;
	string w;
	while(str[i]!='\0'){
		if(str[i]!=' ')
			w += str[i];
		else{
			res.push_back(w);
			w = "";
		}
		i++;
	}
	if( w.length()>0 )
		res.push_back(w);
}

int main(){
	int n;
	string in;
	while( getline(cin,in), in[0]!='0' ){
		sscanf( in.c_str(), "%d", &n );
		vector<string> words;
		rep(i,n){
			getline(cin,in);
			split(in, words);
		}
		char k;
		getline(cin, in);
		sscanf(in.c_str(),"%c",&k);
		sort( words.begin(), words.end() );
		vector<t_dict> dict;
		dict.push_back(makeDict(words[0],1));
		for( int i=1; i<words.size(); i++ ){
			if( dict[dict.size()-1].w == words[i] ){
				dict[dict.size()-1].c++;
			}else{
				dict.push_back(makeDict(words[i],1));
			}
		}
			sort(dict.begin(), dict.end());
			int outs = 0;
			for(int i=0; i<dict.size()&&outs<5; i++){
				if( dict[i].w[0] == k ){
					if(outs>0)	cout << " ";
					cout << dict[i].w;
					outs++;
				}
			}
			if(outs==0)	cout << "NA";
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
order=[]
for number in range(10):
    hight=int(input())
    order.append(hight)
for j in range(9):
    for i in range(9):
        if order[i] < order[i+1]:
            a = order[i]
            b = order[i+1]
            order[i] = b
            order[i+1] = a
for i in range(3):
    print(order[i])

Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <algorithm>

# define REP(i,n) for(int i=0; i<n;i++)

using namespace std;

int h, w, n, d;

bool check(vector<vector<int> >result, vector<int> p, int t){
	REP(i,n){
		if (t==2){
			/*/
			cout << endl << "(";
			REP(l,n) cout << p[l] << ",";
			cout << ")" << endl;
			REP(j,h){
				REP(k,w) printf("%02d ", result[j][k]);
				cout << endl;
			}
			/*/
		}
		int maxj, maxk, minj, mink;
		maxj = -1; maxk = -1; minj = h; mink = w;
		REP(j,h){
			REP(k,w){
				if (result[j][k]==p[i]){
					if (j>maxj) maxj = j;
					if (k>maxk) maxk = k;
					if (j<minj) minj = j;
					if (k<mink) mink = k;
				}
			}
		}
		//if (t==2) printf("p[i]=%d max:%d,%d min:%d,%d\n", p[i], maxj, maxk, minj, mink);
		for (int j=minj; j<=maxj; j++){
			for (int k=mink; k<=maxk; k++){
				if (result[j][k]<0){
					return false;
				}else if (result[j][k]==p[i]){
					result[j][k] = -1;
				}
			}
		}
	}
	return true;
}

int solve(int t){
	//int d;
	//cin >> d;
	
	//REP(t,d){
		bool materials[27];
		string input;
		char letter;
		vector<int> p;
		
		cin >> h >> w;
		n = 0;
		REP(i,26) materials[i] = false;
		
		vector<vector<int> > result(h);
		
		REP(j,h){
			cin >> input;
			REP(k,w){
				letter = (int)input[k]-65;
				if (letter>=0){
					result[j].push_back(letter);
					if (!materials[letter]){
						n++;
						p.push_back(letter);
						materials[letter] = true;
					}
				}else{
					result[j].push_back(-1);
				}
			}
		}
	
	sort(p.begin(), p.end() );
		//REP(i,n) cout << p[i] << " ";
		//cout << p.size();
		//cout << endl;
		
		do{
			if (check(result, p, t)){
				//REP(i,n) cout << p[i] << " ";
				//cout << endl;
				cout << "SAFE" << endl;
				return 0;
			}
		} while(next_permutation(p.begin(), p.end() ) );
		
		cout << "SUSPICIOUS" << endl;
		//}
	return 0;
	
}

int main(){
	int d;
	cin >> d;
	REP(t,d) solve(t);
	return 0;
}




Measured memory_bytes: 3200
N=int(input())
A=[int(_) for _ in input().split()]
B=[int(_) for _ in input().split()]
C=[int(_) for _ in input().split()]
ans=0
a=10000000
for i in A:
  ans+=B[i-1]
  if i==a+1:
    ans+=C[a-1]
  a=i  
  
print(ans)

Measured memory_bytes: 3064
table :: [Int]
table = loop 0 []
  where
    loop i xs
      | i > 86 = xs
      | i == 0 = loop (i+1) (2:xs)
      | i == 1 = loop (i+1) (1:xs)
      | otherwise = loop (i+1) (a+b:xs)
        where
          [a,b] = take 2 xs
      
main = do
  n <- readLn :: IO Int
  print $ table !! (86 - n)


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
    while(1){
        int n;
        cin >> n;
        if(!n) break;

        vector<pair<int, int> > ary(n);
        for(int i = 0;i < n;i++){
            int p, d1, d2;
            cin >> p >> d1 >> d2;
            ary.push_back(pair<int, int>(d1 + d2, p));
        }
        sort(ary.begin(), ary.end());
        pair<int, int> ans = ary.back();
        cout << ans.second << ' ' << ans.first << endl;
    }
    return 0;
}

Measured memory_bytes: 1428
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
SA = list(accumulate(A))
SB = list(accumulate(B))
ans = 0
for i in range(n):
    if i >= 1:
        ans = max(SA[i] + SB[n - 1] - SB[i - 1], ans)
    else:
        ans = max(SA[i] + SB[n - 1], ans)
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max(0, min(B, D) - max(A, C)) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
s1=input()
s2=input()
ans=0
mod=10**9+7

if s1[0]==s2[0]:
    i=1
    ans+=3
    dual=False
else:
    i=2
    ans+=6
    dual=True
while i<N:
    if dual:
        if s1[i]==s2[i]:
            dual=False
        else:
            ans*=3
            ans%=mod
            i+=1
    else:
        ans*=2
        ans%=mod
        if s1[i]!=s2[i]:
            dual=True
            i+=1
    i+=1
print(ans%mod)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int calcDivisionNum(int num) {
    int dn = 0;
    while (num) {
        if (num % 2 == 0) {
            ++dn;
            num /= 2;
        } else {
            break;
        }
    }
    return dn;
}

int main() {
    int N;
    cin >> N;

    int dn = -1;
    int index = 0;
    for (int i = 1; i <= N; ++i) {
        if (dn < calcDivisionNum(i)) {
            dn = calcDivisionNum(i);
            index = i;
        }
    }
    cout << index << endl;

}


Measured memory_bytes: 3488
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if abs(a-b) <= k and abs(a-c) <= k and abs(a-d) <= k and abs(a-e) <= k and abs(b-c) <= k and abs(b-d) <= k and abs(b-e) <= k and abs(c-d) <= k and abs(c-e) <= k and abs(d-e) <= k:
        print("Yay!")
else:
        print(":(") 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

bool helper(string s) {
 string t(s.rbegin(), s.rend());
  return s == t;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  string s;
  cin>>s;
  int n = s.size();
  if(helper(s) && helper(s.substr(0, (n-1)/2)) && helper(s.substr((n+1)/2)))
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 256
a, b = input().split()
ansb = []
for i in range(int(a)):
    ansb.append(b)
ansa = []
for i in range(int(b)):
    ansa.append(a)
ansa = "".join(ansa)
ansb = "".join(ansb)
ans = [ansa, ansb]
ans.sort()
print(ans[0])


Measured memory_bytes: 3060
from collections import defaultdict
N = int(input())
d = defaultdict(int)
XY = sorted([list(map(int,input().split())) for _ in range(N)])
for i in range(N):
  for j in range(i):
    d[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
print(N - max(d.values(), default=0))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=1e5+5;

int main(){
    int a,b,c;
    int x,y;
    cin >> a >> b >> c >> x >> y;
    int k = min(x,y);
    long long ans1=(long long)2*k*c,ans2,ans3;
    ans1+=(x-k)*a+(y-k)*b;
    ans2=x*a+y*b;
    ans3=max(x,y)*2*c;
    cout << min(ans1,min(ans2,ans3)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a = 0, b = 0;
    if (n / 10 == 9){
        a = 1;
    }
    if (n % 10 == 9){
        b = 1;
    }
    if (a || b){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
  double n;
  cin >> n;
  int k;
  k = (int)n;
  if(k%2==0) cout << 0.5 << endl;
  else cout << (n+1)/(2*n) << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int n;
	scanf("%d", &n);
	int tmp;
	unordered_map<int, bool> a;
	int freecolour = 0;
	rep(i, n) {
		scanf("%d", &tmp);
		if (tmp < 400) {
			a[0] = true;
		}
		else if (tmp < 800) {
			a[1] = true;
		}
		else if (tmp < 1200) {
			a[2] = true;
		}
		else if (tmp < 1600) {
			a[3] = true;
		}
		else if (tmp < 2000) {
			a[4] = true;
		}
		else if (tmp < 2400) {
			a[5] = true;
		}
		else if (tmp < 2800) {
			a[6] = true;
		}
		else if (tmp < 3200) {
			a[7] = true;
		}
		else {
			++freecolour;
		}
	}
	int count = 0;
	for (auto aa : a) {
		count += aa.second;
	}
	printf("%d\n%d\n", max(1, count), count + freecolour);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> v;
    int co = 0;
    for(int i =0; i < n; i++)
    {
       long long x; cin >> x;
       if(x == 0)
       {
          co = 1;
       }
       v.push_back(x);
    }
    if(co)
    {
       cout << 0;
       return 0;
    }

    long long unsigned res = 1;
    long long unsigned tmp;
    for(int i =0; i < n; i++)
    {
       tmp = 1000000000000000000/res;
       if(v[i] > tmp)
       {
          cout << -1;
          return 0;
       }
       res*=v[i];
    }
    cout << res;

}


Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

const int m = 2019;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    vi x(m);
    rep(i,m){
        cin >> x[i]; 
    }
    if(n>=m){cout << 0 <<endl;return 0;}
    sort(all(x));
    reverse(all(x));
    vi s(m-1,0);
    rep(i,m-1){
        s[i] = x[i] -x[i+1];
    }
    sort(all(s));
    reverse(all(s));
    ll tot = x[0] - x[m-1];
    ll ooi = 0;
    rep(i,n-1){
        ooi += s[i];
    }
    cout << tot - ooi << endl;
    return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;


 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;



ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}
int f(int x)
{
    int sum=0;
    while(x)
    {
        sum+=x%10;
        x/=10;
    }    
    return sum;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,ans=0;cin>>n>>a>>b;
    rep1(i,n)
    {
        int tmp=f(i);
        if(tmp<=b&&tmp>=a)
        ans+=i;
    }
    cout<<ans;

}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
int main(){
	char w[4][4];
	char s[4];
	int count;
	int r[4];
	int i;
	int j;
	
	strcpy(w[0], "AC");
	strcpy(w[1], "WA");
	strcpy(w[2], "TLE");
	strcpy(w[3], "RE");
	
	r[0] = 0;
	r[1] = 0;
	r[2] = 0;
	r[3] = 0;
	
	scanf("%d", &count);
	for(i = 0; i < count; i++){
		scanf("%s", s);
		for(j = 0; j < 4; j++){
			if(!strcmp(w[j], s)){
				r[j]++;
			}
		}
	}
	
	for(i = 0; i < 4; i++){
		printf("%s x %d\n", w[i], r[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1736
// AOJ 2169 Colored Octahedra
// 2018.3.20 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char hash[16777218];

int tbl[24][8] = {
{0,1,2,3,4,5,6,7},{0,3,7,4,1,2,6,5},{0,4,5,1,3,7,6,2},
{1,0,4,5,2,3,7,6},{1,2,3,0,5,6,7,4},{1,5,6,2,0,4,7,3},
{2,1,5,6,3,0,4,7},{2,3,0,1,6,7,4,5},{2,6,7,3,1,5,4,0},
{3,0,1,2,7,4,5,6},{3,2,6,7,0,1,5,4},{3,7,4,0,2,6,5,1},
{4,0,3,7,5,1,2,6},{4,5,1,0,7,6,2,3},{4,7,6,5,0,3,2,1},
{5,1,0,4,6,2,3,7},{5,4,7,6,1,0,3,2},{5,6,2,1,4,7,3,0},
{6,2,1,5,7,3,0,4},{6,5,4,7,2,1,0,3},{6,7,3,2,5,4,0,1},
{7,3,2,6,4,0,1,5},{7,4,0,3,6,5,1,2},{7,6,5,4,3,2,1,0}};

char name[8][22];
char id[8]; int n;
char used[8];
char color[8];
int  ans;

int check()
{
	int i, j, id;
	char t[8];

	id = 0; for (i = 0; i < 8; i++) id = (id << 3) | color[i];
	if (hash[id]) return 0;
	hash[id] = 1;
	for (j = 1; j < 24; j++) {
		for (i = 0; i < 8; i++) t[i] = color[tbl[j][i]];
		id = 0; for (i = 0; i < 8; i++) id = (id << 3) | t[i];
		hash[id] = 1;
	}
	return 1;
}

void rec(int k)
{
	int  i;
	char f[8];
	
	if (k == 8) {
		if (check()) ans++;
		return;
	}
	memset(f, 0, 8);
	for (i = 0; i < 8; i++) {
		if (used[i] || f[id[i]]) continue;
		color[k] = id[i], f[id[i]] = 1;
		used[i] = 1, rec(k+1), used[i] = 0;
	}
}

int main()
{
	int i, j, max;

    while (1) {
		memset(hash, 0, sizeof(hash));
		n = 0;
		for (i = 0; i < 8; i++) {
			if (scanf("%s", name[i]) != 1) return 0;
			for (j = 0; ; j++) {
				if (j == i) { id[i] = n++; break; }
				if (!strcmp(name[j], name[i])) { id[i] = id[j]; break; }
			}
		}
		if (n == 1) { puts("1"); continue; }
		if (n == 8) { puts("1680"); continue; }

		for (i = 0; i < 8; i++) used[id[i]]++;
		max = 0;
		for (i = 1; i < 8; i++) if (used[i] > max) max = i;
		for (i = 0; i < 8; i++) if (id[i] == max) break;

		ans = 0;
		memset(used, 0, 8);
		used[i] = 1, color[0] = id[i];
		rec(1), used[i] = 0;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 18088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;cin >> n >> m;
	if(n == 1 || m == 1){
		if(n == 1 && m == 1) cout << 1 << endl;
		else if(n == 1) cout << m - 2 << endl;
		else cout << n - 2 << endl;
	}
	else cout << (n - 2) * (m - 2) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////


int main() {
    int n;
    I(n);

    if(n==1)cout<<"Hello World"<<endl;
    else {
        int a,b;
        cin>>a>>b;
        cout<<(a+b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	s1 := readString()
	s2 := readString()
	s3 := readString()
	ans := string([]byte{s1[0], s2[0], s3[0]})
	println(strings.ToUpper(ans))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    int h[100000];
    for(int i=0;i<n;i++)cin>>h[i];
    int dp[100000];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
int main(){
	int x, y;
	cin >> x >> y;
	set<int> S0,S1,S2;
	S0.insert(1);
	S0.insert(3);
	S0.insert(5);
	S0.insert(7);
	S0.insert(8);
	S0.insert(10);
	S0.insert(12);
	S1.insert(4);
	S1.insert(6);
	S1.insert(9);
	S1.insert(11);
	S2.insert(2);
	int px,py;
	if(S0.find(x)!=S0.end()) px = 0;
	else if(S1.find(x)!=S1.end()) px = 1;
	else px = 2;
	if(S0.find(y)!=S0.end()) py = 0;
	else if(S1.find(y)!=S1.end()) py = 1;
	else py = 2;

	if(px == py) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    int a , b , k;

    cin >> a >> b >> k;


    ll ans = max(a,b);

    vector<int>v;


    for(int i=1; i<=ans; i++)
    {
        if((a%i==0 && b%i==0))
        {
            v.pb(i);
        }
    }

    cout << v[v.size()-k] << endl;





    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iomanip>
#define ll long long int
#define add push_back

using namespace std; 

int main() {

    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);

    int T;  
    // cin >> T;
    T = 1;
    while(T--){
        ll a,b,c,d; cin >> a >> b >> c >> d;
        ll mx = max(a*c, a*d);
        mx = max(mx, b*c);
        mx = max(mx, b*d);
        cout << mx << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <cassert>
#include <deque>
using namespace std;
#define int64_t long long
constexpr int64_t MOD=1e9+7;
int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",a*b/2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> v;
int main() {
  cin >> n;
  read_n(v, n);
  sort(begin(v), end(v));
  double u = v[0];
  for (i64 i = 1; i < n; ++i) u = (u + v[i]) / 2;
  printf("%.10f\n", u);
  return 0;
}



Measured memory_bytes: 256
var a,b:longint;
    x,can:boolean;
    s:string;
    i:longint; 
begin
  readln(a,b);
  readln(s);
  if a+b+1<>length(s) then
  begin
    writeln('No');
    exit;
  end;
  for i:=1 to length(s) do
  if s[i]='-' then
  begin
    if x then
    begin
      writeln('No');
      exit;
    end else
    begin
      x:=true;
      if (i-1=a) then can:=true;
    end;
  end;
  if can then writeln('Yes') else writeln('No');
end.



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define vi                vector<ll>
#define vii               vector<pair<ll,ll>>
#define vpp               vector<pair<ll,pair<ll,ll>>>
#define vll               vector<ll>
#define vc                vector<char>
#define vs                vector<string>
#define mll               map<ll,ll>
#define mci               map<char,ll>
#define msi               map<string,ll>
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz(c)             (ll)c.size()
#define len(c)            (ll)c.length()
#define hell              (ll)1000000007
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define trav(a,i)         for(auto& i: a)
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define invect(v,n)       for(ll i=0;i<n;i++ ){ll arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        forloop(n){ll aset;cin>>aset;s.insert(aset);}
#define F                 first
#define S                 second
#define pii               pair<ll,ll>
#define PB                pop_back
#define copy(a,b)         copy(all(a),back_inserter(b));
#define section(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define sp(n)             setprecision(n)
#define fin               freopen( "input.txt", "r", stdin );
#define fout              freopen( "output.txt", "w", stdout );
#define outall(a)         loop(i,0,sizeof(a)/sizeof(a[0])) cout<<a[i]<<" "; cout<<endl
#define endl "\n"
const ll N=300001;
const ll MOD = 1000 * 1000 * 1000 + 7;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}

//vector<ll> v;
 /*ll powm(ll a,ll b, ll m){
    if(b==0) return 1;
    ll t=powm(a,b/2,m);
    if(b%2) return a*t%m*t%m;
    return t*t%m;
 }
 */
/*ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}*/
 
/*int bs(int a[],int low, int high, int val)
{
    int mid=(low+high)/2;
    if(low>high) return -1;
    if(a[mid]>val) bs(a,low,mid-1,val);
    else if(a[mid]<val) bs(a,mid+1,high,val);
    else return mid;
}*/
 
void solve(){
    ll n,l,r,i,j,sum=0,count=0,max_sum=INT_MIN,max_value=INT_MIN,k;
    cin>>n;
    loop(i,1,n+1){
        loop(j,1,n+1){
            loop(k,1,n+1){
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum;
}

signed main(){
    //fin fout
    fast
    ll t=1; //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3652
//
// Created by tac on 2016/10/23.
//

#include <cstdlib>
#include <cmath>
#include <iostream>

namespace {

bool is_prime(const int n) {
    if (n == 2 || n == 3) {
        return true;
    }
    if (n % 2 == 0) {
        return false;
    }
    bool ret = true;
    int limit = static_cast<int>(std::ceil(std::sqrt(n)));
    for (int i = 3; i <= limit ; i += 2) {
        if (n % i == 0) {
            ret = false;
            break;
        }
    }
    return ret;
}

}

int main() {
    int n;
    int s;
    int count = 0;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> s;
        if (is_prime(s)) {
            ++count;
        }
    }
    std::cout << count << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int x[601];
LL ans[1000001];
typedef pair<int,int>P;
priority_queue<P,vector<P>,greater<P> >que;
bool used[602];
int main(){
	cin>>N;
	REP(i,N){
		used[i]=false;
	}
	REP(i,N*N){
		ans[i]=-1;
	}
	REP(i,N){
		cin>>x[i];
		x[i]--;
		ans[x[i]]=i;
		REP(j,i){
			que.push(P(x[i],i));
		}
	}
	/*REP(i,N*N){
		cout<<ans[i]+1;
		if(i!=N*N-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}*/
	REP(i,N*N){
		if(ans[i]==-1){
			if(que.empty()){
				cout<<"No"<<endl;
				return 0;
			}
			P p=que.top();
			que.pop();
			ans[i]=p.second;
			if(used[p.second]==true&&p.first!=1e9){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			REP(j,N-1-ans[i]){
				que.push(P(1e9,ans[i]));
			}
			used[ans[i]]=true;
		}
	}
	cout<<"Yes"<<endl;
	REP(i,N*N){
		cout<<ans[i]+1;
		if(i!=N*N-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    int half = d.size() / 2;

    if (d[half] != d[half-1]) {
        cout << d[half] - d[half-1] << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S, T;
    cin >> S >> T;
    int q;
    cin >> q;
    vector<int> sa(S.size()+1),sb(S.size()+1),ta(T.size()+1),tb(T.size()+1);
    rep(i,0,S.size()){
        if(S[i] == 'A'){
            sa[i+1]++;
        }else if(S[i] == 'B'){
            sb[i+1]++;
        }
    }
    rep(i,0,T.size()){
        if(T[i] == 'A'){
            ta[i+1]++;
        }else if(T[i] == 'B'){
            tb[i+1]++;
        }
    }

    rep(i,0,sa.size()-1){
        sa[i+1] += sa[i];
        sb[i+1] += sb[i];
    }
    rep(i,0,ta.size()-1){
        ta[i+1] += ta[i];
        tb[i+1] += tb[i];
    }

    rep(i,0,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        int cntS = 0;
        if((sa[b] - sa[a-1] + 2 * (sb[b] - sb[a-1])) % 3 == (ta[d] - ta[c-1] + 2 * (tb[d] - tb[c-1])) % 3){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;

bool n, e, s, w; 
int i, x;
string d;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);

	cin >> d;
	x=d.length();
	for (i=0; i<x; i++) {
		if (d[i]=='N') {
			n=true;
		}
		if (d[i]=='E') {
			e=true;
		}
		if (d[i]=='S') {
			s=true;
		}
		if (d[i]=='W') {
			w=true;
		}
 	}
 	if (n!=s or e!=w) {
 		cout << "No";
 	}
 	else {
 		cout << "Yes";
 	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1e9;


ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b & 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

//////////////////////////////////////////////

const int N = 800;

int dy[] = {-1,1,0,0};
int dx[] = {0,0,-1,1};
pii st;
int r,c,k;
string M[N + 5];
bool vis[N + 5][N + 5];

bool inRange(int y, int x){
	return y >= 0 && y < r && x >= 0 && x < c;
}

int solve(){
	queue < pair < pii , int > > q;
	while(!q.empty()) q.pop();
	q.push(MP(st,k));
	int y,x,yy,xx,ret = INF,mn,val,move;
	while(!q.empty()){
		y = q.front().FI.FI;
		x = q.front().FI.SE;
		move = q.front().SE;
		q.pop();
		if(vis[y][x]) continue;
		if(y == 0 || y == r - 1 || x == 0 || x == c-1) return 1;
		vis[y][x] = true;
		mn = min(min(x,c-x-1), min(y, r-y-1));
		val = 0;
		if(mn % k > 0) val = 1;
		val += mn / k;
		ret = min(ret, val+1);
		if(move == 0) continue;
		FOR(i,4){
			yy = y + dy[i];
			xx = x + dx[i];
			if(inRange(yy,xx) && !vis[yy][xx] && M[yy][xx] == '.'){
				q.push(MP(MP(yy,xx),move-1));
			}
		}
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> r >> c >> k;
	FOR(i,r){
		cin >> M[i];
		FOR(j,c){
			if(M[i][j] == 'S'){
				st = MP(i,j);
			}
		}
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 1280
# ２次元配列バージョン
# あらかじめ空の配列を用意しておくバージョン
n = int(input())
suits = ["S", "H", "C", "D"]
cards = []
for s in suits:
    for x in range(1, 14):
        cards.append([s, x])
for i in range(n):
    e = [int(l) if l.isnumeric() else l for l in input().split()]
    if e in cards:
        cards.remove(e)

for c in cards:
    print("{} {}".format(c[0], c[1]))



Measured memory_bytes: 5600
X, N = gets.split(" ").map(&:to_i)
p = gets.split(" ").map(&:to_i).sort
i = 1

if p.include?(X) 
    loop do
        if !(p.include?(X - i))
            puts X - i
            break
        elsif !(p.include?(X + i))
            puts X + i
            break
        else
            i += 1
        end
    end

else
    puts X
end

Measured memory_bytes: 14288
#include<bits/stdc++.h>

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int main()
{
    FAST
    int a,b;
    cin>>a>>b;
    ll ans=0;
    ll c=1;
    while(c<b){
        c--;
        c+=(a);
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#include<iostream>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define fir first
#define sec second
#define pb  push_back
#define mp  make_pair

typedef long long ll;

const int N = 120;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}

void minimize(vector<pair<int,int> > &in,int &num){
  int g=-1;
  if (in.size() == 1){
    if (in[0].sec == 0){
      num=1;
      return;
    }
    g=gcd(in[0].sec,num);
    num/=g;
    in[0].sec/=g;
    return;
  }
  rep(j,in.size()){
    if (in[j].sec == 0);
    else if (g==-1)g=in[j].sec;
    else g=gcd(g,in[j].sec);
  }
  if (g>0 && num%g == 0){
    num/=g;
    rep(j,in.size())in[j].sec/=g;
  }
}

bool check(int n,vector<pair<int,int> > *in,int *num,int l){
  rep(i,n){
    if (l % num[i] != 0)return false;
  }
  
  vector<int> out(l,0);
  rep(i,n){
    int tmp=l/num[i];
    rep(j,in[i].size()){
      out[in[i][j].sec*tmp]|=in[i][j].fir;
    }
  }

  rep(i,out.size())printf("%02X",out[i]);
  printf("\n");  
  return true;
}

void solve(int n,vector<pair<int,int> >*in,int *num){
  REP(i,1,1025){
    if (check(n,in,num,i))return;
  }
  printf("Too complex.\n");
}

main(){
  int te;
  int num[N];
  vector<pair<int,int> > in[N];
  cin>>te;
  while(te--){
    int n;
    cin>>n;
    rep(i,n){
      in[i].clear();
      string inp;
      cin>>inp;
      num[i]=inp.size()/2;
      rep(j,inp.size()/2){
	if (inp[j*2]=='0'&&inp[j*2+1]=='0')continue;
	in[i].pb(mp(
		    (inp[j*2]-'0')*16+(inp[j*2+1]-'0'),
		    j
		    )
		 );
      }

      if (in[i].size() == 0)num[i]=1;
      minimize(in[i],num[i]);
    }
    solve(n,in,num);
  }
  return false;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int a[100]={0},x=0,b[100]={0},max=0;
	while(scanf("%d",&a[x])!=EOF)
	{
		if(a[x]<=0||a[x]>100)
		{
			x--;
		}
		else
		{
			b[(a[x]-1)]++;
		}
		x++;
	}

	for(int n=0;n<100;n++)
	{
		if(max<b[n])
		{
			max=b[n];
		}
	}
	for(int n=0;n<100;n++)
	{
		if(max==b[n])
		{
			printf("%d\n",n+1);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,z,w;
    cin >> n >> z >> w;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    if(n == 1) {
        cout << abs(a[0]-w) << endl;
        return 0;
    }
    cout << max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])) << endl;
}


Measured memory_bytes: 256