akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ALDS1_5B
{
    class Program
    {
        static int count = 0;
        static void Merge(long[] array, int left, int mid, int right)
        {
            var n1 = mid - left;
            var n2 = right - mid;

            var l = new List<long>();
            var r = new List<long>();

            for (var n = 0; n < n1; n++)
                l.Add(array[left + n]);
           
            for (var n = 0; n < n2; n++)
                r.Add(array[mid + n]);
            
            l.Add(9999999999);
            r.Add(9999999999);

            var i = 0;
            var j = 0;

            for (var k = left; k < right; k++)
            {
                count++;
                if (l[i] <= r[j])
                {
                    array[k] = l[i];
                    i++;
                }
                else
                {
                    array[k] = r[j];
                    j++;
                }
            }
        }

        static void MergeSort(long[] array, int left, int right)
        {
            if (left + 1 < right)
            {
                var mid = (left + right) / 2;
                MergeSort(array, left, mid);
                MergeSort(array, mid, right);
                Merge(array, left, mid, right);
            }
        }

        static void Main()
        {
            var len = int.Parse(Console.ReadLine());
            var array = Array.ConvertAll(
                Console.ReadLine().Split(' '),
                e => long.Parse(e)
            );
            MergeSort(array, 0, len);
            Console.WriteLine(string.Join(" ",
                Array.ConvertAll(array, e => e.ToString())
            ) + "\n" + count.ToString());
        }
    }
}


Measured memory_bytes: 87160
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef int Type;
  int segn2;
  vector<Type> data,s_data;
  
  StarrySkyTree(int n){
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,0);
    s_data.assign(segn2*2,0);
  }
  
  //get maximum value of [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(r<a || b<l) return -INF; //大きさに注意
    if(a<=l && r<=b) return data[k] + s_data[k];
    return max(query(a,b,l,(l+r)/2,k*2+1),query(a,b,(l+r)/2+1,r,k*2+2))+s_data[k];
  }
  
  //add x to [a,b]
  Type add(int a,int b,Type x,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b){
      s_data[k]+=x;
    }else if(a<=r && l<=b){
      data[k] = max(add(a,b,x,l,(l+r)/2,k*2+1),add(a,b,x,(l+r)/2+1,r,k*2+2));
    }
    return data[k] + s_data[k];
  }
  
};

bool hasnext[SIZE], hasown[SIZE];
int prevmax[SIZE];

int main(){
  int n, m, x;

  scanf("%d", &n);

  for(int i=0;i<n;i++) prevmax[i] = -1;
  
  for(int i=0;i<n;i++){
    scanf("%d", &m);
    for(int j=0;j<m;j++){
      scanf("%d", &x);
      x--;
      hasnext[i] |= x == i+1;
      hasown[i] |= x == i;
      if(x < i) prevmax[i] = max(prevmax[i], x);
    }
  }

  StarrySkyTree seg(n+1);

  seg.add(1,n, -INF);
  
  for(int i=0;i<n;i++){
    if(!hasown[i] && !hasnext[i]){
      seg.add(prevmax[i]+1, i, 1);
    }

    int res = seg.query(0,i);
    
    seg.add(i+1, i+1, res - seg.query(i+1, i+1));

    if(!hasown[i] && hasnext[i]){
      seg.add(prevmax[i]+1, i, 1);
    }
  }

  cout << n - seg.query(0,n) << endl;
  
  return 0;
}



Measured memory_bytes: 5432
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
if h > 0:
    count += (h + a - 1) // a
#output
print(count)

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

int main() {
  int A, B;
  cin >> A>> B;
  //vector<int> p(N);
  
  rep(i, 3){
   if(i+1 != A && i+1 != B) cout<<i+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,i;
	char s[15];
	scanf("%d%d%s",&a,&b,s);
	if(s[a]!='-'){
		puts("No");
		return 0;
	}
	for(i=0;i<a+b+1;i++){
		if(i!=a){
			if(s[i]!='0'&&s[i]!='1'&&s[i]!='2'&&
			s[i]!='3'&&s[i]!='4'&&s[i]!='5'&&
			s[i]!='6'&&s[i]!='7'&&s[i]!='8'&&
			s[i]!='9'){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


def main():
    N = int(input())
    for i in range(1, 3501):
        for j in range(1, i + 1):
            fb = 4 * i * j - N * (i + j)
            if fb <= 0:
                continue
            fa = N * i * j
            k = int(fa / fb)
            if (k * fb == fa):
                print("{} {} {}".format(i, j, k))
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 5588
import sys
import math
i=0
while i<50:
    m,f,r=map(int,input().split())
    if(m==-1 and f==-1 and r==-1):
        break
    if(m==-1 or f==-1):
        print('F')
    elif(m+f>=80):
        print('A')
    elif(m+f>=65 and m+f<80):
        print('B')
    elif(m+f>=50 and m+f<65):
        print('C')
    elif(m+f>=30 and m+f<50):
        if(r>=50):
            print('C')
        else:
            print('D')
    else:
        print('F')
    i=i+1


Measured memory_bytes: 5652
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
bool is_prime(ll nn){
    for(ll i=2; i*i <= n ;i++){
        if(nn%i==0) return 0;
    }
    return 1;
}

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c){
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

int a, L;

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}
inline int toint(string s) {int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string tostr(T x) {
	ostringstream sout;sout<<x;
	string res = sout.str();
	while (res.size() < L) res ="0" + res;
	return res;
}



map<string,int> ma;

int main() {
    //freopen( "C:\\Users\\t2ladmin\\Dropbox\\Contest\\input.in", "r", stdin );
    
	while (cin >> a >> L) {
		if (a == 0 && L == 0) break;
		string sa = tostr(a);

		ma.clear();
		ma[sa] = 1;

		for (int i = 1; i < 30; ++i) {
			string s1 = sa, s2 = sa;
			sort(ALL(s1), greater<char>());
			sort(ALL(s2));

			int num = toint(s1) - toint(s2);
			sa = tostr(num);

			//cout << i << " : " << s1 << ", " << s2 << ", " << sa << endl;

			if (ma[sa] != 0) {
				cout << ma[sa]-1 << " " << toint(sa) << " " << i-ma[sa]+1 << endl;
				break;
			}
			ma[sa] = i+1;
		}	
	}
    
    return 0;
}


Measured memory_bytes: 1256
# coding: utf-8

n = int(input())

max_val = -10 ** 10
min_val = int(input())

for i in range(n - 1):
    t = int(input())
    max_val = max(max_val, t - min_val)
    min_val = min(min_val, t)

print(max_val)

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int *N, T, comp;
    string result;
    cin >> T;
    N = new int[T];

    for (int i = 0; i < T; i++)
        cin >> N[i];

    sort(N, N + T);

    for (int i = 0; i < T - 1; i++)
        comp += N[i];
    result = (comp > N[T - 1]) ? "Yes" : "No";

    cout << result << endl;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    int a[n];
    map<int,int> m;
    long long sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
        m[a[i]]++;
    }
    int t;
    cin>>t;
    while(t--){
        long long b,c;
        cin>>b>>c;
        sum -= m[b]*b;
        int x = m[b];
        m[c] += x;
        m[b] = 0;
        sum += x*c;
        cout<<sum<<endl;
    }
	return 0;
}


Measured memory_bytes: 8396
N,Y = map(int,input().split())
ans = 0
for a in range(N+1):
  for b in range(N+1-a):
    c = N-a-b
    if a*10000+b*5000+c*1000 == Y:
      z = a
      y = b
      x = c
      ans = 1
      break
      
if ans == 1:
  print(z,y,x)
else:
  print(-1,-1,-1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int main(){
    int a, b, c, k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(k<=a){ printf("%d",k); }
    else if(k<=a+b){ printf("%d",a); }
    else if(k<=a+b+c){ printf("%d",a-(k-a-b)); }
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int main(){
  int k;
  cin>>k;
  long long ans=0;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        int tmp=gcd(a,b);
        ans+=gcd(tmp,c);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}
      

Measured memory_bytes: 3564
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int x, y, ans;
	while (cin >> x >> y && x != EOF) {
		ans = x + y;
		if (ans < 10) cout << 1 << endl;
		else if (10 <= ans && ans < 100) cout << 2 << endl;
		else if (100 <= ans && ans < 1000) cout << 3 << endl;
		else if (1000 <= ans && ans < 10000) cout << 4 << endl;
		else if (10000 <= ans && ans < 100000) cout << 5 << endl;
		else if (100000 <= ans && ans < 1000000) cout << 6 << endl;
		else cout << 7 << endl;
	}
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <string>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

int main()
{
	ll n, p;
	cin >> n >> p;
	ll ans = 0;

	//除外
	if (p == 1) {
		cout << 1;
		return 0;
	}
	if (n == 1) {
		cout << p;
		return 0;
	}

	//1から最大公約数を検索
	for (ll i = 1; pow(i, n) <= p; i++) {
		ll D = pow(i, n);
		//指数表示にして指数がnと同じなら
		if (p%D == 0)ans = max(ans, i);
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

int MOD=1000000007;

int main()
{
  map<string,long long>mp;
  long long N,ma=0; cin >> N;
  string S;
  for(int i=0; i<N; i++){
    cin >> S;
    mp[S]+=1;
  }
  for(auto x : mp) ma=max(x.second,ma);

  for(auto i=mp.begin(); i!=mp.end(); i++){
    if(i->second==ma) cout << i->first << endl;
  }
}


Measured memory_bytes: 25216
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1005;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0){
		c-=b;
		a-=d;
	}
	if(c<=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits> 

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<ll> VL;
typedef vector<VL> VVL;

int n, m, sol;
VI C;
VVI g;
VL adj;
ll used;

int Count(ll guarded) {
	int res = 0;
	for (int i = 0; i < n; ++i)
		if (guarded&(1LL << i))
			res += C[i];
	return res;
}

void dfs(int u, int par, ll guarded) {
	if ((adj[u] ^ (1LL << par))&used) return;
	used |= (1LL << u);
	guarded |= adj[u];
	if (u == n-1) {
		sol = min(sol, Count(guarded));
		used ^= (1LL << u);
		return;
	}
	for (auto& v : g[u]) {
		if ((1LL << v)&used) continue;
		dfs(v, u, guarded);
	}
	used ^= (1LL << u);
}

int main() {
	ios::sync_with_stdio(false);
	while (cin >> n >> m) {
		C = VI(n);
		for (auto& x : C) cin >> x;
		g = VVI(n);
		adj = VL(n, 0);
		int u, v;
		for (int i = 0; i < m; ++i) {
			cin >> u >> v;
			--u; --v;
			g[u].push_back(v);
			g[v].push_back(u);
			adj[u] |= (1LL << v);
			adj[v] |= (1LL << u);
		}
		sol = 1 << 30;
		used = 0;
		dfs(0, 52, 0);
		cout << sol << '\n';
	}
}

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

int main()
{
    int n, q;
    int order, index, value;

    cin >> n >> q;

    queue<int> Q[n];

    for( int i = 0; i < q; i++ )
    {   
        cin >> order >> index;

        switch( order )
        {
            case 0:
                cin >> value;
                Q[index].push(value);
                break;
            case 1:
                if( Q[index].size() == 0 );
                else
                    cout << Q[index].front() << endl;
                break;
            case 2:
                if( Q[index].size() == 0);
                else
                    Q[index].pop();
                break;
        }
    }
    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    int count = 1;
    int ans = 0;
    FOR(i,1,n){
        if(a[i]==a[i-1])count++;
        else {
            ans += count/2;
            count = 1;
        }
    }
    ans += count/2;
    COUT(ans);
    return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;

int main(){
    Int X; cin >> X;

    Int now = 100, ans = 0;
    while(now < X){
        now = now + now/100;
        ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n,m,i,j,p[15],tmp,s[15][15],t[15],num[15],q,ans=0,sum;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&num[i]);
        for(j=1;j<=num[i];j++)
            scanf("%d",&s[i][j]);
    }
    for(i=1;i<=m;i++)
        scanf("%d",&t[i]);
    for(i=0;i<pow(2,n);i++)
    {
        memset(p,0,sizeof(p));
        j=1,tmp=i;
        while(tmp!=0)
        {
            p[j]=tmp%2,j++;
            tmp/=2;
        }
        for(j=1;j<=m;j++)
        {
            sum=0;
            for(q=1;q<=num[j];q++)
                if(p[s[j][q]]==1)
                sum++;
            if(sum%2!=t[j])
                break;
        }
        if(j>m)
            ans++;
    }
    printf("%d",ans);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int p[n-1];
  for (int i=0; i<n; i++) {
    cin >> p[i];
  }
  int count = 0;
  int lmin = p[0];
  for (int i=0; i<n; i++) {
    if (p[i] <= lmin) count++;
    lmin = min(lmin, p[i]);
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
int main(void){
int x;
int y;
int c;
for(;;){
scanf("%d %d",&x,&y);
if(x==0&&y==0)break;
else{
if(x>y){
c=x;
x=y;
y=c;
}
printf("%d %d\n",x,y);
}
}
return 0;
}

Measured memory_bytes: 2660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	char str[21] = "\0";
	int X;

	scanf("%s", str);

	for (X = strlen(str)-1; X > 0; X--)
	{
		if (X <= (strlen(str) - 1) - X)
			break; 

		str[(strlen(str)-1) - X] ^= str[X];
		str[X] ^= str[(strlen(str)-1) - X];
		str[(strlen(str)-1) - X] ^= str[X];
	}
	printf("%s\n", str);

	return 0;
}

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


//?´???°?????°??????????????°??????
//??¨?????????????????????????????¨??????
int IsPrimeNumber(int num){

	int count = 0;
	//?´???°????????????num?????§????¢??????§??????
	//??????30?????§????´???°?????°????????????1*30???2*15???3*10???5*6??¨??°??????????????¨??????
	//5????¶???????????????§????????\???????´???°?????¢?????§???????????¨??????????????????????????§???
	//???30?????§????´???°??????????????????????????°????????\???????´???°?????§?????????
	//???30?????§????´???°???4?????????????????\???????´???°???4??????????????¨????????????

	if (num == 2 || num == 3){ return 1; }
	else if (num < 2 || num % 2 == 0 || num % 3 == 0){ return 0; }
	else{
	
		for (int n = 5; n < sqrt(num)+1; n++){
			if (num%n == 0)return 0;
		}
		return 1;
	}

}


int main(){

	int n,num,count=0;
	cin >> n;

	for (int j = 0; j < n; j++){
		cin >> num;
		if (IsPrimeNumber(num) == 1)count++;
		
	}cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0
let f v c = if c = 'g' then v+1 else v-1
let () =
  let r = Scanf.scanf "%s" list_of_str |> List.fold_left f 0 in
  Printf.printf "%d\n" (r/2)

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

  #define ll long long
  #define int long long
  #define f(i,l,n) for(ll i=l;i<n;i++)
  #define E "\n"
  #define bp __builtin_popcount
  const int M = 1e9+7;

  
  int32_t main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    f(i,0,n) cin >> a[i],mp[a[i]]++;

    const int N=1e6+5;
    bool flg=true;
    vector<bool> isp(N,0);
    f(i,2,N)
    {
      if(isp[i]==0)
      {
          int cnt=0;
          for(int j=i;j<N;j+=i) isp[j]=1,cnt+=mp[j];
          if(cnt>1) 
          {
            flg=false;
            break;
          }
      }

    }

    int g=0;
      f(i,0,n) g=__gcd(g,a[i]);
      if(g==1 and flg) cout<<"pairwise coprime\n";
      else if(g==1) cout<<"setwise coprime\n";
      else cout<<"not coprime\n";

    return 0;
  }

Measured memory_bytes: 73624
#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<climits>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int INF = INT_MAX / 2;
const int NUM = 10;
const int N = 11;
const int S = 331;
const int P = (1 << NUM);

int n, s;
int dp[N][S][P];

void make_dp(){
    REP(i, N) REP(j, S) REP(k, P) dp[i][j][k] = 0;
    int num = 0;
    for(int mask = 1; mask < (1 << NUM); mask = (mask << 1)){
        dp[1][num][mask] = 1;
        ++num;
    }

    FOR(i, 2, N){
        num = 0;
        for(int mask = 1; mask < (1 << NUM); mask = (mask << 1)){
            FOR(j, (num * i), S){
                for(int k = 1; k < (1 << NUM); ++k){
                    if((k & mask) != 0) continue;
                    int p = (k | mask);
                if(j - (num * i) >= 0) dp[i][j][p] += dp[i - 1][j - (num * i)][k];
                }
            }
            ++num;
        }
    }
}

int main(){
    make_dp();
    while(cin >>n >>s){
        if(n >= N || s >= S){
            cout <<0 <<endl;
            continue;
        }
        int ans = 0;
        REP(i, P) ans += dp[n][s][i];
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 15724
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [Usize1; n]
   }
   let mut map = BTreeMap::new();
   for &a in a.iter() {
      map.entry(a).and_modify(|v| *v += 1).or_insert(1);
   }
   let mut parity = 0;
   for &v in map.values() {
      parity += v - 1;
   }
   let ans = map.len() - parity % 2;
   println!("{}", ans);
}


Measured memory_bytes: 7056
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n;
map<int,int> mp1,mp2;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=0;i<n;i++){
		if(i%2) mp2[v[i]]++;
		else mp1[v[i]]++;
	}
	vector<pii> a,b;
	for(map<int,int>::iterator it=mp1.begin();it!=mp1.end();it++) a.pb(MP(it->se,it->fi));
	for(map<int,int>::iterator it=mp2.begin();it!=mp2.end();it++) b.pb(MP(it->se,it->fi));
	sort(rall(a));
	sort(rall(b));
	//for(int i=0;i<sz(a);i++) cout<<a[i].fi<<'-'<<a[i].se<<' ';
	int res;
	if(a[0].se==b[0].se){
		if(sz(a)==1&&sz(b)==1){
			cout<<n/2;
			re 0;
		}
		res=max(a[0].fi+b[1].fi,a[1].fi+b[0].fi);
	}
	else res=a[0].fi+b[0].fi;
	cout<<n-res;
	re 0;
}

Measured memory_bytes: 12604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Is_SFT(ll n){
  ll a[10]={};
  while(n>0){
    a[n%10]++;
    n/=10;
  }
  if(a[3]>0&&a[5]>0&&a[7]>0) return 1;
  else return 0;
}
ll f(ll n,ll cur,ll &a){//制限、今の数,カウント用変数
  if(cur<=n){
    if(Is_SFT(cur)) a++;
  }
  for(int i=3;i<=7;i+=2){
    if(10*cur+i<=n) f(n,10*cur+i,a);
  }
}
int main(){
  ll n,a;
  cin >> n;
  f(n,0,a);
  cout << a << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;
int n;
ll a,b,c,d,f[N<<1],invf[N<<1];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll C(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
int main()
{
    f[0]=invf[0]=1;
    for(int i=1;i<N<<1;i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
    scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
    ll ab=a+b;
    a=a*qpow(ab,mod-2)%mod;b=b*qpow(ab,mod-2)%mod;d=100*qpow(100-c,mod-2)%mod;
    ll ans=0;
    for(int i=n;i<n*2;i++)
        ans=(ans+(qpow(a,n)*qpow(b,i-n)%mod+qpow(b,n)*qpow(a,i-n)%mod)*C(i-1,n-1)%mod*d%mod*i%mod)%mod;
    printf("%lld\n",ans);
}


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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] n = new long[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
        long s = long.Parse(Console.ReadLine());
        Console.WriteLine(n[s - 1]);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int a,b,h,m;
cin>>a>>b>>h>>m;
double angle1 = abs(0.5 * (h * 60 + m) - 6 * m);
double pi=2*acos(0.0);
double angle=(angle1*pi)/180;
double y=sqrt(a*a+b*b-2*a*b*cos(angle));
printf("%.20lf\n",y);

	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

mat G(210);
int BFS(int s){
    int rev=0;
    vec d(210,-1);d[s]=0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int p=que.front();que.pop();
        for(auto q:G[p]){
            if(d[q]!=-1){
                if(abs(d[q]-d[p])==1)continue;
                else return -1;
            }
            d[q]=d[p]+1;
            rev=max(rev,d[q]);
            que.push(q);
        }
    }
    return rev+1;
}

int main(){
    int N;cin>>N;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            char S;cin>>S;
            if(i<j && S=='1'){
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }
    int ans=-1;
    for(int i=1;i<=N;i++){
        ans=max(ans,BFS(i));
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    int T1,T2,R1,R2;
    
    cin >> T1 >> T2 >> R1 >> R2;
    
    if(R1 != -1 && R2 != -1){
        if(R1 > R2)
            cout << "Alice"<< endl;
        else if(R2 > R1)
            cout << "Bob" << endl;
        else
            cout << "Draw" << endl;
    }else{
        if(T1 < T2)
            cout << "Alice"<< endl;
        else if(T2 < T1)
            cout << "Bob" << endl;
        else
            cout << "Draw" << endl;
    }
}


Measured memory_bytes: 3120
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    it.next();
    let k: usize = it.next().unwrap().parse().unwrap();
    let mut ans = 0;
    for s in it {
        let h: usize = s.parse().unwrap();
        if h >= k {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
while true
gx,gy=gets.split.map(&:to_i)
break if gx==0 && gy == 0
d=Array.new(17).map{Array.new(17,0)}
d[0][0]=1;
gets.to_i.times{
  x,y=gets.split.map(&:to_i)
  d[x-1][y-1]=-1;
}
0.upto(gx-1){|i|
  0.upto(gy-1){|j|
    next if d[i][j]==-1
    if i && d[i-1][j]!=-1
      d[i][j]+=d[i-1][j] end
    if j && d[i][j-1]!=-1
      d[i][j]+=d[i][j-1] end
  }
}
puts d[gx-1][gy-1]
end

Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, A, B;
    cin >> N >> A >> B;
    int x = N / (A + B);
    int y = N % (A + B);

    cout << x * A + min(y, A) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b;
	static int k=0;
	static int[] ans;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		li=new List<int>[s[0]];
		b=new bool[s[0]];
		k=s[0]-1;
		for(int i=0;i<s[0];i++){li[i]=new List<int>();}
		for(int i=0;i<s[1];i++){
			int[] e=sc.Ia;
			li[e[0]].Add(e[1]);
		}
		ans=new int[s[0]];
		for(int i = 0;i<s[0];i++) {
			if(!b[i]){Fu(i);}
		}
		Console.WriteLine(String.Join("\n",ans));
	}
	static void Fu(int a){
		b[a]=true;
		for(int i=0;i<li[a].Count;i++){
			if(!b[li[a][i]]){Fu(li[a][i]);}
		}
		ans[k]=a;
		k--;
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}


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

using namespace std;

typedef long long ll;

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

  int l, r;
  cin >> l >> r;
  if (l <= 0 && r >= 0) {
    cout << "Zero\n";
    return 0;
  }
  if (l > 0) {
    cout << "Positive\n";
    return 0;
  }
  int len = r - l + 1;
  if (len % 2 == 0) {
    cout << "Positive\n";
  } else {
    cout << "Negative\n";
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    vector <int> a(s.length());
    vector <int> diff9(s.length());
    vector <int> diff9Sum(s.length(),0);
    for(int i = 0; i < s.length(); i++){
        a[i] = (int)((int)s[i] - (int)'0');
        diff9[i] = 9-a[i];
        if(i==0){
            diff9Sum[i] = diff9[i];
        }else{
            diff9Sum[i] = diff9[i] + diff9Sum[i];
        }
    }
    long ans = 0;
    for(int i = 1; i < s.length(); i++){
        if(diff9[i]==0){
            continue;
        }else{
            a[i-1]--;
            for(int j = i; j < s.length(); j++){
                a[j] = 9;
            }
            break;
        }
    }
    for(int i = 0; i < s.length(); i++){
        //cout << a[i];
        ans+=a[i];
    }
    //cout << endl;
    cout << ans << endl;


}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int S[200005]={0};
bool T[200005]={0};

int main(){
  int n;
  cin>>n;
  ll ans=1;
  for(int i=1;i<=2*n;i++){
    char c;cin>>c;
    if(c=='B')S[i]=1;
    else S[i]=2;
  }
  if(S[1]==2){
    cout<<0<<endl;
    return 0;
  }
  T[1]=0;
  for(int i=2;i<=2*n;i++){
    if(S[i]!=S[i-1])T[i]=T[i-1];
    else if(T[i-1]==0)T[i]=1;
    else T[i]=0;
  }
  ll num=1;
  for(int i=2;i<=2*n;i++){
    if(T[i]==0)num++;
    else {
      ans=(ans*num)%MOD;
      num--;
    }
    if(num<0){
      cout<<0<<endl;
      return 0;
    }
  }
  if(num!=0){
    cout<<0<<endl;
    return 0;
  }
  for(int i=2;i<=n;i++){
    ans=(ans*i)%MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n-r+1;
	int sum = 1;
	for(int i =s;i<=n;i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string s;
	cin >> s;
	cout << s.substr(0, s.size()-8);
}

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

int main(){
  int a,b;
  std::cin >> a >> b;
  if (a==b) {
    std::cout << "a == b" << std::endl;
  } else if(a<b) {
    std::cout << "a < b" << std::endl;
  } else {
    std::cout << "a > b" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<=999;i++){
		ll ch=i;
		for(ll j=0;j<n;j++){
			ll now=s[j]-'0';
			if(ch%10==now){
				ch/=10;
				for(ll k=j+1;k<n;k++){
					ll now=s[k]-'0';
					if(ch%10==now){
						ch/=10;
						for(ll l=k+1;l<n;l++){
							ll now=s[l]-'0';
							if(ch%10==now){
								ans++;
								goto d;
							}
						}
						goto d;
					}
				}
				goto d;
			}
		}
		d:;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    string s;
    int k;
    cin>>s>>k;
    const int l=s.size();
    REP(i,l){
        if(s[i]=='a')continue;
        if(s[i]+k>'z'){
            k-='z'-s[i]+1;
            s[i]='a';
        }
    }
    s[l-1]+=k%26;
    if(s[l-1]>'z')s[l-1]-=26;
    cout<<s<<endl;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;

#define int long long
signed main(){
   IOS;
   int a,b,c;cin>>a>>b>>c;
   if(c-a-b<0)cout<<"No"<<endl;
   else if((a+b-c)*(a+b-c)-4*a*b>0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;    

     
   return 0;
}

Measured memory_bytes: 384
n, k = gets.split.map(&:to_i)
a = []
a = gets.split.map(&:to_i)
l = {}
n.times do |i|
  l[i+1] = a[i]
end

# puts "#{l}"

ns = 1
# 閉路長
cl = 0
list = [ns]
# list中の値を添え字としてそのインデックスを覚えておく配列
idx = [nil]
idx.push(0)
1.upto l.size do |i|
  ns = l[ns]
  # puts "#{idx} #{ns}"
  if not idx[ns].nil?
    cl = i - idx[ns]
    break
  end
  list.push(ns)
  idx[ns] = i
end

# puts "#{list}"
# puts cl
# 閉路以外の長さ
ncl = list.size - cl
# puts ncl

ans = 0
cnt = 0
if k <= ncl
  ans = list[k]
else
  # 閉路での移動回数
  cnt = k - ncl
  cnt = cnt % cl
  ans = list[ncl+cnt]
end
puts ans

Measured memory_bytes: 37032
import sys

PRIMES=[]
SIEVES=[]
def sieve(m):
    N=range(1,m+2,2)
    r=int(m**.5)+1
    h=len(N)
    N[0]=0
    for i in range(h):
        x=N[i]
        if x>r: break
        if x and i+x<h:
            N[i+x:h:x]=[0] * ((h-1-i-x)/x+1)
    return N
def prime(n):
    global SIEVES
    if SIEVES==[]: SIEVES=sieve(n)
    primes =[2]+filter(None,SIEVES[:n/2])
    return primes
PRIMES=prime(105000)
for n in sys.stdin:
    n=int(n)
    if n==0: break
    print sum(PRIMES[:n])

Measured memory_bytes: 8260
#include<stdio.h>
int main(){
  int n,d,x,a,i,k;
  scanf("%d%d%d",&n,&d,&x);
  for(i=1;i<=n;i++){
    scanf("%d",&a);
    k=1;
    while(k<=d){
      x++; k+=a;
    }
  }
  printf("%d\n",x);
  return 0;
}

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

string S, T;

bool check() {
    char R[2][26]; // 対応表
    for (int i=0; i < 26; ++i) R[0][i] = R[1][i] = -1; // -1で初期化

    for(int i=0; S[i] != '\0'; ++i) {
        if(R[0][S[i]-'a'] < 0) 
            R[0][S[i]-'a'] = T[i]-'a';
        else if(R[0][S[i]-'a'] != T[i]-'a') 
            return false;
        
        if(R[1][T[i]-'a'] < 0) 
            R[1][T[i]-'a'] = S[i]-'a';
        else if(R[1][T[i]-'a'] != S[i]-'a') 
            return false;
    }

    return true;
}

int main() {

    cin >> S >> T;

    if(check()) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main()
{
  int a[100],i;
  for(i=0;i<5;i++)
  {
    cin>>a[i];
  }
  if(a[0]==0)
    cout<<1;
  else if(a[1]==0)
    cout<<2;
  else if(a[2]==0)
    cout<<3;
  else if(a[3]==0)
    cout<<4;
  else if(a[4]==0)
    cout<<5;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int dp[100100];
int n,m;
vector<int> ga[100100];
int u,v;
int d(int x){
	if(dp[x]!=-1)
		return dp[x];
	int &res=dp[x];
	res=0;
	for(int i=0;i<ga[x].size();i++){
		int y=ga[x][i];
		res=max(res,d(y)+1);
	}
	return res;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		ga[u].push_back(v);
	}
	int res=0;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++){
		res=max(res,d(i));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, 1, 1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;

    vector<int> num(n + 1, 0);

    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        ++num[i];
        ans += (ll)i * num[i];

        for (int j = i * 2; j <= n; j += i) {
            ++num[j];
        }
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 42320
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define mod2 998244353
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll;
ll num[ten52];
//priority_queue<pair<ll,ll>> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=1,k1=1,ans=0,pre;
    string s="ACL";
    cin>>n;
    for(i=0;i<n;i++)
    {
        cout<<s;
    }

    return 0;
}





Measured memory_bytes: 3600
if __name__ == '__main__':
    num = int(input())
    int_list = [int(i) for i in input().split()]

    result = {}
    for i in int_list:
        if str(i) in result:
            result[str(i)] += 1
        else:
            result[str(i)] = 1

        if str(i + 1) in result:
            result[str(i + 1)] += 1
        else:
            result[str(i + 1)] = 1

        if str(i - 1) in result:
            result[str(i - 1)] += 1
        else:
            result[str(i - 1)] = 1

    print(max(result.values()))


Measured memory_bytes: 21756
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D,answer=0,a,b=0,count=0;
  cin>>N>>D;
  vector<vector<int>> X(N,vector<int>(D));
    for (int i=0; i < N; ++i) {
  	for (int j=0; j < D; ++j) { 
      cin >> X[i][j];
	}
   }
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      b=0;
      for(int k=0;k<D;k++){
        a=X[i][k]-X[j][k];
        b+=a*a;
      }
  for(int k=0;k<=b;k++){
    if(k*k==b) count++;
  }
    }
  }
  cout<<count<<endl;
}
        

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <limits>
#include <string>
#include <vector>
using namespace std;

const int kInf = numeric_limits< int >::max() / 2;

int N, Li[14];
string str[14];
vector< string > vstr;
int ln[14][14];

void preprocess(void);
void solve(void);

int main() {
  while (cin >> N, N) {
    for (int i = 0; i < N; ++i) cin >> str[i], Li[i] = str[i].length();
    preprocess();
    solve();
  }

  return 0;
}

void preprocess(void) {
  bool is_cntd[14];

  fill(&is_cntd[0], &is_cntd[14], false);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N && !is_cntd[i]; ++j) {
      if (i == j) continue;
      if (Li[i] < Li[j] || (Li[i] == Li[j] && i < j)) {
        if (str[j].find(str[i]) != string::npos)
          is_cntd[i] = true;
      }
    }

  vstr.clear();
  for (int i = 0; i < N; ++i)
    if (!is_cntd[i])
      Li[vstr.size()] = Li[i], vstr.push_back(str[i]);
  N = vstr.size();

  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) {
      if (i == j) continue;
      int k = min(Li[i], Li[j]) - 1;
      while (k >= 0) {
        if (vstr[i].compare(Li[i] - k, Li[i], vstr[j], 0, k) == 0)
          break;
        --k;
      }
      ln[i][j] = Li[j] - k;
    }
}

void solve(void) {
  static int f[1 << 14][14], res;

  fill(&f[0][0], &f[1 << N][0], kInf);
  for (int i = 0; i < N; ++i)
    f[1 << i][i] = Li[i];

  for (int i = 0; i < (1 << N); ++i)
    for (int j = 0; j < N; ++j)
      if (f[i][j] < kInf)
        for (int k = 0; k < N; ++k)
          if (!(1 << k & i))
            f[1 << k | i][k] = min(f[1 << k | i][k], f[i][j] + ln[j][k]);

  res = kInf;
  for (int i = 0; i < N; ++i)
    res = min(res, f[(1 << N) - 1][i]);
  cout << res << "\n";
}

Measured memory_bytes: 2116