akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define MOD 1000000007
 
int main()
{
	
    speed;
    // test{};
  	ll a,b;
  cin>>a>>b;
  if(a!=0&&a<=9&&b!=0&&b<=9)
    cout<<a*b<<endl;
  else
    cout<<-1<<endl;

    
    return 0;

}	

Measured memory_bytes: 256
main = do
    a <- readLn :: IO Int
    _ <- readLn :: IO Int
    _ <- readLn :: IO Int
    _ <- readLn :: IO Int
    e <- readLn :: IO Int
    k <- readLn :: IO Int
    if e-a <= k
        then putStrLn "Yay!"
        else putStrLn ":("



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



int main() {
  long long int A,B,C,K,ans=0;
  cin >> A>>B>>C>>K;
  
    if (K <= A)
    {
      cout << K << endl;
      return 0;
    }
    
      ans += A;
      K -= (A+B);
      if (K > 0)
      {
        ans -= K;
        cout << ans;
        return 0;
      }
      else
      {
        cout << ans;
      }
    
    
  
  return 0;
}

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

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vll;

vi binary_digit(ll x){
  vi ans(50);
  for(int k=0;k<50;++k){
    int a=(x>>k)&1;
    ans[k]=a;
  }
  return ans;
}

vi minority(vll& A){
  vi count(50);
  int N=A.size();
  for (int n=0;n<N;++n){
    vi bi=binary_digit(A[n]);
    for (int i=0;i<50;++i){
      count[i]+=bi[i];
    }
  }

  vi ans(50);
  for (int i=0;i<50;++i){
    if(count[i]<N-count[i]){ans[i]=1;}
    else{ans[i]=0;}
  }

  return ans;
}

int main(){
  int N;cin>>N;ll K;cin>>K;
  vll A;
  for (int n=0;n<N;++n){
    ll a;cin>>a;A.push_back(a);
  }

  vi K_bin=binary_digit(K);
  vi mino=minority(A);
  ll X=0;
  int diff_flag=0;
  int K_top_flag=0;
  for (int i=49;i>=0;--i){
    if(K_bin[i]==1){K_top_flag=1;}
    if(K_top_flag==1){
      if(diff_flag==0&&K_bin[i]==0){
        X+=0;
      }
      else{
        X+=mino[i]*(ll)pow(2,i);
        if(K_bin[i]!=mino[i]){diff_flag=1;}
      }
    }
  }

  ll ans=0;
  for (int i=0;i<N;++i){
    ans+=X^A[i];
  }
  cout << ans;
  return 0;
}

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

int main(){
    int a,b;    cin>>a>>b;
    string s;   cin>>s;

    string ans="Yes";

    if(s[a]!='-')ans="No";
    else{
        s[a]='0';

        for(int i=0;i<=a+b;i++){
            if('0'<=s[i] && s[i]<='9')ans="Yes";
            else{
                ans="No";
                break;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    size_t x,y;
    cin >> x >> y;
    size_t ans = 0;
    for (size_t i = x; i <= y; i = (i<<1)) {
       ans++; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

int n,m;
double ef[105][105];

double func(){
	double ans=0,dp[105][105]={0};
	for(int i=0;i<n;i++){
		dp[0][i]=1;
	}
	for(int i=1;i<m;i++){
		for(int j=0;j<n;j++){
			double tmp=0;
			for(int k=0;k<n;k++){
				tmp=max(tmp,dp[i-1][k]*ef[k][j]);
			}
			dp[i][j]=tmp;
		}
	}
	for(int i=0;i<n;i++){
		ans=max(ans,dp[m-1][i]);
	}
	return ans;
}

int main(){
	cout<<shosu(2);
	while(1){
		cin>>n>>m;
		if(n==0&&m==0) break;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>ef[i][j];
			}
		}
		cout<<func()<<endl;
	}
}

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

using namespace std;

int main()
{
    int a, b, ans = 0;
    scanf("%d %d",&a, &b);
    if(a%2 == 0)
        ans++;
    if(b%2 == 0)
        ans++;
    if(ans == 0)
        printf("Odd\n");
    else
        printf("Even\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,n,k;
int main(){
	scanf("%lld %lld",&n,&k);
	if (k%2==0){
		a=n/(k/2);
		b=n/k;
		c=a-b;
		printf("%lld\n",b*b*b+c*c*c);
	}
	else {
		a=n/k;
		printf("%lld\n",a*a*a);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long

int gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

int main(){

	int N, X;
	int x[100001];

	cin >> N >> X;

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

	int g = abs(X - x[0]);
	for (int i = 1; i < N; i++){
		g = gcd(g, abs(X - x[i]));
	}

	cout << g << endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

#define One -1
#define Two -2
#define Three -3


int A[101][101], B[101], C[101], D[101];
int n; 
int time;

void DepthFirstSearch(int m){

  int i;

  //printf("ok\n");
  D[m] = Two;
  time++;
  B[m] = time;

  for(i = 0;i <= n;i++){
    if(A[m][i] && D[i] == Three){
      DepthFirstSearch(i);
    }
  }
  D[m] = One;
  C[m] = ++time;
}

void DepthFirst(int l){
  int i;
  for(i = 0;i < l;i++){
    if(D[i] == Three){
      //printf("ok\n");
      DepthFirstSearch(i);
    }
  }
}

int main(){

  int i,j;
  int id,d,f;

  scanf("%d",&n);

  for(i = 0; i < 100;i++){
    for(j = 0;j < 100;j++){
      A[i][j] = 0;
    }
    D[i] = Three;
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&d);
    for(j = 0;j < d;j++){
      scanf("%d",&f);
      A[i][f-1] = 1;
    }
  }

  DepthFirst(n);

  for(i = 0;i < n;i++){
    printf("%d %d %d\n",i+1,B[i],C[i]);
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > 9 || b > 9)
            System.out.println("-1");
        else 
            System.out.println(a * b);
    }
}

Measured memory_bytes: 23764
#include        <bits/stdc++.h>
using   namespace       std;
typedef long long ll;

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int X;
        cin >>X;
        if (X<600)
                cout <<8 <<endl;
        else if (X<800)
                cout <<7 <<endl;
        else if (X<1000)
                cout <<6 <<endl;
        else if (X<1200)
                cout <<5 <<endl;
        else if (X<1400)
                cout <<4 <<endl;
        else if (X<1600)
                cout <<3 <<endl;
        else if (X<1800)
                cout <<2 <<endl;
        else
                cout <<1 <<endl;
        return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#define MAX 2000200
#define INT_MIN -2000000300
using namespace std;
typedef long long ll;

class priority_queue{
private:
  int index;
  int Array[MAX];

  int heapIncreaseKey(int i,ll key){
    if(key < Array[i])return -1;
    Array[i] = key;
    while(i > 1 && Array[getParent(i)] < Array[i]){
      ll h = Array[i];
      Array[i] = Array[getParent(i)];
      Array[getParent(i)] = h;
      i = getParent(i);
    }
  }

  void maxHeapify(int i){
    ll l = getLeft(i);
    ll r = getRight(i);
    ll largest;
    if(l <= index && Array[l] > Array[i])largest=l;
    else largest=i;
    if(r<=index && Array[r] > Array[largest])largest = r;
    if(largest != i){
      ll h;
      h = Array[i];
      Array[i] = Array[largest];
      Array[largest] = h;
      maxHeapify(largest);
    } 
  }

public:

  priority_queue(){
    index = 0;
  }

  void Insert(ll key){ //maxHeapInsert
    ++index;
    Array[index] = INT_MIN;
    heapIncreaseKey(index,key);
  }

  ll heapExtractMax(){
    if(index < 1)return -1;
    ll max = Array[1];
    Array[1] = Array[index];
    index--;
    maxHeapify(1);
    return max;
  }


  int getParent(int i){
    return i/2;
  }

  int getLeft(int i){
    return 2*i;
  }

  int getRight(int i){
    return 2*i+1;
  }

};



int main(){
  string op;
  ll val;
  priority_queue pque = priority_queue();

  while(true){
    cin >> op;
    if(op == "insert"){
      scanf("%lld",&val);
      pque.Insert(val);
    }
    else if(op == "extract"){
      printf("%lld\n",pque.heapExtractMax());
    }
    else if(op == "end")break;
  }

  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n;
    cin >> n;
    string s[n];
    char memo[5] = {'M','A','R','C','H'};
    ll cnt[5] = {};

    rep(i,0,n){
        cin >> s[i];
        rep(j,0,5){
            if(s[i][0] == memo[j]){
                cnt[j]++;
            }
        }
    }

    ll ans = 0;
    rep(i1,0,5){
        rep(i2,i1+1,5){
            rep(i3,i2+1,5){
                ans += cnt[i1]*cnt[i2]*cnt[i3];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6708
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=200000000000005LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
int n,m,k;
int a;
int t=0;
void swap(int &c,int &d){
	int f=c;
	c=d;
	d=f;
}
int main() {
	cin>>n;
	cin>>a;
	int b;
	rep(i,0,n-1){
		cin>>b;
		while(1) {
		    if(a<b)swap(a,b);
		    if(!b)break;
		    a%=b;
		}
	}
	cout<<a<<endl;
	return 0;
}


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

int main () {
  int X;
  int i, j;
  bool v[m];
  cin >> X;
  for (i = 0; i < m; i++)
    v[i] = true;
  v[0] = v[1] = false;
  for (i = 2; i < m; i++)
    if (v[i])
      for (j = 2*i; j < m; j += i)
        v[j] = false;
  for (i = X; i < m; i++) {
    if (v[i]) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 384
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x-1,y-1)
print(uf.group_count()-1)

Measured memory_bytes: 75416
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    ll N , M ;
    cin >> N >> M ;
    
    vector<bool>oks(N + 1 , true) ;
    for(int i=0;i<M;++i){
    int a;cin>>a;
    oks[a]=false;
    }

   vector<ll>dp(N+1);
   dp[0]=1;
   for(ll now=0;now<N;++now){
   for(ll next=now+1;next<=min(N,now+2);next++){
   if(oks[next]){
   dp[next]+=dp[now];
   dp[next]%=1000000007;
   }
   }
   }
  
   cout<<dp[N]<<endl;

    
    


   
    return 0 ;
}

 


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

int main() {
  int n, l = 0, r = l, ans = 0;
  cin >> n;

  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  while (l < n) {
    if (h[l] == 0)
      l++;
    else if (h[l] > 0) {
      r = l;
      while (h[r] > 0 && r < n) {
        h[r]--;
        r++;
      }
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def main():
    n = int(input())
    ans = ""
    alpa = "abcdefghijklmnopqrstuvwxyz"
    while n:
        ans += alpa[n%26-1]
        n-=1
        n//=26
    ans2 = ""
    for i in range(len(ans)):
        ans2 += ans[len(ans)-i-1]
    print(ans2)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll ma = 0;
    rep(i, 1, sqrt(m)+1){
        if(!(m % i)){
            if(i >= n){
                ma = max(ma, m / i);
            }
            if(m / i >= n){
                ma = max(ma, i);
            }
        }
    }
    cout << ma << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

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

    if (A == B && A == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    char s;
    scanf("%c",&s);
    if (s=='A') printf("%c",'T');
    if (s=='T') printf("%c",'A');
    if (s=='G') printf("%c",'C');
    if (s=='C') printf("%c",'G');
    return 0;
}

Measured memory_bytes: 1584
from itertools import groupby

def solve():
    N = int(input())
    a = [input() for _ in range(N)]
    a.sort()
    M = int(input())
    b = [input() for _ in range(M)]
    b.sort()
    
    d = {}
    gr = groupby(a)
    for key, group in gr:
        d.setdefault(key, []).append(len(list(group)))
    
    gr = groupby(b)
    for key, group in gr:
        d.setdefault(key, []).append(-len(list(group)))
    
    m = 0
    for k, v in d.items():
        su = sum(v)
        if su > m:
            m = su
    return m

print(solve())

Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int n,m,i,j,h,k;
        n = input.nextInt();
		m = input.nextInt();
        int[][] a = new int[n][m];
		int[] b = new int[m];
		int[] c = new int[n];
		for(i=0;i<n;i++) {
        for (j=0;j<m;j++){
            h=input.nextInt();
            a[i][j]=h;
            }
		}
        for(j=0;j<m;j++){
            k=input.nextInt();
            b[j]=k;
        }
        for (i=0;i<n;i++) {
            c[i]=0;
        for(j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
            }
        }
        for (i=0;i<n;i++){
            System.out.println(c[i]);
        }
    }
}


Measured memory_bytes: 40768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tmp = n;
        while (tmp >= 0) {
            if (tmp % 7 == 0) {
                System.out.println("Yes");
                return;
            }
            tmp -= 4;
        }
        tmp = n;
        while (tmp >= 0) {
            if (tmp % 4 == 0) {
                System.out.println("Yes");
                return;
            }
            tmp -= 7;
        }
        System.out.println("No");
    }
}


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

int main()
{
	int a[4];
	for (int i = 0; i < 4; i++) cin >> a[i];
	sort(begin(a), end(a));

	if (a[0] == a[1] && a[2] == a[3]) cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}

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

const double half = 1.0/2.0;

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

  double totalProbability = 0;

  for(int i=1;i<=N;i++) {
    double pro = 1.0 / N;
    if(i >= K) {
      totalProbability += pro;
      continue;
    }
    int total = i;
    while(total < K) {
      pro *= half;
      total = total * 2;
    }

    totalProbability += pro;
  }

  cout << setprecision(20) << totalProbability << endl;
}

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mx 3000
ll n,m;

int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ck,k,p,q,r,t,add=0,w,x,y,z;
  
    for(int i=1;i<=5;i++){
        cin>>c;
        if(c==0)d=i;
    }
    cout<<d<<endl;

    return 0;
}




Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int n;
    int i,j;
    long long int sum=0;
    long long int max;
    
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        long int a[n];
        for(i=0;i<n;i++){
            scanf("%ld",&a[i]);
        }
        max=a[0];
        for(j=0;j<n;j++){
            for(i=j;i<n;i++){
                sum+=a[i];
                if(sum>max) max=sum;
            }
            sum=0;
        }
        printf("%lld\n",max);
        sum=0;
        max=0;
    }
    return 0;
}


Measured memory_bytes: 1984
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

const ll MAXINDx = 3001;
const ll MAXINDy = 3001;


ll dp[MAXINDx][MAXINDy] = {0};

int main(){
    string s,t;

    cin >>s>>t;

    for(int i = 0; i < MAXINDx; i++){
        for(int j = 0;j < MAXINDy;j++){
            dp[i][j] = -1;
        }
    }

    dp[0][0] = 0;

    for(int i = 1; i <= s.size();i++){
        for(int j = 1; j <= t.size(); j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], max(dp[i][j-1], dp[i][j]));
            }
        }
    }

    string ans = "";

    int i = (int)s.size(), j = (int)t.size();
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j--;
        }
        else{
            ans = s[i-1]+ans;
            i--;j--;
        }
    }

    cout <<ans<<endl;


    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}


*/


Measured memory_bytes: 70656
#include<stdio.h>
#include <stdlib.h>
void qsort(
	void* base, size_t num, size_t size,
	int (*compare)(const void* a, const void* b)
); int desc(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}
int main(void) {
	int n;
	scanf("%d", &n);

	int p[51];
	int bp[51];

	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
		bp[i] = p[i];
	}
	
	
	int count = 0;
	int hako[51];
	int k = 1;
	int temp;
	int flg = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] == k) {
			k++;
		}
		else {
			for (int j = i; j < n; j++) {
				if (p[j] == k) {
					temp = p[j];
					p[j] = p[i];
					p[i] = temp;
				}
			}
			k++;
			count++;
		}
	}
	if (count >= 2) {
		printf("NO\n");
	}
	else {
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string O,E;
cin >> O >> E;
for(int i = 0;i < O.size();i++) {
  if (i == E.size()) cout << O.at(i);
  else cout << O.at(i) << E.at(i);
}
cout << endl;


return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

  int count;

  typedef struct {

    int id;
    int month;
    int day;

  } dealing;

  dealing deal[2000];
  int idx;
  
  int calculated[2000];
  int idx2;

  int flag;
  char* p;
  char buf[50];

  dealing temp;
  int i,j,k;

  idx=0;

  while(1) {

    fgets(buf,sizeof(buf),stdin);

    buf[strlen(buf)-1]='\0';

    if(buf[0]=='\0') break;

    p=strtok(buf,",");
    //printf("%d\n",atoi(p));
    deal[idx].id=atoi(p);
    //printf("id=%d\n",deal[idx].id);
    p=strtok(NULL,",");
    deal[idx].day=atoi(p);
    //printf("day=%d\n",deal[idx].day);
    deal[idx].month=0;
    //printf("id=%d,month=%d,day=%d\n",deal[idx].id,deal[idx].month,deal[idx].day);
    idx++;

  }
 
  //for(i=0;i<idx;i++) printf("%d %d %d\n",deal[i].id,deal[i].month,deal[i].day);

  while(fgets(buf,sizeof(buf),stdin)!=NULL) {

    buf[strlen(buf)-1]='\0';

    p=strtok(buf,",");
    deal[idx].id=atoi(p);
   
    p=strtok(NULL,",");
    deal[idx].day=atoi(p);

    deal[idx].month=1;

    idx++;

  }

  for(i=0;i<idx-1;i++) {

    for(j=i+1;j<idx-i;j++) {

      if(deal[i].id>deal[j].id) {

	temp=deal[i];
	deal[i]=deal[j];
	deal[j]=temp;

      }

    }

  }

  //for(i=0;i<idx;i++) printf("%d %d %d\n",deal[i].id,deal[i].month,deal[i].day);

  idx2=0;

  for(i=0;i<idx;i++) {

    flag=0;

    for(j=0;j<idx2;j++) {

      if(calculated[j]==deal[i].id) goto Next;

    }

    calculated[idx2]=deal[i].id;
    idx2++;

    count=0;

    for(k=i;k<idx;k++) {

      if(deal[i].id==deal[k].id) {

	if(deal[k].month==0) flag=1;

	if(flag==1 && deal[k].month==1) flag=2;

	count++;

      }

    }

  Next:
    if(flag==2) printf("%d %d\n",deal[i].id,count);

  }
    
  return 0;

}

    
  
  

  

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
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>;

int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int q = a / m; 
        int t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
int mod=1e9+7;
int fac[200005];
int solve(int n,int r)
{
   if(n<0||n<r)
      return 0;
   int z=fac[n];
   z=(z*modInverse(fac[r],mod))%mod;
   z=(z*modInverse(fac[n-r],mod))%mod;
   return z;
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,m,a,b;
   cin>>n>>m>>a>>b;
   fac[0]=1;
   for(int i=1;i<=200000;i++)
      fac[i]=(fac[i-1]*i)%mod;
   int ans=0;
   for(int i=0;i<=b-1;i++)
   {
      int z=solve(n-a-1+i,i)%mod;
      // cout<<z<<"\n";
      z=(z*solve(m-i-1+a-1,a-1))%mod;
      ans=(ans+z)%mod;
      // cout<<ans<<"\n";
   }
   // cout<<ans<<"\n";
   int zz=solve(n+m-2,n-1);
   zz=(zz-ans+mod)%mod;
   cout<<zz;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

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

int main(){
    int n,r;
    cin >> n >> r;
    if(n < 10) cout << r + 100 * (10 - n) << endl;
    else cout << r << endl;
    
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b){
        printf("a == b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    return 0;
}


Measured memory_bytes: 2044
d,n=gets.split.map(&:to_i)
k = ""
if d == 0 && n == 100
  puts 101
elsif d == 1 && n == 100
  puts 10100
elsif d == 2 && n == 100
  puts 1010000
else
d.times do
  k += "00"
end
puts n.to_s + k
end


Measured memory_bytes: 1788
#include <cstdio>

#define N 100100
#define ll long long

struct Edge {
	int v, w, nxt;
} e[N << 1];
int head[N << 1], cnt;
inline void addedge(int u, int v, int w) {
	e[++cnt] = (Edge){v, w, head[u]};
	head[u] = cnt;
}

int col[N], flag, num[4];
int dye(int x, int c) {
	if (col[x])	{
		if (col[x] != c)
			flag = false;
		return 0;
	}
	col[x] = c;
	num[c]++;
	num[0]++;
	int ans = 0;
	for (int i = head[x]; i; i = e[i].nxt)
		ans += 1 + dye(e[i].v, (c + e[i].w) % 3 + 1);
	return ans;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1, a, b; i <= m; i++) {
		scanf("%d %d", &a, &b);
		addedge(a, b, 0);
		addedge(b, a, 1);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		if (!col[i]) {
			num[0] = num[1] = num[2] = num[3] = 0;
			flag = true;
			int ret = dye(i, 1);
			if (flag == 0)
				ans += (ll)num[0] * num[0];
			else if (num[1] && num[2] && num[3])
				ans += (ll)num[1] * num[2] + (ll)num[2] * num[3] + (ll)num[3] * num[1];
			else
				ans += ret / 2;
		}
	printf("%lld\n", ans);
}

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,c;
  cin>>s>>c;
  int dp[s.size()+1][c.size()+1];
  for(int i=0;i<s.size()+1;i++)
  {
    dp[i][0]=0;
  }
  for(int i=0;i<c.size()+1;i++)
  {
    dp[0][i]=0;
  }
  for(int i=1;i<s.size()+1;i++)
  {
    for(int j=1;j<c.size()+1;j++)
    {
      if(s[i-1]==c[j-1])
      {
        dp[i][j]=dp[i-1][j-1]+1;
      }
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
  string ans="";
  int i=s.size();
  int j=c.size();
  while(i>0 && j>0)
  {
    if(dp[i][j]==dp[i-1][j])
      i--;
    else if(dp[i][j]==dp[i][j-1])
      j--;
    else
    {
      ans.push_back(s[i-1]);
      i--;
      j--;
    }
  }
	reverse(ans.begin(),ans.end());
  	cout<<ans;
}

  

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
 
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const ll INF = 10010001010;
const int inf = 1000034000;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int ans = 0;
  bool OK = false;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    A[i]--;
    if(A[i] == 1){
      OK = true;
    }
  }
  if(!OK){
    cout << -1 << endl;
    return 0;
  }
  else{
    int now = 0;
    for(;;){
      if(now == 1){
        cout << ans << endl;
        break;
      }
      if(ans >= N){
        cout << -1 << endl;
        break;
      }
      ans++;
      now = A[now];
    }
  }
} 

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

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

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

  vector<vector<char>> pica(n,vector<char>(n));
  vector<vector<char>> picb(m,vector<char>(m));

  rep(i,n)rep(j,n) cin >> pica.at(i).at(j);
  rep(i,m)rep(j,m) cin >> picb.at(i).at(j);

  bool flag=true;
  rep(i,n-m+1){
    rep(j,n-m+1){
      flag = true;
      rep(k,m){
        rep(l,m){
          if(pica.at(i+k).at(j+l)!=picb.at(k).at(l)){flag=false; break;}
        }
        if(!flag) break;
      }
      if(flag) break;
    }
    if(flag) break;
  }

  if(flag) cout << "Yes";
  else cout << "No";

  
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int a,b,c;
cin>>a>>b>>c;
if(a+b+c>=22){
    cout<<"bust"<<endl;
}
else cout<<"win"<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i

if n == 1
  puts 'Yes'
  puts '2'
  puts '1 1'
  puts '1 1'
  exit
end

if n == 3
  puts 'Yes'
  puts '3'
  puts '2 1 2'
  puts '2 3 1'
  puts '2 2 3'
  exit
end

oks = [1]
2.upto(10**5) do |i|
  if i == (oks.last + oks.size + 1)
    oks.push(i)
  end
end

if !oks.include?(n)
  puts 'No'
  exit
end

num = oks.index(n) + 1

ans = Array.new(num + 1) { Array.new }
counts = Array.new(n, 0)

i = 1
(1..num + 1).to_a.combination(2) do |a, b|
  ans[a-1].push(i)
  ans[b-1].push(i)
   i += 1
end

puts 'Yes'
p num + 1
ans.each do |an|
  puts "#{an.size} #{an.join(' ')}"
end


Measured memory_bytes: 6140
cards = {
        'S': [r for r in range(1, 13+1)],
        'H': [r for r in range(1, 13+1)],
        'C': [r for r in range(1, 13+1)],
        'D': [r for r in range(1, 13+1)]
        }

n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Measured memory_bytes: 6724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;


namespace ABC94
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            string ans = "NO";
            if (b + a >= x && a <= x)
            {
                ans = "YES";
            }
            else
            {
                ans = "NO";
            }
            
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	int N,i;
	scanf(" %d",&N);
	for (i = 1; i * i <= N; i++){}
	printf("%d\n", (i - 1) * (i - 1));

	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A,B=[0]*n,[0]*n
    for i in range(n):
        A[i],B[i]=map(int,input().split())
    A.sort()
    B.sort()
    if n%2==1:
        print(B[n//2]-A[n//2]+1)
    else:
        print(int(((B[n//2-1]+B[n//2])/2-(A[n//2-1]+A[n//2])/2)*2)+1)

if __name__=='__main__':
    main()

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

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

	int n; string s;
	cin >> n >> s;
	int ans = 1;
	for(int i=1; i<n; i++){
		if(s[i] != s[i-1]) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3724
<?php
  $dat = trim(fgets(STDIN));
  $day = [
    'SUN' => 7,
    'MON' => 6,
    'TUE' => 5,
    'WED' => 4,
    'THU' => 3,
    'FRI' => 2,
    'SAT' => 1
  ];
  echo $day[$dat] . PHP_EOL;


Measured memory_bytes: 4728
package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = int(math.MaxInt32)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func uniqIntSlice(a []int) []int {
	m := make(map[int]struct{})
	for _, v := range a {
		m[v] = struct{}{}
	}
	u := []int{}
	for k := range m {
		u = append(u, k)
	}
	return u
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

//a:old b:new a>b -> a=b (update) more small
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func main() {
	n := nextInt()
	h := make([][3]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			h[i][j] = nextInt()
		}
	}
	dp := make([][3]int, n+1)

	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				chmax(&dp[i+1][j], dp[i][k]+h[i][j])
			}
		}
	}
	fmt.Println(max(dp[n][0], dp[n][1], dp[n][2]))
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a <= c && c <= b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define mp make_pair
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define Task ""
using namespace std;
const int N=200005;
const int mod=1000000007;
int n, a[N], dp[N], sum[N], cnt;

void setup() {
    cin >> n;
    rep(i, 1, n) {
        int x; cin >> x;
        if(x!=a[cnt]) {
            a[++cnt]=x;
        }
    }
}

void add(int &a, int b) {
    a=(a+b)%mod;
}

void calc() {
    dp[0]=1;
    rep(i, 1, cnt) {
        add(dp[i], dp[i-1]);
        add(dp[i], sum[a[i]]);
        add(sum[a[i]], dp[i-1]);
    }
    cout << dp[cnt];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    setup();
    calc();
    return 0;
}


Measured memory_bytes: 2560
import math
import numpy as np

# N,K = map(int,input().split())
# A = np.sort(list(map(int,input().split())))
# F = np.sort(list(map(int,input().split())))[::-1]
#         if np.sum(AF[AF>0]) > K: 

S = list(input())
if S[0]=='>':
    S = ['<']+S
if S[-1]=='<':
    S = S+['>']

N=len(S)
D=np.zeros(N)
nc = 1
cur = S[0]
curi = 0
for i in range(1,N):
    if S[i]==cur:
        nc += 1
    else:
        D[curi] = nc
        cur = S[i]
        curi += 1
        nc = 1
D[curi] = nc
D = D[D>0]
D=D.reshape([-1,2])
Asum = 0
for d in D:
    a1 = max(d)
    a2 = min(d)
    Asum += int((a1+1)*a1/2 + a2*(a2-1)/2)

print(Asum)

Measured memory_bytes: 22280
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 764
#include<stdio.h>

int A[1000000], n;

int main(){
  int i, 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(binarySearch(key)){
      sum++;
    }
  }
  printf("%d\n",sum);

  return 0;
}

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid]){
      return 1;
    }
    if(key > A[mid]){
      left = mid + 1;
    }
    else if(key < A[mid]){
      right = mid;
    }
  }
  return 0;
}
	


Measured memory_bytes: 2116
li = list(input())
od = li[0::2]
ev = li[1::2]
for i in range(len(od)):
    if od[i] == "R" or od[i] == "U" or od[i] == "D":
        pass
    else:
        print("No")
        exit()
for j in range(len(ev)):
    if ev[j] == "L" or ev[j] == "U" or ev[j] == "D":
        pass
    else:
        print("No")
        exit()
print("Yes")

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int X[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) cin>>X[i];
	
	if(N>=M) {
		cout<<0<<endl;
		return;
	}
	sort(X,X+M);
	vector<int> V;
	FOR(i,M-1) V.push_back(X[i+1]-X[i]);
	sort(ALL(V));
	ll ret=0;
	FOR(i,M-N) ret+=V[i];
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1276
m = input()
n = int(m.split()[0])
k = int(m.split()[1])
t = []
for i in range(n):
    t.append(int(input()))
t.sort()
a = None
for i in range(len(t)-k+1):
    w = abs(-1*t[i] + t[i+k-1])
    if i == 0:
        a = w
    elif a > w:
        a = w
print(a)

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

typedef long long ll;


bool valid(ll N, const vector<ll>& d){
    string s = to_string(N);
    for(auto c : s) 
	for(auto& val : d) {
	    if( val == c-'0' ) return true;
	}
    return false;
}

int main () {

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

    while( valid(N,d) ) {
	N++;
    }
    cout << N << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < (n); i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REPEACH(itr, k) for (auto &&itr : k)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;


const ll INF = 1ll << 60;
const ll MOD = 1000000007;

vector<bool> prime_table(int n)
{
    vector<bool> prime(n*10+1, true);
    if (n >= 0)
        prime[0] = false;
    if (n >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= n*10; i++)
    {
        if (!prime[i])
            continue;
        for (int j = i + i; j <= n*10; j += i)
        {
            prime[j] = false;
        }
    }
    return prime;
}

int main()
{
    int x;
    cin >> x;
    vector<bool> ans=prime_table(x);
    while(1){
        if(ans[x]==true){
            cout << x << endl;
            return 0;
        }
        else{
            x++;
        }
    }
}

Measured memory_bytes: 384
/*
    Code by CNH_Tourist
    Date Created: 10/6/2019
*/
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

/*---------------------Define--------------------*/
#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const ll mod=1e9+7;
int test=1;
const int N=100100;
/*-----------------------------------------------*/

/*---------------SegmentTree Build---------------
void build(int node, int Start, int End)
{
    if(Start == End)
    {
        // Leaf node will have a single element
        tree[node] = A[start];
    }
    else
    {
        int mid = (Start + End) / 2;
        // Recurse on the left child
        build(2*node, Start, mid);
        // Recurse on the right child
        build(2*node+1, mid+1, End);
        // Internal node will have the sum of both of its children
        tree[node] = tree[2*node] + tree[2*node+1];
    }
}
------------------------------------------------*/

int n,W;
int w[110],v[110];
int dp[100100];
int tmp[100100];

int main()
{
    FAST
    //FileInOut
    cin>>n>>W;
    for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    memset(tmp,-1,sizeof(tmp));

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=100000;j++) tmp[i]=dp[i];

        tmp[v[i]]=max(dp[v[i]], W-w[i]);

        for(int j=1;j<=100000;j++)
        {
            if(j>=v[i] && dp[j-v[i]]!=-1)
                tmp[j]=max(dp[j-v[i]]-w[i],dp[j]);
        }

        for(int j=1;j<=100000;j++)
            dp[j]=tmp[j];
        //cout<<i<<endl;
        //for(int i=10;i<=140;i+=10)
        //    cout<<dp[i]<<" ";
        //cout<<endl<<endl;
    }

    for(int i=100000;i>=1;i--)
        if(dp[i]!=-1)
        {
            cout<<i;
            return 0;
        }

}


Measured memory_bytes: 1024
import heapq

N,K=map(int,input().split())
TD=[[int(x) for x in input().split()] for y in range(N)]

TD=sorted(TD,key = lambda x:-x[1])

ans=0
neta=set([])
rep_neta=[]

for i in range(K):
    a,b=TD[i]
    if not (a in neta):
        neta.add(a)
        ans+=b
    else:
        ans+=b
        rep_neta.append(b)

ans+=len(neta)**2

cnt=ans

for i in range(K,N):
    if len(rep_neta) == 0 :
        break
    else:
        a,b=TD[i]
        if not (a in neta):
            cnt+=2*len(neta)+1
            cnt+=b-rep_neta.pop(-1)
            neta.add(a)
            ans=max(ans,cnt)

print(ans)


Measured memory_bytes: 26880
n = int(input())
pl = [int(input()) for _ in range(n)]

d = {}
for i in range(n):
    d[pl[i]] = i

dp = [1]*n
p = 1
while p<n:
    if d[p+1]>d[p]:
        dp[d[p+1]] = dp[d[p]]+1
    p += 1
print(n-max(dp))


Measured memory_bytes: 41108
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new ArrayList<>());
		}
		for (int i = 0; i < n; i++) {
		    int from = sc.nextInt() - 1;
		    int count = sc.nextInt();
		    for (int j = 0; j < count; j++) {
		        graph.get(from).add(sc.nextInt() - 1);
		    }
		}
		int[] costs = new int[n];
		Arrays.fill(costs, Integer.MAX_VALUE);
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(0, 0));
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.idx] <= p.value) {
		        continue;
		    }
		    costs[p.idx] = p.value;
		    for (int x : graph.get(p.idx)) {
		        queue.add(new Path(x, p.value + 1));
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    sb.append(i + 1).append(" ");
		    if (costs[i] == Integer.MAX_VALUE) {
		        sb.append(-1);
		    } else {
		        sb.append(costs[i]);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 28196