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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x;
    cin>>x;
    int ans=0;

    if(x>=1800){
        ans=1;
    }else if(x>=1600){
        ans=2;
    }else if(x>=1400){
        ans=3;
    }else if(x>=1200){
        ans=4;
    }else if(x>=1000){
        ans=5;
    }else if(x>=800){
        ans=6;
    }else if(x>=600){
        ans=7;
    }else{
        ans=8;
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

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

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

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

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

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

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

string to_string(string s){
    return s;
}

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

void debug_print(){
    cerr<<endl;
}

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

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

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

int main(){
    string s;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
    return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll L;
double ans;
int main(){
	cin >> L;
	ans = L / 3.0;
	printf("%.7lf", ans*ans*ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
int main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    ll x=ceil(n/2.0);
    if(x>=k)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,sum;
int s(int x){
    int res = 0;
    while(x>0){
        res += x%10;
        x/=10;
    }
    return res;
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    sum = s(n);
    if(n%sum==0)cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;

int main(){
	char x,y;
	cin>>x>>y;
	if(x>y){
		cout<<">"<<endl;
	}else if(x<y){
		cout<<"<"<<endl;
	}else{
		cout<<"="<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    
    int n ;
    
    int taro = 0, hana = 0 ;
    
    std::string taroStr, hanaStr ;
    
    std::cin >> n ;
    
    for (int i=0; i<n; i++) {
        
        std::cin >> taroStr >> hanaStr ;
        int tarop=0, hanap=0 ;
        
        for (int i=0; i<std::min(taroStr.length(), hanaStr.length()); i++) {
            for (char alf='z'; alf>='a'; alf--) {
                
                if ( alf == taroStr[i] && alf == hanaStr[i] ) {
                    tarop += 1 ;
                    hanap += 1 ;
                } else if ( alf == taroStr[i] ) {
                    tarop += 1 ;
                    break ;
                } else if ( alf == hanaStr[i] ) {
                    hanap += 1 ;
                    break ;
                }
            }
            
            if (tarop != hanap){
               break ;
            }
            
        }
        
        if ( tarop == hanap ) {
            tarop += ( taroStr.length() > hanaStr.length() ) ;
            hanap += ( taroStr.length() < hanaStr.length() ) ;
        }
        
        taro += (tarop > hanap) * 3 ;
        hana += (tarop < hanap) * 3 ;
        hana += (tarop == hanap) ;
        taro += (tarop == hanap) ;
        
    }
    
    printf("%d %d\n", taro, hana) ;
    
    return 0 ;
}



Measured memory_bytes: 3264
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

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

  private static final long MOD = 1000000007L;

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();
    int n = s.length();
    int[] leftAs = new int[n];
    int[] leftQs = new int[n];
    int[] rightCs = new int[n];
    int[] rightQs = new int[n];

    int qCount;

    int aCount = 0;
    qCount = 0;
    for (int i = 0; i < n; i++) {
      leftAs[i] = aCount;
      leftQs[i] = qCount;
      char c = s.charAt(i);
      if (c == 'A') aCount++;
      else if (c == '?') qCount++;
    }

    int cCount = 0;
    qCount = 0;
    for (int i = n - 1; 0 <= i; i--) {
      rightCs[i] = cCount;
      rightQs[i] = qCount;
      char c = s.charAt(i);
      if (c == 'C') cCount++;
      else if (c == '?') qCount++;
    }

    long[] pow3 = new long[qCount + 1];
    pow3[0] = 1;
    for (int i = 1; i <= qCount; i++) {
      pow3[i] = (pow3[i - 1] * 3L) % MOD;
    }

    long sum = 0;
    // fix B
    for (int i = 0 ; i < n; i++) {
      char c = s.charAt(i);
      if (c != 'B' && c != '?') continue;
      long left = leftAs[i] * pow3[leftQs[i]] % MOD;
      if (1 <= leftQs[i]) left += leftQs[i] * pow3[leftQs[i] - 1];
      long right = rightCs[i] * pow3[rightQs[i]] % MOD;
      if (1 <= rightQs[i]) right += rightQs[i] * pow3[rightQs[i] - 1];
      sum += (left % MOD) * (right % MOD);
      sum = sum % MOD;
    }
    os.println(sum);
  }
}


Measured memory_bytes: 26796
#include <cstdio>
#include <cstring>
#include <algorithm>
int n,s,d;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&s,&d);
		if((s>=0 && d<=0) ||(s<=0 && d>=0)){
			s=abs(s);
			d=abs(d);
			int cnt=0;
			while(s>0){
				if(s&1)cnt++;
				s>>=1;
			}
			while(d>0){
				if(d&1)cnt++;
				d>>=1;
			}
			printf("%d\n",cnt);
		}else{
			s=abs(s);
			d=abs(d);
			int cnt=0,v=0;
			while(s!=d){
				if(s>>v & 1){
					if(s>d)s-=1<<v;
					else s+=1<<v;
					cnt++;
				}
				if(d>>v & 1){
					if(s>d)d+=1<<v;
					else d-=1<<v;
					cnt++;
				}
				v++;
			}
			printf("%d\n",cnt);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class ConsoleApp1
{

    public static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        var y = int.Parse(Console.ReadLine());
        var z = int.Parse(Console.ReadLine());

        x = x - y;
        Console.WriteLine(x - z*(x/z));
    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int N;
	cin>>N;
	if(N%10==9 || N/10==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

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

int main(){
    ll n;
    cin>>n;

    cout<<n*(n-1)/2<<endl;
}


Measured memory_bytes: 256
import itertools
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, Q = map(int, input().split())
abcd = tuple(tuple(map(int, input().split())) for _ in range(Q))

ans = 0
for A in itertools.combinations_with_replacement(range(1, M + 1), r=N):
    score = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            score += d
    if ans < score:
        ans = score
print(ans)

Measured memory_bytes: 9176
a,b=map(int,input().split())
ct=0
c=list(map(int,input().split()))
point=[0]*(len(c)+1)
for i in range(b):
    l,s=map(int,input().split())
    l-=1
    s-=1
    if c[l]>c[s]:
        point[s]+=1
    elif c[l]<c[s]:
        point[l]+=1
    else:
        point[s]+=1
        point[l]+=1
print(point.count(0)-1)

Measured memory_bytes: 84912
import itertools

s = input()

reslist = []

def diverge(current_list, pos):
    if pos == len(s):
        reslist.append(current_list)
        return
    stick_list = current_list.copy()
    current_list.append(int(s[pos]))
    diverge(current_list, pos + 1)
    stick_list[-1] = stick_list[-1]*10 + int(s[pos])
    diverge(stick_list, pos + 1)

diverge([int(s[0])], 1)

# print(reslist)

sol = 0

for res in reslist:
    sol += sum(res)

print(sol)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char p[300005][10];
long long qs[300005],qs2[300005];
main()
{
	int t,ck=1,ck2=0;
    long long s,cal=0,tmp=0;
    scanf("%d",&t);
    for(int i = 1;i <= 2*t-1;i++)
    {
        if(i%2==1)
        {
            scanf("%lld",&qs[i/2+1]);
            long long cs=qs[i/2+1];
            if(p[i/2][0]=='-')
            cs=-cs;
            qs2[i/2+1]=qs2[i/2]+cs;
            //printf("%lld-->",qs2[i/2+1]);
        }
        else
        {
            scanf("%s",p[i/2]);
        }
    }
    long long cas=0,mx=qs2[t];
    for(int i = t;i >= 1;i--)
    {
        cas+=qs[i];
        qs[i]+=qs[i+1];
        if(p[i-1][0]=='-')
        {
            //printf("-->");
            mx=max(mx,qs2[i-1]-2*cas+qs[i]);
            //printf("pos = %d    %lld<--%lld\n",i,mx,qs2[i-1]-2*cas+qs[i]);
            cas=0;
        }
    }
    printf("%lld",mx);
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int s,a,c;

int R(int i){
  return (a*i+c)%256;
}

double calch(vector<int> &vec){
  vector<int> cnt(256, 0);
  for(int i:vec) cnt[i]++;
  double ret=0;
  rep(i,256) if(cnt[i]>0) ret += (double)cnt[i] * log((double)cnt[i]);
  return ret;
}

int main(){
  int n;
  while(cin>>n, n){
    vector<int> vec(n);
    rep(i,n) cin>>vec[i];

    double best=-INF;
    int bs=-1,ba=-1,bc=-1;
    for(s=0; s<16; s++) for(a=0; a<16; a++) for(c=0; c<16; c++){
      vector<int> o(vec);
      int pre=s;
      rep(i,n){
        pre = R(pre);
        o[i] = (o[i]+pre)%256;
      }
      double h = calch(o);
      if(best < h){
        best = h;
        bs=s;
        ba=a;
        bc=c;
      }
    }
    cout<<bs<<" "<<ba<<" "<<bc<<endl;
  }

  return 0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
using namespace std;

map<string, int > b;
int n, maxn = -1;
string str;

int main() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> str;
        maxn = max(maxn, ++b[str]);
    }
    for(auto i : b) {
        if(i.second == maxn)
            cout << i.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <algorithm>
#define mod 998244353

long long dp[2010][2010], sum[2010];
long long fac[2010], inv[2010];
long long ans[2010];

long long C(int a, int b) {return fac[a] * inv[b] % mod * inv[a - b] % mod;}

long long Sum(int i) {if(i < 0) return 0; return sum[i];}

int main()
{
	fac[0] = inv[0] = inv[1] = 1;
	for(int i = 1; i <= 2000; i++) fac[i] = fac[i - 1] * i % mod;
	for(int i = 2; i <= 2000; i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 1; i <= 2000; i++) inv[i] = inv[i] * inv[i - 1] % mod;
	int k, n; scanf("%d%d", &k, &n);
	dp[0][0] = 1;
	for(int i = 1; i <= k; i++)
	{
		for(int j = 0; j <= n; j++) sum[j] = (Sum(j - 1) + dp[i - 1][j]) % mod;
		for(int j = 0; j <= n; j++)
			dp[i][j] = sum[j] % mod;
	}
	for(int w = 1; w <= (k + 1 >> 1); w++)
	{
		for(int a = 0; a <= w; a++)
		{
			ans[w] = (ans[w] + dp[k - w][n - a] * C(w, a)) % mod;
		}
	}
	int s = 0;
	for(int i = 2; i <= 2 * k; i++)
	{
		if(i % 2 == 0) s++;
		if(i > k + 1) s--;
		printf("%lld\n", ans[s]);
	}
	return 0;
}

Measured memory_bytes: 31616
H, W = map(int, input().split())
graph = [input().split() for _ in range(H)]
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(H):
    for j in range(W):
        if graph[i][j] == "snuke":
            print(alpha[j]+str(i+1))
            exit()


Measured memory_bytes: 3060
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int INF=1000000000000000000;
  long long int n,a,x[55],i,j,k,dp[55][55][3010];
  scanf("%lld %lld\n",&n,&a);
  for(i=1;i<=n;i++){
    scanf("%lld ",&x[i]);
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      for(k=0;k<=2500;k++){
        dp[i][j][k]=0;
      }
    }
  }
  for(i=0;i<=n;i++){
    dp[i][0][0]=1;
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      for(k=0;k<=2500;k++){
        if(k-x[i]>=0){
          dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
        }
        else{
          dp[i][j][k]=dp[i-1][j][k];
        }
      }
    }
  }
  long long int ans=0;
  for(i=1;i<=n;i++){
    ans+=dp[n][i][a*i];
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main() {
  string S;
  cin>>S;
  int a;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='+'){
      a++;
    }
    else{
      a--;
    }
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    ll n, m;
    cin >> n >> m;

    ll s[m];
    char c[m];
    rep(i, m) {
        cin >> s[i];
        cin >> c[i];
    }

    ll ans = -1;
    rep(i, 1000) {
        string temp = to_string(i);
        bool judge = true;
        if (temp.length() != n) {
            judge = false;
        }
        rep(j, m) {
            if (temp[s[j] - 1] != c[j])
                judge = false;
        }
        if (judge) {
            ans = i;
            break;
        }
    }

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



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

int main() {
  int n;
  cin >> n;  
  if ( n < 1200 ) cout << "ABC" << endl;
  else if( 1200 <= n && n < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int X,N,P,ans_small,ans_big;
    vector<int> p_small;
    vector<int> p_big;
    cin >> X >> N;
    for(int i=0; i<N; i++){
        cin >> P;
        if(P<=X) p_small.push_back(P);
        if(P>=X) p_big.push_back(P);
    }
    sort(p_small.begin(),p_small.end());
    sort(p_big.begin(),p_big.end());
    ans_big=X;
    ans_small=X;
    for(int i=0; i<p_big.size(); i++){
        if(ans_big==p_big.at(i)){
            ans_big++;
        }else{
            break;
        }
    }
    for(int i=p_small.size()-1; i>=0; i--){
        if(ans_small==p_small.at(i)){
            ans_small--;
        }else{
            break;
        }
    }
    if(X-ans_small<=ans_big-X){
        cout << ans_small << endl;
    }else{
        cout << ans_big << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int s,n,k;
  cin>>n>>k>>s;
  if(s==1e9)
  {
    for(int i=1;i<=k;i++)
    {
      cout<<s<<' ';
    }
    for(int i=k+1;i<=n;i++)
    {
      cout<<1<<' ';
    }
    cout<<'\n';
  }
  else
  {
    for(int i=1;i<=k;i++)
    {
      cout<<s<<' ';
    }
    for(int i=k+1;i<=n;i++)
    {
      cout<<1000000000<<' ';
    }
    cout<<'\n';
  }
}

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

using namespace std;

const int maxn=1e5+5,mod=1e9+5;

typedef long long ll;

struct f
{
    int l,r;
} rob[maxn];

bool cmp(f a,f b)
{
    return a.r<b.r;
}

int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        int i;
        for(i=0; i<N; i++)
        {
            int x,L;
            scanf("%d%d",&x,&L);
            rob[i].l=x-L;
            rob[i].r=x+L;
        }
        sort(rob,rob+N,cmp);
        int ans=1;
        f jq=rob[0];
        for(i=1; i<N; i++)
        {
            if(jq.r<=rob[i].l)
            {
                ans++;
                jq=rob[i];
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,ans=0;
	string s;
	cin>>n>>s;
	rep(i,1000){
		bool f1,f2,f3;
		f1=f2=f3=false;
		char p1,p2,p3;
		p1='0'+(i/100);
		p2='0'+(i%100-i%10)/10;
		p3='0'+(i%10);
		rep(j,n){
			if(!f1){
				if(s[j]==p1)f1=true;		
			}else if(!f2){
				if(s[j]==p2)f2=true;
			}else if(!f3){
				if(s[j]==p3)f3=true;
			}else{
				break;
			}
		}
		if(f1&&f2&&f3)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
int minimumCost(int price[], int n) 
{ 
	sort(price, price + n); 
	int totalCost = 0; 
	for (int i = n - 1; i > 1; i -= 2) { 
		if (i == 2) { 
			totalCost += price[2] + price[0]; 
		} 
		else { 
			int  price_first = price[i] + price[0] + 2 * price[1]; 
			int  price_second = price[i] + price[i - 1] + 2 * price[0]; 
			totalCost += min(price_first, price_second); 
		} 
	} 
	if (n == 1) { 
		totalCost += price[0]; 
	} 
	else { 
		totalCost += price[1]; 
	} 

	return totalCost; 
} 
int32_t main() 
{ 
	int n; cin>>n;
	int k;cin>>k;
    int  price[n];
	int tp=0;
	for(int i=0;i<n;++i)
	{cin>>price[i]; tp+=price[i];}
	sort(price, price + n); 
	int ans=0;
	for(int i=n-1;i>=0;--i){
		if(k>0){
			k--;
		}
		else
			ans+=price[i];
	}	
	cout<<ans;
	return 0; 
} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
 	
int main() {

	int N;
	cin>>N;
	if(N==1){
		ce("Hello World")
	}else{
		int A,B;
		cin>>A>>B;
		ce(A+B)
	}
	
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<string.h>
int main()
{  char s;
   int i,t,b[90000],a[90000],n,j,p,q,k;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   scanf("%d",&a[i]);
   scanf("%d",&j);
   for(i=0;i<j;i++)
   scanf("%d",&b[i]);
   p=n;q=j;t=0;
   for(k=i=1;i<p;i++)	
   {  for(j=0;j<k;j++)		          
      {  if(a[j]==a[i])  
	     break;			//思路：如果没有重复,a[i]的值递给a[k],如果a[i]与前面相比有重复，则用break，使a[i]的值不给a[k]; 
	  }		
	  if(j==k)   
	  a[k++]=a[i];
   }		
   for(i=0;i<k;i++)
     for(j=0;j<q;j++)
     if(a[i]==b[j]) t++;
   printf("%d\n",t);
}


Measured memory_bytes: 2016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int l[m],r[m];
	for(int i=0;i<m;i++)
	{
		cin>>l[i]>>r[i];
	}
	

	cout<<max(*min_element(r,r+m)-*max_element(l,l+m)+1,0)<<endl;
	return 0;
}

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

int main(){
	string S;
	int c=0,flag=0;
	cin >> S;
	for(int i=0;i<S.length();i++){
		if(S[i]=='C'){c=1;}
		if(c==1 && S[i]=='F'){flag=1;}
	}
	if(flag==1){cout << "Yes" << endl;}
	else{cout << "No" << endl;}
	return 0;
}


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


def can_mono(a):
    len_a = len(a)
    for i in range(len_a - 2):
        if a[i + 1] < a[i] - 1:
            return False
        if a[i + 1] < a[i]:
            for j in range(i + 1, len_a - 1):
                if a[j + 1] < a[i + 1]:
                    return False
                if a[j + 1] > a[i + 1]:
                    break
                if a[j + 1] == a[i + 1]:
                    continue
    return True


if can_mono(a):
    result = 'Yes'
else:
    result = 'No'
print("{}".format(result))

Measured memory_bytes: 14400
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int X = Integer.valueOf(s.next());
		
		int angle = X;
		int ret = 1;
		while(true) {
			if(angle % 360 == 0) {
				System.out.println(ret);
				return;
			}
			ret++;
			angle += X;
		}
	}
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 998244353;
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
ll mypow(ll a, ll b){
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
ll k , n ;
cin >> k >> n ;
vector<ll> ans(2*k-1);
COMinit();
for (ll i = 2; i <= 2*k; i++)
{
  ll kk;
  if(i<k+1)kk=i-1;
  else kk=2*k+1-i;
  if(i%2){
    rep(j,kk/2+1){
      ll te=COM(kk/2,j)*mypow(2,j);
      te%=mo;
      te*=COM(n-j+j+k-kk-1,j+k-kk-1);
      te%=mo;
      ans[i-2]+=te;
      ans[i-2]%=mo;
    }
  }
  else{
    rep(j,kk/2+1){
      ll te=COM(kk/2,j)*mypow(2,j);
      te%=mo;
      te*=COM(n-j+j+k-kk-1,j+k-kk-1);
      te%=mo;
      ans[i-2]+=te;
      ans[i-2]%=mo;
    }
    rep(j,kk/2+1){
      ll te=COM(kk/2,j)*mypow(2,j);
      te%=mo;
      te*=COM(n-j+j+k-kk-1-1,j+k-kk-1);
      te%=mo;
      ans[i-2]+=te;
      ans[i-2]%=mo;
    }
  }
}

for(auto a:ans){
  cout << a << endl;
  
}
return 0;
}

Measured memory_bytes: 12288
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    M, *DC = map(int, read().split())
    D = DC[::2]
    C = DC[1::2]

    total = sum(d * c for d, c in zip(D, C))
    q, r = divmod(total, 9)
    ans = sum(C) - 1 + q - (r == 0)
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29660
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,d,cnt=0; cin>>n>>d;
    rep(i,n){
        ll x,y; cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3580
from collections import deque
import numpy as np

H,W = map(int,input().split())
maze = [input() for _ in range(H)]

ans = 0
for x in range(H):
    for y in range(W):
        if maze[x][y] == "#":
            continue
        distance = [[0]*W for _ in range(H)]
        #start位置
        stack = deque([[x,y]])
        
        while stack:
            h,w = stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h, new_w = h+i, w+j
                if new_h < 0 or new_w < 0 or new_h >= H or new_w >= W:
                    continue
                elif maze[new_h][new_w] != "#" and distance[new_h][new_w] == 0:
                    distance[new_h][new_w] = distance[h][w]+1
                    stack.append([new_h, new_w])
        
        #start位置は0で初期化
        distance[x][y] = 0
        #print(distance[0])
        #print(distance[1])
        #print(distance[2])
        #print()
        ans = max(ans, np.max(distance))
        
print(ans)


Measured memory_bytes: 12436
n, k = gets.split.map(&:to_i)

#puts "#{n} #{k}"

array = Array.new(n, false) 
# true  : お菓子を持ってる。
# false : お菓子を持っていない。

#puts "array::#{array}"

while d = gets do # dを読む
    have_snack = gets.split.map(&:to_i) # A1 ... Ai ... An
    have_snack.each do |sunuke_number|
        array[sunuke_number -1] = true
    end
end

#puts "array::#{array}"

puts array.count(false)


Measured memory_bytes: 14340
#include <iostream>
#include <atcoder/math>
#include <map>
#include <vector>
#include <utility>
using namespace std;
using namespace atcoder;
typedef long long ll;
map<ll,ll> mp;
vector<pair<ll,ll>> v;
ll pw(ll a, ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a);
        (a *= a); x /= 2;
    }
    return ret;
}

int main(){
    ll i,j,n; cin >> n;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    n *= 2;
    ll ans = n - 1;
    for(i=2;i*i<=n;i++){
        while(n%i==0){
            n /= i; mp[i]++;
        }
    }
    if(n!=1) mp[n]++;
    for(auto x:mp) v.push_back(x);
    int k = v.size();
    for(i=0;i<(1<<k);i++){
        ll x = 1,y = 1;
        for(j=0;j<k;j++){
            ll s = v[j].first,t = v[j].second;
            if(i & (1<<j)) x *= pw(s,t);
            else y *= pw(s,t);
        }
        if(y==1 || x==1) continue;
        ll c = inv_mod(y,x);
        ll d = (c*y - 1)/x;
        ll r = min(c/x,d/y);
        ans = min(ans,c*y - r*x);
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    int max1 = max(a + b, a - b);
    cout << max(max1, a * b);
    return 0;
}


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

num_list = [0]*(n+1)
for i in a:
    num_list[i] += 1

cnt = 0
for i in num_list:
    cnt += i*(i-1)/2

for i in a:
    print(int(cnt +1 -num_list[i]))


Measured memory_bytes: 24748
import sys
input = sys.stdin.readline

n = int(input())

cnt = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    
    if cnt == 3:
        break

if cnt == 3:
    print('Yes')
else:
    print('No')

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] ={ 1, 0, -1, 0 };
int dy[4] ={ 0, 1, 0, -1 };

int main()
{
    int n, m, k;
    cin>>n>>m>>k;
    vector<ll> va(n);
    REP(i, n)
        cin>>va[i];
    vector<ll> vb(m);
    REP(i, m)
        cin>>vb[i];
    vector<ll> va2=va;
    FOR(i, 1, n)
        va2[i]+=va2[i-1];
    vector<ll> vb2=vb;
    FOR(i, 1, m)
        vb2[i]+=vb2[i-1];
    int idxb=m-1;
    int ans=0;
    REP(i, n+1) {
        if (i==0) {
            idxb=distance(vb2.begin(), upper_bound(ALL(vb2), k))-1;
            ans=idxb+1;
        }
        else {
            while (idxb>=0&&va2[i-1]+vb2[idxb]>k) {
                idxb--;
            }
            if (va2[i-1]>k)
                break;
            ans=max(ans, i+idxb+1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  string s;
  cin >> s;
  string t="";
  t=t+s[0]+s[1]+s[2];
  cout << t << endl;
}   


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> L(N);
    vector<int> cnt(2001, 0);
    for(int i = 0; i < N; i++){
        cin >> L[i];
        cnt[L[i]]++;
    }
    for(int i = 1; i <= 2000; i++){
        cnt[i] += cnt[i - 1];
    }

    // for(int i = 0; i < 10; i++) cout << cnt[i] << endl;

    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int a = L[i];
            int b = L[j];
            int s = a + b;
            int d = abs(a - b);
            ans += cnt[s - 1] - cnt[d];
            if(d < a && a < s) ans--;
            if(d < b && b < s) ans--;
        }
    }
    cout << ans / 3 << endl;
    return 0;
}


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

ls=list("abcdefghijklmnopqrstuvwxyz")

if N<=26:
	print(ls[N-1])
elif N<=702:
	M=N-26-1
	ans1=M//26**1
	ans2=M%26**1
	print(ls[ans1]+ls[ans2])
elif N<=18278:
	M=N-702-1
	ans1=M//26**2
	M=M%26**2
	ans2=M//26**1
	M=M%26**1
	ans3=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3])
elif N<=475254:
	M=N-18278-1
	ans1=M//26**3
	M=M%26**3
	ans2=M//26**2
	M=M%26**2
	ans3=M//26**1
	M=M%26**1
	ans4=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4])
elif N<=12356630:
	M=N-475254-1
	ans1=M//26**4
	M=M%26**4
	ans2=M//26**3
	M=M%26**3
	ans3=M//26**2
	M=M%26**2
	ans4=M//26**1
	M=M%26**1
	ans5=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5])
elif N<=321272406:
	M=N-12356630-1
	ans1=M//26**5
	M=M%26**5
	ans2=M//26**4
	M=M%26**4
	ans3=M//26**3
	M=M%26**3
	ans4=M//26**2
	M=M%26**2
	ans5=M//26**1
	M=M%26**1
	ans6=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5]+ls[ans6])
elif N<=8353082582:
	M=N-321272406-1
	ans1=M//26**6
	M=M%26**6
	ans2=M//26**5
	M=M%26**5
	ans3=M//26**4
	M=M%26**4
	ans4=M//26**3
	M=M%26**3
	ans5=M//26**2
	M=M%26**2
	ans6=M//26**1
	M=M%26**1
	ans7=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5]+ls[ans6]+ls[ans7])
elif N<=217180147158:
	M=N-8353082582-1
	ans1=M//26**7
	M=M%26**7
	ans2=M//26**6
	M=M%26**6
	ans3=M//26**5
	M=M%26**5
	ans4=M//26**4
	M=M%26**4
	ans5=M//26**3
	M=M%26**3
	ans6=M//26**2
	M=M%26**2
	ans7=M//26**1
	M=M%26**1
	ans8=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5]+ls[ans6]+ls[ans7]+ls[ans8])
elif N<=5646683826134:
	M=N-217180147158-1
	ans1=M//26**8
	M=M%26**8
	ans2=M//26**7
	M=M%26**7
	ans3=M//26**6
	M=M%26**6
	ans4=M//26**5
	M=M%26**5
	ans5=M//26**4
	M=M%26**4
	ans6=M//26**3
	M=M%26**3
	ans7=M//26**2
	M=M%26**2
	ans8=M//26**1
	M=M%26**1
	ans9=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5]+ls[ans6]+ls[ans7]+ls[ans8]+ls[ans9])
elif N<=146813779479510:
	M=N-5646683826134-1
	ans1=M//26**9
	M=M%26**9
	ans2=M//26**8
	M=M%26**8
	ans3=M//26**7
	M=M%26**7
	ans4=M//26**6
	M=M%26**6
	ans5=M//26**5
	M=M%26**5
	ans6=M//26**4
	M=M%26**4
	ans7=M//26**3
	M=M%26**3
	ans8=M//26**2
	M=M%26**2
	ans9=M//26**1
	M=M%26**1
	ans10=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5]+ls[ans6]+ls[ans7]+ls[ans8]+ls[ans9]+ls[ans10])
else:
	M=N-146813779479510-1
	ans1=M//26**10
	M=M%26**10
	ans2=M//26**9
	M=M%26**9
	ans3=M//26**8
	M=M%26**8
	ans4=M//26**7
	M=M%26**7
	ans5=M//26**6
	M=M%26**6
	ans6=M//26**5
	M=M%26**5
	ans7=M//26**4
	M=M%26**4
	ans8=M//26**3
	M=M%26**3
	ans9=M//26**2
	M=M%26**2
	ans10=M//26**1
	M=M%26**1
	ans11=M//26**0
	print(ls[ans1]+ls[ans2]+ls[ans3]+ls[ans4]+ls[ans5]+ls[ans6]+ls[ans7]+ls[ans8]+ls[ans9]+ls[ans10]+ls[ans11])



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

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

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


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


int main()
{
    int n,m; cin >> n >> m;
    int a[m],b[m];
    int ans = 0;
    rep(i,m) cin >> a[i] >> b[i];
    rep(i,m){
        UnionFind uf(n);
        rep(j,m){
            if(i == j) continue;
            
            uf.unite(a[j]-1,b[j]-1);
        }
        if(uf.tree_size(0) != n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    int n,a[100]={0};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<a[n-1];
    for(int i=1;i<n;i++){
        int j=(n-1)-i;
        cout<<" "<<a[j];
    }
    cout<<endl;
    
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>

int main(){
    char *mark = "SHCD";
    int card[4][13] = { 0 };
    
    int i, j;
    int n, t;
    char c;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; ++i){
        scanf(" %c %d", &c, &t);
        card[strchr(mark, c) - mark][t - 1] = 1;
    }
    
    for(i = 0; i < 4; ++i){
        for(j = 0; j < 13; ++j){
            if(!card[i][j]){
                printf("%c %d\n", mark[i], j + 1);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	int n;
	cin >> n;
	int a[n],f=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		if(a[i]==0)
		{
			f=1;
		}
	}
	if(f)
	{
		cout << "0" ;
		return 0;
	}
	
	int mul=1,ans=1e18;
	for(int i=0;i<n;i++)
	{
		float x=(ceil)(ans*1.0/mul*1.0);
		
		x=(int)x;
		if(a[i]>x)
		{
			cout << "-1";
			return 0;
		}
		
		mul*=a[i];
		if(mul>ans)
		{
			cout << "-1";
			return 0;
		}
		
	}
	if(mul>ans || mul<0)
	cout << "-1";
	else
	cout << mul;
	//cout << mul;
}


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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int ct = 0;
    for (int i = min(a,b); i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            ct++;
            if (ct == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = True
ans = 0
while flag:
    flag = False
    for j in range(N-1,0,-1):
        if A[j] < A[j-1]:
            A[j],A[j-1] = A[j-1],A[j]
            flag = True
            ans += 1
print(*A)
print(ans)



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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

signed main()
{
    int N;
    cin >> N;
    int N_one = N % 10;
    switch (N_one){
        case 0:
            cout << "pon";
            break;
        case 1:
            cout << "pon";
            break;
        case 6:
            cout << "pon";
            break;
        case 8:
            cout << "pon";
            break;
        case 3:
            cout << "bon";
            break;
        default:
            cout << "hon";
            break;
    }

}


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

using namespace std;

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

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

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> cnt(N + 1, 0);

    rep2(i, 1, N + 1) {
        for (ll j = i; j <= N; j += i) {
            cnt[j] ++;
        }
    }
    ll ans = 0;
    rep2(i, 1, N + 1) {
        ans += i * cnt[i];
    }
    cout << ans << '\n';
}

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


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    long long tot = 0, a = 0, b = 0, c = 0, q = 1, INV = fast_exp(3, MOD - 2) % MOD;

    for(auto i : s){
        if(i == 'A'){
            ++a;
        } else if(i == 'B'){
            b += a;
        } else if(i == 'C'){
            c += b;
        } else {
            c += b * INV;
            b += a * INV;
            a += INV;
            q *= 3;
        }
        a %= MOD; b %= MOD; c %= MOD; q %= MOD;
    }

    cout << c * q % MOD << "\n";

    return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vl h;
  inputv(h,n);
  vl dp(n+2,INF);
  dp[0] = 0;
  rep(i,n){
    dp[i+1] = min(dp[i+1], (dp[i] + abs(h[i+1] - h[i])));
    dp[i+2] = dp[i] + abs(h[i+2] - h[i]);
                                   }
                                   
  cout << dp[n-1];
    
 return 0;
}

Measured memory_bytes: 1908
#include <math.h>
#include <stdio.h>
#include <string.h>
void swap_int(int* x, int* y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swap_char(char* x, char* y) {
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

void asc_sort(int* array, int n) {
    int i, j;
    for (i = 0; i < n - 1; i++) {
        for (j = i + 1; j < n; j++) {
            if (array[i] > array[j]) {
                swap_int(&array[i], &array[j]);
            }
        }
    }
}

void dec_sort(int* array, int n) {
    int i, j;
    for (i = 0; i < n - 1; i++) {
        for (j = i + 1; j < n; j++) {
            if (array[i] < array[j]) {
                swap_int(&array[i], &array[j]);
            }
        }
    }
}

int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}

int min(int x, int y) {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}

int main(void) {
    char str[200000];
    int n;
    int i, j, k;

    scanf("%s", str);
    n = strlen(str);

    for (i = 0; i < n; i += 2) {
        printf("%c", str[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256