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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
int nxt[200][2];
string s[200];
vector<string> ss[200];
double sim[200];
int mem[200][200];

void predfs(int v){
  int l=nxt[v][0],r=nxt[v][1];
  if(l==-1){
    s[v]="()";
    ss[v].push_back(s[v]);
    sim[v]=0;
    return ;
  }
  assert(r!=-1);
  predfs(l); predfs(r);

  int cnt=0;
  rep(i,ss[l].size()){
    bool ok=false;
    rep(j,ss[r].size()){
      if(ss[l][i]==ss[r][j])ok=true;
    }
    if(ok)cnt++;
  }

  s[v]="("+min(s[l],s[r])+max(s[l],s[r])+")";
  rep(i,ss[l].size())ss[v].push_back(ss[l][i]);
  rep(i,ss[r].size())ss[v].push_back(ss[r][i]);
  ss[v].push_back(s[v]);
  sort(all(ss[v]));
  uni(ss[v]);
  sim[v]=(double)cnt/(double)(ss[v].size()-1);
}

int cmp(int x,int y){ // x > y : 1, x == y : 0, x < y : -1
  if(mem[x][y]!=-2)return mem[x][y];
  int& a=mem[x][y];
  if(sim[x]!=sim[y]){
    if(sim[x]<sim[y])return a=1;
    else return a=-1;
  }
  if(nxt[x][0]==-1&&nxt[y][0]==-1)return a=0;
  int lx=nxt[x][0],rx=nxt[x][1];
  int ly=nxt[y][0],ry=nxt[y][1];
  assert(lx!=-1); assert(rx!=-1); assert(ly!=-1); assert(ry!=-1);
  if(cmp(lx,rx)==-1)swap(lx,rx);
  if(cmp(ly,ry)==-1)swap(ly,ry);
  if(cmp(lx,ly)!=0)return a=cmp(lx,ly);
  else return a=cmp(rx,ry);
}

void dfs(int v,bool isl){
  int l=nxt[v][0],r=nxt[v][1];
  if(l==-1)return ;
  int c=cmp(l,r);
  if((isl&&c==-1)||(!isl&&c==1)){
    swap(nxt[v][0],nxt[v][1]);
  }
  dfs(nxt[v][0],true);
  dfs(nxt[v][1],false);
}

void show(int v){
  int l=nxt[v][0],r=nxt[v][1];
  if(l==-1){
    cout<<"x"; return ;
  }
  cout<<"(";
  show(l);
  cout<<" ";
  show(r);
  cout<<")";
}

int main(){
  while(1){
    string input;
    cin>>input;
    if(input=="0")break;
    N=0;
    stack<P> st;
    memset(nxt,-1,sizeof(nxt));
    while(1){
      rep(i,input.size()){
        if(input[i]=='('){
          if(st.size()>0){
            nxt[st.top().fi][st.top().se]=++N;
            st.top().se++;
          }
          st.push(P(N,0));
        }
        if(input[i]=='x'){
          if(st.size()>0){
            nxt[st.top().fi][st.top().se]=++N;
            st.top().se++;
          }
        }
        if(input[i]==')'){
          st.pop();
        }
      }
      if((int)st.size()==0)break;
      cin>>input;
    }

    N++;
    rep(i,N)sim[i]=0.0;
    rep(i,N)ss[i].clear();
    predfs(0);
    rep(i,N)rep(j,N)mem[i][j]=-2;
    dfs(0,true);
    show(0);
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3272
# include <bits/stdc++.h>
# define int long long
using namespace std;
const int MAXN=2e5+10;
struct rec{ int pre,to,w;}a[2*MAXN];
int d[MAXN],head[MAXN],ans;
int n,m,tot=0,INF;
bool inq[MAXN],vis[MAXN];
void adde(int u,int v,int w)
{
	a[++tot].pre=head[u];
	a[tot].to=v;
	a[tot].w=w;
	head[u]=tot;
}
bool spfa(int s)
{
	vis[s]=true;
	memset(inq,false,sizeof(inq));
	queue<int>q; q.push(s); d[s]=0;inq[s]=true;
	int curmax,curmin; curmax=curmin=0;
	while (!q.empty()){
		int u=q.front();q.pop();
		for (int i=head[u];i;i=a[i].pre) {
			int v=a[i].to;
			if (d[v]==INF) {
				d[v]=d[u]+a[i].w;
				curmax=max(curmax,d[v]);
				curmin=min(curmin,d[v]);
				ans=max(curmax-curmin,ans);
				vis[v]=true;
				if (inq[v]==false) q.push(v);
			}else {
				if (d[v]!=d[u]+a[i].w) return false;
			}
		}
	}
	return true;
}
signed main()
{
//	freopen("line.in","r",stdin);
//	freopen("line.out","w",stdout);
	memset(d,0x3f,sizeof(d)); INF=d[0];
	cin>>n>>m;
	int u,v,w;
	while (m--) {
		cin>>u>>v>>w;
		adde(u,v,w);
		adde(v,u,-w);
	}
	memset(vis,false,sizeof(vis));
	ans=0;
	for (int i=1;i<=n;i++)
	 if (vis[i]==false&&spfa(i)==false)
	  {
	  	printf("No\n");
	  	return 0;
	  }
	 cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 13184
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // printTestValue();
    // abc170_d();
    abc169_b();

  }

  public static void abc169_b() {
    try (Scanner sc = new Scanner(System.in)) {
      int size = Integer.parseInt(sc.next());
      long ans = 1L;
      List<Long> list = new ArrayList<Long>();

      for (int xx = 0; xx < size; xx++) {
        list.add(Long.parseLong(sc.next()));
      }
      Collections.sort(list);
      if (list.get(0) == 0L) {
        System.out.println(0);
        return;
      }
      Collections.reverse(list);
      for (int yy = 0; yy < size; yy++) {
        if (BigInteger.valueOf(ans).multiply(BigInteger.valueOf(list.get(yy)))
          .compareTo(BigInteger.valueOf((long) Math.pow(10d, 18d))) == 1) {
          System.out.println(-1);
          return;
        }
        ans *= list.get(yy);
      }
      System.out.println(ans);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }
}

Measured memory_bytes: 62412
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n==1){
	
	
	    cout<<"Hello World\n";
        exit(0);
	}
	if(n==2)
	{
		int x,y;
		cin>>x>>y;
		cout<<x+y;
		
	}return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
	public class Main
		{ public static void main(String[] args)
			{   
			    Scanner scanner = new Scanner(System.in);
			    int x = scanner.nextInt();
			    int y = scanner.nextInt();
			    int a[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
			    
			    if (a[x] == a[y]) {
			        System.out.println("Yes");
			    } else {
			        System.out.println("No");
			    }
				
				}
			}		
					

Measured memory_bytes: 22100
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <iostream> 
using namespace std;
struct node
{
	int x,y;
}a[200010];
int ednum[100010];
int flag[100010];
unsigned long long dis[100010];
bool cmp(const node &a,const node &b)
{
	if(a.x==b.x) return a.y<b.y;
	return a.x<b.x;
}
unsigned long long dfs(long long x)
{
	long long j;
	unsigned long long ans=0,num=0;
	for(j=ednum[x-1];j<ednum[x];j++)
	if(flag[a[j].y]==0)
	{
		flag[a[j].y]=1;
		num=num+1;
		ans=ans+dfs(a[j].y);
		flag[a[j].y]=0;
	}
	dis[x]=num+ans*100003;
	return dis[x];
} 
int main()
{
	long long i,j,n,len,x,num,ans;
	while(~scanf("%lld",&n))
	{
		memset(ednum,0,sizeof(ednum));
		for(i=0;i<n-1;i++) 
		{
			scanf("%d%d",&a[i].x,&a[i].y);
			a[i+n-1].x=a[i].y;
			a[i+n-1].y=a[i].x;
			ednum[a[i].x]++; ednum[a[i].y]++;
		}
		for(i=1;i<=n;i++) ednum[i]+=ednum[i-1];
		sort(a,a+2*n-2,cmp);
		memset(dis,0,sizeof(dis));
		memset(flag,0,sizeof(flag));
		flag[1]=1;
		dfs(1);
		sort(dis,dis+n);
		ans=0;
		for(i=1,num=1;i<n;i++)
		{
			if(dis[i]==dis[i-1]) num++;
			else
			{
				ans=ans+(num-1)*num/2;
				num=1;
			}
		}
		ans=ans+(num-1)*num/2;
/*		for(i=1;i<=n;i++)
		{
			printf("i:%lld dis:%llu\n",i,dis[i]);
		}*/
		printf("%lld\n",ans);
	}
	return 0;
} 

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

using namespace std;

int main(){
    int n;
    string ans = "No";

    cin >> n;

    for(int i = 0;i < (n/4)+1;i++){
        for(int j = 0;j < (n/7)+1;j++)
            if(i*4+j*7 == n) ans = "Yes";
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
candidates = []
for i, _ in enumerate(A):
    add_num = 0
    for a in A[i:]:
        add_num += a
        candidates.append(add_num)

ans = 0
for i in range(40, -1, -1):
    k_candidates = []
    for candidate in candidates:
        if candidate & (1 << i):
            k_candidates.append(candidate)
    if len(k_candidates) >= K:
        ans += 1 << i
        candidates = k_candidates
print(ans)

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

int func(int n) {
  if (n % 2 == 0) {
    return n / 2;
  } else {
    return 3 * n + 1;
  }
}

int main() {
  int s;
  cin >> s;
  map<int, int> cmap;
  cmap[s] = 1;

  int count = 1;
  while(true) {
    count += 1;
    s = func(s);
    if (cmap.find(s) != cmap.end()) {
      cout << count << endl;
      break;
    } else {
      cmap[s] = 1;
    }
  }
  return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a==b)cout<<"Draw"<<endl;
  else if(a==1)cout<<"Alice"<<endl;
  else if(b==1)cout<<"Bob"<<endl;
  else if(a>b)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
from collections import deque,defaultdict
n=int(input())
es=[[] for i in range(n)]
es2=[]
for i in range(n-1):
    a,b=map(int,input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)
    es2.append((a-1,b-1))
k=0
col=[1]+[0]*(n-1)

a=defaultdict()
par= [0]*n
total = 0
q = deque()
q.append(0)

while q:
    c = 1
    p = q.popleft()
    for i in es[p]:
        if col[i] == 0:
            col[i] = 1
            if c == par[p]:
                c += 1
            a[(p,i)] = c
            par[i] = c
            c += 1
            q.append(i)
    total = max(total,c-1)

print(total)
for pair in es2:
    print(a[pair])

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

int main()
{
    bool used[101];
    int ans = 0;
    memset(used,0,sizeof(used));
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for (int i = a;i<b;i++)used[i] = true;
    for (int i= c;i<d;i++)
    	if (used[i])ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	string s1, s3, s2;
	cin>>s1>>s2;
	int a, b;
	cin>>a>>b;
	cin>>s3;
	if(!s3.compare(s1))
	{
	    a--;
	}
	else
	{
	    b--;
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register
#define ll long long
#define in inline
#define get getchar()
in int read()
{
	int t=0, x=1; char ch=get;
	while ((ch<'0' || ch>'9') && ch!='-') ch=get;
	if (ch=='-') ch=get, x=-1;
	while (ch<='9' && ch>='0') t=t*10+ch-'0', ch=get;
	return t*x;
}
const int _=311;
vector< pair< int,int> > v[_];
ll n,m,f[_][_][_];
#define mod 1000000007
int main()
{
	n=read(), m=read();
	for ( re int i=1; i<=m; i++)
	{
		int l=read(), r=read(), x=read();
		v[r].push_back( make_pair(l,x) );
	}
	f[1][0][0]=1;
	for ( re int i=1; i<=n; i++)
	{
		for ( re int q=0, sz=v[i].size(); q<sz; q++)
		{
			int l=v[i][q].first, x=v[i][q].second;
			for ( re int j=0; j<i; j++)
				for ( re int k=0; k<=(j-(j>0)); k++)
				{
					if (x==1)
					{
						if (j>=l) f[i][j][k]=0;
						continue;
					}
					else if (x==2)
					{
						if ( k>=l || l>j ) f[i][j][k]=0;
						continue;
					}
					else
					{
						if ( l>k ) f[i][j][k]=0;
						continue;
					}
				}
		}
		if(i==n)break;
		for ( re int j=0; j<i; j++ )
			for ( re int k=0; k<=(j-(j>0)); k++)
			{
				if(f[i][j][k])
				{
					f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod;
					f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%mod;
					f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%mod;
				}
			}
	}
	ll ans=0;
	for ( re int i=0; i<n; i++ )
		for ( re int j=0; j<=(i-(i>0)); j++)
			ans=(ans+f[n][i][j])%mod;
	cout<<ans*3%mod<<endl;
}


Measured memory_bytes: 227584
#include<stdio.h>

int main(){
	int a[3],i,j;
	
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				int temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d",a[i]);
		if(i <2){
			printf(" ");
		}else{
				printf("\n");
		}
	}
	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;
const ll MOD=1e9+7;


int main(){
int k,cnt;
  cnt=0;
vector<int> v(5);
  REP(i,5){
  cin>>v[i];
  }
  cin>>k;
  REP(i,4){
  if(v[i+1]-v[i]<=k)cnt++;
  }
  REP(i,3){
  if(v[i+2]-v[i]<=k)cnt++;
  }
  REP(i,2){
  if(v[i+3]-v[i]<=k)cnt++;
  }
  if(v[4]-v[0]<=k)cnt++;
  if(cnt==10)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main
{

  final static int[] WEIGHT =
  { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final int num = Integer.parseInt(input.readLine());

      System.out.println(solver(num));
    }

  }


  private static String solver(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    List<String> stringList = new ArrayList<>();

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        stringList.add(String.valueOf(WEIGHT[count]));
      }
      count++;
    }
    return String.join(" ", stringList);
  }
}

Measured memory_bytes: 24244
#include<iostream>
#include<string>
#include<cstring>
#include<stack>
using namespace std;

main(){
  long long n;
  stack<int> k;
  while(cin >> n,n){
    int c,f;
    if(n<0){
      c=1;
      n=n*(-1);
    }
    else {
      c=0;
    }
    while(n){
      if(c%2){
	if(n%10){
	  k.push(10-n%10);
	  n=n/10+1;
	}
	else {
	  k.push(0);
	  n=n/10;
	}
      }
	else{
	  k.push(n%10);
	  n=n/10;
	}
      c++;
    }
    while(!k.empty()){
      cout << k.top();
      k.pop();
    }
    cout << endl;
  }
}

Measured memory_bytes: 1196
while True:
    m,f,r = map(int,input().split())
    ret = 'F'
    if m==f==r==-1: break
    elif -1 in (m,f): pass
    elif m + f >= 80: ret = 'A'
    elif m + f  >= 65: ret = 'B'
    elif m + f  >= 50: ret = 'C'
    elif m + f  >= 30: 
        ret = 'D'
        if r >= 50:ret = 'C'
    print(ret)

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1){
    int n,m;
    vector<vector<int>> a(1000);
    cin >> n;
    if(!n) break;
    for (int i = 0; i < n; ++i) {
      int h,r;
      cin >> h >> r;
      a[h].emplace_back(r);
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      int h,r;
      cin >> h >> r;
      a[h].emplace_back(r);
    }
    vector<vector<int>> dp(1000,vector<int>(1000));
    for (int i = 1; i < 1000; ++i) {
      for (int j = 0; j < 1000; ++j) {
        dp[i][j] = dp[i-1][j];
        for (int r : a[i]) {
          if (r > j) continue;
          dp[i][j] = max(dp[i][j],dp[i-1][r-1]+1);
        }
      }
    }
    cout << dp[999][999] << endl;
  }
  return 0;
}

Measured memory_bytes: 5052
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n,k;
	cin >> n >> k;

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

	if(( n-1 ) % ( k-1 ) >0){
		cout << ( n-1 ) / ( k-1 )+1 <<endl;
	}
	else{
		cout << ( n-1 ) / ( k-1 ) <<endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................

vector<ll>vec[200005];

int main()
{
    fast
    
    ll n,m,i;
    cin>>n;
    ll a[n+1];
    for(i=1;i<n;i++)
    {
        cin>>a[i];
        vec[a[i]].pb(i);
    }
    for(i=1;i<=n;i++)
    cout<<vec[i].size()<<"\n";
    
    
    
    return 0;
}

Measured memory_bytes: 16084
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int[] mountains = new int[10];
        int i = 0;
        while(true){
            String s = r.readLine();
            mountains[i++] = Integer.valueOf(s);
            if(i >= 10) break;
        }
        Arrays.sort(mountains);
        for(i = 9; i > 6; i--) {
            System.out.println(mountains[i]);
        }
	}
}

Measured memory_bytes: 24460
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    int answer = 0;
    int[][] vertexes = new int[n][];
    for(int i = 0; i < n; i++)
    {
      int cc = int.Parse(Console.ReadLine());
      vertexes[i] = new int[cc*2];
      for(int j = 0; j < cc; j++)
      {
        string[] input = Console.ReadLine().Split(' ');
        vertexes[i][2*j] = int.Parse(input[0])-1;
        vertexes[i][2*j+1] = int.Parse(input[1]);
      }
    }

    for(long i = 0; i < (1 << (int)n); i++)//bit全探索
    {
      bool truee = true;
      for(long checkDigit = 0; checkDigit < n; checkDigit++)//右からcheckDigit桁目を見る
      {
        if((i & (1<<(int)checkDigit)) != 0)//右からcheckDigit番目が1ならば
        {
          //checkDigit番目の操作

          for(int j = 0; j < vertexes[checkDigit].Length/2; j++)
          {
            //Console.WriteLine(i+" "+j+" "+vertexes[checkDigit][2*j+1]+" "+(i & (1<<(vertexes[checkDigit][2*j]))));
            if(vertexes[checkDigit][2*j+1] != ((i & (1<<(vertexes[checkDigit][2*j])))!=0?1:0))
            {
              truee = false;
            }
          }
        }
      }

      if(truee)
      {
        //Console.WriteLine(i);
        int answerMemo = 0;
        for(long checkDigit = 0; checkDigit < n; checkDigit++)//右からcheckDigit桁目を見る
        {
          if((i & (1<<(int)checkDigit)) != 0)//右からcheckDigit番目が1ならば
          {
            answerMemo++;
          }
        }
        answer = Math.Max(answer,answerMemo);
      }
    }

    Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11220
using System;
using System.Linq;

namespace abc056
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            var input = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            if (input[1] <= input[2] && input[2] <= (input[0] + input[1]))
                ans = 0;
            else if (input[1] <= input[2] + input[0] && input[2] + input[0] <= input[1] + input[0])
                ans = 0;
            else if (input[2] + input[0] < input[1])
                ans = input[1] - (input[2] + input[0]);
            else
                ans = input[2] - (input[1] + input[0]);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()[::-1]
T = input()[::-1]
l = u = 1
r = W
d = H
for s, t in zip(S,T):
    if t == "U":
        d = min(d + 1, H)
    elif t == "D":
        u = max(1, u - 1)
    elif t == "R":
        l = max(1, l - 1)
    else:
        r = min(r + 1, W)


    if s == "U":
        u += 1
    elif s == "D":
        d -= 1
    elif s == "R":
        r -= 1
    else:
        l += 1
    if l > r or u > d or l > W or r < 1 or u > H or d < 1:
        print("NO")
        break
else:
    if u <= sr <= d and l <= sc <= r:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9828
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A,B;
	cin >> A >> B;
	vector<int> P(N);
	rep(i,N)cin >> P[i];
	int a = 0 ,b = 0,c = 0;
	rep(i,N){
		if(P[i]<=A)a++;
		else if(P[i] <= B)b++;
		else c++;
	}
		cout << min({a,b,c}) << endl;
}

Measured memory_bytes: 256
/**
 * File    : D3.cpp
 * Author  : Kazune Takahashi
 * Created : 8/19/2018, 8:27:56 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M, Q;
int L[200010];
int R[200010];
int p[100010];
int q[100010];
int imos[510][510];

int main()
{
  cin >> N >> M >> Q;
  for (auto i = 0; i < M; i++)
  {
    cin >> L[i] >> R[i];
  }
  for (auto i = 0; i < Q; i++)
  {
    cin >> p[i] >> q[i];
  }
  fill(&imos[0][0], &imos[0][0] + 510 * 510, 0);
  for (auto i = 0; i < M; i++)
  {
    imos[L[i]][R[i]]++;
  }
  for (auto i = 1; i <= N; i++)
  {
    for (auto j = 1; j <= N; j++)
    {
      imos[i][j] += imos[i][j - 1] + imos[i - 1][j] - imos[i - 1][j - 1];
    }
  }
  for (auto i = 0; i < Q; i++)
  {
    cout << imos[q[i]][q[i]] - imos[p[i] - 1][q[i]] << endl;
  }
}

Measured memory_bytes: 4224
A, B=map(int,input().split())

N = B - A + 1
Ans = 0

for i in range(N):
  TmpN = A + i
  S = str(TmpN)
  if S[0]==S[4] and S[1]==S[3]:
    Ans += 1

print(Ans)
  
  



Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int ans=1,n,k;
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;++i)
	{
		ans+=min(ans,k);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll mod = 1000000007;
ll p;
ll b[3005];
ll x[3005];
ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}

ll inv(ll a) {
    return beki(a, mod - 2);
}
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> p;
    mod = p;
    for(int i = 0; i <= p; i++) x[i] = i;
    for(int i = 0; i < p; i++) cin >> b[i];
    int n = p - 1;
    for(int k = 0; k <= n-1; k++) {
        for(int i = n; i >= k + 1; i--) {
            b[i] = (b[i] - b[i-1] + mod) * inv(x[i] - x[i-k-1] + mod);
            b[i] %= mod;
        }
    }
        for(int k = n - 1; k >= 0; k--) {
            for(int i = k; i <= n - 1; i++) {
                b[i] = b[i] - b[i+1] * x[k];
                b[i] += mod * mod;
                b[i] %= mod;
            }
        }
    for(int i = 0; i <= n; i++) {
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

        String input = stdIn.nextLine();

        for(char c : input.toCharArray()) {
            if('A' <= c && c <= 'Z') {
                System.out.print((char)(c + 'a' - 'A'));
            } else if('a' <= c && c <= 'z') {
                System.out.print((char)(c + 'A' - 'a'));
            } else {
                System.out.print(c);
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 26968
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

void dfs(vector<int>& nodes, vector<vector<pair<int, int>>>& edges, int st, int col) {
  nodes[st] = col;
  for (auto& vp : edges[st]) {
    if (nodes[vp.first] != -1) continue;
    if (vp.second % 2 == 0) {
      dfs(nodes, edges, vp.first, col);
    } else {
      dfs(nodes, edges, vp.first, col ^ 1);
    }
  }
}

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

  int n;
  cin >> n;
  vector<int> nodes(n, -1);
  vector<vector<pair<int, int>>> edges(n);
  rep(i, n-1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    edges[u].emplace_back(v, w);
    edges[v].emplace_back(u, w);
  }

  dfs(nodes, edges, 0, 0);

  rep(i, n) cout << nodes[i] << endl;

  return 0;
}


Measured memory_bytes: 8960
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string in; cin >> in;
    REP(i, 3) cout << (in[i] == '1' ? '9' : '1');
    return 0;
}


Measured memory_bytes: 256
n = int(input())
d,x = map(int,input().split())
li = [int(input()) for _ in range(n)]

cnt = 0

for i in li:
    s = d/i
    if s == d//i:
        cnt += d//i
    else:
        cnt += d//i + 1

    
print(cnt+x)

Measured memory_bytes: 3060
n,k=map(int,input().split())
a=list(map(int,input().split()))

from itertools import accumulate
for i in range(min(k,100)):
  l=[0]*(n+2)
  for j in range(n):
    left=max(0,j-a[j])
    right=min(n,j+a[j])
    l[left]+=1
    l[right+1]-=1
  s=list(accumulate(l))
  # print(s)
  a=s[:n]
print(*a)

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

ll ans[100000];

bool compP(P p1, P p2) {
  return p1.first > p2.first;
}

bool comp(int a, int b) {
  return a > b;
}

int main() {
  int t;
  cin >> t;
  priority_queue<P, vector<P>, decltype(&compP)> Ql(compP), Qr(compP);
  priority_queue<int, vector<int>, decltype(&comp)> Sl(comp), Sr(comp);
  rep(j, t) {
    int n, ln = 0, rn = 0; ans[j] = 0;
    cin >> n;
    rep(i, n) {
      int k, l, r;
      cin >> k >> l >> r;
      if (l == r) ans[j] += l;
      else if (l > r) {
        ans[j] += r; ln++;
        Ql.push( make_pair(k - 1, l - r) );
      } else {
        ans[j] += l; rn++;
        if (k < n) Qr.push( make_pair(n - 1 - k, r - l) );
      }
    }

    int ln2 = 0;
    rep(i, ln) {
      while (!Ql.empty() && Ql.top().first == i) {
        Sl.push(Ql.top().second);
        ln2++;
        Ql.pop();
      }
      while (ln2 > i + 1) {
        ln2--;
        Sl.pop();
      }
    }

    while (!Ql.empty()) {
      ans[j] += Ql.top().second; Ql.pop();
    }

    while (!Sl.empty()) {
      ans[j] += Sl.top(); Sl.pop();
    }

    int rn2 = 0;
    rep(i, rn) {
      while (!Qr.empty() && Qr.top().first == i) {
        Sr.push(Qr.top().second);
        rn2++;
        Qr.pop();
      }
      while (rn2 > i + 1) {
        rn2--;
        Sr.pop();
      }
    }

    while (!Qr.empty()) {
      ans[j] += Qr.top().second; Qr.pop();
    }

    while (!Sr.empty()) {
      ans[j] += Sr.top(); Sr.pop();
    }

  }

  rep(i, t) {
    cout << ans[i] << endl;
  }

  return 0;
}
/*
*/


Measured memory_bytes: 5536
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<ll(n);++i)
#define repr(i,n) for(ll i=ll(n);i-->0;)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

void test(ll n,ll x,ll m){
  ll ans = 0;
  for(int i=0;i<n;++i){
    cout<<i<<" "<<x<<endl;
    ans += x;
    x = x*x%m;
  }
  cout<<"ans : "<<ans<<endl;
}

signed main(){

  ll n,x,m;
  cin>>n>>x>>m;
  
  ll ans = 0;
  set<ll> st;
  for(ll i=0;i<n;++i){
    ans += x;
    st.emplace(x);
    x = x*x%m;

    if(st.find(x)!=st.end()){
      ll val = x;
      ll looplen = 0;
      ll loopgain = 0;
      dump(val);
      do{
        loopgain += val;
        val = val*val%m;
        looplen++;
      }while(val!=x);
      dump(ans,ans+(n-i-1)/(looplen)*loopgain);
      ans += (n-i-1)/(looplen)*loopgain;
      dump(x,looplen,(n-i-1)/looplen,(n-i-1)%looplen,loopgain);
      ll len = (n-i-1)%looplen;
      dump(m);
      rep(j,len){
        ans += x;
        x = x*x%m;
      }
      break;
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 5948
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string s;

	cin >> s;

	if (s == "a" || s == "i" || s == "u" || s == "e" || s == "o") {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;

	}
}



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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        if(A[i] == 0) {
            printf("0\n");
            return 0;
        }
    }
    double cand = 1.0;
    REP(i, N) {
        cand *= static_cast<double>(A[i]);
    }
    if(cand > 1e18) {
        printf("-1\n");
        return 0;
    }
    int ans = 1;
    REP(i, N) {
        ans *= A[i];
    }

    if (ans > 1000000000000000000LL) {
        printf("-1\n");
        return 0;
    } else {
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 3920
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef complex<double> P;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
	double x,y;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
P projection(L a,P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}
P reflection(L a,P p){
	return p+2.0*(projection(a,p)-p);
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P intersect_ls(L a,L b){
	double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
	double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
	return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}	
int main(){
	int n;
	cin>>n;
	while(n--){
		P p[4];
		PIN(p,4);
		L a=L(p[0],p[1]);
		L b=L(p[2],p[3]);
		printf("%.9f\n",distanceSS(a,b));
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
  
int ans = 1e9;
int main() {
  int n, t, a, b;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (t >= b && a < ans) ans = a;
  }
  if (ans < 1e9) cout << ans << endl;
  else cout << "TLE" << endl;
}

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

int memo[100][100][4];
int w,h;

int solve(int x,int y,int s) {
	if(x==w-1&&y==h-1) return 1;
	if(x>=w||y>=h) return 0;
	if(memo[x][y][s]!=-1) return memo[x][y][s];
	if(s==0) memo[x][y][s]=solve(x+1,y,3)+solve(x,y+1,0);
	if(s==1) memo[x][y][s]=solve(x,y+1,0);
	if(s==2) memo[x][y][s]=solve(x+1,y,2)+solve(x,y+1,1);
	if(s==3) memo[x][y][s]=solve(x+1,y,2);
	return memo[x][y][s]%100000;
}

int main() {
	while(scanf("%d %d",&w,&h),w||h) {
		memset(memo,-1,sizeof(memo));
		printf("%d\n",(solve(1,0,2)+solve(0,1,0))%100000);
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main() {
	int n, a[26];
	cin >> n;
	fill(a, a + 26, 50);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		int t[26] = {};
		for (int j = 0; j < s.length(); j++) {
			t[s[j] - 'a']++;
		}
		for (int j = 0; j < 26; j++) {
			a[j] = min(a[j], t[j]);
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < a[i]; j++) {
			cout << char('a' + i);
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int ans = 753;
    for(int i = 0; i < s-2; i++){
      int n = Integer.parseInt(S.substring(i, i+3));
      int m = Math.abs(753-n);
      ans = m < ans ? m : ans;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  
  int dp[100010];
  rep(i, N+1) dp[i] = INF;
  dp[0] = 0;
  
  rep(i, N) {
    for (int pow6 = 1; pow6 + i <= N; pow6 *= 6) {
      dp[i+pow6] = min(dp[i+pow6], dp[i]+1);
    }
    for (int pow9 = 1; pow9 + i <= N; pow9 *= 9) {
      dp[i+pow9] = min(dp[i+pow9], dp[i]+1);
    }
  }
  cout << dp[N] << endl;
  return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int64_t n, m;
  cin >> n >> m;
  vector<vector<int>> graph(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].emplace_back(b - 1);
    graph[b - 1].emplace_back(a - 1);
  }
  queue<int> qa, qb;
  vector<bool> ua(n), ub(n);
  int64_t ca = 1, cb = 0;
  qa.emplace(0);
  ua[0] = true;
  while (!qa.empty()) {
    while (!qa.empty()) {
      int v = qa.front();
      qa.pop();
      for (int u : graph[v]) {
        if (ub[u]) continue;
        ub[u] = true;
        qb.emplace(u);
        ++cb;
      }
    }
    while (!qb.empty()) {
      int v = qb.front();
      qb.pop();
      for (int u : graph[v]) {
        if (ua[u]) continue;
        ua[u] = true;
        qa.emplace(u);
        ++ca;
      }
    }
  }
  if (ca == n) cout << n * (n - 1) / 2 - m << endl;
  else cout << ca * cb - m << endl;
}



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

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int k, n,a[1000],ans=0;
	scanf("%d%d", &n,&k);
	for (int i = 0; i < n; i++)scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), compare);
	for (int i = 0; i < k; i++)ans += a[i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1752
from collections import defaultdict

N, M = map(int, input().split())

d = defaultdict(int)

if M > 0:
    for i in range(M):
        p, S = input().split()
        p = int(p)
        if d[(p, 'AC')] > 0 and S == 'AC':
            pass
        elif d[(p, 'AC')] == 0 and S == 'AC':
            d[(p, 'AC')] = 1
        elif d[(p, 'AC')] == 0 and S == 'WA':
            d[(p, 'WA')] += 1

ans = 0
penalty = 0

for i in range(1, N + 1):
    if d[(i, 'AC')]:
        ans += d[(i, 'AC')]
        penalty += d[(i, 'WA')]
        # print(i, ans, penalty)

print('{} {}'.format(ans, penalty))




Measured memory_bytes: 38440
#include <stdio.h>
 
int main()
{
  int a,b,c,d,e,f,g;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  e = b-a;
  f = c-b;
  g = c-a;
  if (b - a <= 0)
    e = (b-a)*-1;
  if (c-b <= 0)
    f = (c-b)*-1;
  if (c-a <= 0)
    g = (c-a)*-1;
  if (g <= d || (e <= d && f <= d))
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];

  vector<int> num(n, -1);
  for (int i = 0; i < m; i++) {
    if (num[n-s[i]] == -1) {
      num[n-s[i]] = c[i];
    }
    else if (num[n-s[i]] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n >= 2 && num[n-1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (n >= 2 && num[n-1] == -1) {
    num[n-1] = 1;
  }
  if (n == 1 && num[n-1] == -1) {
    num[n-1] = 0;
  }
  for (int i = n-2; i >= 0; i--) {
    if (num[i] == -1) num[i] = 0;
  }

  int ans = 0;
  int mul = 1;
  for (int i = 1; i < n; i++) mul *= 10;
  for (int i = n-1; i >= 0; i--) {
    ans += mul * num[i];
    mul /= 10;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 60;
int dy[] = {0,0, 1,-1};
int dx[] = {1,-1,0, 0};
bool grid[N][N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m;
    char c;
    cin >> n >> m;
    fore(i,1,n+1) fore(j,1,m+1) {
        cin >> c;
        grid[i][j] = c=='#';
    }
    fore(i,1,n+1) fore(j,1,m+1) {
        if (grid[i][j]) {
            int cnt = 1;
            fore(k,0,4) cnt += grid[i+dy[k]][j+dx[k]];
            if (cnt == 1) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
#!/usr/bin/env perl

use strict;
use warnings;

my ($aa, $bb) = split / /, <>;
chomp $bb;

if ($aa == 1) {
  $aa = 100;
}
if ($bb == 1) {
  $bb = 100;
}

print "Alice\n" if $aa > $bb;
print "Bob\n" if $aa < $bb;
print "Draw\n" if $aa == $bb;


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String S = sc.next().replaceAll("\\?", ".");
	    String T = sc.next();
	    for (int i = S.length() - T.length(); i >= 0; i--) {
	      String s = S.substring(i, i + T.length());
	      if (T.matches(s)) {
	        S = S.replaceFirst(S.substring(0, i) + s, S.substring(0, i) + T).replaceAll("\\.", "a");
	        System.out.println(S);
	        return;
	      }
	    }
	    System.out.println("UNRESTORABLE");
	}
}


Measured memory_bytes: 21716
# ABC073D - joisino's travel
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
    dist = [float("inf")] * size
    checked = [0] * size
    checked[0] = 1
    queue = [(0, start)]
    heapify(queue)
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for next_cost, u in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (cost + next_cost, u))
        checked[v] = 1
        if sum(checked) == size:
            return dist


def main():
    global G, N
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, cost in zip(*[iter(ABC)] * 3):
        G[v].append((cost, u)), G[u].append((cost, v))
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

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


int main(){
	int N;cin >> N;
	int ans = 1;
	while(ans * 2 <= N) ans *= 2;
	cout << ans << endl;
}












Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <bitset>
#include <queue>
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define pb push_back
#define mo 974711
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define MAXN 500005
#define eps 1e-12
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 - '0' + c;
	c = getchar();
    }
    res = res * f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N,C,K;
int T[1000005];
void Solve() {
    read(N);read(C);read(K);
    for(int i = 1 ; i <= N ; ++i) read(T[i]);
    sort(T + 1,T + N + 1);
    int ans = 0;
    int cnt = 0,t = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(t < T[i] || !cnt) {
	    ++ans;
	    t = T[i] + K;
	    cnt = C;
	}
	--cnt;
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 640