akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define spc(x)              cout<<fixed<<setprecision((x));
#define deb(x)              cout<<#x<<" "<<x<<endl;
#define deba(x)             cout<<#x<<": "; for(auto u:x) cout<<u<<" ";  cout<<endl;
#define check               cout<<"hello"<<endl;
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.141592653589793;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    f(i,1,n+1){
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][W+1];


    f(i,0,n+1){
        f(j,0,W+1){
            if(i==0 || j==0){
                dp[i][j]=0;
                continue;
            }
            if(w[i]<=j){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }

    cout<<dp[n][W]<<endl;

    return 0;
}


Measured memory_bytes: 82464
n = int(input())
S = sorted(list(set(list(map(int, input().split())))))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for i in T:
    left = 0
    right = len(S) - 1
    while left < right:
        mid = (left + right) // 2
        #print(i, S[mid], S[left:right+1])
        if i == S[mid]:
            cnt += 1
            #print('found!')
            break
        elif i < S[mid]:
            if i < S[left]:
                break
            elif i == S[left]:
                cnt += 1
                break
            else:
                right = mid - 1
        else:
            if i > S[right]:
                break
            elif i == S[right]:
                cnt += 1
                break
            else:
                left = mid + 1
print(cnt)



Measured memory_bytes: 16708
n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
    print(' '.join(map(str, A)))
    temp = A[i]
    j = i - 1
    while A[j] > temp and j >= 0:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = temp
print(' '.join(map(str, A)))


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int H;
            int A;
            string input;
            int ans = 0;

            input = Console.ReadLine();
            H = int.Parse(input.Split(' ')[0]);
            A = int.Parse(input.Split(' ')[1]);

            while(H > 0)
            {
                H -= A;
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


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

struct TPond
{
	int DownPoint;
	int Surface;
};

void ConstructPond(stack<TPond> &PondRow, stack<int> &DownPointRow, int InputCount)
{
	TPond Pond;
	Pond.DownPoint = DownPointRow.top();
	Pond.Surface = InputCount - DownPointRow.top();
	//????????´???????±????????????§???????±????????????????????????°?±?list???????????????
	//????????´???????±????????????§???????±????????????????????????°????????´???????±???????????????????
	if(!PondRow.empty() && Pond.DownPoint < PondRow.top().DownPoint){
		while(!PondRow.empty() && Pond.DownPoint < PondRow.top().DownPoint){
			Pond.Surface += PondRow.top().Surface;
			PondRow.pop();
		}
	}
	PondRow.push(Pond);
	DownPointRow.pop();
	return;
}

void Output(stack<TPond> PondRow)
{
	stack<TPond> DummyPondRow;
	int Count = 0;
	//?????¢???????±???????
	int SumOfSurface = 0;
	while(!PondRow.empty()){
		SumOfSurface += PondRow.top().Surface;
		DummyPondRow.push(PondRow.top());
		PondRow.pop();
		Count += 1;
	}
	//?????¢?????¨??°???????????????
	cout << SumOfSurface << endl << Count << ' ';
	//?????????????????¢??????????????????
	for(int i = 0; i < Count-1; i++){
		cout << DummyPondRow.top().Surface << ' ';
		DummyPondRow.pop();
	}
	cout << DummyPondRow.top().Surface << endl;
	return;
}

int main()
{
	//?±?(????????????????????°??¨??¢???????????±?????????)????????????list???????????????
	stack<TPond> PondRow;
	//????????????????????°????????????stack???????????????
	stack<int>   DownPointRow;
	//????????????????????°???????????????????????????????????°???????????????
	int InputCount = 0;
	while(true){
		//??????????????????????????\???????????\?????????
		char Input;
		cin >> Input;
		if(cin.good() == false){
			break;
		}
		InputCount += 1;
		//???????????\???????????????DownPointRow???????????????
		if(Input == '\\'){
			DownPointRow.push(InputCount);
		}//???????????\????????????????????´?????????????????????????±?????§??????????
		if(Input == '/' && !DownPointRow.empty()){
			ConstructPond(PondRow, DownPointRow, InputCount);
		}
	}
	if(PondRow.empty()){
		cout << 0 << endl << 0 << endl;
	}else{
		Output(PondRow);
	}
	return 0;
}

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

using namespace std;

int main(){
  int w, h, n;
  cin >> w >> h >> n;

  vector<int> wa(w, 1);
  vector<int> ha(h, 1);

  int x, y, a;
  for(int i = 0;i < n;i++){
    cin >> x >> y >> a;
    switch(a){
      case 1:
        for(int j = 0;j < x;j++){
          wa[j] = 0;
        }
        break;
      case 2:
        for(int j = w - 1;j >= x;j--){
          wa[j] = 0;
        }
        break;
      case 3:
        for(int j = 0;j < y;j++){
          ha[j] = 0;
        }
        break;
      case 4:
      for(int j = h - 1;j >= y;j--){
        ha[j] = 0;
      }
      break;
    }
  }
  int answ = 0;
  int ansh = 0;
  for(int i : wa){
    if(i == 1)answ++;
  }
  for(int i : ha){
    if(i == 1)ansh++;
  }

  cout << answ * ansh << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] p = new int[n];
		int cnt = 0;
		for ( int i = 0; i < n; i++ ) {
			p[i] = in.nextInt();
		}

		for ( int i = 0; i < n; i++ ) {

			if ( 1 <= i && i <= n - 2 ) {
				if ( p[i - 1] < p[i] && p[i] < p[i + 1] ) {
					cnt++;
				} else if ( p[i - 1] > p[i] && p[i] > p[i + 1] ) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}
}

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

int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  vector<ll> b(n);
  rep(i,n) cin >> b.at(i);

  vector<ll> num;
  ll amari = 0;
  ll tarinai_cnt = 0;
  ll tarinai_sum = 0;
  rep(i,n){
    ll c = a.at(i) - b.at(i);
    if( c > 0 ){
      num.push_back(c);
      amari += c;
    }else if( c < 0 ){
      tarinai_cnt++;
      tarinai_sum -= c;
    }
  }
  if( amari < tarinai_sum ){
    cout << -1 << endl;
    return 0;
  }
  if( tarinai_cnt == 0 ){
    cout << 0 << endl;
    return 0;
  }
  sort(num.begin(),num.end());
  ll ans = tarinai_cnt;
  ll sum = 0;
  for(ll i=num.size()-1;i>=0;--i){
    sum += num.at(i);
    ++ans;
    if( sum > tarinai_sum ){
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 5384
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int table[][] = new int[N+2][N+2];
		for(int i=0;i<M;i++) {
			int ai = in.nextInt();
			int bi = in.nextInt();
			table[ai][bi] += 1;
			table[bi][ai] += 1;
		}

		for(int i=1;i<=N;i++) {
			int ans = 0;
			for(int j=1;j<=N;j++) {
				ans += table[i][j];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21844
// Abu Hurayra

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi; 
typedef pair<int, int> pi;
#define pi acos(-1.0)



int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	
	string s , t ;
	cin >> s >> t ;
	int ans = 0;
	for(int i = 0 ; i < s.length() ; i++ )
	{
		if(s[i]!=t[i]) ans ++;
	}
	cout << ans << endl;
	
	
	
	return 0;
}



Measured memory_bytes: 3856
#include <stdio.h>
int main(){
	
	int n;
	int uni[4][3][10]={0};
	int b, f, r, v;
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		scanf("%d", &b);
		scanf("%d", &f);
		scanf("%d", &r);
		scanf("%d", &v);
		
		uni[b-1][f-1][r-1] += v;
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				printf(" %d",uni[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3)
		printf("####################\n");
	}
  return 0;
}

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

int main(){
  int h,w,k;
  string S;
  cin>>S;
  
  if (S=="SUN") cout << 7 << endl;
  if (S=="MON") cout << 6 << endl;
  if (S=="TUE") cout << 5 << endl;
  if (S=="WED") cout << 4 << endl;
  if (S=="THU") cout << 3 << endl;
  if (S=="FRI") cout << 2 << endl;
  if (S=="SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define INF 1e9
#define SIZE 100000

typedef struct{
  char mark;
  int num;
}card;

/*マージソートを用いて安定かどうかを判断する*/

void QuickSort(card *,int,int);
void merge(card *,int,int,int);
void MergeSort(card *,int,int);
int Partition(card *,int,int);
void swap(card *,card *); 


int main(){
  int n,i,check=1;
  card A[SIZE],B[SIZE]; /*BはAと比較するための配列*/
  scanf("%d",&n);
  for(int i=0; i<n; i++){
    scanf(" %c%d",&A[i].mark,&A[i].num);
    B[i] = A[i];
  }
  
  QuickSort(A,0,n-1);
  MergeSort(B,0,n);

  /*比較をした結果安定でないならcheckを0にする*/
  for(i=0; i<n; i++){
    if(A[i].num != B[i].num || A[i].mark != B[i].mark){
      check = 0;
      break;
    }
  }

  if(check) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0; i<n; i++){
    printf("%c %d\n",A[i].mark,A[i].num);
  }

  return 0;
}



void QuickSort(card A[],int p,int r){
  if(p < r){
    int q = Partition(A,p,r);
    QuickSort(A,p,q-1);
    QuickSort(A,q+1,r);
  }
}

void merge(card B[],int left,int mid,int right){
   int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;
  
  card *l,*r;
  l = (card *)malloc((n1+2)*sizeof(card));
  r = (card *)malloc((n2+2)*sizeof(card));
  
  for(i=0; i<n1; i++) l[i] = B[left+i];
  for(i=0; i<n2; i++) r[i] = B[mid+i];
  l[n1].num = r[n2].num = INF;
  
  i=j=0;
  for(k=left; k<right; k++){
    if(l[i].num <= r[j].num){
      B[k] = l[i];
      i++;
    }else{
      B[k] = r[j];
      j++;
    }
  }
  
  free(l);
  free(r);
}

void MergeSort(card * B,int left,int right){
  int mid;
  
  if(left+1 < right ){
    mid = (left + right) / 2;
    MergeSort(B,left,mid);
    MergeSort(B,mid,right);
    merge(B,left,mid,right);
  }
  
}


int Partition(card A[],int p,int r){
  int x,i,j,tmp;
  x = A[r].num;
  i = p-1;
  for(j=p; j<=r-1; j++){
    if(A[j].num <= x){
      i++;
      swap(&A[i],&A[j]);
    }
  }

  swap(&A[i+1],&A[r]);

  return i+1;
}


void swap(card *a,card *b){
  card tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}



Measured memory_bytes: 3768
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;
vector<int>a,b,p;
int N;

int main(void){
  int i,j,k,t,tmp;
  int c,c2;
  a.clear(); b.clear(); p.clear();
  cin>>N;
  a.pb(-1); b.pb(-1); p.pb(-1);
  for(i=1;i<=N;i++){
    cin>>tmp;
    p.pb(tmp);
    a.pb(i*30000);
    b.pb((N-i+1)*30000);
  }

  for(i=1;i<=N;i++){
    b[p[i]]+=i;
  }

  for(i=1;i<=N;i++){
    cout<<a[i]<<" ";
  }
  cout<<endl;

  for(i=1;i<=N;i++){
    cout<<b[i]<<" ";
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 1152
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, a, b = sc.nextInt

  var sum = 0
  for(i <- 0 to n) {
    val s = i.toString.toList
    val tmp = s.map(_.asDigit).sum
    if(tmp >= a && tmp <= b) sum += i
  }
  println(sum)
}

Measured memory_bytes: 31888
#include <iostream>

using namespace std;

int W,E,N,rez = 1 << 30;
string S;

int main(){
    cin >> N;
    cin >> S;
    for(auto it:S){
        E += (it == 'E');
    }
    for(auto it:S){
        E -= (it == 'E');
        rez = min(rez,E + W);
        W += (it == 'W');
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    string a, b;
    cin >> a >> b ;
    //*/
    
    /*
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2) ;
    
    sort(a.begin(), a.end());
    */
    
    //*
    if( a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0) ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //*/
    
    //cout << b * 2 - a << endl;

    return 0; 
}


Measured memory_bytes: 3620
#include <cstdio>  
#include <iostream>  
#include <string.h>  
#include <string>   
#include <map>  
#include <queue>  
#include <deque>  
#include <vector>  
#include <set>  
#include <algorithm>  
#include <math.h>  
#include <cmath>  
#include <stack>  
#include <iomanip>  
#define mem0(a) memset(a,0,sizeof(a))  
#define meminf(a) memset(a,0x3f,sizeof(a))  
using namespace std;  
typedef long long ll;  
typedef long double ld;  
typedef double db;  
const int maxn=200005,inf=0x3f3f3f3f;    
const ll llinf=0x3f3f3f3f3f3f3f3f;     
const ld pi=acos(-1.0L);  
vector<int> v[maxn];  
  
int main() {  
    int n,m,i,j,l,r;  
    scanf("%d%d",&n,&m);  
    priority_queue<int,vector<int>,greater<int> > pq;  
    for (i=1;i<=n;i++) {  
        scanf("%d%d",&l,&r);  
        if (l==0) pq.push(r); else v[l].push_back(r);  
    }  
    for (i=1;i<=m+1;i++) {  
        sort(v[i].begin(),v[i].end());  
    }  
    int pos=-1;  
    for (i=1;i<=m;i++) 
    {     //枚举左界   
        if (v[i].size()>1) 
        {     //当前左界有多个人，则只坐右界最大的那个人   
            for (j=0;j<v[i].size()-1;j++) pq.push(v[i][j]);  
        } 
        else if (v[i].size()==0) 
        {   //当前左界无人  
            pos=max(pos,i);  
            while (!v[pos].size()&&pos<=m) pos++;  
            if (v[pos].size()) v[pos].pop_back();
            else if (!pq.empty())
                if (pq.top()<=i) pq.pop(); 
        }  
    }  
    int ans=pq.size();  
    printf("%d\n",ans);  
    return 0;  
}  

Measured memory_bytes: 8960
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for(int i=0;i<n;i++){
            int [] es = new int[3];
            for(int j=0;j<3;j++) es[j] = in.nextInt();
            Arrays.sort(es);
            if(sq(es[0]) + sq(es[1]) == sq(es[2])){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
    static int sq(int x){ return x*x; };

}

Measured memory_bytes: 23380
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
input = sys.stdin.readline
    
icase=0
if icase==0:
    n,m=map(int,input().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        ai,bi=map(int,input().split())
        a[i]=ai-1
        b[i]=bi-1

pair=[i for i in range(n)]

def root(x):
    if x==pair[x]:
        return x
    else:
        tmp=root(pair[x])
        pair[x]=tmp
        return tmp

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y:
        return
    elif x>y:
        pair[x]=y
    else:
        pair[y]=x

def q087():
    cc=[]
    c1=[1]*n
    c2=defaultdict(int)
    c2[1]=n
    c=n    
    for i in range(m-1):
        rta=root(a[m-i-1])
        rtb=root(b[m-i-1])
        if c1[rta]>=n or c1[rtb]>=n:
            cc.append(0)
            continue
        if rta<rtb:
            d2=c1[rta]
            d3=c1[rtb]
            c1[rta]+=c1[rtb]
            c1[rtb]=0
            d1=c1[rta]
            pair[rtb]=rta
#            unite(a[m-i-1],b[m-i-1])
        elif rta>rtb:
            d2=c1[rta]
            d3=c1[rtb]
            c1[rtb]+=c1[rta]
            c1[rta]=0
            d1=c1[rtb]
            pair[rta]=rtb
#            unite(a[m-i-1],b[m-i-1])
        else:
            cc.append(c)
            continue

        c2[d1]+=1    
        if c2[d2]>0:
            c2[d2]-=1
        if c2[d3]>0:
            c2[d3]-=1
        q=[]
        for c2k,c2v in c2.items():
            if c2v==0:
                q.append(c2k)
        while q:
            del c2[q.pop()]            
        c3=[]
        for c2k,c2v in c2.items():
            c3.append((c2k,c2k*c2v))

        c=0
        for i,c3i in enumerate(c3):
            c+=c3i[1]*(c3i[1]-c3i[0])//2
            for j,c3j in enumerate(c3[0:i]):
                c+=c3i[1]*c3j[1]
        cc.append(c)

    for i in range(m-2,-1,-1):
        print(cc[i])
    print(n*(n-1)//2)
#-------------------------------
q087()
#-------------------------------



Measured memory_bytes: 86592
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug(tail...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    map<string,int> list;
    FOR(i,N){
        string s=get_str();
        ++list[s];
    }
    GI(M);
    FOR(i,M){
        string s=get_str();
        --list[s];
    }
    int max_p=0;
    for(pair<string,int> p:list){
        if(max_p<p.second)max_p=p.second;
    }
    print(max_p);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    int cnt[50][26]={};
    rep(i,n){
        string s;
        cin>>s;
        for(int j=0;j<s.size();j++)cnt[i][s[j]-'a']++;
    }
    rep(i,26){
        int m=INF;
        rep(j,n){
            m=min(m,cnt[j][i]);
        }
        rep(j, m)cout<<(char)(i+'a');
    }
    cout<<endl;
    return 0;
}



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

using namespace std;
const int N = 2e5 + 1, MOD = 1e9 + 7;

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	int n, m;
	scanf("%d %d", &n, &m);
	if (abs(n - m) > 1) {
		printf("%d\n", 0);
		return 0;
	}
	long long f1 = 1, f2 = 1;
	for (int i = 1; i <= n; ++i) {
		f1 *= i;
		f1 %= MOD;
	}
	for (int i = 1; i <= m; ++i) {
		f2 *= i;
		f2 %= MOD;
	}
	long long result = (f1 * f2) % MOD;
	if (!abs(n - m)) {
		result *= 2;
		result %= MOD;
	}
	printf("%lld\n", result);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();

    ll ans = 0;
    for (int msk = 0; msk < 1 << (len-1); msk++) {

        ll num = S[0] - '0';
        for (int i = 0; i < len-1; i++) {
            if (msk & 1 << i) {
                ans += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        ans += num;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut dv = vec![0; n];
    for i in 0..n {
        dv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    dv.sort();
    dv.dedup();
    println!("{}", dv.len());
}


Measured memory_bytes: 4352
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <llong> vl;
typedef vector <string> vs;
typedef vector <vector <llong>> matrix;

typedef pair <llong, llong> pll;

typedef map <llong, llong> mll;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

llong n, m;

int main () {
    android;
    random_device rand;
    #ifdef I_LOVE_DILYA
        freopen ("input.txt", "r", stdin);
    #endif
    cin >> n >> m;
    cout << (1LL << m) * (m * 1900 + (n - m) * 100);
    return 0;
}

Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, H, W;
    cin >> N >> H >> W;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if (H <= a && W <= b) ans++;
    }

    cout << ans << endl;

}



























Measured memory_bytes: 256
def f(n):
    pp=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]#[i for i in sieve.primerange(11,1382) if i%5==1]
    pp=[str(pp[i]) for i in range(n)]
    return ' '.join(pp)
print(f(int(input())))

Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i64>();
    let (a, b, k) = (line[0], line[1], line[2]);
    let mut ans: Vec<i64> = vec![];

    for i in 0..k{
        ans.push(cmp::min(a+i, b));
        ans.push(cmp::max(b-i, a));
    }
    ans.sort();
    ans.dedup();
    for elem in ans{
        println!("{}", elem);
    }
}


Measured memory_bytes: 4352
n, x = map(int,input().split())
a = list(map(int,input().split()))

cnt = 0
for i in range(1,n):
    eat = a[i] + a[i-1] - x
    if eat > 0:
        cnt += eat
        if a[i] >= eat:
            a[i] -= eat
        else:
            a[i-1] -= (eat - a[i])
            a[i] = 0

print(cnt)

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

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int player1=1;
    while(A>0&&C>0){

        if(player1){
            C -= B;
            player1 = 0;
        }
        else{
            A -= D;
            player1 = 1;
        }
    }
    if(!player1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3596
import scala.math

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  def divisors(n: Int): List[Int] =
    for (i <- (1 to n).toList if n % i == 0) yield i

  var a , b = sc.nextInt()
  println(if(divisors(b).indexOf(a) != -1) a+b else  b-a)
}


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

int A, B, C, K;

main()
{
    cin >> A >> B >> C >> K;

    int max_num = max(A, max(B, C));

    int sum = max_num * pow(2, K);
    sum = sum - max_num + (A + B + C);

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

Measured memory_bytes: 256
n = int(input())
S = [1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [1,2,3,4,5,6,7,8,9,10,11,12,13]

for i in range(n):
    variations,number = input().split()
    if variations == 'S':
        S.remove(int(number))
    if variations == 'C':
        C.remove(int(number))
    if variations == 'H':
        H.remove(int(number))
    if variations == 'D':
        D.remove(int(number))

for i in range(len(S)):
    print('{} {}'.format('S',S[i]))

for i in range(len(H)):
    print('{} {}'.format('H',H[i]))

for i in range(len(C)):
    print('{} {}'.format('C',C[i]))

for i in range(len(D)):
    print('{} {}'.format('D',D[i]))




Measured memory_bytes: 5616
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include<queue>
#include<list>
#include<algorithm>

int main()
{
    int n,q,b,e,m;
    std::cin>>n;
    std::vector<int> S;

    for(int i = 0; i < n; i++)
    {
        int hoge;
        std::cin>>hoge;
        S.push_back(hoge);
    }

    S.erase(unique(S.begin(),S.end()),S.end());

    printf("%d",S[0]);
    for(int i = 1; i < S.size(); i++)
    {
        printf(" %d",S[i]);
    }
	printf("\n");

    return 0;
}



Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main(){
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    vector<vector<int> > color(H + 1, vector<int> (W + 1));
    P p = P(1, 1);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < a[i]; j++){
            color[p.first][p.second] = i + 1;
            if(p.first %2 == 1 && p.second != W) p.second++;
            else if(p.first %2 == 1 && p.second == W) p.first++;
            else if(p.first %2 == 0 && p.second != 1) p.second--;
            else if(p.first %2 == 0 && p.second == 1) p.first++;
        }
    }
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cout << color[i][j] << " ";
        }
        cout << endl;
    }
}

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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<int>a(n);

  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  int h=sum/n;
  int h1=h+1;
  int t1=0,t2=0;
  rep(i,n){
    t1+=(h-a[i])*(h-a[i]);
    t2+=(h1-a[i])*(h1-a[i]);
  }
  cout<<min(t1,t2);

}


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

using namespace std;

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

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	int n,k;cin>>n>>k;
	int ans = n-k+1;
	if(ans < 0) ans = 0;
	cout<<ans<<"\n";
}

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

#define ll long long

int main(){
  ll n,m;
  string s = "AC",c;
  cin >> n >> m;
  ll a = 0, A[n], p,B[n];
  for(ll i = 0; i<n; i++){
    A[i] = 0;
    B[i] = 0;
  }
  for(ll i = 0; i<m; i++){
    cin >> p;
    cin >> c;
    if(c == s)
        A[p-1] = 1;
    else{
      if(A[p-1] == 0)
        B[p-1]++;
    }
  }
  ll x = 0, y = 0;
  for(ll i = 0; i<n; i++){
      x += A[i];
      if(A[i] == 1)
        y += B[i];
  }
  cout<< x << " "<< y;
  return 0;
}

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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

template <typename T>
void add_self(T &a, T b)
{
	a += b;
	a %= mod;
}

void solve()
{
	int n;
	cin >> n;
	vector<vector<int>> can(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> can[i][j];
	vector<int> dp(1 << n);
	dp[0] = 1;
	for (int mask = 0; mask < (1 << n); ++mask)
	{
		int a = __builtin_popcount(mask);
		db(a, mask, 1 << n);
		for (int b = 0; b < n; ++b)
			if (a < n && can[a][b] && !(mask & (1 << b)))
				add_self(dp[mask | (1 << b)], dp[mask]);
	}
	cout << dp[(1 << n) - 1];
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 8448
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{   long long w,h,n,z,x,c,a,b,i,j,k,y,max1=0,max2=0,max3=0,max4=0;
    cin>>w>>h>>n;
    z=w;c=h;
    for(i=0;i<n;i++){
        cin>>x>>y>>a;
        if(a==1&&x>max1){z-=(x-max1);max1=(max1>x)?max1:x;}
        else if(a==2&&(w-x)>max2){z-=(w-x-max2);max2=(max2>(w-x))?max2:(w-x);}
        else if(a==3&&y>max3){c-=(y-max3);max3=(max3>y)?max3:y;}
        else if(a==4&&(h-y)>max4){c-=(h-y-max4);max4=(max4>(h-y))?max4:(h-y);}
    }
    if(z>0&&c>0){cout<<z*c;}
    else{cout<<0;}

    return 0;
}


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

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

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

   if (A + B <= 2 * C) ans = A * X + B * Y;
   else if (X <= Y) {
     if (2 * C <= B) ans = Y * 2 * C;
     else ans = X * 2 * C + (Y - X) * B;
   }
   else if (2 * C <= A) ans = Y * 2 * C;
   else ans = Y * 2 * C + (X - Y) * A;

   cout << ans << endl;
 }


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(){
  int N = 0, K = 0, A = 0, d = 0, sunuke[101] = { 0 }, ans = 0;
  scanf("%d", &N);
  scanf("%d", &K);
  ans = N;
  for (int i = 0; i < K; i++) {
    scanf("%d", &d);
    for (int k = 0; k < d; k++) {
      scanf("%d", &A);
      if (sunuke[A] == 0) {
        ans--;
        sunuke[A] = 1;
      }
    }
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1728
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();

   int N = a.length;
   int start = 0;
   int end = a.length;
   for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   }
   for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   }
    System.out.println(end-start+1);
 }
}

Measured memory_bytes: 26416
#include <iostream>
#include <cmath>

using namespace std;
int h, w;

int getDiff(int w, int h) {
  int wd = round(w / 3.);
  int hd = round(h / 2.);
  int rect1 = wd * h;
  int rect2 = (w - wd) * hd;
  int rect3 = (w - wd) * (h - hd);
  int tmp =  max(rect1, max(rect2, rect3)) - min(rect1, min(rect2, rect3));
  return min(tmp, abs(h * (w - wd * 2) - h * wd));
}

void solve() {
  if (h % 3 ==0 || w % 3 ==0) {
    cout << 0 << endl;
    return;
  }
  cout << min(getDiff(w, h), getDiff(h, w)) << endl;
}

int main() {
  cin >> h >> w;
  solve();
}


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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N, X;
    cin >> N >> X;

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

    int count = 1;
    int acc = 0;
    for (int i = 0; i < N; i++) {
        acc += L[i];
        if (acc > X) {
            break;
        }
        count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}


vector<vector<pair<int, int>>> V;
vector<int> res;

void dfs(int t, int c, int p) {
    res[t] = c;
    for (auto x: V[t]) {
        if (x.first == p) continue;
        if (x.second%2 == 0) dfs(x.first, c, t);
        else dfs(x.first, 1-c, t);
    } 
}


int main() {
    int N; cin >> N;
    V.assign(N+1, vector<pair<int, int>>());
    res.assign(N+1, -1);
    for (int i = 0; i < N-1; ++i) { 
        int u, v;  cin >> u >> v;
        ll w; cin >> w;
        V[u].push_back(make_pair(v, w));
        V[v].push_back(make_pair(u, w));
    }
    for (int i = 0; i <= N; ++i) res[i] = -1;
    
    dfs(1, 1, -1);

    for (int i = 1; i <= N; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 8960
#include <stdio.h>

int main() {
	int S, h, m, s;
	scanf("%d", &S);
	h = (S/3600); 
	m = (S -(3600*h))/60;
	s = (S -(3600*h)-(m*60));
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}


Measured memory_bytes: 2076
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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 cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
SS(string,s);
YES(regex_match(s,regex(".*keyence|k.*eyence|ke.*yence|key.*ence|keye.*nce|keyen.*ce|keyenc.*e|keyence.*")));
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define rep(i, N) for (i=0;i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;


int main() {
	int64_t N;

	cin >> N;

	if (N%2) cout << 2*N << endl;
	else cout << N << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;
const int MOD=1e9+7;

int main(){
	int H,W;
	cin>>H>>W;
	int c[26];
	rep(i,26)c[i]=0;
	rep(i,H*W){
		char x;
		cin>>x;
		int a=x-'a';
		c[a]++;
	}
	bool ok=true;
	if(H%2==0&&W%2==0){
		rep(i,26)if(c[i]%4!=0)ok=false;
	}
	else if(H%2==0||W%2==0){
		rep(i,26)if(c[i]%2!=0)ok=false;
		rep(i,26)c[i]/=2;
		int p;
		if(H%2!=0)p=W/2;
		else p=H/2;
		int ct=0;
		rep(i,26)if(c[i]%2!=0)ct++;
		if(ct>p)ok=false;
	}
	else {
		int p=H/2+W/2;
		int ct=0;
		rep(i,26){
			if(c[i]%2==0)c[i]/=2;
			else{
				ct++;
				c[i]/=2;
			}
		}
		if(ct>1)ok=false;
		ct=0;
		rep(i,26)if(c[i]%2!=0)ct++;
		if(ct>p)ok=false;
	}
	if(ok)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	var o int
	arr := scanArrayInt()
	n, a, b := arr[0], arr[1], arr[2]
	for i := 1; i <= n; i++ {
		t, d := 0, i
		for {
			t, d = t+d%10, d/10
			if d == 0 {
				break
			}
		}
		if a <= t && t <= b {
			o += i
		}
	}
	fmt.Println(o)
}

func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 2000000
#define MOD 1000000007
#define INF 10000000000000000

int main(){
  string K;
  int D;
  cin>>K>>D;
  int N=K.size();
  vector<int> a(N);
  for(int i=0;i<N;i++){
    a.at(i)=K.at(i)-'0';
  }

  vector<vector<vector<ll>>> dp(N,vector<vector<ll>>(2,vector<ll>(D,0)));
  for(int i=0;i<a.at(0);i++){
    dp.at(0).at(1).at(i%D)+=1;
  }
  dp.at(0).at(0).at(a.at(0)%D)+=1;
  for(int i=1;i<N;i++){
    for(int j=0;j<D;j++){
      for(int k=0;k<10;k++){
        dp.at(i).at(1).at((j+k)%D)+=dp.at(i-1).at(1).at(j);
      }
      for(int k=0;k<a.at(i);k++){
        dp.at(i).at(1).at((j+k)%D)+=dp.at(i-1).at(0).at(j);
      }
      dp.at(i).at(0).at((j+a.at(i))%D)+=dp.at(i-1).at(0).at(j);
    }
    for(int j=0;j<D;j++){
      dp.at(i).at(1).at(j)%=MOD;
    }
  }

  cout<<(dp.at(N-1).at(0).at(0)+dp.at(N-1).at(1).at(0)-1+MOD)%MOD<<endl;

}


Measured memory_bytes: 17152
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, Y = il()
    ret = 0
    while True:
        X *= 2
        ret += 1
        if X > Y: break

    print(ret)


if __name__ == '__main__':
    main()


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

int main()
{
    long long T[2], A[2], B[2];

    cin >> T[1] >> T[2] >> A[1] >> A[2] >> B[1] >> B[2];

    if (A[1] < B[1])
    {
        swap(A[1], B[1]);
        swap(A[2], B[2]);
    }

    long long C[2], D[2];

    C[1] = A[1] - B[1];
    C[2] = A[2] - B[2];

    D[1] = T[1] * C[1];
    D[2] = T[2] * C[2];

    if (D[1] + D[2] > 0)
    {
        cout << 0 << endl;
        exit(0);
    }

    else if (D[1] + D[2] == 0)
    {
        cout << "infinity" << endl;
        exit(0);
    }

    if (D[1] % (abs(D[2]) - D[1]) != 0)
    {
        cout << (D[1] / (abs(D[2]) - D[1])) * 2 + 1 << endl;
    }

    else
    {
        cout << (D[1] / (abs(D[2]) - D[1])) * 2 << endl;
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int k,modk=0;
	cin >> k;
	set<int>s;
	modk = 7 % k;
	s.insert(modk);
	rep(i, k) {
		if (modk == 0) {
			cout << s.size() << endl;
			return 0;
		}
		modk = (modk * 10 + 7) % k;
		s.insert(modk);
	}
	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 50340
#include <bits/stdc++.h>
#define For(i, j, k) for (int i = j; i <= k; ++i)
#define Forr(i, j, k) for (int i = j; i >= k; --i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
}

const int N = 4e2 + 10, M = 1e5 + 10;
int n, m, s[M], t[M], f[N];
bitset<N> a[N];

inline bool F(int u) {
	a[u][u] = 1;
	Forr(i, m, 1) {
		int x = s[i], y = t[i];
		if (a[u][x] && a[u][y]) return 0;	
		if (a[u][x] || a[u][y]) a[u][x] = a[u][y] = 1;
	}
	return 1;
}

int main() {

	n = read(), m = read();
	For(i, 1, m) s[i] = read(), t[i] = read();

	For(i, 1, n) f[i] = F(i);

	int ans = 0;
	For(i, 1, n) if (f[i]) For(j, i + 1, n) if (f[j])
		ans += (a[i] & a[j]).none();

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


Measured memory_bytes: 1024