akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays; 
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = Integer.parseInt(sc.nextLine());
			
			if(n == 0){
				break;
			}
			
			HashMap<String, Integer> map = new HashMap<String, Integer>();
			
			for(int i = 0; i < n; i++){
				String[] str = sc.nextLine().split(" ");
				
				for(String s : str){
					if(map.get(s) == null){
						map.put(s, 1);
					}else{
						map.put(s, map.remove(s) + 1);
					}
				}
			}
			
			String pur = sc.nextLine();
			
			int max = 0;
			ArrayList<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(); 
			
			for(Map.Entry<String, Integer> elem : map.entrySet()){
				if(elem.getKey().startsWith(pur)){
					list.add(elem);
				}
			}
			
			Collections.sort(list, new Comparator<Map.Entry<String, Integer>>(){

				@Override
				public int compare(Entry<String, Integer> o1,
						Entry<String, Integer> o2) {
					
					if(o2.getValue() - o1.getValue()  == 0){
						return o1.getKey().compareTo(o2.getKey());
					}
					
					return o2.getValue() - o1.getValue();
				}
				
			});
			
			if(list.size() == 0){
				System.out.println("NA");
			}else{
				boolean first = true;
				
				int count = 0;
				for(Map.Entry<String, Integer> elem : list){
					if(count >= 5){
						break;
					}
					
					
					if(first){
						first = false;
					}else{
						System.out.print(" ");
					}
					
					System.out.print(elem.getKey());
					count++;
				}
				
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
#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){
    int A[3][3], N;
    rep(i, 3) rep(j, 3) cin>>A[i][j];
    cin>>N;
    int b;
    rep(i, N){
        cin>>b;
        rep(j, 3) rep(k, 3){
            if(A[j][k]==b) A[j][k]=0;
        }
    }
    bool OK=false, de1=true, de2=true;
    rep(i, 3){
        de1=true;
        de2=true;
        rep(j, 3){
            if(A[i][j]!=0) de1=false;
            if(A[j][i]!=0) de2=false;
        }
        if(de1 || de2) OK=true;
    }
    if(A[0][0]==0 && A[1][1]==0 && A[2][2]==0) OK=true;
    if(A[0][2]==0 && A[1][1]==0 && A[2][0]==0) OK=true;
    cout<<(OK ? "Yes" : "No") <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String n = String.valueOf(N);

		int num = 0;

		for (int i = 0; i < n.length(); i++) {
			num += Integer.valueOf(String.valueOf(n.charAt(i)));
		}

		System.out.println(N % num == 0 ? "Yes" : "No");

	}

}

Measured memory_bytes: 23764
a,b,c,d  = map(int, input().split())
trun = 0
while a > 0 and c > 0:
    if trun == 0:
        c = c - b
        trun = 1
    else:
        a = a - d
        trun = 0

if a <= 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9184
//     COMIN FOR YOU:)

#include<bits/stdc++.h>

using namespace std;

int main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
  
    ios::sync_with_stdio(0);
    cin.tie(0);
      
   long long int n,d,cnt=0;cin>>n>>d;

    while(n--)
    {    
       long long int a,b;cin>>a>>b;
       
        if ((pow(a,2)+pow(b,2))<=(pow(d,2)))
        {
            cnt++;
        }

    }  
      
    cout<<cnt;      


   return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,M;
    cin>>N>>M;
    vi AC(N),WA(N);
    int ac=0, wa=0;
    rep(i,M) {
        int p;
        string S;
        cin>>p>>S;
        if(S=="AC") {
            if(AC.at(p-1)==0) {
                ac++;
                wa+=WA.at(p-1);
            }
            AC.at(p-1)=1;
        }
        else {
            WA.at(p-1)++;
        }
    }
    cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string solve(string s){
	if(s.size()<=25){
		for(char c='a';c<='z';c++){
			if(s.find(c)==string::npos){
				s+=c;
				return s;
			}
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		for(char c=s[i];c<='z';c++)
		{
			if(s.find(c)==string::npos){
				s[i]=c;
				s=s.substr(0,i+1);
				return s;
			}
		}
		s.erase(s.begin()+i);
	}
	return "-1";
}
int main(){
	string s;
	cin>>s;
	cout<<solve(s)<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 305;

char gr[N][N];
int n;
char nw[N][N];

bool check(int x, int y){
  for(int i = 0 ; i < n; i ++ ){
    for(int j = 0 ; j < n ; j ++ ){
      nw[(i + x) % n][(j + y) % n] = gr[i][j];
    }
  }
  for(int i = 0 ; i < n ; i ++ ){
    for(int j = 0 ; j < n ; j ++ ){
      if(nw[i][j] != nw[j][i])
        return false;
    }
  }
  return true;
}

int main(){
  fastIO;
  cin >> n;
  for(int i = 0 ; i < n ; i ++ ){
    for(int j = 0 ; j < n ; j ++ ){
      cin >> gr[i][j];
    }
  }
  int res = 0;
  for(int i = 0 ; i < n ; i ++ )
    res += check(0,i);
  cout << res * n;
  return 0; 
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };


signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  string s;
  cin >> s;
  for(int i = 0;i + 1< sz(s); i++) {
    if(s[i] == 'B' && s[i + 1] == 'C') {
      s.replace(i, 2, "D");
    }
  }
  int ans = 0 , cnt = 0;
  dg(s);
  for(int i = 0; i < sz(s); i++) {
    if(s[i] == 'B' || s[i] == 'C') {
      cnt = 0;
      continue;
    }
    dg3(i , s[i] , cnt);
    if(s[i] == 'A') cnt++;
    if(s[i] == 'D') ans += cnt;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll A=0,B=0,N,x;
ll Q(ll&i,string&S,vector<ll>&F,vector<ll>&G){
  if(S.at(i)=='0')return (A+F.at(i))%(x+1);
  return ((B-G.at(i))%(x-1)+x-1)%(x-1);
}
ll f(ll m){
  if(m==0)return 0;
  ll i=0,n=m;
  while(n>0){
    if(n%2==1)i++;
    n/=2;
  }
  return 1+f(m%i);
}
signed main(){
  ll i,s=1;string S,T;cin>>N>>S;
  T=S;sort(ALL(T));
  x=upper_bound(ALL(T),'0')-T.begin();
  x=N-x;vector<ll>F(N);
  REP(i,N){
    F.at(N-1-i)=s;
    if(S.at(N-1-i)=='1')A+=s;
    s*=2;s%=x+1;A%=x+1;
  }
  s=1;vector<ll>G(N);
  if(x<=1){
    REP(i,N)G.at(i)=-1;
  }
 else REP(i,N){
    G.at(N-1-i)=s;
    if(S.at(N-1-i)=='1')B+=s;
    s*=2;s%=x-1;B%=x-1;
  }
  REP(i,N){
    if(x==1&&S.at(i)=='1')cout<<0<<endl;
    else{
      ll RES=Q(i,S,F,G);
      cout<<1+f(RES)<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 6740
import java.io.*;
import java.util.*;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();
                int M = scan.nextInt();
                int X = scan.nextInt();

                int[] C = new int[N];

                int[][] A = new int[N][M];

                for (int gyou = 0; gyou < N; gyou++) {
                        C[gyou] = scan.nextInt();
                        for (int retsu = 0; retsu < M; retsu++) {
                               A[gyou][retsu] = scan.nextInt(); 
                        }
                }

                int min = 0;
                int first_flag = 1;

                for (int bit = 0; bit < Math.pow(2,N); bit++) {
                        int kingaku = 0;
                        int[] rikaido = new int[M];

                        for (int sft = 0; sft < N; sft++) {
                                if ((1&bit>>sft) == 1) {
                                        kingaku += C[sft];
                                        for (int rikaido_res = 0; rikaido_res < M; rikaido_res++) {
                                                rikaido[rikaido_res] += A[sft][rikaido_res];
                                        }
                                }
                        }

                        int tassei_count = 0;
                        for (int tassei_res = 0; tassei_res < M; tassei_res++) {
                                if (rikaido[tassei_res] >= X) {
                                        tassei_count++;
                                }
                        }

                        if ((tassei_count == M && min > kingaku) || (first_flag == 1 && tassei_count == M)) {
                                min = kingaku;
                                first_flag = 0;
                        }
                }

                if (min == 0) {
                        System.out.println(-1);
                } else {
                        System.out.println(min);
                }
        }
}

Measured memory_bytes: 37576
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
typedef pair<int, int> Pii;

vector<int> watch[10];

int f(vector<int>& a) {
	return a[0] / 5 * 60 * 60 + a[1] * 60 + a[2];
}

string conv(int t) {
	string h = "00", m = "00", s = "00";
	int ss = t % 60, mm = t / 60 % 60, hh = t / 60 / 60;
	s[0] += ss / 10, s[1] += ss % 10;
	m[0] += mm / 10, m[1] += mm % 10;
	h[0] += hh / 10, h[1] += hh % 10;
	return h + ":" + m + ":" + s;
}

bool ok(vector<int>& a) {
	return a[0] % 5 == a[1] / 12;
}

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

	int n;
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			vector<int> a(3);
			for(int j = 0; j < 3; j++) {
				cin >> a[j];
			}
			sort(a.begin(), a.end());
			watch[i] = a;
		}

		vector<Pii> v;
		for(int i = 0; i < n; i++) {
			vector<int> w = watch[i];
			do {
				for(int j = 0; j < 60; j++) {
					vector<int> a = w;
					for(int k = 0; k < 3; k++) {
						a[k] = (a[k] + j) % 60;
					}
					if(!ok(a)) continue;
					int t = f(a);
					v.push_back(Pii(t, i));
				}
			} while(next_permutation(w.begin(), w.end()));
		}
		sort(v.begin(), v.end());
		int m = v.size();

		int ans1 = 0, ans2 = 0;
		int anst = 1 << 28;
		for(int i = 0; i < m; i++) {
			int cnt = 1, t1 = v[i].first;
			vector<int> used(n);
			used[v[i].second] = 1;
			for(int j = 0; j < m; j++) {
				int id = v[(i + j + 1) % m].second, t2 = v[(i + j + 1) % m].first;
				if(!used[id]) {
					used[id] = 1;
					cnt++;
				}
				if(cnt == n) {
					int diff = (t2 + 43200 - t1) % 43200;
					if(anst > diff) {
						anst = diff;
						ans1 = t1;
						ans2 = t2;
					}
					break;
				}
			}
		}

		//cout << anst << endl;
		cout << conv(ans1) << " " << conv(ans2) << endl;
	}
}

Measured memory_bytes: 3148
#include <iostream>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  for(int i = 0; i < Q; ++i){
    int v, w;
    cin >> v >> w;
    if(N == 1) cout << min(v,w) << endl;
    else{
      --v;--w;
      if(v > w) swap(v,w);
      int v_ = v, w_ = w, s = 0, t = 0;
      while(v_ > 0){
        ++s;
        v_ = (v_-1)/N;
        //v_ /= N;
      }
      while(w_ > 0){
        ++t;
        w_ = (w_-1)/N;
        //w_ /= N;
      }
      for(int i = 0; i < (t-s); ++i){
        w = (w-1)/N;
      }
      while(w != v){
        w = (w-1)/N;
        v = (v-1)/N;
      }
      cout << v+1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4050;
char s[N];
int n; ll f;
vector<int> r,g,b;
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;++i){
        if(s[i]=='R') r.push_back(i);
        if(s[i]=='G') g.push_back(i);
        if(s[i]=='B') b.push_back(i);
    }
    for(auto i:r){
        for(auto j:g){
            int op=max(i,j)+abs(i-j);
            if(op<=n&&s[op]=='B') f--;
            op=(i+j)>>1;
            if((j-i)%2==0&&s[op]=='B') f--;
            op=min(i,j)-abs(i-j);
            if(op>=1&&s[op]=='B') f--;
            f+=b.size();
        }
    }
    printf("%lld\n",f);
}

Measured memory_bytes: 3832
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N;
  cin>>N;
  while(N--){
    string s;
    cin>>s;
    int sum = 0;
    REP(i, s.size()) sum += s[i] -'0';
    if(((sum-1)/9 + s.size()) % 2 == 0) cout<<"Fabre wins."<<endl;
    else cout<<"Audrey wins."<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import math

n,d = map(int,input().split())
l = []

for i in range(n):
    array = list(map(int,input().split()))
    l.append(array)

def dist(a,b):
    cnt = 0
    for i in range(len(a)):
        cnt += (a[i]-b[i])**2
    return math.sqrt(cnt)

ans = 0
    
for i in range(n):
    for j in range(i+1,n):
        if dist(l[i],l[j])%1 == 0:
            ans+=1
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define vv vector
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
typedef pair<ll,ll> pll;
typedef vv<ll> vll;
// #define dbg

ll inf =1e14;

void bfs(ll s, vll & dis, vv<vll>& gr){
	queue<pll> q;
	q.emplace(0,s);
	while(!q.empty()){
		pll t= q.front();
		q.pop();
		if(dis[t.ss] != inf)
			continue;
		dis[t.ss] = t.ff;
		for(auto &i: gr[t.ss]){
			if(dis[i] == inf){
				q.emplace(t.ff+1, i);
			}
		}
	}
}

int main(){
	fastio;
	ll n,x,y;
	cin>>n>>x>>y;
	vv<vll> gr(n+1);
	for(ll i =1; i<=n-1; i++){
		gr[i].push_back(i+1);
		gr[i+1].push_back(i);
	}
	gr[x].push_back(y);
	gr[y].push_back(x);

	vv<vll> d(n+1, vll(n+1, inf));
	for(ll i=0; i<n; i++){
		bfs(i+1, d[i+1], gr);
	}
	vll as(n, 0);
	for(ll i=1; i<=n; i++){
		for(ll j=i+1; j<=n; j++){
			as[d[i][j]]++;
		}
	}

	#ifdef dbg
			cerr << ":\n";
			for (auto &i : d)
			{
				for (auto &j : i)
					if (j < 1e9)
						cerr << j << "  ";
					else
						cerr << -1 << " ";
				cerr << endl;
			}
	#endif
	for(ll i=1; i<=n-1; i++){
		cout<<as[i]<<endl;
	}

}

Measured memory_bytes: 31744
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    X,Y = map(int,input().split())
    ans = 0
    power = 1
    while power*X <= Y:
        ans += 1
        power *= 2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), l = in();

    ll sum = 0;
    for (ll i = l; i <= l + n - 1; ++i)sum += i;

    if (l + n - 1 < 0) {
        sum -= l + n - 1;
    } else if (l > 0) {
        sum -= l;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int CC[MAX] = {0};

void init() {
  int i;
  for (i = 0; i < MAX; ++i) {
    CC[i] = i;
  }
}

int find(int a) {
  if (a == CC[a]) {
    return a;
  }

  return CC[a] = find(CC[a]);
}

int isSame(int a, int b) {
  if (find(a) == find(b)) {
    return 1;
  }
  else {
    return 0;
  }
}

void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  CC[b] = a;
}

int main() {
  int n, m, q, i, j, k;
  init();
  scanf("%d %d", &n, &m);
  for ( i = 0; i < m; ++i ) {
    scanf("%d %d", &j, &k);
    unite(j, k);
  }
  scanf("%d", &q);

  for ( i = 0; i < q; i++ ) {
    scanf("%d %d", &j, &k);
    if (isSame(j, k)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}



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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll A, B, C;
	read3(A, B, C);

	ll ans(0);
	ll b = min(B, C);
	ans += 2 * b;
	B -= b;
	C -= b;

	if (C == 0)
		ans += B;
	else
	{
		ans += min(C, A+1);
	}
	pnl(ans);
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const int mod=1e9+7;
int n,a[610],b[610],cnt=0,num=0,c[610];
int f[610][310][310];//从后往前DP。记 f[i,j,k] 表示已经处理完了 i 后面的数，有多少个 j>i,cj=1 的数匹配的是 ≤i 的数，有多少个 j>i,cj=0 的数匹配的是 ≤i 的数。
void add(int &a,int b) {a+=b;a-=(a>=mod)?mod:0;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=2*n;i+=2)
	{
		if(a[i]!=-1&&a[i+1]!=-1) b[a[i]]=b[a[i+1]]=2;
		else if(a[i]!=-1) b[a[i]]=1;
		else if(a[i+1]!=-1) b[a[i+1]]=1;
		else cnt++;
	}
	for(int i=1;i<=2*n;i++)
	{
		if(b[i]==0) c[++num]=0;
		if(b[i]==1) c[++num]=1;
	}
	f[num][0][0]=1;
	for(int i=num;i>=1;i--)
		for(int j=0;j<=min(num,n);j++)
			for(int k=0;k<=min(num,n);k++)
				if(c[i]==1)
                {
                    add(f[i-1][j+1][k],f[i][j][k]);
                    if(k) add(f[i-1][j][k-1],f[i][j][k]);
                }
                else
                {
                    add(f[i-1][j][k+1],f[i][j][k]);
                    if(k) add(f[i-1][j][k-1],f[i][j][k]);
                    if(j) add(f[i-1][j-1][k],(LL)f[i][j][k]*j%mod);
                }
    int ans=f[0][0][0];
    for(int i=1;i<=cnt;i++) ans=(LL)ans*i%mod;
    printf("%d",ans);
}

Measured memory_bytes: 225536
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

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

struct UnionFind {

    vector < int > node;
    UnionFind(int n) : node(n, -1) {}

    bool unite(int x, int y) {
        x = root(x); 
        y = root(y);
        if (x != y) {
            if (node[y] < node[x]) swap(x, y);
            node[x] += node[y]; 
            node[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        return node[x] < 0 ? x : node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
    
};

int N,M;
int p[100010];
int x[100010];
int y[100010];

int main ()
{
    scanf("%d%d", &N, &M);
    REP(i,N) scanf("%d", p + i);
    REP(i,M) scanf("%d%d", x + i, y + i);
    
    UnionFind inst(100010);
    REP(i,M) {
        inst.unite(x[i], y[i]);
    }

    map < int, vector < int > > G;
    for (int i = 1; i <= N; i++) {
        G[inst.root(i)].push_back(i);
    }

    map < int, int > idx;
    REP(i,N) idx[p[i]] = i + 1;

    int ans = 0;
    for (auto itr = G.begin(); itr != G.end(); itr++) {
        vector < int > g = itr->second;
        set < int > use;
        REP(i,g.size()) use.insert(idx[g[i]]);
        REP(i,g.size()) {
            if (use.find(g[i]) != use.end()) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, ans = 0, a, maxa = 0;
    cin >> n;
    int ac[100050] = {0};
    for(int i = 0;i < n;i++){
        cin >> a;
        ac[a]++;
        ac[a - 1]++;
        ac[a + 1]++;
        maxa = max(maxa,a + 1);
    }

    for(int i = 0;i <= maxa;i++){
        ans = max(ans, ac[i]);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> m(n);
    std::vector<int> dp(n, MOD);
    for (int i = 0; i < n; i++) {
        cin >> m[i];
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        if (i + 1 < n) {
            chmin(dp[i + 1], dp[i] + abs(m[i + 1] - m[i]));
        }
        if (i + 2 < n) {
            chmin(dp[i + 2], dp[i] + abs(m[i + 2] - m[i]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr

def main():
    d = int(stdin.readline().rstrip())
    for _ in range(d):
        print(random.randint(1,26))
main()

Measured memory_bytes: 26952
import sys

data = sys.stdin.readline()
res = 0
if "R" == data[1]:
    if "R" == data[0]:
        if "R" == data[2]:
            res = 3
        else:
            res = 2
    else:
        if "R" == data[2]:
            res = 2
        else:
            res = 1
else:
    if "R" == data[0] or "R" == data[2]:
        res = 1

print(res)


Measured memory_bytes: 8992
#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;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;
 
int arr[N];
int posn[N];
int prime[N];

int DP[N];
int k;

int divisors(int n)
{
	int cnt = 0;
	for(int i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			cnt += 2;
			cnt -= (i * i == n);
		}
	}
	return cnt - 1;
}

int f(int idx)
{
	if(idx < 1)
	{
		return 0;
	}
	if(idx == 1)
	{
		return 1;
	}
	int ret = 0;
	if(idx % k == 0)
	{
		return f(idx / k);
	}
	else
	{
		return ((idx - 1) % k == 0);
	}
}
 
void solve() 
{
	int n, k;
	cin >> n >> k;
	if(n == k)
	{
		cout << 0 << endl;
		return;
	}
	if(n == 0)
	{
		cout << 0 << endl;
		return;
	}
	if(n > k)
	{
		int diff = k;
		if(n % k == 0)
		{
			 cout << 0 << endl;
		}
		else
		{
			cout << min(n % k, k - n % k) << endl;
		}
	}
	else
	{
		cout << min(n, k - n) << endl;
	}
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class BUnevenNumbers {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n;
        in>>n;
        if(n<10) out<<n;
        else if(n<100) out<<9;
        else if(n<1000) out<<n-90;
        else if(n<10000) out<<909;
        else if(n<100000) out<<n-9090;
        else out<<90909;
        out<<endl;
    }
};

int main() {
    BUnevenNumbers solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    map<ll, ll> mp;
    rep(i, n) {
        ll m; cin >> m;
        mp[m]++;
    }
    ll count = 0;
    for (auto elem : mp) {
        ll k = elem.first, v = elem.second;
        if (v >= k) count += v - k;
        else count += v;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    string s=is();
    if(s[1]=='B'){
        ose("ARC");
    }else{
        ose("ABC");
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define MP make_pair
#define rep(i, n) for(int i = 0; i < n; i ++)
#define rep1(i, a, b) for(int i = a; i < b; i ++)
#define per1(i, a, b) for(int i = a; i >= b; i --)
typedef long long LL;
int main(void){
	LL n, p; scanf("%lld %lld", &n, &p);
	LL h = sqrt(p) + 1;
	LL ans = 1;
	rep1(i, 2, h+1){
		if(p % i == 0){
			int cnt = 0;
			while( p % i == 0 ){
				p /= i;
				cnt++;
			}
			int t = cnt / n;
			while( t-- ) ans = ans*i;
		}
	}
	if(p != 1){
		if(n == 1) ans *= p;
	
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
n = int(input())

if n%2 == 0:
    su = n+1
    print((n*(n-1)//2)-n//2)
    for i in range(1,n+1):
        for k in range(1,n+1):
            if i+k != su and i < k:
                print(i,k)
if n%2 == 1:
    su = n
    print((n*(n-1)//2)-(n-1)//2)
    for i in range(1,n+1):
        for k in range(1,n+1):
            if i+k != su and i < k:
                print(i,k)


Measured memory_bytes: 3612
#include <stdio.h>
	int yama[50];
	
void maze(int c,int d){
	int kara[50];
	int h;
	for(h = 0;h < c;h++){
		kara[h] = yama[h];
	}
	for(h = 0;h < d;h++){
		yama[h] = yama[h + c];
	}
	for(h = 0;h < c;h++){
		yama[h + d] = kara[h];
		
		
	}
	
}

int main(void)
{
	int a,b;
	int c,d;
	int i,j = 0,q = 0;
	int ans[50];
	while(1){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0)break;
		j = 1;
		for(i = a - 1;i >= 0;i--){
			yama[i] = j;
			j++;
		}
		
		for(i = 0;i < b;i++){
			scanf("%d %d",&c,&d);
			maze(c-1,d);
		}
		printf("%d\n",yama[0]);

	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d});

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n,m;

void input(void){
    cin>>n>>m;
}

void solve(void){
    cout<<max({n+m,n-m,n*m})<<endl;
    return;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    mint nPk(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fact[n] * ifact[n - k];
    }

} combination(10000);


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

    mint ans = combination.nPk(k, n);
    cout << ans.x << endl;

}





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

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int i, n, q, key, A[10000 + 1], sum = 0;
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];

    cin >> q;
    for(i = 0; i < q; i++){
        cin >> key;
        if( (search(A,n,key)) ){
            sum++;
        }
    }
    cout << sum << endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    int ans = 0;
    for (int j = 0; j < s.size(); j++)
      if (s[i] == s[j])
        ans++;
    if (ans % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long 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 pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N, A, B, C;
	cin >> N >> A >> B >> C;

	multiset<ll> ms;
	rep(i, 0, N) {
		ll l;
		cin >> l;
		ms.insert(l);
	}

	set<pair<ll, multiset<ll>>> st({ {0,ms} });

	ll ans = ll_max;
	for (auto itr = st.begin(); itr != st.end();itr++) {
		ms = itr->second;
		ll cnt = itr->first;
		N = ms.size();
		if (2<N && cnt < ans) {
			for (auto itr1 = ms.begin(); itr1 != ms.end(); itr1++) {
				auto itr2 = itr1; itr2++;
				while (itr2 != ms.end()) {
					auto itr3 = itr2; itr3++;
					while (itr3 != ms.end()) {
						ans = min(ans, cnt + abs(*itr1 - C) + abs(*itr2 - B) + abs(*itr3 - A));
						itr3++;
					}
					itr2++;
				}
			}
			auto itr1 = ms.begin();
			while(itr1!=ms.end()){
				ll val1 = *itr1;
				auto itr2 = itr1; itr2++;
				ms.erase(itr1);
				while (itr2 != ms.end()) {
					ll val2 = *itr2;
					ms.erase(itr2);
					auto itr_tmp=ms.insert(val1 + val2);
					st.insert({ cnt + 10,ms });
					ms.erase(itr_tmp);
					itr2 = ms.insert(val2);
					while (itr2 != ms.end() && *itr2 == val2) {
						itr2++;
					}
				}
				itr1 = ms.insert(val1);
				while (itr1 != ms.end() && *itr1 == val1) {
					itr1++;
				}
			}
		}
	}

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


Measured memory_bytes: 4796
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int s=0,n,a[222];
	cin>>n;
	for(int i=0;i<n*2;i++)cin>>a[i];
	sort(a,a+n*2);
	for(int i=0;i<n;i++)
	{
		s+=min(a[i*2],a[i*2+1]);
	}
	cout<<s<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    unordered_set<int> st;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (st.find(a) == st.end())
            st.insert(a);
        else
            st.erase(a);
    }
    cout << st.size() << endl;
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int sum = 0;
    int num = n;
    while(num){
        sum += num%10;
        num =num/10;
    }
    if(n%sum==0){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    
    
    
    return 0;
}























































Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    int now=n;
    int an=0;
    REP(i,n){
        int x;
        R(x);
        now=min(now,x);
        an+=now==x;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := make([]int, n*2)
	for i := 0; i < n*2; i++ {
		fmt.Scan(&l[i])
	}
	ans := 0
	sort.Ints(l)

	for i := 0; i < n; i++ {
		ans += min(l[i*2], l[i*2+1])
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 512