akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF        	1000000000000000007 //1e18+7
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define ld     		long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define mod         1000000007		//1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, mp) for(ll i = (a); i<=(mp); ++i)
#define trav(a, x) 	  for(auto &a : x)
#define re(i,n)       for(ll i = 0; i < n; ++i) 
const int N = 2e5 + 7;
const ld eps=1e-7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template <typename T> T gcd(T a,T mp){ if(a==0) return mp; return gcd(mp%a,a); }
template <typename T> T powm(T a,T mp, ll m){T cnt=1; while(mp>0){ if(mp%2==1) cnt=(cnt*a)%m; mp/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;} 
void prec(){

}
ll BIT[N],ans;
void update(int x, ll val)
{
	for(; x <= N; x += x&-x)
		BIT[x]=max(BIT[x],val);
}
ll prefMax(int idx)
	{
		ll ans = -2e15;
		while(idx > 0)
		{
			ans = max(ans, BIT[idx]);
			idx -= idx & -idx;
		}
		return ans;
	}
void run(){
	map <ll,ll> mp;
	int n;cin>>n;
	int h[n+1],a[n+1];
	rep(i,1,n) cin>>h[i];
	rep(i,1,n) cin>>a[i],mp[h[i]]=a[i];
	rep(i,1,n){
		update(h[i],prefMax(h[i])+mp[h[i]]);
	}
	//rep(i,1,10) cout<<BIT[i]<<" ";
	rep(i,1,200000) ans=max(ans,BIT[i]);
	cout<<ans;
}
int main()
{
    cin.sync_with_stdio(0);cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}


Measured memory_bytes: 15872
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD


X, Y = list(map(int, input().split()))

MOD = 10 ** 9 + 7

if (X + Y) % 3 != 0:
  print(0)
  exit()

if X < Y:
  X, Y = Y, X

if X > Y * 2:
  print(0)
  exit()

N = (X + Y) // 3
M = N * 2 - X

com = comb(N + 1, MOD)

print(com.com(N, M))


Measured memory_bytes: 118764
#include<cstdio>
#include<algorithm>
#include<cmath>
#define re register
const int M = 200010;
int m,sum = 0,ans = 0,sum1 = 0,sum2 = 0;
int num[M],mod1[M],mod2[M],mod[M],bit[M],cal[M];
template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch > '9' || ch < '0'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch <= '9' && ch >= '0'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
inline void pre(){
    for(re int i = 1;i <= m; i++) bit[i] = bit[i >> 1] + (i & 1);
    for(re int i = 1;i <= m; i++)
        cal[i] = cal[i % bit[i]] + 1;
}
int main(){
    read(m); pre();//预处理popcount(m以内的)
    for(re int i = 1;i <= m; i++){
        char ch = getchar();
        for(;ch != '0' && ch != '1'; ch = getchar()) ;
        num[i] = ch - '0'; sum += num[i];
    }
    if(sum == 0){
        for(re int i = 1;i <= m; i++) printf("1\n");
        return 0;
    }
    if(sum == 1){
        for(re int i = 1;i <= m; i++)
            if(num[i] == 1) printf("0\n");
            else if(num[m] == 1 || i == m) printf("2\n");
            else printf("1\n");
        return 0;
    }
    mod1[1] = 1;
    for(re int i = 2;i <= m; i++) mod1[i] = (mod1[i - 1] << 1) % (sum - 1);
    mod2[1] = 1;
    for(re int i = 2;i <= m; i++) mod2[i] = (mod2[i - 1] << 1) % (sum + 1);
    mod[1] = 1;
    for(re int i = 2;i <= m; i++) mod[i] = (mod[i - 1] << 1) % sum;
    for(re int i = 1;i <= m; i++)
        if(num[i])
            (ans += mod[m - i + 1]) %= sum,
            (sum1 += mod1[m - i + 1]) %= (sum - 1),
            (sum2 += mod2[m - i + 1]) %= (sum + 1);
    for(re int i = 1,tot;i <= m; i++)
        if(num[i] == 1)
            if(sum == 1) printf("1\n");
            else
                tot = (sum1 - mod1[m - i + 1] + (sum - 1)) % (sum - 1),
                printf("%d\n",cal[tot % (sum - 1)] + 1);
        else
            tot = (sum2 + mod2[m - i + 1]) % (sum + 1),
            printf("%d\n",cal[tot % (sum + 1)] + 1);
    return 0;
}
/*
3
011

2
1
1

3
001

2
2
0

23
00110111001011011001110

2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
3
*/

Measured memory_bytes: 6240
s=input()
t=input()
s_array=[]
t_array=[]
for i in range(len(s)):
  s_array.append(s[i])
for i in range(len(t)):
  t_array.append(t[i]) 
s_array=sorted(s_array)
 
t_array=sorted(t_array,reverse=True)
for i in range(min([len(s_array),len(t_array)])):
  if s_array[i]<t_array[i]:
    print('Yes')
    exit()
  elif s_array[i]>t_array[i]:
    print('No')
    exit()
if len(s_array)<len(t_array):
  print('Yes')
  exit()
print('No')

Measured memory_bytes: 9092
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int n;
    
    cin >> n;
    
    
    int a[n];
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int max = 0;
    int maxIndex = 0;
    for(int i = 0; i < n; i++){
        if(a[i] > max){
            max = a[i];
            maxIndex = i;
        }
    }
    
    int max2 = 0;
    int max2Index = 0;
    for(int i = 0; i < n; i++){
        if(i == maxIndex){
            continue;
        }
        if(a[i] > max2){
            max2 = a[i];
            max2Index = i;
        }
    }
    
    for(int i = 0; i < n; i++){
        if(a[i] == max){
            cout << max2 << endl;
        } else {
            cout << max << endl;
        }
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const int N = 2e5+10;
int n;
int a[N];
vector<pii> p;
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d", &n);

  rep(i, 0, n){
    scanf("%d", a+i);

    p.PB({a[i], i});
  }

  sort(p.begin(), p.end(), greater<pii>());
  rep(i, 0, n){
    int ans;
    if(p[0].S == i) ans = p[1].F;
    else ans = p[0].F;
    printf("%d\n", ans);
  }

}


Measured memory_bytes: 4080
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int m, n, k;
    scanf("%i %i", &m, &n);
    k = m * n;
    printf("%i", k);
}

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

int main() {
  int d;
  cin >> d;
  ll ans = 0;
  vector<int> open(26, -1);
  vector<ll> c(26);
  vector<vector<ll>> score(d, vector<ll>(26));
  rep(i, 26){
    cin >> c[i];
  }
  rep(i, d){
    rep(j,26){
      cin >> score[i][j];
    }
  }
  rep(i, d){
    ll max = 0;
    int max_index = 0;
    rep(j, 26){
      if(max < score[i][j]){
        max = score[i][j];
        max_index = j;
      }
    }
    ans += max;
    open[max_index] = -1;
    rep(j ,26){
      if(j != max_index){
        c[j]++;
        ans -= c[j] * (open[j] + 1);
      }
    }
    cout << max_index + 1 << endl;
  }
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll a,b,k;

  cin>>a>>b>>k;

  ll g=gcd(a,b);

  ll cnt=0;

  for(ll i=g;i>=0;i--){
    if(g%i == 0) cnt++;
    if(cnt==k){
      cout << i << endl;
      return 0;
    }
  }

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int memo[114514];

int search(int left) {
	int answer = 99999999;
	int sumipe;
	if (left < 0) return answer;
	if (left == 0) return 0;
	if (memo[left]) return ~memo[left];

	answer = search(left - 1) + 1;
	for (sumipe = 6; sumipe <= left; sumipe *= 6) {
		int candidate = search(left - sumipe) + 1;
		if (candidate < answer) answer = candidate;
	}
	for (sumipe = 9; sumipe <= left; sumipe *= 9) {
		int candidate = search(left - sumipe) + 1;
		if (candidate < answer) answer = candidate;
	}

	return ~(memo[left] = ~answer);
}

int main(void) {
	int N;
	if (scanf("%d", &N) != 1) return 1;
	printf("%d\n", search(N));
	return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INFLL = 1e18;
int main() {
    int N,T;
    cin>>N>>T;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin>>A[i]>>B[i];
    }
    vector<vector<ll>> dp1(N+2,vector<ll>(T,-INFLL)),dp2(N+2,vector<ll>(T,-INFLL));
    rep(t,T){
        dp1[0][t] = 0;
        dp2[N+1][t] = 0;
    }
    rep(i,N)rep(t,T){
        chmax(dp1[i+1][t], dp1[i][t]);
        if(t + A[i] < T){
            chmax(dp1[i+1][t+A[i]],dp1[i][t] + B[i]);
        }
    }
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    rep(i,N)rep(t,T){
            chmax(dp2[N+1-i-1][t], dp2[N+1-i][t]);
            if(t + A[i] < T){
                chmax(dp2[N+1-i-1][t + A[i]],dp2[N+1-i][t] + B[i]);
            }
    }
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    ll ans = 0;
    rep(i,N){
        rep(t,T){
            chmax(ans, dp1[i][t] + dp2[i+2][T-1-t] + B[i]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  ll max=a.at(0);
  for(int i=1;i<n;i++){
    if(max>a.at(i))
    sum+=max-a.at(i);
    else if(max<a.at(i))
    max=a.at(i);
  }
  cout << sum << endl;
}



Measured memory_bytes: 4836
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
B = [[int(i) for i in input().split()] for Q in range(Q)]

p = [0]*100001
for i in range(N):
    p[A[i]] += 1

cnt = 0
for j in range(100001):
    cnt += p[j]*j

for i in range(Q):
    cnt = cnt + (B[i][1]- B[i][0]) * p[B[i][0]]

    p[B[i][1]] += p[B[i][0]]
    p[B[i][0]] = 0

    print(cnt)


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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 modpow(ll a, ll n, ll mod) {
  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(0);
  ios::sync_with_stdio(false);

  int A, B;
  cin >> A >> B;
  if(A%3 == 0 || B % 3 == 0 || (A+B)%3==0 ){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
table = []
for i in range(N):
    a, b, c = map(int, input().split())
    table.append((a,b,c))

dpA = [0]*(N+1)
dpB = [0]*(N+1)
dpC = [0]*(N+1)

for i in range(N):
    a, b, c = table[i]
    dpA[i+1] = max(dpB[i], dpC[i]) + a
    dpB[i+1] = max(dpC[i], dpA[i]) + b
    dpC[i+1] = max(dpA[i], dpB[i]) + c

print(max(dpA[N], dpB[N], dpC[N]))


Measured memory_bytes: 65828
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            ll m=last[t];
            last[t]=i+1;
            rep(j,26){
                cn-=c[j]*(i-last[j]+1);
            }
            last[t]=m;
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        ans+=ma;
        last[idx]=i+1;
        v[i]=idx+1;
    }
    ll m=10000;
    rep(o,m){
        vector<ll>vv(d);
        rep(j,d)vv[j]=v[j];
        rep(i,100){
            ll a=rand()%d,b=rand()%26;
            vv[a]=b+1;
        }
        ll cnt=0;
        vector<ll>la(26);
        rep(i,d){
            ll t=vv[i]-1;
            cnt+=s[i][t];
            la[t]=i+1;
            rep(j,26){
                cnt-=c[j]*(i-la[j]+1);
            }
        }
        if(ans<cnt){
            cnt=ans;
            rep(j,d){
                v[j]=vv[j];
            }
        }
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3728
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		String[] sarray = S.split("");
		List<String> listA = new ArrayList<String>(Arrays.asList(sarray));
        List<String> listB = new ArrayList<String>(new HashSet<>(listA));

        if(listB.size() == 2) {
        	int count = 0;
        	for(String s: sarray) {
    			if(s.equals(listB.get(0))) {
    				count++;
    			}
    		}
        	if(count == 2) {
        		System.out.println("Yes");
        	}else {
        		System.out.println("No");
        	}

        }else {
        	System.out.println("No");
        }

	}


}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

typedef long long ll;

ll f(ll n){
    ll cnt=0;
    while(n!=0){
        n/=10;
        cnt++;
    }
    return cnt;
}

int main(){
    ll N;
    cin>>N;
    ll min=99999999;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0){
            if(min>f(N/i))min=f(N/i);
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) 
{ 
    long long res = 1;
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
        y = y>>1;
        x = x*x;
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    long long p[1001]={};
    for(long long i=1;i<=1000;i++)
    {   
        p[i]=power(i,5);
    }
    long long x;
    cin>>x;
    for(long long i=-1000;i<=1000;i++)
    {
        for(long long j=-1000;j<=1000;j++)
        {
            long long a5=0,b5=0;
            if(i>=0)
            {
                a5=p[i];
            }
            else
            {
                a5=-p[-1*i];
            }
            if(j>=0)
            {
                b5=p[j];
            }
            else
            {
                b5=-p[-1*j];
            }
            if((a5-b5)==x)
            {
                cout<<i<<' '<<j<<endl;
                i=1001,j=1001;
            }
        }
    }
    return 0;
}   

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

int n;
string s[100];
int m;
string t[100];

int main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> s[i];
	cin >> m;
	rep(i, m) cin >> t[i];
	
	int ans = 0;
	rep(i, n) {
		string x = s[i];
		int cnt = 0;
		rep(j, n) if (x == s[j]) cnt++;
		rep(j, m) if (x == t[j]) cnt--;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,x;
    cin>>n;
    
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout<<" "<<i;
        }else{
            x=i;
            do{
                if(x%10==3){
                    cout<<" "<<i;
                    break;
                }
                x/=10;
            }while(x);
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >> s;

    vector<int> a(3);

    for (int i = 0; i < 3; i++) {
        if(s[i] == 'a') {
            a[0] += 1;
        } else if (s[i] == 'b') {
            a[1] += 1;
        } else {
            a[2] += 1;
        } 
    }

    if(a[0] == 1 && a[1] == 1 && a[2] == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 

    return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define N 1000000001

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	ll s=0;
	int arr[n];
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}
	sort(arr, arr+n, greater<int>());
	s = arr[0];
	for(int i=1; i<n-1; i++){
		s += arr[(i+1)/2];
	}
	cout << s;

	
	

	return 0;
}

Measured memory_bytes: 4408
from collections import defaultdict
d = defaultdict(list)
n = int(input())
for i in range(n):
    city, point = input().split()
    d[city].append((int(point), i+1))

d2 = sorted(d.items())
for i in range(len(d2)):
    d2[i] = list(d2[i])
    d2[i][1] = sorted((d2[i][1]), reverse = True)
    for j in range(len(d2[i][1])):
        print(d2[i][1][j][1])



Measured memory_bytes: 3316
#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 int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    int lo = 1, hi = 1e9;
    int ans = 0;
    while(lo<=hi){
        int mid = lo + hi;
        mid /= 2;
        int re = 0;
        for (int i = 0; i < n;i++){
            int f = a[i] + mid - 1;
            f /=mid;
            f--;
            re+=f;
        }
        if(re<=k)
        {
            ans = mid;
            hi = mid - 1;
        }
        else{
            lo = mid + 1;
        }
    }
    cout << ans << endl;
}   
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5200
#include<stdio.h>

int main()
{
    int H, N, sum = 0;

    scanf("%d %d", &H, &N);

    int A[N];

    for(int i=0; i<N; i++)
    {
        scanf("%d", &A[i]);

        sum += A[i];
    }

    if(sum>=H)printf("Yes");

    else printf("No");

    return 0;
}

Measured memory_bytes: 2080
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string cur = "", prev = " ", s;
	int ans = 0;
	cin >> s;
	for(char c: s){
		cur += c;
		if(cur != prev)
			ans ++, prev = cur, cur = "";
	}
	cout << ans;
}


Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main(void){
    // Your code here!

  while(true){
   int t;
 cin>>t;
   if(t==0){
   break;
   }
  

 int s=1000-t;
 int w=s/500;
 int e=(s%500)/100;
  int r=((s%500)%100)/50;
  int y=(((s%500)%100)%50)/10;
  int u=((((s%500)%100)%50)%10)/5;
  int o=(((((s%500)%100)%50)%10)%5);
  cout<< w+e+r+y+u+o <<endl;
}
 
} 


Measured memory_bytes: 2996
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  while(100){
    int n,x,ans=0;
    cin >> n >> x;
    if(n==0 && x==0) break;
    for(int i=1; i<=n; i++){
      for(int j=i+1; j<=n; j++){
	for(int k=j+1; k<=n; k++){
	  if(i+j+k == x) ans++;
	}
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3084
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll K,S;
    cin >> K >> S;
    ll out = 0;
    rep(i,K+1){
        rep(j,K+1){
            if(S-i-j<=K&&S-i-j>=0) out++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.02 20:56:07
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */
string s;
ll ret = 0;

int main() {
    cin >> s;
    ll sl = s.size();

    ll an = 0;
    for (ll i = 0; i < sl - 1; i++) {
        if (s[i] == 'A') {
            an++;
            continue;
        }
        if (an > 0 && s[i] == 'B' && s[i + 1] == 'C') {
            ret += an;
            i++;
            continue;
        }
        an = 0;
    }

    cout << ret << '\n';

    /* --------------------------------- */
    return 0;
}

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

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

void solve(){
   int n;
   cin >> n;
   double s=0,x;
   while(n--){
    cin >> x;
    s+=1/x;
   }
   s=1/s;
   cout<<fixed<<setprecision(5)<<s;
}


Measured memory_bytes: 256
/*=======================
Author    : Shounak Dey
Filename  : a.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll a,b,c;
	cin >> a >> b >> c;
	if((a+b+c)>=22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;
	return 0;
}

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

char s[105];

int main()
{
    scanf("%s", s);
    int len = strlen(s), fg = 1;
    for(int i = 0; i < len && fg; i++)
    {
        if((i&1) && s[i] == 'R') fg = 0;
        if(!(i&1) && s[i] == 'L') fg = 0;
    }
    printf(fg ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define MOD 1000000007
#define MAX_H 100005





int main(){

    string s;
    cin >> s;
    bool ans = false;
    int first = 0,last = 0;
    if(s.length() == 2 && s[0] == s[1]){
        cout << "1 2" << endl;
        return 0;
    }

    for(int i = 0;i < s.length()-3+1;i++){

        string t = s.substr(i,3);
        map<char,int> mp;
        REP(j,t.length()){
            mp[t[j]]++;
        }
        map<char,int>::iterator itr;
        for(itr = mp.begin();itr != mp.end();itr++){
            if(itr-> second >= 2){
                first = i+1;
                last = i+1+2;
                ans = true;
            }
        }
        if(ans){
            break;
        }
    }

    if(ans){
        cout << first << " " << last << endl;
    }else{
        cout << "-1 -1" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
n, k = gets.chomp.split.map(&:to_i)
R, S, P = gets.chomp.split.map(&:to_i)
T = gets.chomp.chars

ans = 0

j_map = {
  'r' => P,
  's' => R,
  'p' => S
}
n.times do |i|
  if i < k || T[i] != T[i - k]
    ans += j_map[T[i]]
  else
    T[i] = ''
  end
end

p ans


Measured memory_bytes: 8700
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define el '\n'
#define oo 4294967296

const int N = 2e5;
int n, t;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	//freopen("test.inp", "r", stdin);
	//freopen("test.out", "w", stdout);
	cin >> n;
    rep(i, n) cin >> a[i];
    set<int> sa(a, a+n);
    if (n == sa.size()) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 10368
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var num = parseInt(line[0]);
    var max = 0;
    var min = 10000;
    var data = input[1].split(" ");

    for(var i = 0;i<num;i++){
        data[i] = parseInt(data[i]);        
    }
    
    for(var i = 0;i<num;i++){
        if(max<data[i]){
            max = data[i];
        }
        
        if(min>data[i]){
            min = data[i];
        }
    }
    
    
    console.log(max-min);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;
ll gcd(ll a,ll b){
   if (a%b == 0){
        return(b);
    }
   else{
       return(gcd(b, a%b));
    }
}
int main(){
  int a,b,c;cin>>a>>b>>c;
  int d=gcd(a,b);
  if(c%d==0){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

""" 解説動画を参考にDPにしてみた版(改) """

from fractions import Fraction

N = int(input())

T = []
A = []
for i in range(N):
    t,a = map(int, input().split())
    T.append(t)
    A.append(a)

# 比率を何倍したら実際の値なのかでDPを埋めてく
dp = [0] * (N)
# 始めの基準を1倍とする
dp [0] = 1

for i in range(1,N):
    # 今回 * 前回 の計算が終わったあとで整数未満を切り上げる
    # 小数が17桁以降おかしくなるぽいので、Fractionで分数を使用
    dp[i] = int(-(-(max(Fraction(T[i-1], T[i]), Fraction(A[i-1], A[i])) * dp[i-1]) // 1))

print((T[-1]+A[-1]) * dp[-1])

Measured memory_bytes: 5304
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    rep(i, S.length()) {
        char c = S[i] + N;
        if(c > 'Z') c -= 26;
        cout << c;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3632
n,m = map(int,input().split())
#ll = [list(map(int,input().split())) for _ in [0]*m]
#l=[]
#r=[]
#for i in range(m):
#  l.append(ll[i][0])
#  r.append(ll[i][1])
#l = max(l)
#r = min(r)

l=0
r=n
for _ in range(m):
  a,b = map(int,input().split())
  l = l if l>a else a
  r = r if r<b else b
print(max([0,r-l+1]))

Measured memory_bytes: 3060
N = int(input())
work = []
for _ in range(N):
  tmp = list(map(int, input().split()))
  work.append(tmp)

# 締切Bが大きい順にソート
work.sort(key=lambda x: x[1], reverse=True)
#print(work)

remain_time = work[0][1]
in_time = True

for i in range(N):
  # 現在時刻は制約厳しいほうを採用し、仕事を割り当てる
  remain_time = min(work[i][1], remain_time) - work[i][0]
  #print(i, remain_time)
  # 残り時間がマイナスになるなら失敗
  if remain_time < 0:
    in_time = False
    break

if in_time:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 53856
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  cin>>n;
  while(n--){
    Int r,c;
    cin>>r>>c;
    vector<string> s(r);
    for(Int i=0;i<r;i++) cin>>s[i];
    Int h,w;
    cin>>h>>w;
    vector<string> t(h);
    for(Int i=0;i<h;i++) cin>>t[i];
    Int ans=-1;
    auto in=[&](Int y,Int x){
      return 0<=y&&y<h&&0<=x&&x<w;
    };
    auto check=[&](Int y,Int x){
      vector<string> u=t;
      for(Int i=0;i<r;i++){
	for(Int j=0;j<c;j++){
	  if(s[i][j]=='.') continue;
	  if(!in(y+i,x+j)) return;
	  if(u[y+i][x+j]=='#') return;
	  u[y+i][x+j]='#';
	}
      }
      Int res=0;
      for(Int i=0;i<h;i++){
	Int tmp=0;
	for(Int j=0;j<w;j++){
	  if(u[i][j]=='#') tmp++;
	}
	res+=(tmp==w);
      }
      ans=max(ans,res);
    };
    for(Int k=0;k<4;k++){
      for(Int i=-r+1;i<h;i++)
	for(Int j=-c+1;j<w;j++)
	  check(i,j);
      vector<string> v(c);
      for(Int i=r-1;i>=0;i--)
	for(Int j=0;j<c;j++)
	  v[j].push_back(s[i][j]);
      swap(r,c);
      s=v;
      //for(Int i=0;i<r;i++) cout<<s[i]<<endl;cout<<endl;
    }
    cout<<ans<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 3180
import Data.List

main :: IO ()
main = do
    [_, p] <- map read . words <$> getLine
    as <- map read . words <$> getLine

    let odds  = length $ filter odd as
        evens = length $ filter even as

        ox  = 2 ^ odds

        ox' = if even p && ox == 1 then 1 else ox `div` 2
        ex  = 2 ^ evens

    print $ ox' * ex


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int num = 700;
  for(int i = 0; i < N; i++){
    if(S[i] == 'o'){
      num += 100;
    }
  }
  cout << num << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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


    int n, m;
    cin >> n >> m;
    vector<pair<int, string> > ps(m);
    rep(i, m){
        cin >> ps[i].first >> ps[i].second;
    }

    vector<bool> a(100005);
    vector<int> b(100005);
    fill(all(a), false);
    fill(all(b), 0);

    rep(i, m){
        if(ps[i].second == "AC"){
            a[ps[i].first] = true;
        }else{
            if(!a[ps[i].first]){
                b[ps[i].first]++;
            }
        }
    }

    ll ans1 = 0, ans2 = 0;
    rep(i, n+1){
        ans1 += a[i];
        if(a[i]){
            ans2 += b[i];
        }
    }

    cout << ans1 << " " << ans2 << endl;

    return 0;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;
 
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  long long A,B,C,min;
  cin >> A;
  min = A - 1;
  for (int i = 1; i<= pow(A, 0.5);i++ ){
    B = A/i;
    if (B*i == A){
      C = B + i -2;
      if( min > C ){
        min = C;
      }
    }
  }
    
  cout << min << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

//線形探索

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,A[10000+1],q,key,sum=0;
	
	scanf("%d",&n);
	for(i=0; i<n; i++) scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for(i=0; i<q; i++)
	{
		scanf("%d",&key);
		if(search(A,n,key)) sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}
	


Measured memory_bytes: 2080
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int visited[200010];
vector<vector<int>> G(200010,vector<int>(0));
void dfs(int x){
   
   visited[x]++;
   int s = G[x].size();
   if(s != 0)rep(i,s){
      if(visited[G[x][i]] == 0){
         dfs(G[x][i]);
      }
   }
   return;
}
int main(void){
   int n,m;cin >> n >> m;
   rep(i,m){
      int x,y,z;cin >> x >> y >> z;
      G[--x].pb(--y);
      G[y].pb(x);
   }
   int ans = 0;
   for(int i = 0;i < n;i++){
      if(visited[i] == 0){
         ans++;
         dfs(i);
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 11520
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    ga, sa, ba = map(int, rl().split())
    gb, sb, bb = map(int, rl().split())
    
    dp1 = [0] * 30000000
    dp1[0] = N
    M = N
    for i in range(N + 1):
        dp1[i + ga] = max(dp1[i + ga], dp1[i] - ga + gb)
        dp1[i + sa] = max(dp1[i + sa], dp1[i] - sa + sb)
        dp1[i + ba] = max(dp1[i + ba], dp1[i] - ba + bb)
        M = max(M, dp1[i])
    
    dp2 = [0] * 30000000
    dp2[0] = M
    ans = M
    for i in range(M + 1):
        dp2[i + gb] = max(dp2[i + gb], dp2[i] - gb + ga)
        dp2[i + sb] = max(dp2[i + sb], dp2[i] - sb + sa)
        dp2[i + bb] = max(dp2[i + bb], dp2[i] - bb + ba)
        ans = max(ans, dp2[i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 502940
#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 pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 


int32_t main()
{
	IOS
	int n,w;cin>>n>>w;
	vector<int>V(n+1),W(n+1);
	for(int i=1;i<=n;i++)cin>>W[i]>>V[i];
	vector<int>dp(w+1);
	
	for(int i=1;i<=n;i++)
	{
		auto dp2=dp;
		for(int j=0; j + W[i] <= w; j++)
		{
			dp2[j+W[i]]=max(dp2[j+W[i]],dp[j]+V[i]);
		}
		dp=dp2;
	}
	cout<<dp[w]<<endl;
}
		


Measured memory_bytes: 1804
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << s[3] << " " << s[4] << s[5] << s[6] << s[7] << s[8] << s[9] << s[10] << s[11]  << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
int main(void)
{
    int N, i, a[101], ans=0, count=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> a[i];
    }

    for(i=2; i<=N; i++){
        if(a[i] == a[i-1]){
            count++;

            if(i == 2){
                count++;
            }
        }

        else{
            ans += count/2;

            count = 1;
        }
    }

    ans += count/2;

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

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

int main() {
  ll n, m;
  string s;
  cin >> n >> m;
  cin >> s;

  ll cnt = 0;
  vector<ll> num(n + 1, 0);
  for (ll i = n; i >= 0; i--) {
    if (s[i] == '1') {
      cnt++;
      num[i] = cnt;
    } else {
      cnt = 0;
    }
  }

  // for (ll n : num) {
  //   cout << n << endl;
  // }

  stack<ll> ans;
  ll i = n;
  while (i > 0) {
    ll index = max(i - m, (ll) 0);
    if (s[index] == '0') {
      ans.push(i - index);
      i -= m;
    } else if (num[index] < m) {
      ans.push(m - num[index]);
      i -= m - num[index];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  
  
  while (!ans.empty()) {
    cout << ans.top() << " ";
    ans.pop();
  }
  cout << endl;
}


Measured memory_bytes: 2044
implicit none
integer (8):: a,b,c
character(10) :: s, ss, sss
read(*,*) s, ss, sss

write(*,*) char( ichar(s(1:1))-32 ) //char( ichar(ss(1:1))-32 ) //char( ichar(sss(1:1))-32 ) 

end


Measured memory_bytes: 256