akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  bool flag = true;
  if(a > x) flag = false;
  else if(a + b < x) flag = false;
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3632
import collections


class Dinic:
    def __init__(self, N):
        self.N = N
        self.edges = collections.defaultdict(list)
        self.level = [0 for _ in range(self.N)]
        self.iter = [0 for _ in range(self.N)]

    def add(self, u, v, c, directed=True):
        if directed:
            self.edges[u].append([v, c, len(self.edges[v])])
            self.edges[v].append([u, 0, len(self.edges[u])-1])
        else:  # TODO: must be Verified
            self.edges[u].append([v, c, len(self.edges[v])])
            self.edges[v].append([u, 0, len(self.edges[u]) - 1])
            self.edges[v].append([u, c, len(self.edges[u])])
            self.edges[u].append([v, 0, len(self.edges[v]) - 1])

    def bfs(self, s):
        self.level = [-1 for _ in range(self.N)]
        self.level[s] = 0
        que = collections.deque([s])
        while que:
            v = que.popleft()
            for i in range(len(self.edges[v])):
                e = self.edges[v][i]
                if e[1] > 0 and self.level[e[0]] < 0:
                    self.level[e[0]] = self.level[v] + 1
                    que.append(e[0])

    def dfs(self, v, t, f):
        if v == t:
            return f
        for i in range(self.iter[v], len(self.edges[v])):
            self.iter[v] = i
            e = self.edges[v][i]
            if e[1] > 0 and self.level[v] < self.level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d > 0:
                    e[1] -= d
                    self.edges[e[0]][e[2]][1] += d
                    return d
        return 0

    def maxFlow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0:
                return flow
            self.iter = [0 for _ in range(self.N)]
            f = self.dfs(s, t, float('inf'))
            while f > 0:
                flow += f
                f = self.dfs(s, t, float('inf'))


N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(N)]
graph = Dinic(2*N+2)
for i in range(1, N+1):
    graph.add(0, i, 1)

for i in range(N+1, 2*N+1):
    graph.add(i, 2*N+1, 1)

for i, (a, b) in enumerate(AB):
    for j, (c, d) in enumerate(CD):
        if a < c and b < d:
            graph.add(i+1, N+1+j, 1)

print(graph.maxFlow(0, 2*N+1))

Measured memory_bytes: 4040
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,m,x;
  cin>>n>>m>>x;
  vector<long long int> c(n);
  vector<vector<long long int>> a(n,vector<long long int>(m));
  for(int i=0; i<n; i++){
    cin>>c.at(i);
    for(int j=0; j<m; j++){
      cin>>a.at(i).at(j);
    }
  }

  bool ok=false;
  long long int ans=99999999999999999;
  for(long long int i=0; i<(1<<n); i++){
    bitset<12> hoge=i;
    bool preok=true;
    long long int all=0;
    vector<long long int> pre(m,0);
    for(int j=0; j<n; j++){
      if(hoge.test(j)){
        for(int k=0; k<m; k++){
          pre.at(k)+=a.at(j).at(k);
        }
        all+=c.at(j);
      }
    }

    for(int j=0; j<m; j++){
      if(pre.at(j)<x){
        preok=false;
        break;
      }
    }

    if(preok){
      ok=true;
      ans=min(ans,all);
    }
  }

  if(ok){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        int h = nextInt(sc);
        int w = nextInt(sc);
        char[][] result = new char[h][w];

        for (int i = 0; i < h; i++) {
            Arrays.fill(result[i], '0');
        }


        for (int i = 0; i < h; i++) {
            char[] s = nextString(sc).toCharArray();

            for (int j = 0; j < w; j++) {
                if (s[j] == '#') {
                    // bomb
                    for (int k = j - 1; k <= j + 1; k++) {
                        if (k < 0 || k >= w) {
                            continue;
                        }

                        if (i >= 1) {
                            if (result[i - 1][k] != '#') {
                                result[i - 1][k]++;
                            }

                        }

                        if (k == j) {
                            result[i][k] = '#';
                        } else {
                            if (result[i][k] != '#') {
                                result[i][k]++;
                            }
                        }

                        if (i < h - 1) {
                            if (result[i + 1][k] != '#') {
                                result[i + 1][k]++;
                            }
                        }
                    }
                }
            }
        }

        // output
        for (char[] c : result) {
            out(String.valueOf(c));
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }


    public static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }
}

Measured memory_bytes: 23124
def readinput():
    n,k=map(int,input().split())
    okashi=[]
    for _ in range(k):
        d=int(input())
        l=list(map(int,input().split()))
        okashi.append(l)
    return n,k,okashi

def main(n,k,okashi):
    sunuke=[0]*(n+1)
    for l in okashi:
        for su in l:
            sunuke[su]+=1
    count=0
    for i in range(n):
        if sunuke[i+1]==0:
            count+=1
    return count

if __name__=='__main__':
    n,k,okashi=readinput()
    ans=main(n,k,okashi)
    print(ans)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 15;

int n, m, x, c[maxn], a[maxn][maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> x;
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    int mi = 2e18;
    for(int i = 0; i < (1 << n); i++)
    {
        int curcost = 0;
        for(int j = 0; j < n; j++)
            if(i & (1 << j))
                curcost += c[j];
        if(curcost >= mi)
            continue;
        int tempvals[12] = {0};
        for(int j = 0; j < n; j++)
            if(i & (1 << j))
                for(int k = 0; k < m; k++)
                    tempvals[k] += a[j][k];
        int good = 1;
        for(int k = 0; k < m; k++)
            if(tempvals[k] < x)
                good = 0;
        if(good)
            mi = min(mi, curcost);
    }
    if(mi > 1e18)
        mi = -1;
    cout << mi << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000
typedef long long ll;

//Vを基準にしてwを最小化

int main(){
  ll N,W;
  cin>>N>>W;
  
  ll w[N],v[N];
  rep(i,N) cin>>w[i]>>v[i];
  
  ll V =1000 * 100+1;
  ll DP[V];
  rep(i, V) DP[i]=INF;
  DP[0]=0;
  
  rep(counter,N){
  	for(ll i=V-1;i>=0;i--){
    
      if(i-v[counter]>=0){
          DP[i] =min(DP[i], DP[i-v[counter]]+w[counter]);
        
      }
    }
  }
  
    
  for(ll i=V-1; i>=0; i--){
  	if((DP[i] <= W) && (DP[i]!=0)){
    	cout<<i;
      return 0;
    }
  }
  
}

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

int main(void){
  int result;
  string s;
  cin >> s;
  if(s=="SUN") result=7;
  else if(s=="MON") result=6;
  else if(s=="TUE") result=5;
  else if(s=="WED") result=4;
  else if(s=="THU") result=3;
  else if(s=="FRI") result=2;
  else result=1;

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin >> n;
	cout << n*n*n << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

l = {}
r = {}

for i in range(n):
    x = i + an[i]
    if x not in l:
        l[x] = [i]
    else:
        l[x].append(i)

    x = i - an[i]
    if x not in r:
        r[x] = [i]
    else:
        r[x].append(i)

sum = 0
for k in l:
    if k in r:
        sum += len(l[k])*len(r[k])

print(sum)


Measured memory_bytes: 133796
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int N=32;
		int a[25];
		for(int i=0,an;i<n;++i){
			cin>>an;
			a[i]=an;
		}
		for(int i=0;N;i=(i+1)%n){
			N-=(N-1)%5;
			cout<<N<<"\n";
			N-=a[i];
			if(N<0) N=0;
			cout<<N<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 0
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

	
int dp[100005],ndp[1 << 17];
int n,G,w[5005],p[5005];
int ans;
 
int32_t main(){_
    cin >> n >> G;
    for(int i = 1;i<=n;i++)
    {
        cin >> w[i] >> p[i];
    }
    for(int j = 1;j <= 100000;j++)
    	{
    		dp[j] = 1e18;
    	}
    	const int cons = 1e18;
    for(int i = 1;i <= n;i++)
    {
    	//if(i == 3) rc(dp[6]);
    	for(int j = 0;j <= 100000;j++) ndp[j] = 1e18;
    	for(int j = p[i];j <= 100000;j++)
    	{
    		ndp[j] = min(cons,w[i] + dp[j - p[i]]);
    	}
    	for(int j = 0;j <= 100000;j++)
    	{
    		dp[j] = min(dp[j],ndp[j]);
    	}
    	//cout << dp[21] << '\n';
    }
    for(int j = 100000;j + 1;j--) if(dp[j] <= G) rc(j);
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> even(N / 2), odd(N / 2);
	for (int i = 0; i < N / 2; i++) cin >> even[i] >> odd[i];
	sort(even.begin(), even.end());
	sort(odd.begin(), odd.end());
	even.emplace_back(0), odd.emplace_back(0); // 番兵

	int tmp_e = 1, tmp_o = 1, max_e = 0, max_o = 0, prev_e = 0, prev_o = 0, memo_e = -1, memo_o = -1;
	for (int i = 1; i <= N / 2; i++) {
		
		if (even[i] == even[i - 1]) tmp_e++;
		else {
			if (max_e <= tmp_e) {
				memo_e = even[i - 1];
				prev_e = max_e;
				max_e = tmp_e;
			}
			else if (prev_e <= tmp_e) prev_e = tmp_e;
			tmp_e = 1;
		}		
		if (odd[i] == odd[i - 1]) tmp_o++;
		else {
			if (max_o <= tmp_o) {
				memo_o = odd[i - 1];
				prev_o = max_o;
				max_o = tmp_o;
			}
			else if (prev_o <= tmp_o) prev_o = tmp_o;
			tmp_o = 1;
		}		
	}

	if (memo_o != memo_e) {
		cout << N - max_e - max_o << "\n";
	}
	else {
		if(max_e + prev_o > max_o + prev_e) cout << N - max_e - prev_o << "\n";
		else cout << N - max_o - prev_e << "\n";
	}

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string.h>
using namespace std;

int main(){

    char s[10];
    int out = 999;

    cin >> s;

    for(int i = 2; s[i] != 0; i++){

        int hun, ten, one;
        int x;

        hun = s[i-2];
        ten = s[i-1];
        one = s[i];

        hun = (hun - 48)*100;
        ten = (ten - 48)*10;
        one = one - 48;

        x = hun + ten + one;

        if(x > 753){
            if(x-753 < out)out = x-753;
        }else{
            if(753-x < out)out = 753-x;
        }

    }

    cout << out << endl;
    
    return 0;

}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, l[222], s;

int main() {
	cin >> n;
	rep(i,n*2) cin >> l[i];
	sort(l,l+n*2);
	for (int i = 0; i < 2*n; i += 2) s += min(l[i], l[i+1]);
	cout << s << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

using namespace std;

ll mod(ll a, ll b) { return (a % b + b) % b; }
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}


int main()
{
	fast;
	ll n; cin>>n;
	ll arr[n];
	for(ll i = 0; i < n; i++) cin>>arr[i];
	ll x = 0;
	for(ll i = 0; i < n; i++)
	{
		x = x ^ arr[i];
	}
	for(ll i = 0; i < n; i++)
	{
		arr[i] = arr[i] ^ x;
	}
	for(ll i = 0; i < n; i++) cout << arr[i] << " ";
	cout << endl;
    return 0;    
} 

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int H, W;
  while (cin >> H >> W, H) {
    string s[110];
    bool used[110][110] = {};
    for (int i = 0; i < H; i++) {
      cin >> s[i];
    }
    int y = 0, x = 0;
    bool loop = false;
    while (true) {
      if (used[y][x]) {
        loop = true;
        break;
      }
      used[y][x] = true;
      if (s[y][x] == '>') x++;
      else if (s[y][x] == '<') x--;
      else if (s[y][x] == '^') y--;
      else if (s[y][x] == 'v') y++;
      else break;
    }
    if (loop) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }

  return 0;
}


Measured memory_bytes: 3136
package main

import (
	"fmt"
	"strings"
)

func main(){
	var a,b int
	var str string
	var pic []string
	fmt.Scan(&a,&b)
	for i := 0;i < a;i++{
		fmt.Scan(&str)
		pic = append(pic,str)
	}

	fmt.Println(strings.Repeat("#",b+2))
	for _,str := range pic{
		fmt.Println("#"+str+"#")
	}
	fmt.Println(strings.Repeat("#",b+2))
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
string s;
stack<char> st;
char top2() {
	if (st.size() < 2) return 'A';
	char tmp = st.top(); st.pop();
	char ans = st.top();
	st.push(tmp);
	return ans;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	fw (i, 0, s.length()) {
		st.push(s[i]);
		while (st.size() > 0 && st.top() == 'T' && top2() == 'S') st.pop(), st.pop();
	}
	cout << st.size();
	return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
        
int main(){ 
  int X;
  cin >> X;
  if(X<600){
    cout << 8 << endl;
  }
  else if(X<800){
    cout << 7 << endl;
  }
  else if(X<1000){
    cout << 6 << endl;
  }
  else if(X<1200){
    cout << 5 << endl;
  }
  else if(X<1400){
    cout << 4 << endl;
  }
  else if(X<1600){
    cout << 3 << endl;
  }
  else if(X<1800){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3640
n, k = gets.split(' ').map(&:to_i)

i = k
min_sum = k * (k-1) / 2
max_sum = k * (n + n-k + 1) / 2 
answer = 0

mod = 10 ** 9 + 7

while i <= n + 1
 answer += max_sum - min_sum + 1

 min_sum += i
 max_sum += n - i
 answer %= mod 

 i += 1
end

puts answer

Measured memory_bytes: 14304
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  cout << (n < 1000 ? "ABC" : "ABD") << endl;
  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

solve xs
    | VU.length xs == 1 = 0
    | otherwise = VU.minimum (VU.take 2 xs) + solve (VU.tail xs)

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ (VU.head xs) + (VU.last xs) + solve xs

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//_______________________



int32_t main()
{ 
  io;
 
 
  int n,k;
  string s;
  cin>>n>>s>>k;

  char c=s[k-1];

  for(int i=0;i<n;i++)
  {
    if(s[i]!=c)
      s[i]='*';
  }
  
  cout<<s;
  
 return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int[] a = new int[3];
		for(int i = 0;i < 3;i++){
			a[i] = saori.saori_hayami();
		}
		Arrays.sort(a);
		int ans = a[2]-a[1];
		a[0] += ans;
		if((a[2]-a[0])%2 == 0){
			ans += (a[2]-a[0])/2;
		} else {
			ans += 1;
			a[2]++;
			ans += (a[2]-a[0])/2;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32428
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9; 
const int N = 6e5+5;                                         
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
int f[mxn];
int main () {
	SpeedForce;
	
	int n;
	cin >> n;
	ll ans = 0;
	--n;
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; j += i) {
			++f[j];
		}
		
		ans += f[i];
	}
	
	cout << ans << '\n';
	
	return Accepted;
}

// B...a


Measured memory_bytes: 7512
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y = map(int,input().split())
if a.count(x) == a.count(y) == 1:
  print('Yes')
elif b.count(x) == b.count(y) == 1:
  print('Yes')
elif c.count(x) == c.count(y) == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;

typedef long long ll;

int main(void)
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes" << endl;;
	}
	else
	{

		cout << "No" << endl;;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int>vec(5);
  vector<int>cnt;
  int ans;
  bool jug=false;
  for(int i=0;i<5;i++) {
    cin >> vec[i];
    ans+=vec[i];
    if(vec[i]%10!=0){
      ans=ans+10-vec[i]%10;
      cnt.push_back(vec[i]%10);
      jug=true;
    }
  }
  
  if(jug){
  sort(cnt.begin(),cnt.end());
  cout<< ans-10+cnt[0];
  }else{
    cout << ans;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5, mod = 1e9 + 7;
vector<int> vi[15];
int a[15], p[15];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, k, x;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i){
        cin >> k;
        while (k--){
            cin >> x;
            vi[i].push_back(x);
        }
    }
    for (int i = 1; i <= m; ++i) cin >> p[i];
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i){
        int pos = 1, t = i;
        while (t){
            if (t & 1){
                a[pos] = 1;
            }else a[pos] = 0;
            ++pos;
            t >>= 1;
        }
        bool exist = 0;
        for (int i = 1; i <= m; ++i){
            int cnt = 0;
            for (int j = 0; j < vi[i].size(); ++j){
                if (a[vi[i][j]]) ++cnt;
            }
            if (cnt % 2 != p[i]){
                exist = 1;
                break;
            }
        }
        if (!exist) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif
#define sz(x) ((int)(x).size())
#define forn(i, n) for (int i = 0; i < (n); i++)

#ifdef DEBUG
struct Timestamper {
  string msg;
  clock_t start;

  Timestamper(const string &_msg) : msg(_msg), start(clock()) {}
  ~Timestamper() {
    eprintf("[ %s ] Time=%.3lfs\n", msg.c_str(), (clock() - start) * 1.0 / CLOCKS_PER_SEC);
  }
} __timestamper("end");
#else
struct Timestamper {};
#endif

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int inf = 1e9;

#ifdef DEBUG
#define MY_INTER
#endif

int n;
#ifdef MY_INTER
vi poses;
#endif

int qcnt;

int query(int i) {
  #ifdef DEBUG
  eprintf("Querying %d\n", i);
  #endif
  qcnt++;
  assert(qcnt < 20);
  assert(0 <= i && i < n);
  #ifdef MY_INTER
  return poses.at(i);
  #else
  printf("%d\n", i);
  fflush(stdout);
  char res[100];
  scanf("%s", res);
  if (!strcmp(res, "Vacant")) return -1;
  if (!strcmp(res, "Male")) return 0;
  if (!strcmp(res, "Female")) return 1;
  assert(false);
  #endif
}

void solve() {
  int l = 0, r = n - 1;

  int lval = query(l);
  if (lval == -1) return;
  int rval = query(r);
  if (rval == -1) return;

  eprintf("%d %d\n", lval, rval);
  assert(((lval ^ l) & 1) != ((rval ^ r) & 1));
  for (;;) {
    assert(l + 1 < r);
    int m = (l + r) / 2;
    int mval = query(m);
    if (mval == -1) return;
    if (((lval ^ l) & 1) == ((mval ^ m) & 1)) l = m, lval = mval;
    else if (((rval ^ r) & 1) == ((mval ^ m) & 1)) r = m, rval = mval;
    else assert(false);
  }
}

int main() {
  #ifdef MY_INTER
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
  #endif

  while (scanf("%d", &n) >= 1) {
    #ifdef MY_INTER
    poses.resize(n);
    for (int &p : poses)
      scanf("%d", &p);
    #endif

    qcnt = 0;
    solve();
    #ifndef MY_INTER
    break;
    #endif
  }
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<long int> a(n);
    int sigc = 0;
    long absmin = LONG_MAX;
    for(auto& i : a){
        cin >> i;
    }
    long abssum = 0;
    for(auto i : a){
        long absa = abs(i);
        if(i < 0) sigc++;
        if(absa < absmin) absmin = absa;
        abssum += absa;
    }
    if(sigc%2 == 0) cout << abssum << endl;
    else cout << abssum - 2*absmin << endl;
    return 0;
}


Measured memory_bytes: 1024
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var L = new LinkedList<int>();
        var node = L.AddLast(0);
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0")
            {
                var x = int.Parse(line[1]);
                node = L.AddBefore(node, x);
            }
            else if (line[0] == "1")
            {
                var d = int.Parse(line[1]);
                if (d > 0)
                    for (int j = 0; j < d; j++) node = node.Next;
                else
                    for (int j = 0; j < -d; j++) node = node.Previous;
            }
            else
            {
                var t = node.Next;
                L.Remove(node);
                node = t;
            }
        }
        L.RemoveLast();
        Console.WriteLine(string.Join("\n", L));
    }
}



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

int main() {
  int A, B;
  cin >> A >> B;
  int c = 0;
  for (int i = A; i <= B; i++) {
    if (i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100) / 10) {
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

int a, b;

int main(){
	scanf("%d", &a);
	b = (a + 1) / 2;
	printf("%.8lf\n", (double)b / (double)a);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    vector<ll> str;
    cin>>N;
    rep(i, N*3){
        ll a;
        cin>>a;
        str.push_back(a);
    }
    sort(all(str));
    ll count=0;
    rep(i, N){
        ll th=N+i*2;
        count+=str[th];
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    string tmp1="", tmp2="";
    rep(i, b) tmp1 += to_string(a);
    rep(i, a) tmp2 += to_string(b);
    if (tmp1 < tmp2) cout << tmp1;
    else cout << tmp2;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
pair<int,pair<int,int>> arr[int(1e5+10)];
int cnt[int(1e5+10)][4];
int main()
{  
  fast
  int n;
  cin>>n;
  for(int i=1,x,y,z;i<=n;++i)
  {cin>>x>>y>>z;arr[i]={x,{y,z}};}
  int select[3] {arr[1].first,arr[1].second.first,arr[1].second.second};
  for(int i=1;i<=3;++i)
    cnt[1][i]=select[i-1];
  for(int i=2;i<=n;++i)
  {
   int select[3] {arr[i].first,arr[i].second.first,arr[i].second.second};
    for(int j=1;j<=3;++j)
    {
      if(j==1)
      cnt[i][j]=select[j-1]+max(cnt[i-1][2],cnt[i-1][3]);
     else if(j==2)
      cnt[i][j]=select[j-1]+max(cnt[i-1][1],cnt[i-1][3]);
     else
      cnt[i][j]=select[j-1]+max(cnt[i-1][1],cnt[i-1][2]);
    }
  }
  cout<<max({cnt[n][1],cnt[n][2],cnt[n][3]});
}


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

using namespace std;

const long long INF = 1LL<<60;

int score(int x, int z){
	if(z == 0 || z == 4){
		return x;
	}else if(z == 1 || z == 3){
		if(x > 0){
			return x % 2;
		}else{
			return 2;
		}
	}else{
		return (x + 1) % 2;
	}
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<vector<long long>> dp(n + 1, vector<long long>(5, INF));
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 5; j++){
			for(int k = 0; k <= j; k++){
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + score(a[i], j));
			}
		}
	}
	long long ans = INF;
	for(int i = 0; i < 5; i++){
		ans = min(ans, dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15360
from collections import defaultdict
import sys
sys.setrecursionlimit(1 << 25)  # 再起上限引き上げ

G = defaultdict(lambda: [])

#load data
N,M = map(int,input().split())
color = {key: None for key in range(N)}
#graphをdefaultdictで保持することにする
for _ in range(M):
    s,t = map(int,input().split())
    G[s].append(t)
    G[t].append(s)

#隣接リストを基にたどり着ける友達をグループ化する。
def dfs(node:int, co:int):
    #終了条件、既に訪問済みなら訪問しない
    if color[node] is not None:
        return
    #処理
    color[node] = co
    for n in G[node]:
        dfs(n,co)

    return

#全てのnodeを開始点としてdfsで色分けしてみる
c = 1
for node in G.keys():
    dfs(node,c)
    c += 1

#問題への解答
Q = int(input())
for _ in range(Q):
    s,t = map(int,input().split())
    if (color[s] is not None) and (color[t] is not None) and (color[s] == color[t]):
        print('yes')
    else:
        print('no')



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

int main(){
  int N;
  cin>>N;
  int k=0,l=1000000000;
  for(int i=0;i<N;i++){
    int j;
    cin>>j;
    k=max(k,j);
    l=min(l,j);
  }
  cout<<k-l<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define ld long double
#define vii vector<ii>
#define vll vector<ll>
#define maxn -879879

template<typename T>
void trace(T a){ cout << a << '\n';}
template<typename T, typename... Args>
void trace(T a, Args ...args){ cout << a << ' '; trace(args...);}

int main(){
	vi v;
	int a,b;
	cin >> a >> b;
	for (int i = b-a+1; i <= a+b-1; ++i)
		v.push_back(i);
	for (int i = 0; i < v.size(); ++i)
		cout << v[i] << " \n"[i+1==v.size()];
 	return 0;
}



Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial



def main():
    a = input().split()
    print(a[0][0] + a[1][0] + a[2][0])


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	int a[n]={};
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	int l=1;
	int m=a[0];
	for(int i=1;i<n;i++){
		if(a[i]==m){
			l++;
		}else{
			ans+=l/2;
			l=1;
			m=a[i];
		}
	}
	ans+=l/2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c) cout<<"No";
	else if(a!=b&&a!=c&&b!=c) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<map>
#include<string>
using namespace std;
typedef pair<int,int> P;
int main(){
  map<char,int> tmp;
  tmp['I']=1,tmp['V']=5,tmp['X']=10,tmp['L']=50,tmp['C']=100,tmp['D']=500,tmp['M']=1000;
  string str;
  while(cin >> str){
    int ans = 0,i=0;
    while(1){
      if(i == str.size() - 1) {
	ans += tmp[str[str.size()-1]];
	break;
      }
      if(tmp[str[i]] < tmp[str[i+1]]) ans -= tmp[str[i]];
      else ans += tmp[str[i]];
      i++;
    }
    cout << ans << endl;
  }
}

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

int binarySearch(long* S,long n, long key){
    long left,right,mid;
        left=0;
        right=n;
        while(left < right ){
            mid=(left + right)/2;
            if (S[mid]==key){
                   return 1;
            }else if(key<S[mid]){
                right=mid;
            }else{
                left=mid+1;
            }
        }
    return 0;
}
int main(){
    long S[1000000],T[100000];
    long n,q,a,C=0,i;
    cin >> n;
    for(a=0;a<n;a++){
        cin>>S[a];
    }
    cin>>q;
    for(a=0;a<q;a++){
        cin>>T[a];
    }
    for(i=0;i<q;i++){
        if(binarySearch(S,n,T[i]) == 1){
            C+=1;
        }
    }
    cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 4192
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <cctype>
#include <stack>
#define mst(a,b) memset(a,b,sizeof(a));
const int mod = (int)1e9+7;
const int maxn = 1e5+5;
const int INF = 0x3f3f3f3f;
typedef long long LL;

using namespace std;

int a[2][105];
int n, sum[2][105];

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

bool cmp(LL a, LL b)
{
    return a>b;
}



int main()
{
    scanf("%d", &n);
    int mxn;
    mxn = -INF;
    for(int i = 0; i < 2; i++){
        for(int j = 1; j <= n; j++){
            scanf("%d", &a[i][j]);
            sum[i][j]=sum[i][j-1]+a[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        mxn = max(mxn,sum[0][i]+sum[1][n]-sum[1][i-1]);
    }
    printf("%d", mxn);
    return 0;
}

/*
0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

10
11
100 1 1 1 1 1 1 1 1 1 1

1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648

*/




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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  for (int i = 1; i <= N; ++i) m[i] = 0;

  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    m[a]++;
    m[b]++;
  }
  for (auto const& e: m) {
    cout << e.second << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;

static const int MAX = 200000;

int main() {
  int r[MAX], n;
  cin >> n;

  REP(i, n) {
    cin >> r[i];
  }

  int maxV = -1000000000, minV = r[0];
  FOR(i, 1, n) {
    maxV = max(maxV, r[i] - minV);
    minV = min(minV, r[i]);
  }
  
  cout << maxV << endl;
  return 0;
}


Measured memory_bytes: 3856
x1, y1, r1 = map(int, raw_input().split())
x2, y2, r2 = map(int, raw_input().split())
rr = (x1 - x2)**2 + (y1 - y2)**2
ro = (r1 + r2)**2
ri = (r1 - r2)**2
if rr > ro:
    print 4
elif rr == ro:
    print 3
elif ri < rr < ro:
    print 2
elif ri == rr:
    print 1
else: # rr < ri
    print 0

Measured memory_bytes: 6432
#include<stdio.h>

int main(void){
int a,b,c,i,s;
scanf("%d %d %d" ,&a,&b,&c);
s=0;

for ( i=a ; i<=b ; i++){
   if(c%i==0){s++;}
}
printf("%d\n",s);
return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>

const int Mod = 1000000007;
const int MN = 100005;

int N, Sum; char s[MN];
int nx[MN][2], f[MN];

int main() {
	scanf("%s", s + 1), N = strlen(s + 1);
	int flag = 1;
	for (int i = 1; i < N; ++i) if (s[i] == s[i + 1]) flag = 0;
	if (flag) return puts("1"), 0;
	f[N + 1] = 1, nx[N + 1][0] = nx[N + 1][1] = nx[N + 2][0] = nx[N + 2][1] = N + 2;
	for (int i = N; i >= 1; --i) {
		(Sum += s[i] == 'a' ? 1 : 2) %= 3;
		nx[i][0] = s[i] == 'a' ? i + 1 : s[i + 1] == 'b' ? i + 2 : nx[i + 2][0];
		nx[i][1] = s[i] == 'b' ? i + 1 : s[i + 1] == 'a' ? i + 2 : nx[i + 2][1];
		f[i] = (f[nx[i][0]] + f[nx[i][1]] + (Sum == 0)) % Mod;
	}
	printf("%d\n", (f[1] - (Sum == 0) + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	static int N;
	static int W;
	static int[] w;
	static int[] v;
	static long[][] memo;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		W = sc.nextInt();

		w = new int[N];
		v = new int[N];
		memo = new long[N][W + 1];

		for(int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			for(int j = 0; j <= W; j++)
				memo[i][j] = -1;
		}

		long value = dp(0, W);

		System.out.println(value);
	}
	static long dp(int i, int u) {
		if(i >= N)
			return 0;
		if(memo[i][u] != -1)
			return memo[i][u];
		long value;
		long v1 = 0;
		long v2 = 0;
		if(u >= w[i]) {
			v1 = dp(i + 1, u - w[i]) + v[i];
		}
		value = v2 = dp(i + 1, u);
		if(v1 > v2) {
			value = v1;
		}
		memo[i][u] = value;
		return value;
	}
}


Measured memory_bytes: 126416
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	H := nextInt(sc)
	var maxa int
	b := make([]int, N)

	for i := 0; i < N; i++ {
		a := nextInt(sc)
		maxa = max(maxa, a)
		b[i] = nextInt(sc)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(b)))

	//強い投げ刀を投げられるだけ投げる
	ans := 0
	for i := range b {
		if b[i] >= maxa {
			H -= b[i]
			ans++
			if H <= 0 {
				fmt.Println(ans)
				return
			}
		}
	}
	// まだHPが残っているので最強の振り刀を振り続ける
	for {
		H -= maxa
		ans++
		if H <= 0 {
			fmt.Println(ans)
			return
		}
	}
}


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

int main(){
    long long n;
    long long ans=1000;
    cin>>n;
    vector<long long> A(n),B(n);
    rep(i,n)cin>>A[i];
    long long minv=A[0];
    for(long long i=0;i<n-1;i++){
        if(A[i+1]-A[i]>0){
            ans=(ans/A[i])*A[i+1]+ans%A[i];
            minv=A[i+1];
        }
    }

        cout<<ans;

    }


Measured memory_bytes: 3620