akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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 (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    vint a(3); vin(a);
    sort(all(a));
    int ans = 0;
    while(!(a[0] == a[1] && a[1] == a[2])) {
        if(a[1] < a[2]) {
            a[0]++;
            a[1]++;
        } else {
            a[0] += 2;
        }
        ans++;
        sort(all(a));
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<vector<int>>v(N, vector<int>(M));
	for (auto &i : v)for(auto &j:i)cin >> j;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int box = 0;
			for (int k = 0; k < M; k++)box += pow(v[i][k] - v[j][k], 2);
			int bag = sqrt(box);
			if (bag*bag == box)K++;
		}
	}
	cout << K << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 200011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	/*
		一个左端点 l ，一个右端点 r 。
		枚举左端点，枚举当前右端点最远能拓展到的位置。
		第一次贡献是 C(r - l + 1, 2) + (r - l + 1)
		记一个 lstr 表示上一次的右端点。
		这一次移动了 (r - lstr + 1) 格，即当前左端点
		可以多产生 
		C(r - lstr + 1, 2) + (r - lstr + 1) + (r - lstr + 1) 
		的贡献。 
		总复杂度 O(n) 。 
	*/
	
	ll n, Ans, a[N], V[N];
	ll lstSum = 0, lstXor = 0;
	
	inline ll Calc ( ll a ) { return a * (a - 1) / 2 + a; }
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i] = read();
		for (int l = 1, r = 0; l <= n; ++l) {
			if (r == l - 1) lstSum = lstXor = 0;
			else lstSum -= a[l - 1], lstXor ^= a[l - 1];
			while (r <= n) {
				++r;
				if ((lstXor ^ a[r]) != (lstSum + a[r])) 
					{ --r; break; }
				lstXor ^= a[r], lstSum += a[r];
			}
			r = min((ll) r, n);
			Ans += (r - l + 1);
		} return wln(Ans), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;
char c[20];
map<long long,int> m;
int n;
long long ans;
void f(int p,long long s,long long t){
    if(p>n){
        ans+=s;
        return;
    }
    if(t)f(p+1,s+t,c[p+1]-'0');
    if(p<n)f(p+1,s,t*10+c[p+1]-'0');
}
int main(){
    int i;
    scanf("%s",c+1);
    n=strlen(c+1);
    f(1,0,c[1]-'0');
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    int n,i,t;
    string s;
    cin>>n;

    vector<string>v;
    set<string>st;

    for(i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }

    for(i=0;i<n;i++)
        st.insert(v[i]);

    cout<<st.size();
    cout<<"\n";
    return 0;   //:D
}




Measured memory_bytes: 24972
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    A = sorted([int(input()) for i in range(N)], reverse=True)
    c = 1
    cnt = 0
    if N % 2 == 0:
        print(sum(A[:N // 2 - 1]) * 2 + A[N // 2 - 1] - A[N // 2] - sum(A[N // 2 - 1 + 2:] * 2))
    else:
        ans1 = sum(A[:N // 2]) * 2 - sum(A[N // 2:N // 2 + 2]) - sum(A[N // 2 + 2:] * 2)
        ans2 = sum(A[:N // 2 - 1]) * 2 + sum(A[N // 2 - 1:N // 2 + 1]) - sum(A[N // 2 + 1:] * 2)
        print(max(ans1, ans2))


resolve()

Measured memory_bytes: 47708
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
char S[100];
void solve(){
	rep(i, N){
		if(S[i] == 'Y'){
			cout << "Four" << endl;
			return;
		}
	}
	cout << "Three" << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) {
		cin >> S[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct data {
    int a,b,c;
};
int main() {
    ios_base::sync_with_stdio(false);
    int n,a,b,c;
    cin >> n;
    vector<data> dp(n);
    for(int i=0; i<n; i++) {
        cin >> a >> b >> c;
        if(i==0) dp[i].a=a, dp[i].b=b, dp[i].c=c;
        else {
            dp[i].a = max(dp[i-1].b+a,dp[i-1].c+a);
            dp[i].b = max(dp[i-1].a+b,dp[i-1].c+b);
            dp[i].c = max(dp[i-1].a+c,dp[i-1].b+c);
        }
    }
    cout << max(dp[n-1].a,max(dp[n-1].b,dp[n-1].c)) << "\n";
}


Measured memory_bytes: 1408
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut vs = vec![];
    for _ in 0 .. n {
        vs.push(get!());
    }
    
    let mut ws = vec![];
    ws.push(vs[n-1]);
    for i in 1 .. n {
    	let i = (n-1) - i;
        let v = vs[i];
        let mut lp = 0;
        let mut rp = ws.len();
        while lp < rp {
            let hp = (lp + rp) / 2;
            if ws[hp] <= v {
                lp = hp + 1;
            } else {
                rp = hp;
            }
        }
        if lp == ws.len() {
            ws.push(v);
        } else if ws[lp] <= v {
            ws.insert(lp+1, v);
        } else {
            ws[lp] = v;
            while lp > 0 && ws[lp-1] > ws[lp] {
                ws.swap(lp, lp-1);
                lp -= 1;
            }
            while lp+1 < ws.len() && ws[lp+1] < ws[lp] {
                ws.swap(lp, lp+1);
                lp += 1;
            }
        }
    }
    println!("{}", ws.len());
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll K;
    cin >> K;

    stringstream ss;
    rep(i, K) ss << "ACL";
    cout << ss.str() << endl;
}


Measured memory_bytes: 3580
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define D 10 
#define MAXN (1 << 18)
#define MAXW (100010)

int dp[(1 << D)][MAXW];
int v[MAXN];
int w[MAXN];

int n, q;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 1; i < (1 << D); i++) {
		int (& prevdp)[MAXW] = dp[i / 2];
//		memcpy(prevdp, dp[i / 2], sizeof(dp[0]));
		for (int j = 0; j + w[i] < MAXW; j++) {
			dp[i][j + w[i]] = prevdp[j] + v[i];
		}
		for (int j = 0; j < MAXW; j++) {
			dp[i][j] = max(prevdp[j], dp[i][j]);
		}
		for (int j = 1; j < MAXW; j++) {
			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
		}
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int cur, cap;
		cin >> cur >> cap;
		vector<int> items;
		while (cur >= (1 << D)) {
			items.push_back(cur);
			cur >>= 1;
		}
		int m = items.size();
		int bestval = 0;
		for (int mask = 0; mask < (1 << m); mask++) {
			int curv = 0;
			int curw = 0;
			for (int j = 0; j < m; j++) {
				if (mask & (1 << j)) {
					curv += v[items[j]];
					curw += w[items[j]];
				}
			}
			if (curw > cap) {
				continue;
			}
			curv += dp[cur][cap - curw]; 
			bestval = max(curv, bestval);
		}
		cout << bestval << endl;
	}
	return 0;
}


Measured memory_bytes: 405160
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<random>
#include<ctime>
#include<cstdlib>
#include<complex>
#include<fstream>
using namespace std;

int main(){

  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());

  if(s<t){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
a = list(map(int, input().split()))
t = [1]
x = [0]*n
x[0] = 1
y = 1
z = 0
d = 0
flag = False
for i in range(k):
    t.append(a[t[i]-1])
    if x[a[t[i]-1]-1] != 0:
        y = x[a[t[i]-1]-1]
        z = i+2
        b = [a[t[i]-1]]
        break
    else:
        x[a[t[i]-1]-1] += i+2
        z = i+2
        b = [a[t[i]-1]]
    if i == k - 1:
        flag = True

if flag:
    print(a[t[k-1]-1])
    exit()

d = z-y


if d != 0:
    r = (k - y) % d
else:
    r = k - y

for i in range(r+1):
    b.append(a[b[i]-1])

print(b[r+1])


Measured memory_bytes: 32412
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    d = {"Sunny":1 , "Cloudy":2, "Rainy":0}
    a = ["Sunny", "Cloudy", "Rainy"]
    print(a[d[input().rstrip()]])
    return

#B
def B():
    s = S()
    for i, si in enumerate(s):
        if i % 2:
            if si == "R":
                print("No")
                return
        else:
            if si == "L":
                print("No")
                return
    print("Yes")
    return

#C
def C():
    n, k, q = LI()
    d = [0] * n
    for _ in range(q):
        a = II() - 1
        d[a] += 1
    for a in d:
        if k - (q - a) > 0:
            print("Yes")
        else:
            print("No")
    return

#D
def D():
    n,m = LI()
    a = LI()
    q = []
    for ai in a:
        heappush(q, -ai)
    for _ in range(m):
        heappush(q, heappop(q) / 2)
    ans = 0
    while q:
        ans += int(-heappop(q))
    print(ans)
    return

# E
# 解説AC
# ロリハやZアルゴリズムでもいける
# できないけどDPでできる
def E():
    n = II()
    s = S()
    dp = [[0] * (n + 1) for i in range(n + 1)]
    ans = 0
    for i in range(n - 1, -1, -1):
        for j in range(n - 1, i, -1):
            if s[i] == s[j]:
                dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1)
            ans = max(ans, min(dp[i][j], j - i))
    print(ans)

    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 230536
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,max_count=0;
    string s;
    cin>>n>>s;
    for (int i=1;i<n;i++) {
        string front=s.substr(0,i);
        string back=s.substr(i,n-i);
        int front_size=front.size();
        int back_size=back.size();
        int count=0;
        std::deque<int> deq;
        for (int j=0;j<front_size;j++) {
            for (int k=0;k<back_size;k++) {
                if (find(deq.begin(),deq.end(),front.at(j))==deq.end()&&front.at(j)==back.at(k)) {
                    count++;
                    break;
                }
            }
            deq.emplace_back(front.at(j));
        }
        if (max_count<count) {
            max_count=count;
        }
    }
    cout<<max_count<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n = scan.nextInt();
    	int m = scan.nextInt();
    	
    	int[][] Vec_a = new int[n][m];
    	int[] Vec_b = new int[m];
    	int[] c = new int[n];

    	for(int j = 0; j < n; j++){
    		for(int i = 0; i < m; i++){
        		Vec_a[j][i] = scan.nextInt();
        	}
    	}
    	
    	for(int i = 0; i < m; i++){
    		Vec_b[i] = scan.nextInt();
    	}
    	
    	for(int j = 0; j < n; j++){
    		for(int i = 0; i < m; i++){
        		c[j] += Vec_a[j][i] * Vec_b[i]; 
        	}
    		System.out.println(c[j]);
    	}
    }
    	
}

Measured memory_bytes: 40492
n,m=map(int,input().split())
s=input()
ans=[]
cursor=n
actualfail=0
while cursor!=0:
  if cursor<=m:
    ans.append(cursor)
    break
  failflag=1
  for i in range(m):
    if s[cursor-m+i]=='0':
      failflag=0
      ans.append(m-i)
      cursor-=m-i
      break
  if failflag==1:
    actualfail=1
    break
if actualfail==1:
  print(-1)
else:
  ans.reverse()
  for i in ans:
    print(i)

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


int main(){
	int flag = 0;
	char a,b;
	scanf("%c",&a);
	for(int i = 1;i < 4;++i){
		scanf("%c",&b);
		if(a == b){
			flag = 1;
		}else{
			a = b;
		}
	}
	if(flag)
		puts("Bad");
	else
		puts("Good");
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(i,0,v.size()){cout<<v[i]; if(i!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

vector<int> sikiri(ll in, ll h){
    vector<int> res;
    res.push_back(0);    
    FOR(i,1,1<<h){
        if(in%2==1)res.push_back(i);
        in/=2;
    }
    res.push_back(h+1);
    return res;
}    

int solve(vector<string> &v, vector<int> &s, int k){
    int ans = 0;
    vector<int> ks(s.size());

    FOR(y,0,v[0].size()){//左からの位置
        bool all_clean = false;
        FOR(k_i,1,s.size()){
            //bool one_clean = true;
            int boarder = 0;
            FOR(x,s[k_i-1],s[k_i]){
                if(v[x][y] == '1'){
            //        one_clean = false;
                    ks[k_i]++;
                    boarder++;
                }
            }
            if(boarder>k)return 1e9;
            //if(one_clean) ks[k_i] = 0;
            if(ks[k_i]>k){
                all_clean = true;
            }
        }
        //v1out(ks);
        if(all_clean){
            //cout<<" y = "<<y<<endl;
            ans++;
            FOR(j,0,ks.size())ks[j]=0;
            FOR(k_i,1,s.size())FOR(x,s[k_i-1],s[k_i]){
                if(v[x][y] == '1')ks[k_i]++;
            }
        }
    }
    //cout<<"ans:s.size() "<<ans<<" "<<s.size()-2<<endl;
    return ans+s.size()-2;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,k;
    cin>>h>>w>>k;
    vector<string> v(h);
    FOR(i,0,h){
        cin>>v[i];
    }
    int ans = 1e9;
    FOR(i,0,1<<(h-1)){
        //cout<<"i = "<<i<<endl;
        vector<int> s = sikiri(i,h-1);
        ans = min(ans,solve(v,s,k));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	if(*(a.end()-1)==*(b.begin())&&*(b.end()-1)==*(c.begin())){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Dec 29 04:48:49 2018
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func main() {
	var N, M int
	fmt.Scan(&N)

	arr := make([]string, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	fmt.Scan(&M)
	arr1 := make([]string, M)
	for i := range arr1 {
		fmt.Scan(&arr1[i])
	}

	ans := 0
	for i := range arr {
		m := 0
		for j := range arr {
			if arr[i] == arr[j] {
				m++
			}
		}
		for k := range arr1 {
			if arr[i] == arr1[k] {
				m--
			}
		}
		ans = max(ans, m)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main()
{
  long long a;
  std::cin >> a ;
  std::vector<long long> r;
  long long ans = 1e12;
  for(long long i = 1; i <= std::sqrt(a); i++)
  {
    if(a%i==0)
    {
      long long b = a/i;
      ans = std::min(ans, (b-1)+(i-1));
      // r.push_back((b-1)+(i-1));
    }
  }
  std::cout<<ans<<std::endl;
  // std::cout  << *std::min_element(r.begin(),r.end()) << std::endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
char a[100005];
int x,y,ans;
main(){
std::cin>>a;
for(int i=0;i<sizeof(a);i++)
if(x==y){x++;if(a[i]=='p')ans--;}
else{y++;if(a[i]=='g')ans++;}
printf("%d\n",ans);}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  map<int, int> m;
  vector<int> A(N + 1); for (int i = 1; i <= N; ++i) {cin >> A[i]; ++m[i - A[i]];}
  auto ans = 0LL; for (int i = 1; i <= N; ++i) ans += m[i + A[i]];
  cout << ans << endl;}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;
ll N,K;
v_ll A,B;
int main(){
  cin >> N >> K;

  B.push_back(0);
  for (ll i=0;i<N;i++){
    ll x;
    cin >> x;
    if (x<0){
      A.push_back(-x);
    }
    else{
      B.push_back(x);
    }
  }
  A.push_back(0);
  ll ret=-1;
  ll a=A.size()-1,b=B.size()-1;
  for (ll i=0;i<=K;i++){
    if (i>a)continue;
    if (K-i>b)continue;
    ll p,q,ret2;
    p=A[a-i];
    q=B[K-i];
    if (p>q)ret2=p+q*2;
    else ret2=p*2+q;
    if (ret2<ret || ret<0){ret=ret2;}
  }
  cout << ret << endl;
}


Measured memory_bytes: 1656
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int n,i,a,flag;
    while(cin>>n)
    {
        flag=1;//APPROVED
        for(i=0;i<n;i++)
        {
            cin>>a;
            if(a%2==0&&a%3!=0&&a%5!=0) flag=0;
        }
        if(flag) cout<<"APPROVED"<<endl;
        else cout<<"DENIED"<<endl;
    }
}


Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int sm = 0;
   int x,y;
   int mx = 0;
   for(int i = 0; i < n; ++i){
      cin >> x >> y;
      sm += (x == y);
      if(x != y) sm = 0;
      mx = max(sm,mx);
   }
   if(mx >= 3){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
lli a[200010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;lli t=0ll,sum=0ll;
    cin>>n>>t;
    for(int i=0;i<n;++i)
		cin>>a[i];
	for(int i=1;i<n;++i)
	{
		sum+=min(t,a[i]-a[i-1]);
	}
	cout<<(sum+t)<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

const char mcxi[] = {'m', 'c', 'x', 'i'};
int m = 1000, c = 100, x = 10, i = 1;
int sum;

void calc(string MCXI) {
	rep(j, MCXI.size()) {
		int num = 1;
		if ('2' <= MCXI[j] && MCXI[j] <= '9') num = MCXI[j++] - '0';
		if (MCXI[j] == 'm') sum += num * m;
		else if (MCXI[j] == 'c') sum += num * c;
		else if (MCXI[j] == 'x') sum += num * x;
		else if (MCXI[j] == 'i') sum += num * i;
	}
}

int main() {
	int n; cin >> n;
	while (n--) {
		sum = 0;
		string MCXI1, MCXI2;
		cin >> MCXI1 >> MCXI2;
		calc(MCXI1); calc(MCXI2);

		string ans;
		int d = 1000;
		rep(i, 4) {
			int tmp = sum / d % 10;
			if (tmp > 1) ans += (char)(tmp + '0');
			if (tmp)  ans += mcxi[i];
			d /= 10;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
def islower (t_a,t_b):
	if t_a[1] != t_b[1]:
		return t_a[1] < t_b[1]
	elif t_a[2] != t_b[2]:
		return t_a[2] > t_b[2]
	else :
		return t_a[0] > t_b[0]
while 1:
	T, P, R = map(int,raw_input().split())
	if (T,P,R) == (0,0,0):
		break
	score = [[i,0,0] for i in xrange(1,T+1)]
	wrong = [[0 for i in xrange(P)] for j in xrange(T)]
	for x in xrange(R):
		input_str = raw_input().split(" ")
		tid, pid, time = map(int,input_str[:3])
		message = input_str[3]
		if message == "WRONG":
			wrong[tid-1][pid-1] += 1
		else :
			score[tid-1][1] += 1
			score[tid-1][2] += 1200 * wrong[tid-1][pid-1] + time

	for j in xrange(T - 1):
		for i in xrange(T - 1 - j):
			t_l = score[i]
			t_r = score[i+1]
			if islower(t_l, t_r):
				score[i] = t_r
				score[i+1] = t_l
	for team in score:
		print team[0], team[1], team[2]

Measured memory_bytes: 4312
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{
	public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
      long a=sc.nextLong();
      long b=sc.nextLong();
      long c=sc.nextLong();
      long d=sc.nextLong();
      long product=0;
      long product1=a*c;
      long product2=a*d;
      long product3=b*c;
      long product4=b*d;
      product=Math.max(product1,(Math.max(product2,Math.max(product3,product4))));
      System.out.println(product);
	}
}

Measured memory_bytes: 27072
while True:
    n,x=map(int,input().split())
    if(n==0 and x==0):
        break
    ans=0
    for i in range(1,n):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if(i+j+k==x):
                        ans=ans+1
    print(ans)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,cnt=0;
    map<int,int> m;
    rep(i,6){
        cin >> n;
        m[n]++;
        if(m[n]==2) cnt++;
    } 
    cout << (cnt==2?"YES\n":"NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    double half = (double)W * H / 2;
    bool onCenter = (W % 2 == 0 && W / 2 == x && H % 2 == 0 && H / 2 == y);

    cout << half << " " << (onCenter ? "1" : "0") << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');

            int pos = 0;

            for(int i=0;i<N;i++)
            {
                if (s.Equals("1"))
                    pos = i;
            }

            ans = (pos + K - 2) / (K - 1);
            ans += (N - pos - 3 + K) / (K - 1);

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 20448
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define id(i,j) ((i-1)*m+j)
const int N=210,inf=1e9;
struct fk{int to,nxt,w;}e[N*N*N*2];
int head[N*N*2],cnt=1;
int dis[N*N*2],n,m,Sx,Sy,Tx,Ty,mp[N][N],S,T,ans,tot;
char s[N];
queue<int> q;
void add(int u,int v,int w){e[++cnt].to=v;e[cnt].nxt=head[u];e[cnt].w=w;head[u]=cnt;}
bool bfs(){
    memset(dis,63,sizeof(dis));
    dis[S]=0;q.push(S);
    while(!q.empty()){
        int u=q.front();q.pop();
        for(int i=head[u],v;i;i=e[i].nxt)
            if(e[i].w&&dis[v=e[i].to]>dis[u]+1)
                dis[v]=dis[u]+1,q.push(v);
    }
    return dis[T]<inf;
}
int dfs(int u,int flow){
    if(u==T||!flow)return flow;
    int now=0;
    for(int i=head[u],v;i;i=e[i].nxt)
        if(e[i].w&&dis[v=e[i].to]==dis[u]+1){
            int f=dfs(v,min(flow-now,e[i].w));
            e[i].w-=f;e[i^1].w+=f;now+=f;
        }
    if(!now)dis[u]=-1;
    return now;
}
void dinic(){for(;bfs();ans+=dfs(S,inf));}
int main(){
    scanf("%d%d",&n,&m);tot=n*m;
    S=0;T=tot*2+1;
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
            if(s[j]!='.'){
                if(s[j]=='o'){
                    mp[i][j]=1;
                    add(id(i,j),id(i,j)+tot,1);
                    add(id(i,j)+tot,id(i,j),0);
                }
                else{
                    if(s[j]=='S')mp[i][j]=1,Sx=i,Sy=j;
                    if(s[j]=='T')mp[i][j]=1,Tx=i,Ty=j;
                    add(id(i,j),id(i,j)+tot,inf);
                    add(id(i,j)+tot,id(i,j),0);
                }
            }
    }
    add(S,id(Sx,Sy),inf);
    add(id(Sx,Sy),S,0);
    add(id(Tx,Ty)+tot,T,inf);
    add(T,id(Tx,Ty)+tot,0);
    if(Sx==Tx||Sy==Ty){puts("-1");return 0;}
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(mp[i][j]){
                for(int k=1;k<=n;k++)
                    if(k!=i&&mp[k][j])
                        add(id(i,j)+tot,id(k,j),inf),add(id(k,j),id(i,j)+tot,0);
                for(int k=1;k<=m;k++)
                    if(k!=j&&mp[i][k])
                        add(id(i,j)+tot,id(i,k),inf),add(id(i,k),id(i,j)+tot,0);
            }
        }
    dinic();
    printf("%d\n",ans);
}


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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int sum = 0;
  rep(i, n) {
    int a;
    cin >> a;
    int cnt = 0;
    int ans = 0;
    while(ans <= d) {
      cnt++;
      ans = a*cnt+1;
    }
    sum += cnt;
  }
  int ret = sum  + x;
  
  cout << ret << endl;
  return 0;
}
    

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int a,b;
  string s;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

char s[N], t[N];

int main(){
  int n;
  fastScan(n);
  scanf("%s %s", s, t);
  for(int i = 0; i < n; i++){
    printf("%c%c", s[i], t[i]);
  }
  return 0;
}


Measured memory_bytes: 256
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a(1);
  return String.fromCharCode(n.charCodeAt()+1);
}

Measured memory_bytes: 21956
#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>
#include <random>

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 iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    vector<int> inc(n);
    inc[0] = 1;
    for (int i = 1; i < n; ++i) {
        inc[i] = p[i] > p[i - 1] ? inc[i - 1] + 1 : 1;
    }
    set<int> st;
    for (int i = 0; i < k; ++i) {
        st.insert(p[i]);
    }
    int c = 1;
    bool f = inc[k - 1] >= k;
    for (int i = k; i < n; ++i) {
        st.insert(p[i]);
        if ((inc[i] < k || !f) && (*st.begin() != p[i - k] || *st.rbegin() != p[i])) {
            ++c;
        }
        st.erase(p[i - k]);
        if (inc[i] >= k) f = true;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 11136
// ABC 117 D

#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

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

  int64_t c[40] = {0};
  int64_t a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    for (int j = 0; j < 40; ++j) {
      c[j] += (a >> j) & 0x1;
    }
  }

  int64_t ans = 0;
  // case i = -1: X = K
  for (int i = -1; i < 40; ++i) {
    // Ignore value larger than K.
    if (i != -1 && !(K & (1LL << i))) {
      continue;
    }
    int64_t f = 0;
    for (int k = i + 1; k < 40; ++k) {
      const auto mask = 1LL << k;
      if (K & mask) {
        f += mask * (N - c[k]);
      } else {
        f += mask * c[k];
      }
    }
    if (i >= 0) {
      f += (1LL << i) * c[i];
    }

    for (int k = 0; k < i; ++k) {
      f += (1LL << k) * max(c[k], N - c[k]);
    }

    ans = max(ans, f);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    map<ll,ll> a;
    rep(i,n){
      ll x;
      cin>>x;
      a[x]++;
    }
    ll x=0,y=0,s=x*y;
    for(auto itr:a){
      if(itr.second<=1){
        continue;
      }
      ll cnt=x*itr.first;
      ll cn=y*itr.first;
      if(cnt<s && cn<s){
        continue;
      }
      if(cnt<cn){
        x=itr.first;
        s=cn;
      }else{
        y=itr.first;
        s=cnt;
      }
      if(itr.second>=4 && s<itr.first*itr.first){
        s=itr.first*itr.first;
        x=itr.first;
        y=itr.first;
      }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll a,b;
  cin>>a>>b;
  a--;
  if(a<0) a=0;
  vll bb(0);
  ll cu=2;
  ll i=0;
  while(i!=60){
    ll k=b%cu;
    if(i==0){
      if(b%4==1||b%4==2){
        bb.pb(1);
      }
      else{
        bb.pb(0);
      }
      cu*=2;
      i++;
      continue;
    }
    if(k>=(cu/2)&&k%2==0){
      bb.pb(1);
    }
    else{
      bb.pb(0);
    }
    cu*=2;
    i++;
  }
  cu=2;
  ll j=0;
  vll aa(0);
  while(j!=60){
    ll k=a%cu;
    if(j==0) {
      if(a%4==1||a%4==2){
        aa.pb(1);
      }
      else{
        aa.pb(0);
      }
      cu*=2;
      j++;
      continue;
    }
    if(k>=(cu/2)&&k%2==0){
      aa.pb(1);
    }
    else{
      aa.pb(0);
    }
    cu*=2;
    j++;
  }
  ll ans=0;
  i=0;
  cu=1;
  while(i!=60){
    if(bb[i]==1&&aa[i]==0){
      ans+=cu;
    }
    else if(bb[i]==0&&aa[i]==1){
      ans+=cu;
    }
    cu*=2;
    i++;
  }
  COUT(ans);
}

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

int main(int argc, char const *argv[])
{

    int n;
    scanf("%d", &n);
    
    vector<vector<int> > g(n);

    for(int i = 0;i < n-1;i++){
        int x, y;
        scanf("%d %d", &x, &y);
        x -= 1;
        y -= 1;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vector<int> tmp(n);

    function<int (int, int)> go = [&](int i, int par) {
        int xx = 0;
        for (int j : g[i]) if (j != par) {
            xx ^= go(j, i) + 1;
        }
        return xx;
    };

    int ret = go(0, -1);
    if(ret)
    	printf("Alice\n");
    else
    	printf("Bob\n");
    return 0;
}

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

#define MAX pow(10, 9);

int main(){
	int n;
	cin >> n;
	int R[n];

	for(int i=0; i<n; i++){
		cin >> R[i];
	}

	int max_profit = R[1] - R[0];
	int min_value = R[0];

	for(int i=0; i<n-1; i++){
		if(R[i] < min_value)
			min_value = R[i];
		if(max_profit < R[i+1] - min_value)
			max_profit = R[i+1] - min_value;
	}

	cout << max_profit << endl;


}


Measured memory_bytes: 3868
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <set>
using namespace std;

typedef long long ll;

int n, a, b;
const int maxn = 1e5+1;
ll h[maxn];
bool valid(ll mid)
{
    ll cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        if (h[i] <= mid*b)
            continue;
        cnt += (h[i]-mid*b+a-1)/a;
    }
    return cnt <= mid;
}
int main()
{
    scanf("%d %d %d", &n, &a, &b);
    a -= b;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", h+i);
    }
    int l = 0, r = 1e9, mid, ans;
    while (l <= r)
    {
        mid = (l+r)>>1;
        if (valid(mid))
        {
            ans = mid;
            r = mid-1;
        }
        else
        {
            l = mid+1;
        }
    }
    printf("%d\n", ans);
}

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)

//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}

//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))

int gcd(int a, int b){
   int tmp;
   while(a%b!=0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}
 
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
   vb pn((int)1e4+10); 
void prime_number(int n){
   if(n==0||n==1) //return false;
   fill(all(pn),true);
   pn[0]=false;pn[1]=false;
   loop(i,2,n/2+1){
      if(!pn[i]) continue;
      for(int j=2;i*j<=n;j++){
         pn[i*j]=false;
      }
   }
   //return pn[n];
}

int main(){
   int a,ans=0;
   while(cin>>a){
      ans=0;
      prime_number(a);
      rep(i,a){
         if(pn[i+1]&&pn[a-i]) ans++;
      }
      cout << ans << endl;
   }
}

Measured memory_bytes: 1196
/*
* @Author: 王文宇
* @Date:   2018-04-14 20:22:16
* @Last Modified by:   王文宇
* @Last Modified time: 2018-04-14 20:59:04
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100006;
#define _for(i,a,b) for(int i=a;i<=b;i++)
int n,a[maxn];
long long getnum(int x,int y)
{

}
int main(int argc, char const *argv[])
{
	cin>>n;
	_for(i,1,n)cin>>a[i];
	sort(a+1,a+1+n);
	long long ans1 = 0;
	long long ans2 = 0;
	int l,r;
	_for(i,1,n)
	{
		if(a[i]<=a[n]/2)
		{
			l=i;
		}
		if(a[i]>=a[n]/2)
		{
			r = i;
			break;
		}
	}
	if(a[n]-a[r]>a[l])ans1 = r;
	else ans1 = l;
	cout<<a[n]<<" "<<a[ans1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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 (b<a) { a=b; return 1; } return 0; }

lli k;
string s;

int main(void){
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k)+"..." << endl;
    return 0;
}


Measured memory_bytes: 3488
//
//AtCoder Beginner Contest 068
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

using Graph = vector<vector<int>>;

int main()
{
    int n, m;
    cin >> n >> m;

    Graph g(n);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> dist(n, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : g[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    cout << ((dist[n-1]==2) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 15984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    char a, b;
    cin >> a >> b;
    if(a=='H') out(b);
    else{
        if(b=='H') out('D');
        if(b=='D') out('H');
    }
}


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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
    int K, X;
    IN(K);
    IN(X);
    int min = MAX(X - K + 1, -1000000), max = MIN(X + K - 1, 1000000);
    FOR(i, min, max + 1) {
        cout << i;
        if(i != max) cout << " ";
    }
}

Measured memory_bytes: 256