akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    bitset<200001> bs1(0), bsn(0);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        if (a == 1) bs1[b] = 1;
        if (b == n) bsn[a] = 1;
    }
    auto bs = bs1 & bsn;
    cout << ((bs.any()) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll a,b; cin >> a >> b;
    string ans;
    rep(i,max(a,b)){
        ans += '0' + min(a,b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

struct SegTree {
    int n;
    vi v;

    int pow2fit(int sz){
        int ret = 1;
        while(ret < sz) ret *= 2;
        return ret;
    }

    SegTree(int sz){
        n = pow2fit(sz);
        v = vi(2 * n - 1);
    }

    // v[a] += x
    int add(int a, int x){
        int idx = n - 1 + a;
        v[idx] += x;

        while(idx > 0){
            idx = (idx - 1) / 2;
            v[idx] = v[2 * idx + 1] + v[2 * idx + 2];
        }
    }

    // sum [a, b)
    int getsum(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0) r = n;

        if(a >= r or l >= b) return 0;
        if(a <= l and r <= b) return v[k];

        return getsum(a, b, 2 * k + 1, l, (l + r) / 2) 
             + getsum(a, b, 2 * k + 2, (l + r) / 2, r);
    }
};

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

    int n, Q; cin >> n >> Q;
    SegTree seg(n);

    rep(loop, Q){
        int op, x, y; cin >> op >> x >> y;
        if(op == 0){
            x--;
            seg.add(x, y);
        }
        else {
            x--;
            cout << seg.getsum(x, y) << endl;
        }
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int P[N];
    int S[N];
    for(int i=0;i<N;i++){
        cin >> P[i];
        S[i]=P[i];
    }
    sort(S,S+N);
    int count=0;
    for(int i=0;i<N;i++){
        if(P[i]!=S[i]){
            count++;
        }
    }

    if(count<=2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define prev aenfoawnfon

auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n;
vector<int> a,prev,um;
vector<vector<int>> tree;

void build(int root,int tl,int tr)
{
	if(tl==tr)
	{
		tree[root]={prev[tl]};
		return;
	}
	build(root*2,tl,(tl+tr)/2);
	build(root*2+1,(tl+tr)/2+1,tr);
	tree[root].resize(tree[root*2].size()+tree[root*2+1].size());
	merge(all(tree[root*2]),all(tree[root*2+1]),tree[root].begin());
}


int query(int root,int tl,int tr,int al,int ar,int val)
{
	if(tl>ar || al>tr)
		return 0;
	if(al<=tl && tr<=ar)
	{
		return (upper_bound(all(tree[root]),val)-tree[root].begin());
	}
	return query(root*2,tl,(tl+tr)/2,al,ar,val)+query(root*2+1,(tl+tr)/2+1,tr,al,ar,val);
}


signed main()
{
	fio
	cin>>n; inp(k)
	a.resize(n);
	tree.resize(3*n);
	prev.resize(n);
	um.resize(n);
	vector<int> nxt(n);
	fo(i,n)
	{
		cin>>a[i];
		um[a[i]]=i;
	}
	stack<int> st;
	fo(i,n)
	{
		while(st.size() && st.top()<a[i])
			st.pop();
		if(st.size())
			prev[i]=um[st.top()];
		else
			prev[i]=-1;
		st.push(a[i]);
	}
	while(st.size())
		st.pop();
	for(int i=n-1;i>=0;i--)
	{
		while(st.size() && st.top()>a[i])
			st.pop();
		if(st.size())
			nxt[i]=um[st.top()];
		else
			nxt[i]=n;
		st.push(a[i]);
	}
	int ans=0;
	bool sel[n]={0};
	fo(i,n-k+1)
	{
		if(prev[i+k-1]>=i || i==0 || nxt[i-1]<=i+k-1)
		{
			sel[i]=1;
			//ans++;
		}
	}
	int ct=1;int cc=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1])
			ct++;
		else
			ct=1;
		if(ct>=k)
		{
			sel[i-k+1]=0;
			cc++;
		}
	}
	if(cc)
		cc=1;
	fo(i,n)
		ans+=sel[i];
	cout<<ans+cc<<'\n';
	printclock;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

ll gcd(ll a,ll b){while(b!=0){a%=b; swap(a,b);} return a;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  C-=A; D-=B;
  C=abs(C);
  D=abs(D);
  if(0==C || 0==D){cout<<0<<endl; return 0;}
  cout<<C+D-gcd(C,D)<<endl;
  

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

N,K=map(int,input().split())
MOD=10**9+7
branch=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  branch[a-1].append(b-1)
  branch[b-1].append(a-1)

if K==1:
  if N==1:
    print(1)
  else:
    print(0)
  exit()
  
P=[0]*(K-1)
P[K-2]=K-2
for i in range(K-3,0,-1):
  P[i]=P[i+1]*i%MOD
  
def PPP(start,num):
  if start<num:
    return 0
  if start==K-2:
    return P[start-num+1]
  if start==K-1:
    return P[start-num+2]*(K-1)%MOD
  
ans=1

def draw(parent,nord):
  global ans
  children=len(branch[nord])-(parent !=-1)
  if children==0:
    return
  #(K-2)*(K-1)*... をchildrenの数だけ掛ける。
  ans=ans*PPP(K-1-(parent !=-1),children)%MOD
  for b in branch[nord]:
    if b != parent:
      draw(nord,b)

for i in range(len(branch[0])+1):
  ans=ans*(K-i)%MOD
for bra in branch[0]:
  draw(0,bra)
print(ans)


Measured memory_bytes: 92332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[10],q[10],f[10],tmp,n,a,b,k=0;
bool flag1,flag2;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=n;i++) scanf("%lld",&p[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&q[i]);
	do{
		k++,flag1=flag2=false;
		for(int i=1;i<=n;i++){
			if(p[i]!=f[i]) flag1=true;
			if(q[i]!=f[i]) flag2=true;
		}
		if(!flag1) a=k;
		if(!flag2) b=k;
	}while(next_permutation(f+1,f+n+1));
	printf("%lld",abs(a-b));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int cnt,a,b,c,num;
scanf("%d %d %d\n",&a,&b,&c);
num=a;cnt=0;
while((num<=b)){
if(c%num==0){
cnt++;
}
num++;
}
printf("%d\n",cnt);
return 0;
}

Measured memory_bytes: 600
for _ in range(int(input())):
    G = list(map(int, input().split()))
    yokomata = []
    tatemata = []
    for i in range(int(input())):
        m = (list(map(int, input().split())))
        if m[1] == m[3]:
            yokomata.append([max(m[0], m[2]), m[1]])
        else:
            tatemata.append([m[0], max(m[1], m[3])])
    matrix = [[0 for i in range(G[0]+1)] for j in range(G[1]+1)]
    matrix[0][0] = 1
    for i in range(1, G[0]+1):
        if [i, 0] in yokomata:
            continue
        else:
            matrix[0][i] = matrix[0][i-1]
    for j in range(1, G[1]+1):
        if [0, j] in tatemata:
            continue
        else:
            matrix[j][0] = matrix[j-1][0]
    for j in range(1, G[1] + 1):
        for i in range(1, G[0] + 1):
            if [i, j] in yokomata and [i, j] in tatemata:
                matrix[j][i] = 0
            elif [i, j] in yokomata:
                matrix[j][i] = matrix[j-1][i]
            elif [i, j] in tatemata:
                matrix[j][i] = matrix[j][i-1]
            else:
                matrix[j][i] = matrix[j-1][i] + matrix[j][i-1]
    if matrix[G[1]][G[0]] == 0:
        print("Miserable Hokusai!")
    else:
        print(matrix[G[1]][G[0]])


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

int main() {
  int A , B;
  cin >> A >> B;
  if(A!=1&&B!=1){
  	cout << 1 << endl;	
  }else if(A!=2&&B!=2){
  	cout << 2 << endl;
  }else if(A!=3&&B!=3){
  	cout << 3 << endl;
  }
}


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

int main() {
	multiset<int> ms; int temp;
	for (int i = 0; i < 3; i++) { cin >> temp; ms.insert(temp); }
	for (auto itr = ms.begin(); itr != ms.end(); itr++) {
		cout << *itr << (itr != --ms.end() ? " " : "");
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3100
N = int(input())
S = input()
B = [0] * (N + 1)
W = [0] * (N + 1)

for i in range(1, N + 1):
    B[i] = B[i - 1]
    if S[i - 1] == '#':
        B[i] += 1
for i in range(N - 1, -1, -1):
    W[i] = W[i + 1]
    if S[i] == '.':
        W[i] += 1
ans = 10**10
for i in range(N + 1):
    ans = min(ans, B[i] + W[i])
print(ans)

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

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
    cout << 0 << endl;
  }else{
    cout << min({a * b, b * c, c * a}) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int n, a;
    std::cin >> n;
    int count = 0;
    
    for (int i = 1; i <= n ; i++)
    {
        std::cin >> a;
        if (i % 2 == 1 && a % 2 == 1)
        {
            count++;
        }
    }
    
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3620
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N,M = map(int,input().split())
    to = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        to[a].append(b)        
        to[b].append(a)        
    # print(to)
    guide = [0] * N
    guide[0] = 1
    q = deque()
    q.append(0)
    while len(q) > 0:
        u = q.popleft()
        for v in to[u]:
            # print(guide)
            if guide[v] != 0:
                continue
            guide[v] = u+1
            q.append(v)

    print("Yes")
    for g in guide[1:]:
        print(g)

if __name__ == '__main__':
    main()


Measured memory_bytes: 37728
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		h[i] = nextInt(sc)
	}
	ok := true
	prev := -1
	for i := 0; i < n; i++ {
		if prev > h[i] {
			ok = false
			break
		} else if prev < h[i] {
			h[i]--
		}
		prev = h[i]
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;//list用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static List<int> t = new List<int>();
    static decimal result;
static int N;
    static void Main()
    {
Read1();
Read2();
   //全ケタが３つ周期になるはず    

      t.Add(s[0]);
      int[] count=new int[3];
      count[0]=1;count[1]=1;count[2]=1;
for(int i=1;i<N;i++){int a=t.Count;if(a>3){break;}for(int j=0;j<a;j++){if(t[j]==s[i]){count[j]++;break;}if(j==a-1){t.Add(s[i]);}}}
      //全0は例外的にＯＫ。
for(int i=0;i<N;i++){if(s[i]!=0){break;}if(i==N-1){Console.WriteLine("Yes");return;}}
if(t.Count==2 && (t[0]==0 || t[1]==0) && (count[0]==count[1]*2 || count[0]*2==count[1])){Console.WriteLine("Yes");return;}
      //上記二つ以外なら３つである必要がある
      if(t.Count!=3){Console.WriteLine("No");return;}
//各ケタの周期が011,101,110,000のどれか(つまり合計０)になればＯＫ。
      if((t[0]^t[1]^t[2])==0 && count[0]==count[1] && count[1]==count[2]){Console.WriteLine("Yes");return;}else{Console.WriteLine("No");return;}


    }

    static void Read1()
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()
    {
        string[] tmp=Console.ReadLine().Split(' ');
      for(int i=0;i<N;i++)
      {
        s.Add(int.Parse(tmp[i]));
      }
    }
}


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

#define INF 10000

int temp[5] = {10,50,100,500}, n;

int foo(int temp2[]){
	int a = 0, temp3[4] = {}, f = 0, b = 0;
	for(int i =0; i < 4; i++)a +=temp2[i]*temp[i];//cout<<"a "<<a<<endl;
	a = a - n;
	for(int i = 3; i >= 0; i--){
		b += temp3[i] += a/temp[i];//cout<<a<<endl;
		a     -= (a/temp[i])*temp[i];//cout<<a<<endl;
		f += temp3[i]*temp2[i];
	}
	//for(int i =0; i < 4; i++){cout<<temp2[i]<<" "<<temp3[i]<<endl;}
	return f?INF*2:b;
}

int main(){
	int a, b, c, d, e, f, count = 0;
	while(1){
		int ans[4]= {}, mi = INF, temp2[4];
		cin>>n;
		
		if(!n) break;
		if(count++)cout<<endl;
		cin>>a>>b>>c>>d;
		
		for(int i = 0; i <= a; i++)
			for(int j = 0; j <= b; j++)
				for(int k = 0; k <= c; k++)
					for(int l = 0; l <= d; l++){
						int temp2[] = {i,j,k,l};
						e = i*10+j*50+k*100+l*500;
						f = i+j+k+l;//cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
						if(e >= n){//cout<<foo(temp2)<<" "<<e<<" "<<n<<" "<<f<<" "<<mi<<endl;
							if(foo(temp2)-f < mi){ans[0]=i;ans[1]=j;ans[2]=k;ans[3]=l;mi = foo(temp2)-f;}
						}
					}
		
		for(int i = 0; i < 4; i++)
			if(ans[i])cout<<temp[i]<<" "<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include<iostream>
#include<string>

using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	int D[10];
	int i, j;
	for (i = 0; i < K; i++)	cin >> D[i];
	bool can=false;
	for (i = N; i <100000; i++) {
		for (j = 0; j < K; j++) {
			if (to_string(i).find(to_string(D[j])) != string::npos) {
				can = false;
				j = K;
			}
			else {
				can = true;
			}
		}

		if (can) {
			cout << i << endl;
			i = 100000;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine((N + 1) / 2 >= K ? "YES" : "NO");
	}
	int N,K;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const printRectangle = input => {
  const array = input.split(`\n`);

  for (let i = 0; i < array.length; i++) {
    const [h, w] = array[i].split(' ').map(Number);
    if (h === 0 && w === 0) return false;
    console.log(Array(h + 1).join(Array(w + 1).join('#') + '\n'));
  }
};

printRectangle(input);



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

int main(){
  int n;
  cin >> n;
 
  while(n>0){
	int pm[n],pe[n],pj[n];
	int hei[n],me[n];
	string student[n];
	for(int i=0;i<n;i++){
		cin >> pm[i] >> pe[i] >> pj[i];
		hei[i]=(pm[i]+pe[i]+pj[i])/3;
		me[i]=(pm[i]+pe[i])/2;
	}
	for(int i=0;i<n;i++){
		if(pm[i]==100||pe[i]==100||pj[i]==100)
			student[i]="A";
		else if(me[i]>=90)
			student[i]="A";
		else if(hei[i]>=80)
			student[i]="A";
		else if(hei[i]>=70)
			student[i]="B";
		else if(hei[i]>=50&&(pm[i]>=80||pe[i]>=80))
			student[i]="B";
		else
			student[i]="C";
	}

	for(int i=0;i<n;i++){
		cout << student[i] << endl;
	}

	cin >> n;
  }

  return 0;
}


Measured memory_bytes: 1192
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if s == "AC":
    ac += 1
  if s == "WA":
    wa += 1
  if s == "TLE":
    tle += 1
  if s == "RE":
    re += 1
print("AC x %d" % ac)
print("WA x %d" % wa)
print("TLE x %d" % tle)
print("RE x %d" % re)
  

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

using namespace std;
const int MOD = 998244353;

long long mod_pow(long long a, long long n)
{
  long long ret = 1;
  while (n) {
    if (n % 2) {
      ret = (ret * a) % MOD;
    }
    a = (a * a) % MOD;
    n /= 2;
  }
  return ret;
}

int main()
{
  int N;
  int d[100000], cnt[100000];
  
  scanf("%d", &N);
  fill(cnt, cnt + N, 0);
  
  int ma = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", d + i);
    cnt[d[i]]++;
    ma = max(ma, d[i]);
  }
  
  if (d[0] != 0 || cnt[0] != 1) {
    printf("0\n");
    return 0;
  }
  
  long long ans = 1;
  for (int i = 1; i <= ma; i++) {
    ans = ans * mod_pow(cnt[i - 1], cnt[i]) % MOD;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, A[100000]; cin >> N;
  REP(i, N) cin >> A[i];
  int ans = 0;
  REP(i, N){
    ans += A[i]/2; A[i]%=2;
    if(i+1 < N){
      int m = min(A[i], A[i+1]);
      ans += m;
      A[i] -= m; A[i+1] -= m;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 3e5+5;
const int inf = 1e18+7;
const int mod = 1e9+7;

int n,m;
int a[nax], b[nax];
vector<int>adj[nax];

/*
 * DO SOMETHING RATHER THAN DOING NOTHING
 * */

signed main(){
    fast;

    cin>>n>>m;
    for(int i=0;i<n;i++){
         cin>>a[i];
    }
     for(int i=0;i<n;i++) b[i]=inf;
    b[0] = 0;
    for(int i=1;i<n;i++){
         for(int j=1;j<=m;j++){
              if(i>=j){
                   b[i] = min(b[i], abs(a[i-j]-a[i])+b[i-j]);
              }
         }
    }
    cout<<b[n-1]<<endl;
    return 0;
}



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

int main(){
  int n, m;
  cin >> n >> m;
  deque<int> odd, even;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    (a & 1 ? odd : even).push_back(a);
  }
  int k = odd.size();
  if (k > 2) return cout << "Impossible\n", 0;
  if (k > 0) even.push_front(odd[0]);
  if (k > 1) even.push_back(odd[1]);
  for (int i = 0; i < m; ++i) {
    cout << even[i] << (i != m - 1 ? ' ' : '\n');
  }
  if (m == 1) even.push_front(0);
  ++even[0];
  if (--even.back() == 0) even.pop_back();
  m = even.size();
  cout << m << '\n';
  for (int i = 0; i < m; ++i) {
    cout << even[i] << (i != m - 1 ? ' ' : '\n');
  }
}

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

using namespace std;
int x, y;
vector <int> sets[2];
int main() {
	cin >> x >> y;
	if (x == 2 || y == 2) {
		cout << "No" << endl;
		return 0;
	}
	sets[0].push_back(1);
	sets[0].push_back(3);
	sets[0].push_back(5);
	sets[0].push_back(7);
	sets[0].push_back(8);
	sets[0].push_back(10);
	sets[0].push_back(12);
	sets[1].push_back(4);
	sets[1].push_back(6);
	sets[1].push_back(9);
	sets[1].push_back(11);
	int set_x, set_y;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < sets[i].size(); ++j) {
			if (x == sets[i][j])
				set_x = i;
			if (y == sets[i][j])
				set_y = i;
		}
	}
	if (set_y == set_x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int n,m,l;
   
 
    cin >> n >> m >>l;
  
   int t = 0;
   for(int i = 0;i<10;i++){
     
     
     
     if(i == 0){
    
        t = n*l-m;
       cout << t << endl;
       
     }else{
       
       cout << n*t-m << endl;
       
        t =  n*t-m;
     }
     
   }

  
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int buil[5][4][11];
  int builnum, floor, room, info, person, i, j, k;

  for(i=1; i < 5; i++){
    for(j=1; j < 4; j++){
      for(k=1; k < 11; k++){
	buil[i][j][k] = 0;
      }
    }
  }

  scanf("%d", &info);

  for(i=0; i < info; i++){
    scanf("%d %d %d %d", &builnum, &floor, &room, &person);
      buil[builnum][floor][room] += person;
  }

  i=1;

  while(1){
    for(j=1; j < 4; j++){
      for(k=1; k<11; k++){
	printf(" %d",buil[i][j][k]);
      }
      printf("\n");
    }
    if(i == 4)break;
    printf("####################\n");
    i++;
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;
using VLL = vector <long long>;
using VVLL = vector <VLL>;
using PLL = pair<long long, long long>;

const int MAXD = 35;
const long long INF = 1000000000LL * 1000000000LL;

inline bool checkCross(long long dblk1, long long dblk2) {
    if (dblk2 - dblk1 >= 3) {
        return true;
    } else {
        for (long long y = dblk1+1; y < dblk2; ++y) {
            if (y % 3 == 1) {
                return true;
            }
        }
    }
    return false;
}

inline long long getDist(long long div, long long a, long long b, long long da, long long db) {
    long long blk1 = a / div;
    long long blk2 = b / div;

    long long dblk1 = da / div;
    long long dblk2 = db / div;

    if (blk1 == blk2 && blk1%3 == 1 && checkCross(min(dblk1, dblk2), max(dblk1, dblk2))) {
        long long from = blk1 * div - 1;
        long long to = (blk1+1) * div;
        return min(abs(a-from)+abs(b-from), abs(a-to)+abs(b-to));
    }

    return abs(a-b);
}

long long solve(long long a, long long b, long long c, long long d) {
    long long bx = abs(a-c);
    long long by = abs(b-d);
    long long dx = bx;
    long long dy = by;
    long long div = 1;

    for (int i = 0; i < MAXD; ++i) {
        dx = max(dx, getDist(div, a, c, b, d));
        dy = max(dy, getDist(div, b, d, a, c));

        div *= 3;
    }

    return max(dx + by, bx + dy);
}

int main() {
    int Q;
    cin >> Q;

    while (Q--) {
        long long a;
        long long b;
        long long c;
        long long d;

        cin >> a >> b >> c >> d;
        cout << solve(a-1, b-1, c-1, d-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
long long n,ans;
void test(long long m)
{
	if (n/m==n%m)
	ans+=m;
}
int main()
{
	cin >> n;
	for (long long m=1;m*m<=n;m++)
	{
		if (m!=1 && n%m==0)
		test(m-1);
		if (m*m!=n)
		test(n/m-1);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"  
  
using namespace std;  
  
#define ll          long long int   
#define inf         (ll)1e17  
  
static const int maxn = 100 + 5;  
static const int Max = 1e5 + 5;  
  
ll dp[maxn][Max];  
bool memoize[maxn][Max];  
  
int w[maxn], val[maxn];  
  
int N, W;  
  
ll solve(int pos, int make)  
{  
  if (pos >= N)   
  {  
      if (make == 0) return 0;  
      return inf;  
  }  
  ll &ret = dp[pos][make];  
  bool &mem = memoize[pos][make];  
  if (mem) return ret;  
  mem = 1;  
  ret = inf;  
  if (make - val[pos] >= 0) ret = min(ret, w[pos] + solve(pos+1, make - val[pos]));  
  ret = min(ret, solve(pos+1, make));  
  return ret;  
}  
                                        
int main()  
{  
    scanf("%d %d", &N, &W);  
    for (int i = 0; i < N; i++) scanf("%d %d", &w[i], &val[i]);  
    for (int make = 100000; make >= 0; make--)  
    {  
        ll ans = solve(0, make);  
        if (ans <= W)   
        {  
            printf("%d\n", make);  
            break;  
        }  
    }  
}  


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

int main() {
    int n;cin>>n;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    bool result=true;
    for(int i=1;i<n;i++){
        if(h[i]-h[i-1]>=1) h[i]--;

    }
    rep(i,n-1){
        if(h[i+1]<h[i]) result=false;
    }
    if(result) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && a==c) cout<< 1 << endl;
  else if(a!=b && a!=c && b!=c) cout << 3 << endl;
  else cout << 2 << endl;
}

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

int main() {
    char a; cin >> a;

    if (isupper(a)) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
    
    return 0;
}

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

int gcd(int a,int b){//最大公約数
    if(a==0||b==0){
        return max(a,b);
    }

    while(b!=0){
        int r=a%b;
        a=b;
        b=r;
    }
    return(a);
}

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

    int n;
    cin>>n;

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

    vector<int> right(n+1),left(n+1);
    left[1]=a[1];
    right[n]=a[n];

    for(int i=2;i<=n;i++){
        left[i]=gcd(left[i-1],a[i]);
    }

    for(int i=n-1;i>=0;i--){
        right[i]=gcd(right[i+1],a[i]);
    }

    int ans=left[n-1];
    ans=max(ans,right[2]);

    for(int i=2;i<=n-1;i++){
        ans=max(ans,gcd(left[i-1],right[i+1]));
    }

    cout<<ans<<"\n";

    return 0;
}


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


void solve(long long N, std::vector<long long> T, long long M, std::vector<long long> P, std::vector<long long> X){
    long long sum = accumulate(T.begin(), T.end(), 0);
    for (int i = 0; i < M; i++) {
	cout << sum - T[P[i]-1] + X[i] << endl;
    }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> T(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
    }
    long long M;
    scanf("%lld",&M);
    std::vector<long long> P(M);
    std::vector<long long> X(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&P[i]);
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(T), M, std::move(P), std::move(X));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int a,b; cin >> a >> b;
  int cnt = 0;
  for(int i = a; i <= b; i++) {
    auto str = to_string(i);
    auto rstr = str;
    reverse(str.begin(), str.end());
    if(rstr == str) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n, k = inpm()
hl = inpl()
ans = 0
for h in hl:
    if(h >= k):
        ans += 1
print(ans)

Measured memory_bytes: 91620
X,Y,A,B,C=map(int,input().split())
import numpy as np
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))
Xa=np.array(P+Q+R)
Ya=np.array([i for i,j in enumerate([A,B,C]) for k in range(j)])
x = np.argsort(Xa)
Xa=Xa[x]
Xa=Xa[::-1]
Ya=Ya[x]
Ya=Ya[::-1]
ans=0
N=0
nokori=[X,Y]
for i in range(A+B+C):
  if Ya[i]==2:
    N+=1
    ans+=Xa[i]
  elif nokori[Ya[i]]>0:
    nokori[Ya[i]]-=1
    ans+=Xa[i]
  if sum(nokori)==N:
    break
print(ans)
  

Measured memory_bytes: 35420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int MAX_N = 200005;
const int INF = 1001001001;
 
vector<int> a, ans;
vector<int> to[MAX_N];
int dp[MAX_N];
 
void dfs(int v, int p=-1) {
  int i = lower_bound(dp, dp+MAX_N, a[v]) - dp;
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = i;
  if (p != -1) ans[v] = max(ans[v], ans[p]);
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  dp[i] = old;
}
 
int main() {
  int n;
  cin >> n;
  a = ans = vector<int>(n);
  rep(i,n) cin >> a[i];
  rep(i,n-1) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    to[v].push_back(u);
    to[u].push_back(v);
  }
  rep(i,MAX_N) dp[i] = INF;
  dp[0] = -INF;
  dfs(0);
  rep(i,n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 30836
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*988244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
map<ll, ll> M;
void input() {
    cin >> n;
    rep(i, n) {
        cin >> x;
        A.pb(x);
    }
}
void solve() {
    sort(all(A));
    B = vl(1000010, 1);
    rep(i, n) {
        M[A[i]]++;
        if(M[A[i]] == 1) {
            k = A[i];
            for(ll j = 2; j * k < 1000010; j++) {
                B[j * k] = 0;
            }
        }
        if(M[A[i]] == 2) {
            B[A[i]] = 0;
        }
    }

    rep(i, n) { ans += B[A[i]]; }

    cout << ans << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 25112
#include <iostream>
#include <vector>
#include <utility>
using i64 = long long;

std::vector<std::vector<int>> g;
std::vector<int> a, ret, dp;

void dfs(const int v, const int p) {
    for (const int to : g[v]) {
        if (to == p) continue;
        const int k = std::lower_bound(dp.begin(), dp.end(), a[to]) - dp.begin();
        if (k == dp.size()) {
            dp.push_back(a[to]);
            ret[to] = k;
            dfs(to, v);
            dp.pop_back();
        } else {
            const int old = dp[k];
            dp[k] = a[to];
            ret[to] = dp.size() - 1;
            dfs(to, v);
            dp[k] = old;
        }
    }
}

int main() {
    int n;
    std::cin >> n;
    g.resize(n + 1); a.resize(n + 1); ret.resize(n + 1);
    for (int i = 1; i <= n; i++) std::cin >> a[i];
    for (int i = 1; i < n; i++) {
        int u, v;
        std::cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    ret[1] = 1;
    dp.push_back(0);
    dp.push_back(a[1]);
    dfs(1, 0);

    for (int i = 1; i <= n; i++) std::cout << ret[i] << '\n';

    return 0;
}


Measured memory_bytes: 30124
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	char[][] table;
	public void run() {
		for(;;) {
			int R = sc.nextInt();
			int C = sc.nextInt();
			if (R == 0) break;
			table = new char[R][C];
			for (int i = 0; i < R; i++) table[i] = sc.next().toCharArray();
			
			int r = 0, c = 0;
			
			int limit = R * C + 10;
			boolean end = false;
			int step = 0;
			for (; step < limit && !end; step++) {
				switch (table[r][c]) {
				case '>': { c++; }  break;
				case '<': { c--; }  break;
				case '^': { r--; }  break;
				case 'v': { r++; }  break;
				case '.': {end = true;} break;
				}
			}
			if (step >= limit) {
				System.out.println("LOOP");
			} else 
				System.out.println(c + " " + r);
			
		}
	}
}

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

int main(){
	int b, k;
	int c = 0;
  int a[4];
	for(int i = 0; i < 5; i++){
		cin >> a[i];
	}
	cin >> k;
	for(int i = 0; i < 5; i++){
		for (int j = 0; j < 5; j++){
		  b = a[i] - a[j];
		  if(b > k){
      c++;
		  }
		}
	}
	if(c > 0){
	  cout << ":(";
	}else{
		cout << "Yay!";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int h, w; cin>>h>>w;
    string s[2010];
    for(int i=0; i<h; i++) cin>>s[i];
    int c1[2010][2010], c2[2010][2010];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; ){
            if(s[i][j]!='#'){
                int r=j;
                while(r<w && s[i][r]!='#') r++;
                for(int t=j; t<r; t++) c1[i][t]=r-j;
                j=r;
            }else{
                c1[i][j]=0; j++;
            }
        }
    }
    for(int j=0; j<w; j++){
        for(int i=0; i<h; ){
            if(s[i][j]!='#'){
                int r=i;
                while(r<h && s[r][j]!='#') r++;
                for(int t=i; t<r; t++) c2[t][j]=r-i;
                i=r;
            }else{
                c2[i][j]=0; i++;
            }
        }
    }
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]!='#') ans=max(ans, c1[i][j]+c2[i][j]-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
using namespace std;
int main(){
	map<char, int> c;
	string s; cin >> s;
	long long ans = 0;
	for(auto v : s){
		for(auto e : c) if(e.first != v) ans += e.second;
		c[v]++;
	}
	cout << 1+ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream> 
#include<cstdio>
#include<string>
using namespace std;
string s;
int ans;
int main()
{
   cin>>s;
   for(int i=0;i<s.size();i++)
   {
   	   for(int j=i+1;j<s.size();j++)
   	   if (s[i]=='C'&&s[j]=='F') ans++;
   }
   if (ans>0) cout<<"Yes"<<endl;
   else cout<<"No"<<endl; 
	    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define Q 500
int Search(int);
int S[N];
int n;
int main(){
  int i,j,q,count=0;
  int T[Q];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
    for(j=0;j<q;j++){
      if(Search(T[j])==1)
	count++;
    }
  printf("%d\n",count);
  return 0;
}

int Search(int key){
  int i=0;
  S[n]=key;
  while(S[i]!=key)
    i++;
  if(i==n) return 0;
  else return 1;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int h,w,n;
int a[100010],b[100010];
int f[]={-2,-2,-2,-1,-1,-1,0,0,0};
int g[]={-2,-1,0,-2,-1,0,-2,-1,0};
int l[]={0,0,0,1,1,1,2,2,2};
int m[]={0,1,2,0,1,2,0,1,2};
set<P> st,used;
int ans[10];
signed main(){
	cin>>h>>w>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		st.insert({a[i],b[i]});
	}
	int res=0;
	rep(i,n){
		rep(j,9){
			int na=a[i]+f[j],nb=b[i]+g[j];
			if(used.find({na,nb})!=used.end())continue;
			used.insert({na,nb});
			if(na<0||h<=na+2||nb<0||w<=nb+2)continue;
			int cnt=0;
			rep(k,9){
				if(st.find({na+l[k],nb+m[k]})!=st.end())cnt++;
			}
			ans[cnt]++;
			res++;
		}
	}
	rep(i,10){
		if(!i)cout<<(h-2)*(w-2)-res<<endl;
		else cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 64256
#include <cstdio>
#include <cassert>
#include <set>
using namespace std;
int D[4][2]={{1,1},{1,-1},{-1,1},{-1,-1}};
main(){
	int T,d,p,q,m,n;
	for(scanf("%d",&T);T;T--){
		set<pair<int,int> >s;
		scanf("%d%d",&p,&q);
		for(m=0;m*m<=p*p+q*q;m++)
			for(n=m?0:1;m*m+n*n<=p*p+q*q;n++)
				for(d=0;d<4;d++)
				if((D[d][0]*m*p+D[d][1]*n*q)%(m*m+n*n)==0 && (D[d][0]*m*q-D[d][1]*n*p)%(m*m+n*n)==0){
					s.insert(make_pair(D[d][0]*m,D[d][1]*n));
				}
		assert(s.size()>=8||s.size()==4);
		puts(s.size()==8?"P":"C");
	}
}

Measured memory_bytes: 1020
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int ary[n], max = 1e18, prod = 1, fjg = 0, nol = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &ary[i]);
    fjg = (ary[i] > max) ? 1 : fjg;
    prod *= ary[i];
    (ary[i]) ? max /= ary[i] : nol = 1;
  }

  (nol) ? puts("0") : ((fjg) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

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

int main() {
    int N, D;
    scanf("%d %d", &N, &D);
    int X[N];
    int Y[N];
	for (int i=0; i<N; i++) {
		cin >> X[i] >> Y[i];
	}

    int count=0;
    double d;

    for (int i=0; i<N; i++) {
        d = pow(X[i], 2) + pow(Y[i], 2);
        d = pow(d, 0.5);
        if (d <= D) {
            count++;
        }
	}

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 4700
#include <stdio.h>

#define INF (1 << 28)
#define N 100

#define min(a, b) ((a) < (b) ? (a) : (b))

int n;
int table[N][N];

// Warshall-Floyd
void warshall_floyd(){
    int i, j, k;
    
    for(i = 0; i < n; ++i){
        for(j = 0; j < n; ++j){
            for(k = 0; k < n; ++k){
                table[j][k] = min(table[j][k], table[j][i] + table[i][k]);
            }
        }
    }
}

int main(){
    int i, j;
    int r, k, t;
    int p, s, d, v;
    
    for(i = 0; i < N; ++i){
        for(j = 0; j < N; ++j){
            table[i][j] = INF;
        }
    }
    
    scanf("%d", &n);
    
    for(i = 0; i < n; ++i){
        scanf("%d %d", &r, &k);
        
        for(j = 0; j < k; ++j){
            scanf("%d", &t);
            
            table[r - 1][t - 1] = 1;
        }
    }
    
    warshall_floyd();
    
    scanf("%d", &p);
    
    for(i = 0; i < p; ++i){
        scanf("%d %d %d", &s, &d, &v);
        
        if(table[s - 1][d - 1] + 1 > v){
            printf("NA\n");
        }
        
        else {
            printf("%d\n", table[s - 1][d - 1] + 1);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2048
a_1=list(map(int,input().split()))
a_2=list(map(int,input().split()))
a_3=list(map(int,input().split()))
n=int(input())
b=[int(input()) for i in range(n)]
result=0
if (a_1[0] in b) and (a_1[1] in b) and (a_1[2] in b):
  result=1
if (a_2[0] in b) and (a_2[1] in b) and (a_2[2] in b):
  result=1
if (a_3[0] in b) and (a_3[1] in b) and (a_3[2] in b):
  result=1
if (a_1[0] in b) and (a_2[0] in b) and (a_3[0] in b):
  result=1
if (a_1[1] in b) and (a_2[1] in b) and (a_3[1] in b):
  result=1
if (a_1[2] in b) and (a_2[2] in b) and (a_3[2] in b):
  result=1
if (a_1[0] in b) and (a_2[1] in b) and (a_3[2] in b):
  result=1
if (a_1[2] in b) and (a_2[1] in b) and (a_3[0] in b):
  result=1
  
if result==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <sstream>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define FOR(i, l, r) for (int (i) = (l); (i) < (r); ++(i))
#define REP(i, n) FOR((i), 0, (n))

long long cnt[100];
int n;
string s;

int main() {
	cin >> n;
	REP(i, n) {
		char c;
		cin >> c;
		if (c == 'Y') {
			cout << "Four" << endl;
			exit(0);
		}
	}

	cout << "Three" << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.SQLOutput;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        int k = Integer.parseInt(input.readLine());
        int x = Integer.parseInt(input.readLine());
        int y = Integer.parseInt(input.readLine());
        if (k >= n) {
            System.out.println(n *  x);
        }else {
            int sum = k * x;
            sum+= (n-k) * y;
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 23252
w,h,n=map(int,input().split())
left,right,down,up=0,w,0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:left=max(left,x)
    elif a==2: right=min(right,x)
    elif a==3: down=max(down,y)
    elif a==4: up=min(up,y)
print(max(0,right-left)*max(0,up-down))

Measured memory_bytes: 3064
def my_sign(x):
    return (x > 0) - (x < 0)

N = int(input())
A = list(map(int,input().split()))
tsum = 0 #これが答え。いくつ足したか。
nsum = A[0]
#一個目をプラスにする場合
if A[0] <= 0:
  nsum = 1
  tsum = 1-A[0]
for i in range(1,N):
  #print(nsum,nsum+A[i],tsum)
  if my_sign(nsum)*my_sign(nsum+A[i]) == -1: #符号が違う場合はそのままでおｋ
    #print(nsum,"A")
    nsum += A[i]
  else:
    if nsum>0: #次で負にする必要がある
      #print(abs(nsum+A[i]+1))
      tsum += abs(nsum+A[i]+1)
      nsum = -1
    else:
      #print(nsum+A[i],abs(nsum+A[i]-1),"X")
      tsum += abs(nsum+A[i]-1)
      nsum = 1      
ans = tsum
#print(ans)
tsum = 0 #これが答え。いくつ足したか。
nsum = A[0]
#一個目をマイナスにする場合
if A[0] >= 0:
  nsum = -1
  tsum = A[0]+1
for i in range(1,N):
  #print(nsum,nsum+A[i],tsum)
  if my_sign(nsum)*my_sign(nsum+A[i]) == -1: #符号が違う場合はそのままでおｋ
    nsum += A[i]
  else:
    if nsum>0: #次で負にする必要がある
      tsum += abs(nsum+A[i]+1)
      nsum = -1
    else:
      #print(nsum,nsum+A[i])
      tsum += abs(nsum+A[i]-1)
      nsum = 1
ans = min(ans,tsum)
print(ans)
      

Measured memory_bytes: 20320
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2+9;
const int K = 1e6;

int n, k;
int a[N];
bool dp[K]; // 石の個数が k 個なら first は必ず負ける

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    fill(&dp[0], &dp[K], true);
    for(int s = 0; s <= k; s++) {
        for(int i = 1; i <= n; i++) {
            if(dp[s])   dp[s + a[i]] = false;
        }
    }

    cout << (dp[k] ? "Second" : "First") << endl;
}

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

int main(){
   int a, b;
   int c=2;
   cin>>a;
   cin>>b;
   int d=a%c;
   int e=b%c;
   int f=d*e;
   
   if(f==0)
        cout<<"Even"<<endl;
   else
        cout<<"Odd"<<endl;
    
    return 0;
}

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

#define N	15
#define INF	0x3f3f3f3f

int max(int a, int b) { return a > b ? a : b; }

int main() {
	static int ww[N][N], ss[1 << N], dp[1 << N][N];
	int n, m, i, j, b;

	scanf("%d%d", &n, &m);
	while (m--) {
		int w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ww[i][j] = ww[j][i] = w;
		ss[1 << i | 1 << j] += w;
	}
	for (i = 0; i < n; i++)
		for (b = 0; b < 1 << n; b++)
			if (b & 1 << i)
				ss[b] += ss[b ^ 1 << i];
	for (b = 1; b < 1 << n; b++)
		for (i = 0; i < n; i++)
			dp[b][i] = -INF;
	dp[1][0] = 0;
	for (b = 1; b < 1 << n; b++)
		for (i = 0; i < n; i++) {
			int x, c, b_;

			x = dp[b][i];
			if (x == -INF)
				continue;
			b_ = (1 << n) - 1 ^ b, c = 0;
			do
				dp[b | c][i] = max(dp[b | c][i], x + ss[c | 1 << i]);
			while (c = c - b_ & b_);
			for (j = 0; j < n; j++)
				if ((b & 1 << j) == 0 && ww[i][j])
					dp[b | 1 << j][j] = max(dp[b | 1 << j][j], x + ww[i][j]);
		}
	printf("%d\n", ss[(1 << n) - 1] - dp[(1 << n) - 1][n - 1]);
	return 0;
}


Measured memory_bytes: 3784