akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

int dx[8] = { 1,0,0,-1,1,1,-1,-1 };
int dy[8] = { 0,-1,1,0,-1,1,-1,1 };

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a;
    string b;
    cin >> a >> b;
    int x = 0;
    rep(i, b.size()) {
        if (b[i] != '.') {
            x = x * 10 + (b[i] - '0');
        }
    }
    int ab = a * x;
    cout << ab / (int)100 << endl;

    return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;
import java.util.stream.Stream;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int N = Integer.parseInt(n);
		int[] w_list = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] data_wa = new int[N];
		
		data_wa[0] =  w_list[0];
		for(int i=1;i<N;i++) {
			data_wa[i] = data_wa[i-1] + w_list[i];
		}
		
		int min_value= Math.abs(data_wa[N-1] - data_wa[0]);
		
		for(int i=1;i<N-1;i++) {
			int S1 = data_wa[i];
			int S2 = data_wa[N-1] - data_wa[i];
			if(Math.abs(S1 - S2) < min_value) min_value = Math.abs(S1 - S2);
		}
		System.out.print(min_value);
	}
}


Measured memory_bytes: 27460
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;
// A - Multiplication 1
class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		long N= sc.nextInt(); //

		//long ans = sc.nextLong();
		BigInteger ans = BigInteger.valueOf(0);
		long x = 0;
		BigInteger v = BigInteger.valueOf(Long.valueOf("1000000000000000000"));

		boolean exFlg = false;

		ArrayList<Long> lstA;
		lstA = new ArrayList<Long>();

		for (int i=0; i < N; i++) {
			x = sc.nextLong();
			// 0掛けしていれば終わり
			if (x == 0) {
				exFlg = true;
				break;
			}
			lstA.add(x);
		}

		if (!exFlg) {
			ans = BigInteger.valueOf(lstA.get(0));
			for (int i=1; i < N; i++) {

				ans= ans.multiply(BigInteger.valueOf(lstA.get(i)));

				try {
					if (ans.subtract(v).longValueExact() > 0) {
						ans = BigInteger.valueOf(-1);
						break;
					}

				} catch (Exception e) {
					ans = BigInteger.valueOf(-1);
					break;
				}

			}

		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 51812
A, B = map(int, input().split(" "))
cnt = 0

def isKaibun(num):
    _s = str(num)
    if _s[0] == _s[4] and _s[1] == _s[3]:
        return True
    else:
        return False

for n in range(A, B+1):
    if isKaibun(n):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX_V 10001
using namespace std;
 
int V,m;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V]={};
int cmp[MAX_V];
 
void add_edge(int from, int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}
 
void dfs(int v){
  used[v] = true;
  for(int i = 0;i < G[v].size();i++){
    if(!used[G[v][i]])dfs(G[v][i]);
  }
  vs.push_back(v);
}
 
void rdfs(int v,int k){
  used[v] = true;
  cmp[v] = k;
  for(int i = 0;i < rG[v].size();i++){
    if(!used[rG[v][i]]) rdfs(rG[v][i],k);
  }
}
 
void scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v = 0;v < V;v++){
    if(!used[v]) dfs(v);
  }
  memset(used,0,sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1;i >= 0;i--){
    if(!used[vs[i]])rdfs(vs[i],k++);
  }
  return;
}

int main()
{
  int a,b,q;

  cin>>V>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    add_edge(a,b);
  }
 
  scc();
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>a>>b;
    if(cmp[a]==cmp[b])cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

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

using namespace std;

#define MAX 101
#define INF INT_MAX/4

int G[MAX][MAX], N;

int dijkstra(int a,int b){
  bool used[MAX];
  int cost[MAX];
  memset(used,false,sizeof(used));
  fill(cost, cost+N, INF);

  cost[a] = 0;
  while(true){
    int v = -1;
    for(int u = 0 ; u < N ; u++){
      if(!used[u] && (v == -1 || cost[u] < cost[v])){
        v = u;
      }
    }

    if(v == -1) break;
    used[v] = true;

    for(int u = 0 ; u < N ; u++){
      cost[u] = min(cost[u],cost[v]+G[v][u]);
    }
  }

  return cost[b];
}

int main(){
  int K, num, a, b, c;

  while(scanf("%d%d",&N,&K), (N | K)){
    fill(G[0], G[N], INF);

    while(K--){  
      scanf("%d",&num);
      if(num){
        cin >> a >> b >> c;
        a--, b--;
        if(G[a][b] > c){
          G[a][b] = G[b][a] = c;
        }
      }else{
        cin >> a >> b; a--, b--;
        int val = dijkstra(a,b);
        if(val != INF){
          printf("%d\n",val);
        }else{
          puts("-1");
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1272
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
print(ceil(N/2))


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000

template <typename T>
struct Dinic{
	struct edge{
		int to;
		T weight;
		int ind;
	};
	vector<vector<edge>> E;
	T inf;
	
	Dinic(vector<vector<pair<int,T>>> &e,T iv = 1000000001){
		inf = iv;
		E.resize(e.size(),vector<edge>());
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				edge t = {e[i][j].first,e[i][j].second,0};
				E[i].push_back(t);
			}
		}
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				E[i][j].ind = E[E[i][j].to].size();
				edge t = {i,0,j};
				E[E[i][j].to].push_back(t);
			}
		}
	}
	
	T maximum_flow(int s,int t){
		
		T ret = 0;
		
		while(true){
			vector<int> dis(E.size(),-1);
			queue<int> Q;
			Q.push(s);
			dis[s] = 0;
			while(Q.size()!=0){
				int u = Q.front();
				Q.pop();
				for(int i=0;i<E[u].size();i++){
					if(E[u][i].weight<=0)continue;
					int v = E[u][i].to;
					if(dis[v]!=-1)continue;
					dis[v] = dis[u]+1;
					Q.push(v);
				}
			}
			if(dis[t]==-1)break;
			
			vector<int> it(E.size(),0);
			
			while(true){
				T F = dfs(s,t,inf,it,dis);
				if(F==0)break;
				ret+=F;
			}
		}
		return ret;
	}
	
	T dfs(int now,int t,T f,vector<int> &it,vector<int> &dis){
		if(now==t)return f;
		
		for(int &i=it[now];i<E[now].size();i++){
			int to = E[now][i].to;
			T weight = E[now][i].weight;
			if(weight<=0||dis[now]+1!=dis[to]){
				continue;
			}
			T F = dfs(to,t,min(f,weight),it,dis);
			if(F!=0){
				E[now][i].weight-=F;
				E[E[now][i].to][E[now][i].ind].weight+=F;
				return F;
			}
		}
		return 0;
	}
	
};

int main(){

	int N;
	cin>>N;
	vector<long long> a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	
	vector<vector<pair<int,long long>>> E(3*N+2,vector<pair<int,long long>>());
	long long T = 1000000000;
	for(int i=0;i<3*N;i+=3){
		E[i].emplace_back(i+1,T);
		E[i+1].emplace_back(i+2,-a[i/3]+T);
		E[i+2].emplace_back(3*N+1,Inf);
		E[3*N].emplace_back(i,Inf);
	}
	
	for(int i=1;i<=N;i++){
		for(int j=i*2;j<=N;j+=i){
			E[3*(j-1)+1].emplace_back(3*(i-1)+1,Inf);
		}
	}
	
	Dinic<long long> D(E,Inf);
	//cout<<D.maximum_flow(3*N,3*N+1)<<endl;
	cout<<-(D.maximum_flow(3*N,3*N+1)-T*N)<<endl;
	
	return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/agc002/tasks/agc002_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll a, b;
    cin >> a >> b;
    if (a == 0 || b == 0 || (a < 0 && b > 0))
    {
        cout << "Zero" << endl;
        return 0;
    }

    if (a > 0)
    {
        cout << "Positive" << endl;
        return 0;
    }

    if (a < 0 && b < 0)
    {
        if ((b - a + 1) % 2 == 0)
        {
            cout << "Positive" << endl;
            return 0;
        }
        else
        {
            cout << "Negative" << endl;
            return 0;
        }
        
    }
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> bs[100005];
    rep(i, n){
        int a, b;
        cin >> a >> b;
        bs[a].emplace_back(b);
    }

    ll ans = 0;
    priority_queue<int, vector<int>> q;
    for (int i = 1; i <= m ; i++){
        rep(j, bs[i].size()){
            q.push(bs[i][j]);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 5632
N = int(input())

A = list(map(int,input().split()))
flag = True
for i in range(N):
  if A[i]%2 == 0:
    if A[i]%3 != 0 and A[i]%5 != 0:
      flag = False
if flag == True:
  print("APPROVED")
else:
  print("DENIED")


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

using namespace std;

void sort(int n, string* a){
   for(int i = 0; i < n; i++){
       for(int j = i+1; j < n; j++){
           if(a[i] > a[j]){
               string temp;
               temp = a[j];
               a[j] = a[i];
               a[i] = temp;
           }
       }
   }
   return;
}

int main(){
    int n;
    cin >> n;
    string a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    std::sort(a,a+n);
    int counter = 1;
    int temp_counter = 1;
    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]){
            temp_counter++;
            if(i == n-2 && temp_counter > counter){
                counter = temp_counter;
            }
        }
        else{
            if(temp_counter > counter){
                counter = temp_counter;
            }
            temp_counter = 1;    
        }
    }
    temp_counter = 1;
    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]){
            temp_counter++;
        }
        else{
            temp_counter = 1;
        }
        if(temp_counter == counter){
           cout << a[i] << endl;
        }
    }
    if(counter == 1){
        cout << a[n-1] << endl;
    } 
    return 0;
}

Measured memory_bytes: 14208
fun main(args:Array<String>) {
	val s= readLine()!!
	val k = readLine()!!.toInt()
	
	(0 until k).map {i ->
		(0 until s.length-i).map {j->
			s.substring(j..j+i)
		}
	}.flatten().distinct().sorted().let { println(it[k-1]) }
}

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

int main() {
  int cnt = 0, max = 0;
  string S;
  cin >> S;

  for(int i = 0; i < S.length(); i++) {
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      cnt++;
      for(int j = i+1; j < S.length(); j++) {
        if(S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') {
          cnt++;
        } else break;
      }
    } else continue;
    if(cnt > max) max = cnt;
    cnt = 0;
  }
  cout << max << endl;
}

Measured memory_bytes: 3628
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;


/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

#include <queue>
//https://cpprefjp.github.io/reference/queue/priority_queue/pop.html
//std::priority_queue<ll> que;
//que.push(val);
//ll getv = que.top();
//que.pop();
//typedef pair<ll,ll> P;  
//priority_queue<P,vector<P>, greater<P> > que;
//que.push(P(0,base_index));

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;

    map<ll,ll> count_map1;
    map<ll,ll> count_map2;


    rep(ni,N){
        cin >> ltmp;
        if(ni%2==0) count_map1[ltmp]++;
        else count_map2[ltmp]++;
    }

    typedef pair<ll,ll> P;  
    priority_queue<P,vector<P>, less<P> > que1;
    priority_queue<P,vector<P>, less<P> > que2;


    for(auto x : count_map1) {
        ll val = x.first;
        ll cnt = x.second;
        que1.push(P(cnt,val));
    }
    for(auto x : count_map2) {
        ll val = x.first;
        ll cnt = x.second;
        que2.push(P(cnt,val));
    }
    que1.push(P(0,1000001));
    que2.push(P(0,1000001));

    P top1 = que1.top();
    que1.pop();
    P top2 = que2.top();
    que2.pop();

    //cout << top1.second << endl;
    //cout << top2.second << endl;
    if( top1.second != top2.second){
        ll ans = N - top1.first - top2.first;
        cout << ans << endl;
    }else{
        P sec1 = que1.top();
        que1.pop();
        P sec2 = que2.top();
        que2.pop();

        ll ans1 = N - top1.first - sec2.first;
        ll ans2 = N - sec1.first - top2.first;
        
        ll ans = ans1;
        if(ans>ans2) ans = ans2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 11808
#include<stdio.h>
#define MAX 250

int main(){

  int i,H,A[MAX],n=0;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
    n++;
  }

  for(i=1;i<=H;i++){

    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1)printf("parent key = %d, ",A[i/2]);
    if(n>=i*2)printf("left key = %d, ",A[i*2]);
    if(n>=i*2+1)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
a=get_i

ans=0
(N-1).times do|i|
  if a[i]==i+1
      a[i],a[i+1]=a[i+1],a[i]
      ans+=1
  end
end
if a[N-1]==N
    ans+=1
end
puts ans

Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string S;
	cin >> S;
	bool ans = false;
	for(int i = 1; i < S.size(); i++)
		if(S[i - 1] == S[i]) ans = true;

	if(ans)
		cout << "Bad";
	else
		cout << "Good";
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int,input().split())
HW = [N, N]
ans = (N - 2) ** 2
L_HW = [[N - 2 for i in range(N)] for j in range(2)]
for _ in range(Q):
    vh, x = map(int,input().split())
    vh -= 1
    if x > HW[1 - vh]:
        ans -= L_HW[1 - vh][x]
    else:
        L_HW[1 - vh][x+1:HW[1 - vh]] = [HW[vh]-2] * (HW[1 - vh]-x-1)
        HW[1 - vh] = x
        ans -= HW[vh] - 2
print(ans)

Measured memory_bytes: 27588
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    int a,b,c,sum;
    cin>>a>>b>>c;

    if((a+b+c) >= 22){
        cout<<"bust";
    }
    else{
        cout<<"win";
    }
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cctype>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>

using Amida=std::vector<size_t>;

Amida append(const Amida &lhs, const Amida &rhs) {
  Amida res(lhs.size());
  std::iota(res.begin(), res.end(), 0);
  for (size_t i=0; i<res.size(); ++i)
    res[i] = rhs[lhs[i]];

  return res;
}

Amida repeat(const Amida &base, int times) {
  Amida res(base.size());
  std::iota(res.begin(), res.end(), 0);
  for (Amida dbl=base; times; times>>=1) {
    if (times & 1) res = append(res, dbl);
    dbl = append(dbl, dbl);
  }
  return res;
}

Amida parse(
    const std::string &s, size_t &i, const std::map<char, Amida> &expr,
    size_t preced=0) {

  if (preced == 1) {
    int times=1;
    if (isdigit(s[i])) {
      times = s[i]-'0';
      while (++i < s.length() && isdigit(s[i]))
        times = times*10+s[i]-'0';
    }
    if (isupper(s[i])) {
      Amida base=expr.at(s[i++]);
      return repeat(base, times);
    }
    if (s[i] == '(') {
      Amida base=parse(s, ++i, expr, 0);
      assert(s[i] == ')');
      ++i;
      return repeat(base, times);
    }
    assert(false);
  }

  Amida lhs=parse(s, i, expr, 1);
  while (i < s.length()) {
    char op=s[i];
    if (op != '+') break;
    Amida rhs=parse(s, ++i, expr, 1);
    lhs = append(lhs, rhs);
  }
  return lhs;
}

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::map<char, Amida> expr;
  for (size_t i=0; i<K; ++i) {
    char p;
    size_t h;
    scanf(" %c %zu", &p, &h);
    Amida g(N);
    std::iota(g.begin(), g.end(), 0);
    for (size_t r=1; r<h; ++r) {
      for (size_t c=1; c<N; ++c) {
        int f;
        scanf("%d", &f);
        if (f) std::swap(g[c-1], g[c]);
      }
    }
    Amida gg(N);
    for (size_t c=0; c<N; ++c)
      gg[g[c]] = c;

    expr[p] = gg;
  }

  size_t E;
  scanf("%zu", &E);
  for (size_t i=0; i<E; ++i) {
    char buf[1024];
    scanf("%s", buf);
    std::string s=buf;
    size_t j=0;
    Amida vla=parse(s, j, expr);
    Amida res(N);
    for (size_t k=0; k<N; ++k)
      res[vla[k]] = k;
    for (size_t k=0; k<N; ++k)
      printf("%zu%c", res[k]+1, k+1<N? ' ':'\n');
  }
}



Measured memory_bytes: 2908
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    vector<int> deg(4, 0);
    for (int i = 0; i < 3; ++i) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        deg[x]++;
        deg[y]++;
    }

    int cnt[] = {0, 0};
    for (int i = 0; i < 4; ++i) {
        if (deg[i] == 1) ++cnt[0];
        else if (deg[i] == 2) ++cnt[1];
    }

    if (cnt[0] == 2 && cnt[1] == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
void a()
{
  int a, b;
  cin >> a >> b;
  for(int i = 0; i < 16; i++)
  {
    if(i % 2 == 0)
    {
      a--;
    }else{
      b--;
    }
  }
  if(a <= 0 && b <= 0)
  {
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}
void b()
{
  int n, d;
  cin >> d >> n;
  if(d == 0)
  {
    if(n == 100)
    {
      cout << 101 << endl;
    }else{
      cout << n << endl;
    }
  }else if(d == 1)
  {
    if(n == 100)
    {
      cout << 10100 << endl;
    }else{
      cout << n * 100 << endl;
    }
  }else{
    if(n == 100)
    {
      cout << 1010000 << endl;
    }else{
      cout << n * 10000 << endl;
    }
  }
}
void c()
{
  int n;
  cin >> n;
  vector<long long int> a(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  long long int total = 0;
  for(auto e : a)
  {
    if(e % 2 != 0) continue;
    while (e % 2 == 0)
    {
      e /= 2;
      total++;
    }
  }
  cout << total << endl;
}

int main() {
  a();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A, B, C = input(), input(), input()

count = 0
for n in range(N):
	a, b, c = A[n], B[n], C[n]
	if a == b == c:
		continue
	if a == b or b == c or c == a:
		count += 1
		continue
	count += 2
print(count)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back 
#define mp make_pair
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535 

int main(){
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL); cout.tie(NULL);
 	double r; cin >> r;
 	cout << fixed; cout << setprecision(5);
 	cout << 2*r*PI << endl;
 	return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;
import java.util.HashSet;

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

        int N = scanner.nextInt();
        HashSet<Long> list = new HashSet<Long>();

        for(int i = 0; i < N; i++) {
            list.add(scanner.nextLong());
        }
        
        if(N == list.size()){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
	}
}

Measured memory_bytes: 71876
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<long long> a(n);
	for (long long& e : a) cin >> e;
	long long ans = 1000;
	for (int i = 1; i < n; ++i)
		if (a[i - 1] < a[i])
			ans = ans - ans / a[i - 1] * a[i - 1] + ans / a[i - 1] * a[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3544
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    h, n = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    print("Yes" if sum(a) >= h else "No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 52464
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
char buf[1 << 23], *ps = buf, *pt = buf;
#define getchar() (ps == pt && (pt = (ps = buf) + fread(buf, 1, 1 << 23, stdin), ps == pt) ? EOF : *ps++)
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
void print(int x, char ch = '\n'){
	if (x == 0) return putchar('0'), putchar(ch), void(0);
	int cnt = 0, num[25];
	for (x < 0 ? putchar('-'), x = -x : 0; x; x /= 10) num[++cnt] = x % 10;
	while (cnt) putchar(num[cnt] ^ '0'), --cnt;
	putchar(ch);
}
const int N = 105, M = 305, P = 1000000007;
int n, m, C[M][M];
char a[N];
void initC(int n){
	for (register int i = 0; i < n; ++i){
		C[i][0] = C[i][i] = 1;
		for (register int j = 1; j < i; ++j)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
	}
}
int cnt, pos[N], suf[N], f[N], dp[N][N], ans;
void DP(int s, int sr){ // 一共 s + sr 段，sr 段是单独的 R，s 段含有 B (B, BRB, BRBRB, ...)
	register int ts = s + sr, x = sr + ts - 1, y = 2 * s + 1, lim = n - x;
	if (lim < 0) return;
	for (register int i = 1; i <= m; ++i) suf[i] = 1;
	cnt = 0, *pos = 0;
	for (register int i = 1; i <= m; ++i) // 把能开的 rb 都先开掉（使得费用上界尽量大）
		if (a[i] == 'r' && cnt < s) ++cnt, suf[i] = 0;
		else if (a[i] == 'b' && *pos < cnt) pos[++*pos] = i, suf[i] = 0;
	if (*pos < s) return;
	cnt = 0;
	for (register int i = 1; i <= m; ++i) // 开完 rb 后从前往后拿 r 给单独的 R（使得费用上界尽量大）
		if (a[i] == 'r' && suf[i] && cnt < sr) ++cnt, suf[i] = 0;
	if (cnt < sr) return;
	suf[m + 1] = 0;
	for (register int i = m; i; --i) suf[i] += suf[i + 1];
	for (register int i = 1; i <= s; ++i) f[i] = suf[pos[s - i + 1]] + i * 2;
	// f[i] 费用前 i 小的段的费用之和上界（从后往前第 i 个 b 后面能用的位置数量）
	for (register int i = 0; i <= s; ++i)
		for (register int j = 0; j <= lim; ++j)
			dp[i][j] = 0;
	dp[0][0] = 1;
	for (register int i = 2; i <= ((lim + 3) >> 1); ++i) // 费用
		for (register int j = s - 1; ~j; --j) // 段数
			for (register int k = lim - 1; ~k; --k) // 每段长度之和
				if (dp[j][k])
					for (register int tj = j + 1, len = (i << 1) - 3, tk = k + len; tj <= s; ++tj, tk += len){
						if (tk > lim || (tk + tj * 3) / 2 > f[tj]) break;
						dp[tj][tk] = (dp[tj][tk] + 1ll * dp[j][k] * C[tj][j]) % P;
					}
	for (register int i = 0; i <= lim; ++i, ++x)
		if (dp[s][i]) ans = (ans + 1ll * C[ts][s] * C[n + y][x + y] % P * dp[s][i]) % P;
}
int main(){
	n = read(), m = read();
	for (register int i = 1; i <= m; ++i) while (!islower(a[i] = getchar())) ;
	initC(M);
	for (register int i = 0; i <= n; ++i)
		for (register int j = 0; j <= n - i; ++j)
			if (i == 0 && j == 0) ++ans;
			else DP(i, j);
	printf("%d\n", ans);
}


Measured memory_bytes: 512
n, l = [int(i)  for i in input().split()]
apple=[]
sub=[]
for i in range(1,n +1):
    apple.append(l + i -1)
    
for i in range(n):
    ap=apple.copy()
    ap[i]=0
    sub.append(sum(apple) - sum(ap))


a=list(map(abs, sub))
b=a.index(min(a))
apple.pop(b)
print(sum(apple))

Measured memory_bytes: 3064
n=int(input())
v=list(map(int,input().split()))
w=sorted(a for a in v[0::2])
x=sorted(a for a in v[1::2])
a=[[0,i]for i in range(10**5+1)]
b=[[0,i]for i in range(10**5+1)]
for t in w:
    a[t][0]+=1
for t in x:
    b[t][0]+=1
c=sorted(a)
d=sorted(b)
e=c[len(c)-1][0]
i=c[len(c)-1][1]
f=d[len(d)-1][0]
g=c[len(c)-1][0]
h=d[len(d)-1][0]
for t in range(len(c)):
    if i!=d[len(d)-1][1]:break
    e=c[len(c)-t-1][0]
    i=c[len(c)-t-1][1]
i=d[len(d)-1][1]
for t in range(len(d)):
    if i!=c[len(c)-1][1]:break
    g=d[len(d)-t-1][0]
    i=d[len(d)-t-1][1]
print(min(n-e-f,n-g-h))

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

int main(int argc, char *argv[]){
  map<char,long long> mp;
  mp['M']=0;
  mp['A']=0;
  mp['R']=0;
  mp['C']=0;
  mp['H']=0;
  int N;
  cin>>N;
  for(int i=0; i<N; i++){
    string s;
    cin>>s;
    if(s[0]=='M'||s[0]=='A'||s[0]=='R'||s[0]=='C'||s[0]=='H'){
      mp[s[0]]++;
     // cout<<mp[s[0]]<<endl;
    }
  }
   
  char c1[10]={'M','M','M','M','M','M','A','A','A','R'};
  char c2[10]={'A','A','A','R','R','C','R','R','C','C'};
  char c3[10]={'R','C','H','C','H','H','C','H','H','H'};
  long long sum=0;
  for(int i=0; i<10; i++){
    //cout<<mp[c1[i]]<<"*"<<mp[c2[i]]<<"*"<<mp[c3[i]]<<endl;
    sum+=mp[c1[i]]*mp[c2[i]]*mp[c3[i]];
  }
  cout<<sum<<endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define puts(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);


void solve(void){
	int N, M;
	cin >> N >> M;
	putln((N%M?N:-1));
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let cols = lines.shift().split(/\s/).map((v) => v - 0);
    let N = cols[0], M = cols[1], X = cols[2], Y = cols[3];
    let x = lines.shift().split(/\s/).map((v) => v - 0);
    let y = lines.shift().split(/\s/).map((v) => v - 0);
    let Xmax = Math.max(...x);
    let Xmin = Math.min(...x);
    let Ymax = Math.max(...y);
    let Ymin = Math.min(...y);
    const f = () => {
        if (X < Y) {
        if (Xmin < Y) {
        if (Xmax < Y) {
        if (X < Ymin) {
        if (X < Ymax) {
        if (Xmax < Ymin) {
            return true;
        } else return false;
        } else return false;
        } else return false;
        } else return false;
        } else return false;
        } else return false;
    }
    console.log(f() ? "No War" : "War");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{ 
  int a[200001],b[200001],c[200001],i,j,n,ans,rep;
  long long int k;
  cin>>n>>k;
  for(i=1;i<=n;i++){cin>>a[i];b[i]=0;c[i]=0;}
  ans=0;
  i=1;
  while(1)
  { 
    if(b[i]==0){b[i]=1;c[i]=ans;}
    else{rep=ans-c[i];break;}
    i=a[i];
    ans++;
    if(ans==k){cout<<i;return 0;}
  }
  k=k-c[i];
  k=k%rep;

  for(j=0;j<k;j++){i=a[i];}
  cout<<i;
  
  
  
}

Measured memory_bytes: 5952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		int count = 0;

		int seisuu = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}

		for (int i = 0; i < n -1; i++) {
			for (int j = i + 1; j < n; j++) {
				double dist = 0.0;
				for (int k = 0; k < d; k++) {
					double diff = (x[i][k] - x[j][k]);
					dist += Math.pow(diff, 2);
//					System.out.println(dist);
				}
				dist = Math.sqrt(dist);
//				System.out.println(dist);
				seisuu = (int)dist;
				if ((double)seisuu == dist) {
					count++;

				}
			}
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 22612
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var a, b, c int
	con.Scan(&a, &b, &c)
	if a+b == c || b+c == a || a+c == b {
		con.Println("Yes")
	} else {
		con.Println("No")
	}
	return nil
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back


using namespace std;
int N,M,A,B;
deque<int> deq;
int x,order;
int main(){
	cin >> N >> M >> A >> B;
	REP(i,N){
		cin >> x;
		deq.PB(x);
	}
	int orderA=-1;
	REP(i,N+1){
		if(i==N || deq[i]<A){
			order=i-1;
			break;
		}
	}
	if(N-(order+1)<M) 
		REP(i,N){
			if(deq[N-i-1]<=B){
				order=min(order,N-i-2);
			}
			else{
				break;
			}
		}
	cout << order+1 << endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
char s[1000005];
int main()
{
	scs(s+1);
	int maxx=0,cou=0;
	for(int i=1;i<=3;i++){
		if(s[i]=='R')cou++;
		else {
			maxx=max(maxx,cou);cou=0;
		}
	}maxx=max(maxx,cou);
	pf("%d\n",maxx);
}

Measured memory_bytes: 3820
#Pyramid
n=int(input())
data=[]
for i in range(n):
    X,Y,H=map(int,input().split())
    data.append([H,X,Y])
data.sort(reverse=True)
for i in range(101):
    for j in range(101):
        H=abs(data[0][1]-i)+abs(data[0][2]-j)+data[0][0]
        for k in range(1,n):
            if max(H-abs(data[k][1]-i)-abs(data[k][2]-j),0)==data[k][0]:
                continue
            else:
                break
        else:
            print(str(i)+" "+str(j)+" "+str(H))

Measured memory_bytes: 3188
unittest
{
	assert( [ "AtCoder Beginner Contest" ].parse.expand.solve == "ABC" );
	assert( [ "AtCoder Snuke Contest" ].parse.expand.solve == "ASC" );
	assert( [ "AtCoder X Contest" ].parse.expand.solve == "AXC" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	return "A" ~ s[ 8 ] ~ "C";
}


Measured memory_bytes: 256
N = gets.chomp.to_i
s = Hash.new(0)
N.times do |n|
  word = gets.chomp
  s[word] += 1
end
M = gets.chomp.to_i
M.times do |n|
  word = gets.chomp
  s[word] -= 1
end
max_amount = s.max{|a,b| a[1] <=> b[1]}[1]
max_amount > 0 ? print("#{max_amount}") : print("0")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	ll N;
	scanf("%lld", &N);
	ll size=pow(2,N);
	multiset<ll> a;
	rep(i, size) {
		ll t;
		scanf("%lld", &t);
		a.insert(t);
	}

	queue<ll> q;
	auto itr=max_element(a.begin(), a.end());
	q.push(*itr);
	q.push(-1);
	a.erase(itr);
	while(1){
		ll t=q.front();
		q.pop();
		debug(t);
		if(t==-1){
			if(a.size()==0){
				p("Yes");
				exit(0);
			}
			q.push(-1);
			continue;
		}
		auto itr=a.lower_bound(t);
		if(itr==a.begin()){
            p("No");
            exit(0);
        }
		itr--;
		q.push(t);
		q.push(*itr);
		debug(*itr);
		a.erase(itr);
	}

	return 0;
}


Measured memory_bytes: 13696
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int digit(int n){
   if(n < 10)  return n;
   return digit(n/10) + n%10;
}
int main(){
  int D,T,S;
  cin>>D>>T>>S;
  string SS="No";
  if(D<=T*S) SS="Yes";
  cout<<SS;
return 0;}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N,M;
vector<int> X;

int main(){
    cin >> N >> M;
    X.resize(N);
    rep(i,N) cin >> X[i];

    vi cnt(100005,0);
    rep(i,N) cnt[X[i]]++;
    vi modcnt(M+10,0);
    rep(i,N) modcnt[X[i]%M]++;

    int ans = 0;

    for(int i=0;i<M;i++){
        int j = (M - i)%M;
        if(i == j){
            ans += modcnt[i] / 2;
            modcnt[i] %= 2;
        }else{
            int a = min(modcnt[i],modcnt[j]);
            ans += a;
            modcnt[i] -= a;
            modcnt[j] -= a;
        }
    }

    for(ll i=0;i<M;i++){
        // check modcnt[i]
        for(ll j=0;i+j*M<=100000ll;j++){
            if(modcnt[i] <= 1) break;
            int a = min(modcnt[i],cnt[i+j*M])/2;
            ans += a;
            modcnt[i] -= a*2;
            cnt[i+j*M] -= a*2;
        }
    }
    cout << ans << endl;
}


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

int N, M, X, Y;
vector<int> x;
vector<int> y;

int main(){
  cin >> N >> M >> X >> Y;
  
  int val;
  for(int i = 0; i < N; i++){
    cin >> val;
    x.push_back(val);
  }

  for(int i = 0; i < M; i++){
    cin >> val;
    y.push_back(val);
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  for(int i = -100; i <= 100; i++){
    if(x[N-1] < i && i <= y[0] && X < i && i <= Y){
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
  return 0;
 
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int a = sc.nextInt();
		int L=a/100;
		int R=a%100;
		if(1<=L&&L<=12){
		if(1<=R&&R<=12) out.printf("AMBIGUOUS\n");
		else out.printf("MMYY\n");
		}else{
		if(1<=R&&R<=12)out.printf("YYMM\n");
		else out.printf("NA\n");
		}
		out.close();
	}
	
	
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int,int> pi;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  	int n;
  	cin >> n;
  	cout << !n;
}

Measured memory_bytes: 3632
#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>;

int main() {
  int n;
  cin >> n;
  ll a=1;
  ll b=1;
  ll c=1;
  ll d=1;
  ll M = 1000000007;
  ll res = 0;
  rep(i,n){
    a*=10;
    b*=9;
    c*=9;
    d*=8;
    a%=M;
    b%=M;
    c%=M;
    d%=M;
    res=(a-b-c+d+M+M)%M;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3440
N,K = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x10 = N
x2 = Base_10_to_n(x10, K)
print( len(str(x2)) )

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    string s; cin>>s;

    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 ==0)
        {
            //奇数かつL
            if (s[i]=='L')
            {
                cout<<"No"<<endl;
                return 0;
            }
            
        }
        else
        {
            if (s[i]=='R')
            {
                cout<<"No"<<endl;
                return 0;
            }
            
        }
        
    }
    
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp::*;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let token: String = std::io::stdin()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(non_snake_case)]
fn main() {
    let N: u32 = read();
    let mut K: usize = read();
    let S: String = read_line();
    let mut cnt1: Vec<u32> = Vec::new();
    let mut cnt0: Vec<u32> = Vec::new();
    let mut chars = S.chars();
    let mut tmp_b: bool = true;
    let mut tmp_cnt = 0u32;
    for c in chars {
        if c as u8 - 48 == tmp_b as u8 {
            tmp_cnt += 1;
        } else {
            if tmp_b {
                cnt1.push(tmp_cnt);
            } else {
                cnt0.push(tmp_cnt);
            }
            tmp_cnt = 1;
            tmp_b = !tmp_b;
        }
    }
    if tmp_b {
        cnt1.push(tmp_cnt);
    } else {
        cnt0.push(tmp_cnt);
    }
    if cnt1.len() == cnt0.len() {
        cnt1.push(0);
    }
    let mut acc1 = vec![0u32; cnt1.len()+1];
    let mut acc0 = vec![0u32; cnt0.len()+1];
    acc1[0] = 0;
    acc0[0] = 0;
    for i in 0..cnt1.len() {
        acc1[i+1] = acc1[i] + cnt1[i];
    }
    for i in 0..cnt0.len() {
        acc0[i+1] = acc0[i] + cnt0[i];
    }

    K = min(K, cnt0.len());
    let mut ans = 0u32;
    for i in 0..cnt0.len()-K+1 {
        ans = max(ans, acc1[i+K+1]-acc1[i]+acc0[i+K]-acc0[i]);
    }

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


Measured memory_bytes: 4352