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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr(i, a, b) for (int i = (int)(a - 1); i >= b; i--)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x " = " << x << endl
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX / 3

set<int> v[100000];
int minds[100000], mindt[100000];
ll cnt[2][100000];

int main() {
  cin.sync_with_stdio(false);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    v[x].insert(y);
    v[y].insert(x);
  }
  rep(i, n) minds[i] = mindt[i] = INF;
  queue<P> qs, qt;
  qs.push(P(s, 0));
  while (qs.size()) {
    P p = qs.front();
    qs.pop();
    if (minds[p.fi] < INF) continue;
    minds[p.fi] = p.se;
    each(itr, v[p.fi]) if (minds[itr] == INF) qs.push(P(itr, p.se + 1));
  }
  qt.push(P(t, 0));
  while (qt.size()) {
    P p = qt.front();
    qt.pop();
    if (mindt[p.fi] < INF) continue;
    mindt[p.fi] = p.se;
    each(itr, v[p.fi]) if (mindt[itr] == INF) qt.push(P(itr, p.se + 1));
  }
  int st = minds[t];
  rep(i, n) {
    if (minds[i] < st) cnt[0][minds[i]]++;
    if (mindt[i] < st) cnt[1][mindt[i]]++;
  }
  ll ans = 0;
  rep(i, st - 1) { ans += cnt[0][i] * cnt[1][st - 2 - i]; }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 27952
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<30;


int main(){
    int n;cin >> n;
    string s;cin >> s;
    int ans = INF;
    bool f = false;
    vector<int> a(n+1,0),b(n+1,0);
    for (int i = 0; i < n; i++) {
        a[i+1] = a[i] + (s[i]=='#');
    }
    for (int i = n-1; i >= 0 ; i--) {
        b[i] = b[i+1] + (s[i]=='.');
    }
    for (int i = 0; i <= n; i++) {
        ans = min(ans,a[i]+b[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2180
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e9+7;
const ll MAXN=1000200;
ll i,j,mask,test;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n,k;
cin>>n>>k;
vector<ll> v(n);
F(i,0,n)
{
    cin>>v[i];
}
ll init=0,f=k-1,minn=mod;
F(i,f,n)
{
    ll p=0;
   if(v[f]*v[init]<=0)
   {
     p=min(abs(v[f]),abs(v[init]));
     p+=abs(v[f]-v[init]);
   }
   else
   {
       p=max(abs(v[f]),abs(v[init]));
   }
   minn=min(minn,p);
   f++;
   init++;
}
cout<<minn;
return 0;
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int main()
{
    fastio;
    int n,x,y;
    cin>>n>>x>>y;

    int cnt[3000];
    set_ar(cnt,0);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int dist = min(j-i,abs(x-i)+abs(j-y)+1);
            cnt[dist]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<cnt[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
struct LCA {
  int N, logN; // logN-1 == floor(lg(N-1))
  vector<vector<int>> G;
  vector<int> depth;
  // vから根の方向に2^k回登ったときのノード parent[k][v]
  vector<vector<int>> parent;
 
  LCA(int size) : N(size), G(size), depth(size) {
    logN = 0;
    for(int x = 1; x < N; x *= 2) logN++;
    parent.assign(max(logN, 1), vector<int>(N));
  }
 
  // どちらが根であってもOK
  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }
 
  void dfs(int v, int par, int dep) {
    depth[v] = dep;
    parent[0][v] = par;
    for(int next : G[v]) {
      if(next != par) dfs(next, v, dep + 1);
    }
  }
 
  void init(int root) {
    dfs(root, -1, 0);
    for(int k = 1; k < logN; k++) {
      for(int v = 0; v < N; v++) {
        if(parent[k - 1][v] == -1) parent[k][v] = -1;
        else parent[k][v] = parent[k - 1][parent[k - 1][v]];
      }
    }
  }
 
  int lca(int u, int v) {
    if(depth[u] > depth[v]) swap(u, v); // vのほうが深くなる
    // uとvの深さが同じになるまでvを根の方向に移動する
    for(int k = 0; k < logN; k++) {
      if(((depth[v] - depth[u]) >> k) & 1) {
        v = parent[k][v];
      }
    }
    if(u == v) return u;
    for(int k = logN - 1; k >= 0; k--) {
      if(parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};
 
int main() {
  int N; cin >> N;
  LCA lca(N);
  for(int u = 0; u < N; u++) {
    int k; cin >> k;
    while(k--) {
      int v; cin >> v;
      lca.add_edge(u, v);
    }
  }
  lca.init(0);
  int Q; cin >> Q;
  while(Q--) {
    int u, v; cin >> u >> v;
    cout << lca.lca(u, v) << endl;
  }
}

Measured memory_bytes: 16088
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <random>
#include <unordered_map>

using namespace std;

struct Point{
    double x,y;
    Point* next;
};

uint64_t toKey(int x, int y){
    union Key{
        uint64_t key;
        int x[2];
    };
    Key K;
    K.x[0]=x, K.x[1]=y;
    return K.key;
}

void build(unordered_map<uint64_t, Point*>& Grid, double d, int i, Point *P){
    Grid.clear();
    for(int j=0;j<=i;j++){
        int x=floor(P[j].x/d),y=floor(P[j].y/d);
        uint64_t key = toKey(x,y);
        if(Grid.count(key)!=0){
            P[j].next=Grid[key];
        }
        Grid[key]=&P[j];
    }
}

double distance(Point& a, Point &b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

double search(unordered_map<uint64_t, Point*>& Grid, double d, Point& P){
    int x=floor(P.x/d),y=floor(P.y/d);
    uint64_t key;
    double minimum=1e10;
    for(int dx=-1;dx<2;dx++){
        for(int dy=-1;dy<2;dy++){
            key=toKey(x+dx,y+dy);
            if(Grid.count(key)){
                Point *p=Grid[key];
                while(p!=NULL){
                    if(minimum>distance(*p,P)) minimum=distance(*p,P);
                    p=p->next;
                }
            }
        }
    }
    return minimum;
}

void insert(unordered_map<uint64_t, Point*>& Grid, double d, Point& P){
    int x=floor(P.x/d),y=floor(P.y/d);
    uint64_t key = toKey(x,y);
    if(Grid.count(key)!=0){
        P.next=Grid[key];
    }
    Grid[key]=&P;
}

int main(){
    int n;
    cin >> n;
    Point P[n];
    for(int i=0;i<n;i++){
        cin >> P[i].x >> P[i].y;
        P[i].next=NULL;
    }
    //??????????????£???????????????
    random_device rd;
    mt19937 mt(rd());//?????????????????§?????????????????????????????????
    uniform_int_distribution<int> dist(0,n-1);
    for(int i=0;i<n;i++){
        int j = dist(mt);
        Point p = P[i];
        P[i]=P[j];
        P[j]=p;
    }
    unordered_map<uint64_t, Point*> Grid;
    double delta=distance(P[0],P[1]);
    build(Grid,delta,1,P);
    for(int i=2;i<n;i++){
        double d2=search(Grid,delta,P[i]);
        if(d2>=delta){
            insert(Grid,delta,P[i]);
        }else{
            delta=d2;
            build(Grid,delta,i,P);
        }
    }
    cout.precision(6);
    cout << fixed;
    cout << delta << endl;
    return 0;
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
    // adj[v].push_back(u); 
} 

// void printGraph(vector<int> adj[], int V) 
// { 
//     for (int v = 0; v < V; ++v) 
//     { 
//         cout << "\n Adjacency list of vertex "
//              << v << "\n head "; 
//         for (auto x : adj[v]) 
//            cout << "-> " << x; 
//         printf("\n"); 
//     } 
// } 

int main()
{
	int n, q, a, b;
	cin>>n>>q;
	vector<int> adj[n];
	vector<int> parent(n+1, -1);
	for(int i = 0; i < n-1; i++)
	{
		cin>>a>>b;
		parent[b]=a;
		addEdge(adj, a, b);
	}
	// vector<int> parent(n+1, -1);
	// for(int i = 0; i < parent.size(); i++)
	// {
	// 	// cout<<"YO"<<endl;
	// 	cout<<parent[i]<<endl;
	// }

	vector<int> ans(n+1, 0);
	int p, x;
	for(int i = 0; i < q; i++)
	{
		cin>>p>>x;
		ans[p]+=x;
	}

	// for(int i = 0; i < ans.size(); i++) cout<<ans[i]<<" ";
	// 	cout<<endl;
	// // cout<<ans[1]<<" "
	for(int i = 2; i <= parent.size(); i++)
	{
		// cout<<"YO"<<endl;
		// cout<<ans[i]<<" ";
		ans[i] = ans[i] + ans[parent[i]];
	}
	for(int i = 1; i < ans.size(); i++)
	{
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	// printGraph(adj, n);
	// vector<double> a(n);
	// double sum = 0;

	// for(int i = 0 ; i < n; i++)
	// {
	// 	cin>>a[i];
	// 	// sum+=(1.0/(1.0*a[i]));

	// }
	// sort(a.begin(), a.end());
	// sum = a[0];
	// for(int i = 1; i < n; i++)
	// {
	// 	sum=(sum+a[i])/2.0;
	// }
	// double ans = (1.0/sum);
	// cout<<fixed<<setprecision(6)<<sum<<endl;

}
	

Measured memory_bytes: 14848
sa=input()
sb=input()
sc=input()
k="a"
while min(len(sa), len(sb), len(sc)) >= 0:
  if k=="a":
    if len(sa)==0:
      print("A")
      exit()
    else:
      k=sa[0]
      sa=sa[1:]
  elif k=="b":
    if len(sb)==0:
      print("B")
      exit()
    else:
      k=sb[0]
      sb=sb[1:]
  else: 
    if len(sc)==0:
      print("C")
      exit()
    else:
      k=sc[0]
      sc=sc[1:]

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#define pi acos(-1)
using namespace std;
double aabs(double x)
{
	if(x<0)return -x;
	return x;
}
struct Dice{
	int q1,q2,q3,q4,q5,q6;
};

int main(){
	Dice d;
	char od;
	int n;

	
	scanf("%d %d %d %d %d %d", &d.q1, &d.q2, &d.q3, &d.q4, &d.q5, &d.q6);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b,c;
		cin>>a>>b;
		if(a==d.q1)
		{
			if(b==d.q2)c=d.q3;
			else if(b==d.q3)c=d.q5;
			else if(b==d.q5)c=d.q4;
			else if(b==d.q4)c=d.q2;
		}
		else if(a==d.q2)
		{
			if(b==d.q3)c=d.q1;
			else if(b==d.q1)c=d.q4;
			else if(b==d.q4)c=d.q6;
			else if(b==d.q6)c=d.q3;
		}
		else if(a==d.q3)
		{
			if(b==d.q2)c=d.q6;
			else if(b==d.q1)c=d.q2;
			else if(b==d.q5)c=d.q1;
			else if(b==d.q6)c=d.q5;
		}
		if(a==d.q4)
		{
			if(b==d.q2)c=d.q1;
			else if(b==d.q1)c=d.q5;
			else if(b==d.q5)c=d.q6;
			else if(b==d.q6)c=d.q2;
		}
		else if(a==d.q5)
		{
			if(b==d.q1)c=d.q3;
			else if(b==d.q3)c=d.q6;
			else if(b==d.q6)c=d.q4;
			else if(b==d.q4)c=d.q1;
		}
		else if(a==d.q6)
		{
			if(b==d.q2)c=d.q4;
			else if(b==d.q4)c=d.q5;
			else if(b==d.q5)c=d.q3;
			else if(b==d.q3)c=d.q2;
		}
		cout<<c<<endl;
	}
	
	return 0;
}




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

public class Program
{
    public static void Main(string[] args)
    {
        var sa = Console.ReadLine().Split(' ');
        var n = int.Parse(sa[0]);
        var m = int.Parse(sa[1]);
        var x = int.Parse(sa[2]);
        var y = int.Parse(sa[3]);


        var xa = Console.ReadLine().Split(' ');
        var xl = new SortedSet<int>();
        xl.Add(x);
        foreach (var item in xa)
        {
            xl.Add(int.Parse(item));
        }

        var ya = Console.ReadLine().Split(' ');
        var yl = new SortedSet<int>();
        yl.Add(y);
        foreach (var item in ya)
        {
            yl.Add(int.Parse(item));
        }

        if (xl.Max<yl.Min)
        {
            Console.WriteLine("No War");
        }
        else
        {
            Console.WriteLine("War");
        }


    }
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

// LCS(longest common subsequence)
// http://www.deqnotes.net/acmicpc/1458/
int dp[3005][3005];
int pre[3005][3005]; // 1: i,j から 2: i+1,j から 3: i,j+1 から
void lcs(string &x, string &y) {
    memset(dp, 0, sizeof(dp));
    int xn = x.size();
    int yn = y.size();
    for (int i = 0; i < xn; i++) {
        for (int j = 0; j < yn; j++) {
            if (x[i] == y[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                pre[i + 1][j + 1] = 1;
            } else {
                if (max(dp[i][j + 1], dp[i + 1][j]) == dp[i + 1][j]) {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                    pre[i + 1][j + 1] = 2;
                } else {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                    pre[i + 1][j + 1] = 3;
                }
            }
        }
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    lcs(s, t);
    string ans = "";
    int x = s.size(), y = t.size();
    while (pre[x][y] != 0) {
        if (pre[x][y] == 1) {
            x -= 1, y -= 1;
            ans += s[x];
        } else if (pre[x][y] == 2) {
            y -= 1;
        } else {
            x -= 1;
        }
    }
    reverse(ans.begin(), ans.end());

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


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
bool isNum(ll x){
    bool nana=false, go=false, san=false;
    while(x>0){
        int num=x%10;
        x/=10;
        if(num==3) san=true;
        if(num==5) go=true;
        if(num==7) nana=true;
    }
    return san&&go&&nana;
}

int main(){
    fast_io

    ll n;
    cin>>n;
    queue<ll> que;

    que.push(3);
    que.push(5);
    que.push(7);

    ll ans=0;
    ll cnt=0;
    while (ans<=n){
        ll x=que.front();
        que.pop();
        que.push(x*10+3);
        que.push(x*10+5);
        que.push(x*10+7);

        if(isNum(x) && x<=n) {
            cnt++;
            //cout<<cnt<<":"<<x<<endl;
        }
        ans=x;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            int m = Integer.parseInt(reader.readLine());
            int g = Integer.parseInt(reader.readLine());
            int d = Integer.parseInt(reader.readLine());
            int[][] data = new int[d + 1][n + 2];
            for (int i = 1; i <= n; i++) {
                data[0][i] = i;
            }
            String[] lines = new String[d + 1];
            for (int i = 1; i <= d; i++) {
                line = "0" + reader.readLine() + "0";
                lines[i] = line;
                for (int j = 1; j <= n; j++) {
                    data[i][j] = data[i - 1][j];
                }
                for (int j = 1; j < n; j++) {
                    if (line.charAt(j) == '1') {
                        data[i][j] = data[i - 1][j + 1];
                        data[i][j + 1] = data[i - 1][j];
                        j++;
                    }
                }
            }
            int x = data[d][g];
            if (x == m) {
                out.println(0);
                continue;
            }
            String result = "1";
            for (int i = 1; i <= d; i++) {
                int editIndex = 0;
                for (int j = 1; j <= n; j++) {
                    if (data[i][j] == m) {
                        if (data[i][j - 1] == x) {
                            editIndex = j - 1;
                            break;
                        } else if (data[i][j + 1] == x) {
                            editIndex = j;
                            break;
                        }
                    }
                }
                if (editIndex != 0) {
                    boolean found = false;
                    for (int j = editIndex - 1; j <= editIndex + 1; j++) {
                        if (lines[i].charAt(j) == '1') {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        result = i + " " + editIndex;
                        break;
                    }
                }

            }
            out.println(result);
        }
    }
}

Measured memory_bytes: 9696
from typing import List, Dict


def main(N: int, A: List[int]):
    bosses: Dict[int, List[int]] = {}

    for i, boss in enumerate(A, start=2):
        if boss not in bosses:
            bosses[boss] = [i]
        else:
            bosses[boss].append(i)

    for worker in range(1, N + 1):
        if worker not in bosses:
            print(0)
        else:
            print(len(bosses[worker]))


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split())))

    main(N, A)

Measured memory_bytes: 54100
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cD = Counter(D)
cT = Counter(T)

kD = set(cD.keys())

for k, v in cT.items():
  if k not in kD or cD[k] < v:
    print("NO")
    exit()
print("YES")

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

int colors[100005];

bool is_bipartite_graph(const Graph &graph, int v, int c) {
    colors[v] = c;
    for (int u: graph[v]) {
        if (colors[u] == c) {
            return false;
        }
        if (colors[u] == 0 && !is_bipartite_graph(graph, u, -c)) {
            return false;
        }
    }
    return true;
}

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

void Main() {
    int N, M;
    cin >> N >> M;
    Graph graph(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    if (is_bipartite_graph(graph, 0, 1)) {
        int b = 0;
        rep(i, ARRAY_SIZE(colors)) {
            if (colors[i] == 1)b += colors[i];
        }
        int w = N - b;
        cout << (ll) b * w - M << '\n';
    } else {
        cout << (ll) N * (N - 1) / 2 - M << '\n';
    }


}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

struct UnionFind{
    vector<ll> rank,p,size;
    UnionFind(int n){
        rank.resize(n,0);
        p.resize(n,0);
        size.resize(n,0);
        for(int i = 0; i < n; i++){
            p[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    int root(int x){
        if(x != p[x]){
            p[x] = root(p[x]);
        }
        return p[x];
    }
    bool unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return false;
        if(rank[rx] > rank[ry]){
            p[ry] = rx;
            size[rx] += size[ry];
        }else{
            p[rx] = ry;
            size[ry] += size[rx];
            if(rank[rx] == rank[ry]){
                rank[ry]++;
            }
        }
        return true;
    }
    int tree_size(int x){
        return (size[root(x)]);
    }
};



int main()
{
    ll n,m; cin >> n >> m;
    vector<P> v;
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        v.push_back(make_pair(a,b));
    }
    UnionFind uf(n);
    reverse(v.begin(),v.end());
    ll com = (n*(n-1))/2;
    vector<ll> ans;
    rep(i,m){
        ll a = v[i].first, b = v[i].second;
        if(uf.same(a,b)){
            ans.push_back(com);
        }else{
            ans.push_back(com);
            com -= uf.tree_size(a) * uf.tree_size(b);
            uf.unite(a,b); 
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,m){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 5364
import heapq
n,m = map(int,input().split())
AB =[tuple(map(int,input().split())) for i in range(n)]
ans,memo=0,0
hq=[]
AB.sort(key=lambda tup:tup[0])
for day in range(m):
	for i in range(memo,n):
		if AB[i][0]<=(day+1):
			heapq.heappush(hq,-AB[i][1])
			memo+=1
		else:
			break
	if len(hq):	
		ans += -heapq.heappop(hq)
print(ans)




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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N, X;
vec<int> v;

signed main() {
	cin >> N >> X;
	// v.resize(N);
	v.push_back(0);
	rep (i, N) {
		// cin >> v[i];
		int a;
		cin >> a;
		v.push_back(a);
	}

	int t = 0;
	int cnt =0 ;
	rep (i, v.size()) {
		t += v[i];
		if (t <= X) {
			cnt++;
		} else {
			break;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    vector<int> ans;
    for(int i=1;i<60;i+=2){
        if(n&(1LL<<i)){
            n+=(1LL<<(i+1));
        }
    }
    rep(i,60){
        if (n & (1LL << i))
        {
            ans.push_back(1);
        }
        else
        {
            ans.push_back(0);
        }
    }
    reverse(ans.begin(),ans.end());
    int i = 0;
    while(i<ans.size()&&ans[i]==0){
        i++;
    }
    if(i==ans.size()){
        cout << 0 << endl;
    }
    else{
        while(i<ans.size()){
            cout << ans[i];
            i++;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
 int N;
 int K;
 int X;
 int Y;
 int sum =0;
 
cin  >>N >> K >> X >> Y;
 
for(int i=1; i<=N; i++){
 if(i <=K){
  sum +=X;
}
else {
 sum +=Y;
}
 
}

cout << sum <<endl;
return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x/500) * 1000;
  x %= 500;
  ans += (x/5) * 5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let x: usize = sc.read();

    let mut is_prime = [true; 1000000];
    is_prime[0] = false;
    is_prime[1] = false;
    for p in 2..is_prime.len() {
        if is_prime[p] {
            let mut cur = p * 2;
            while cur < is_prime.len() {
                is_prime[cur] = false;
                cur += p;
            }
        }
    }

    for i in x.. {
        if is_prime[i] {
            println!("{}", i);
            return;
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5372
#include "bits/stdc++.h"

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kMax9 = 1000000010;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, int n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

double dist(double lhs, double rhs) {
  return sqrt(lhs * lhs + rhs * rhs);
}

// int binary(int bina){
//   int ans = 0;
//   for (int i = 0; bina>0 ; i++)
//   {
//     ans = ans+(bina%2)*pow(10,i);
//     bina = bina/2;
//   }
//   return ans;
// }

const long km = 62;

long n, m, k, t;
string binary(ll dec){
  string s;
  while (dec > 0) {
    s.pb((dec % 2) + '0');
    dec /= 2;
  }
  auto j = km - long(s.size());
  rep(i, 0, j - 1) { s.pb('0'); }
  // reverse(s.begin(), s.end());
  return s;
}

ll exp2k(long x) {
  ll ans = 1;
  rep(i, 1, x) {
    ans = (ans * x) % kMod;
  }
  return ans;
}

int main() {
  ll ans = 0;
  long n, m, a, b, x, y;
  string s, t;
  vector<string> ss;
  vector<ll> aa;
  vector<ll> ba;
  vector<ll> xx;
  vector<ll> yy;

  cin >> n >> s >> t;

  rep(i, 0, n - 1) {
    cout << s[i] << t[i];
  }

  cout << endl;

  return 0;
}


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

int main(){
  int N,W;
  cin >> N >> W;
  int v[N],w[N];
  for(int i=0; i<N; i++)
    cin >> v[i] >> w[i];

  int DP[N+1][W+1];

  for(int j=0; j<=W; j++)
    DP[0][j] = 0;

  for (int i=1; i<=N; i++)
    for(int j=0; j<=W; j++)
      if(j<w[i-1])
        DP[i][j] = DP[i-1][j];
      else{
        if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1])
          DP[i][j] = DP[i-1][j];
        else
          DP[i][j] = DP[i-1][j-w[i-1]]+v[i-1];
      }

  cout << DP[N][W] << endl;
  return 0;
}



Measured memory_bytes: 7008
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==b){
    printf("Draw\n");
  }
  else if(a==1){
    printf("Alice\n");
  }
  else if(b==1){
    printf("Bob\n");
  }
  else if(a>b){
    printf("Alice\n");
  }
  else if(b>a)
  {
      printf("Bob\n");
  }

    return 0;
}


Measured memory_bytes: 128
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2294"

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

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#endif
//BEGIN CUT HERE
struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#endif
//BEGIN CUT HERE
struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  Int n;
  cin>>n;
  vector<double> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  cout<<(a.back()-a.front())/(n-1)<<endl;
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed main(){
  return 0;
}
#endif

#undef call_from_test

signed main(){
  using D = long double;
  int h,n,p,m,k;
  cin>>h>>n>>p>>m>>k;
  p--;

  vector<int> bs(h,-1);
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    bs[h-x]=y-1;
  }

  auto dp=make_v<D>(h+1,k+1,n+1);
  fill_v<D>(dp,0);

  dp[0][0][p]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<=k;j++){
      if(~bs[i]){
        swap(dp[i][j][bs[i]],dp[i][j][bs[i]+1]);
        for(int l=0;l<n;l++) dp[i+1][j][l]+=dp[i][j][l];
        continue;
      }
      for(int l=0;l<n;l++) dp[i+1][j][l]+=dp[i][j][l];
      if(j+1>k) continue;
      for(int l=0;l<n;l++){
        D x=0.0;
        if(l+1<n)  dp[i+1][j+1][l+1]+=dp[i][j][l]/(n-1.0),x+=1.0;
        if(l-1>=0) dp[i+1][j+1][l-1]+=dp[i][j][l]/(n-1.0),x+=1.0;
        dp[i+1][j+1][l]+=dp[i][j][l]*(n-1.0-x)/(n-1.0);
      }
    }
  }

  D ans=*max_element(dp[h][k].begin(),dp[h][k].end());
  for(int i=0;i<k;i++){
    ans/=(h-m-i);
    ans*=(i+1);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 85092
// Parallelism
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0021& lang=jp
// https://onlinejudge.u-aizu.ac.jp/#/problems/0021
// 中央×前

#include <iostream>
#include <vector>
#include <string>
#include <complex>
using namespace std;

#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

typedef complex<double> xy_t;
const double eps = 1e-11;

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

double signed_area(xy_t v1, xy_t v2) {
	return cross_product(v1, v2) / 2;
}

bool is_pararell(xy_t a, xy_t b, xy_t c, xy_t d) {
	xy_t v1 = xy_t(b.real()-a.real(), b.imag()-a.imag());
	xy_t v2 = xy_t(d.real()-c.real(), d.imag()-c.imag());

	// cout << signed_area(v1, v2) << endl;

	if (abs(signed_area(v1, v2)) < eps) return true;
	else return false;
}


int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<string> vs;
	while(n--) {
		double x1, x2, x3, x4;
		double y1, y2, y3, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		xy_t a = xy_t(x1, y1);
		xy_t b = xy_t(x2, y2);
		xy_t c = xy_t(x3, y3);
		xy_t d = xy_t(x4, y4);
		if (is_pararell(a, b, c, d)) vs.pb("YES");
		else vs.pb("NO");
	}

	for (auto v:vs) {
		if (v == "YES") YES;
		else NO;
	}


}




Measured memory_bytes: 3116
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  string S; //配列として使える
  int N, i, M;  
  
  cin >> N;
  cin >> S;

  if(N % 2 == 1){
    printf("No\n");
    return 0;
  }

  M = N/2; 
  
  for(i=0;i<M;i++){
    if(S[i] != S[i+M]){
      printf("No\n");
      return 0;      
    }
  }
  printf("Yes\n");

  return 0; 
}


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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)
N = int(input())
data = defaultdict(int)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a, b = (0,0)はそれを入れるのみなので，
# カウントから抜かして(a,b)の数を最後に足せば良い
# どちらかが0の場合は，
# a=0ならb=0のモノが対比となる

cnt_zero = 0

for i in range(N):
    a, b = map(int, input().split())
    div = gcd(abs(a), abs(b))

    # マイナスはaだけ
    if a <0 and b <0:
        a, b = -a, -b
    elif b < 0:
        a, b = -a, -b

    if a ==0 and b==0:
        cnt_zero += 1
        continue

    if a ==0:
        data[(0, 1)] += 1
        data[(1, 0)] += 0
        continue

    if b ==0:
        data[(1, 0)] += 1
        data[(0, 1)] += 0
        continue

    data[(a//div, b//div)] += 1
    if a > 0:
        data[(-b//div, a//div)] += 0
    else:
        data[(b // div, -a // div)] += 0

mod = 1000000007
res = 1


for d in data:
    if d[0]>0 and d[1]>0:
        val = data[d]
        a1 = data[(-d[1], d[0])]
        # print(d, val, a1)
        if val == 0:
            res *= pow(2, a1, mod)
        elif a1 > 0:
            res *= pow(2, val, mod) + pow(2, a1, mod) - 1
            data[(-d[1], d[0])] = 0
        else:
            res *= pow(2, val, mod)
        res %= mod
        # print(res)
    # aが0の場合
    if d[0]==0:
        val = data[d]
        a1 = data[(1, 0)]

        if val == 0:
            res *= pow(2, a1, mod)
        elif a1 > 0:
            res *= pow(2, val, mod) + pow(2, a1, mod) - 1
        else:
            res *= pow(2, val, mod)
        res %= mod

print((res+cnt_zero-1)%mod)


Measured memory_bytes: 183912
import java.util.Scanner;

public class Main {
	 public static void main(String args[]){
		 Scanner std = new Scanner(System.in);
		 int x = std.nextInt();
		 int a = std.nextInt();
		 if(x<a) {
			 System.out.println(0);
		 }
		 else {
			 System.out.println(10);
		 }
	 }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define LLI long long int

const double PI = acos(-1.0);

int main() {
    // freopen("in.txt", "r", stdin);

    double a, b, c, A, B, C;
    cin >> a >> b >> C;
    C = PI * C / 180;
    c = sqrt(a*a + b*b - 2.0*a*b*cos(C));

    double s = a * b * sin(C) / 2;
    double l = a + b + c;
    double h = 2 * s / a;
    cout << setprecision(10) << s << " " << l << " " << h << endl;

    return 0;
}



Measured memory_bytes: 3488
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

/// 配列に含まれる要素(T: Ord + Copy)別にその個数を数えて
/// `BTreeMap<T, usize>`の形にして返す
pub fn unique_count<T: Ord + Copy>(v: &[T]) -> BTreeMap<T, usize> {
    let mut map = BTreeMap::new();
    for e in v {
        let h = map.entry(*e).or_insert(0);
        *h += 1;
    }
    map
}

fn main() {
    let (n, m): (usize, usize) = input_two();
    let a: Vec<usize> = input_vec();
    let mut accum = vec![0; n+1];
    let mut zeros = 1usize;
    for i in 1..n+1 {
        accum[i] = (accum[i-1] + a[i-1] % m) % m;
    }

    let uc = unique_count(&accum).values().cloned().collect::<Vec<_>>();
    let mut ans = 0usize;
    for v in uc {
        ans += v * (v - 1) / 2;
    }

    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 8444
Imports System.Collections.Generic
Imports System.Console
Module Program
    Function f(A As Integer, B As Integer, C As Integer) As String
        For k As Integer = 0 to 10000000
            If (k * A) Mod B = C Then
                    Return "YES"
            End If
        Next k
        Return "NO"
    End Function
 	
 	Sub Main()
 	    Dim inputs as String()
        inputs = Console.ReadLine().Split(" ")
	    Dim A As Integer = inputs(0)
	    Dim B As Integer = inputs(1)
	    Dim C As Integer = inputs(2)
        Console.WriteLine(f(A,B,C))
    End Sub
End Module


Measured memory_bytes: 13140
#include <iostream>

using namespace std;
int s[4];
int main()
{
    int a , b;
    cin >> a >> b;
    s[a] = 1;
    s[b] = 1;
    for(int i = 1; i <= 3; i ++) {
        if(s[i] == 0) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[10005];
int b[10005];
int main(){
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> b[i];
	}
	int temp = 1;
	int j = 1;
	for (int i = 1; i <= n; i++){//将每一个数遍历一遍 
		while (b[i] > 0){ 
			a[j] = temp;
			j++;
			b[i]--;
		}
		temp++;
	}
	for (int i = 1; i <= h; i++){//这是输出的主体 
		if (i % 2 == 1){//奇数行 
			for (int p = w*(i - 1) + 1; p <= i*w; p++){
				cout << a[p] << " ";
			}
			if (i != h){
				cout << endl;
			}
		}else if (i % 2 == 0){//偶数行 
			for (int p = w*i; p >= w*(i - 1) + 1; p--){
				cout << a[p] << " ";
			}
			if (i != h){
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

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

  int min = -1;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      if (min == -1) {
        min = c;
      } else if (c < min) {
        min = c;
      }
    }
  }

  if (min == -1) {
    cout << "TLE" << endl;
  } else {
    cout << min << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] b = new int[a];
		int c;
		int d = a/2;
		int Answer = 0;
		for(int i = 0; a>i; i++) {
			c = sc.nextInt();
			b[i] = c;
		}
		Arrays.sort(b);
		int f = b[d];
		int g = b[d-1];
		Answer = f-g;
		System.out.println(Answer);
	}
}

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

int main(){
	int h,w;
	while(1){
		cin>>h>>w;
		if(h==0&&w==0) break;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if((i+j)%2==0){
					cout<<'#';
				}else{
					cout<<'.';
				}
			}
			cout << endl;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
long long int power(long long int a,long long int b,long long int p)
{
    long long int res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
bool check(long long int k){
	for(int i=0;i<to_string(k).length();i++){
		if(to_string(k)[i]!='7')
		return false;
	}
	return true;
}
int main(){
	long long int sum=0,k,mod=0;
	cin>>k;
	/*if(check(k)){
		cout<<(int)(log10(k)+1)<<endl;
		return 0;
	}*/
	map<long long int,long long int> m;
	while(true){
		mod+=(7%k)*(power(10,sum,k)%k);
		mod%=k;
		if(m[mod])
		break;
		m[mod]=1;
		if(!mod){
			cout<<(sum+1)<<endl;
			return 0;
		}
		sum++;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 66108
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a,b,c,d;
  	long long tmp;
    string s;
    
    //a = b = c = d = tmp = 0;
    //vector<int>a();
  	d = 0;

    cin >> a >> b;
 	long double x[a];
    long double y[a];
    long double ans[a];
    for(int i = 0;i < a;i++){
        cin >>  x[i];
        cin >>  y[i];
        //cout << x[i] <<  "   " << y[i];  
    }
    for(int i = 0;i < a;i++){
        tmp = x[i]*x[i] + y[i]*y[i];
      	ans[i] = sqrt(tmp);
        if(ans[i] <= b){
          
          d++;
    		}
  
    }
    cout << d;

}


Measured memory_bytes: 13108
#include<stdio.h>
int main(){
	int a,b,i,s,n;
	for(s=0;scanf("%d %d %d",&a,&b,&n)!=EOF;s=0){
		for(i=1; i<=n; i++){
			a -= b * (a / b);
			a *= 10;
			s+=a / b;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
ans = 10000

for x in range(1, N // 2 + 1):
    SUM = 0
    A = x
    B = N - x
    while A > 0 or B > 0:
        SUM += A % 10 + B % 10
        A //= 10
        B //= 10
    if ans > SUM:
        ans = SUM

print(ans)

Measured memory_bytes: 2940