akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
string tmp="NESW";
				
int xv[]={0,1,0,-1};
int yv[]={-1,0,1,0};

int main(){
	int H,W;
	long long int L;
	while(cin>>H>>W>>L,H){
		char M[102][102];
		int p;
		int x,y;
		for(int i=0;i<=H+1;i++)M[0][i]=M[W+1][i]='#';
		for(int i=0;i<=W+1;i++)M[i][0]=M[i][H+1]='#';
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>M[j][i];
				if(M[j][i]!='.'&&M[j][i]!='#'){
					x=j;
					y=i;
					if(M[j][i]=='N')p=0;
					if(M[j][i]=='E')p=1;
					if(M[j][i]=='S')p=2;
					if(M[j][i]=='W')p=3;
					
				}
			}
		}
		int flag[102][102][4];
		memset(flag,-1,sizeof(flag));
		int ff=1;
		for(long long int i=0;1;){
			
			if(flag[x][y][p]<0){
				flag[x][y][p]=i;
			}
			else if(ff){
				ff=0;
				int kaga=i-flag[x][y][p];
				long long int ll=L-i;
				ll/=kaga;
				ll--;
				ll*=kaga;
				L-=ll;
				//cout<<"$ "<<kaga<<endl;
				
				/*
				35-11=24
				24/4=6
				
				
				35
				11
				4
				
				31
				27
				23
				19
				15
				
				
				
				*/
				
			}
			
			while(M[x+xv[p]][y+yv[p]]=='#'){
				p=(p+1)%4;
			}
			x+=xv[p];
			y+=yv[p];
			i++;
			//if(ff||1)cout<<"# "<<y<<" "<<x<<" "<<tmp[p]<<" "<<i<<endl;
			if(i==L){
				cout<<y<<" "<<x<<" "<<tmp[p]<<endl;
				break;
			}
			
		
		}
		
	}
	
	
	
	return 0;
}


Measured memory_bytes: 1392
#include<bits/stdc++.h>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
using namespace std;

vii A,B,C;
vector<vector<int> > v;

int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll n;   cin>>n;     v.resize(n);    
    A.resize(n,-1);
    B.resize(n,-1);
    C.resize(n,-1);
    for(auto &i: v)     i.resize(3);
    forin(0,n)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    A[0] = v[0][0];
    B[0] = v[0][1];
    C[0] = v[0][2];
    for(ll i=1; i<n; i++)
    {
        A[i] =  max( B[i-1]+ v[i][0],C[i-1]+ v[i][0]);
        B[i] =  max( A[i-1]+ v[i][1],C[i-1]+ v[i][1]);
        C[i] =  max( A[i-1]+ v[i][2],B[i-1]+ v[i][2]);
    }
    ll ans = max(A[n-1] , max(B[n-1],C[n-1]));
    cout<<ans<<endl;

}


Measured memory_bytes: 8064
num=int(input())
if(num%10==2 or num%10==4 or num%10==5 or num%10==7 or num%10==9):
  print("hon")
elif(num%10==0 or num%10==1 or num%10==6 or num%10==8):
  print("pon")
elif(num%10==3):
  print("bon")

Measured memory_bytes: 9196
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main() {
	int n, q;
	vector<int64_t> a;
	int64_t sum_t = 0;
	int64_t sum_a = 0;
	int64_t allsum = 0;
	cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		int64_t ai;
		cin >> ai;
		a.push_back(ai);
		if (i % 2 == n%2) sum_a += ai;
		else sum_t += ai;
		allsum += ai;
	}
	vector<int64_t> thr;
	vector<int64_t> val;
	for (int i = 1; i < n; ++i) {
		int ind1 = n - 1 - i;
		int ind2 = n - 1 - 2 * i;
		if (ind2 >= 0) {
			int64_t t = (a[ind1] + a[ind2]) / 2;
			thr.push_back(t);
			val.push_back(sum_a);
			sum_a = sum_a - a[ind1] + a[ind2];
		}
		else {
			ind2 = 0;
			int64_t t = (a[ind1] + a[ind2]) / 2;
			thr.push_back(0);
			val.push_back(sum_a);
		}
	}
	reverse(thr.begin(), thr.end());
	reverse(val.begin(), val.end());
	for (int i = 0; i < q; ++i) {
		int64_t xi;
		cin >> xi;
		auto ite = lower_bound(thr.begin(), thr.end(),xi);
		int dis = distance(thr.begin(), ite)-1;
		if (dis <= 0) dis = 0;
		cout << allsum-val[dis] << endl;
	}
	return 0;
}

Measured memory_bytes: 4252
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
long long int p=1e9 +7;
int n;
int moves[100];
int ans[100007]={0};
int solve(int k){
    if(ans[k]){
        return ans[k];
    }
    for(int i=0;i<n;i++){
        if(k>=moves[i]){
        if(solve(k-moves[i])==2){
            ans[k]=1;
            return ans[k];
        }
      }
    }
   ans[k]=2;
   return ans[k];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	   int k;
	   cin>>n>>k;
	   for(int i=0;i<n;i++){
	       cin>>moves[i];
	   }
	   ans[0]=2;
	   if(solve(k)==1){
	    cout<<"First";   
	   }
	   else{
	       cout<<"Second";
	   }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
ll memo[87] = {0};

ll lucas(ll n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (memo[n] > 0) return memo[n];
  memo[n] = lucas(n - 1) + lucas(n - 2);
  return memo[n];
}

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

  ll n; cin >> n;
  cout << lucas(n) << "\n";
}


Measured memory_bytes: 3620
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i64> = get_vec();
    let (n,a,b) = (v[0], v[1], v[2]);
    let ranks : String = get_one();

    let mut foreign = 0;
    let mut all = 0;
    for c in ranks.chars() {
        if c == 'a' {
            if all < a + b {
                println!("{}", "Yes");
                all += 1;
            }
            else {
                println!("{}", "No");
            }
        }
        else if c == 'b' {
            if all < a + b && foreign < b {
                println!("{}", "Yes");
                all += 1;
                foreign += 1;
            }
            else {
                println!("{}", "No");
            }
        }
        else {
            println!("{}", "No");
        }
    }
}


Measured memory_bytes: 4732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int nums[] = CPUtils.readIntArray(N, in);

            boolean ok = true;
            Arrays.sort(nums);
            Set<Integer> set = new HashSet<>();
            for (int el : nums)
            {
                if (el != 1 && set.contains(el))
                {
                    ok = false;
                    break;
                }
                set.add(el);
            }

            Set<Integer> divisors = new HashSet<>();
            for (int i = N - 1; i >= 0 && ok; i--)
            {
                if (divisors.contains(nums[i]))
                {
                    ok = false;
                    break;
                }
                for (int div = 2; div <= Math.sqrt(nums[i]); div++)
                {
                    if (nums[i] % div == 0)
                    {
                        if (divisors.contains(div) || divisors.contains(nums[i] / div))
                        {
                            ok = false;
                            break;
                        }
                        divisors.add(div);
                        divisors.add(nums[i] / div);
                    }
                }
            }

            if (ok)
            {
                out.println("pairwise coprime");
                return;
            }

            ok = true;
            int gcd = nums[0];
            for (int i = 1; i < N; i++)
            {
                gcd = CPUtils.gcd(gcd, nums[i]);
            }
            if (gcd != 1) ok = false;
            if (ok)
            {
                out.println("setwise coprime");
                return;
            }
            out.println("not coprime");
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

        public static int gcd(int n1, int n2)
        {
            if (n2 == 0)
            {
                return n1;
            }
            return gcd(n2, n1 % n2);
        }

    }
}



Measured memory_bytes: 100952
#include <iostream>
#include <string.h>
using namespace std;

int dp[101][4][4];//何日目から、どのぱすたを、何日連続で食べているか
int plan[101];//先に決められている予定　要素：日付

#define MOD 10000;

int main(void)
{
		int day;
		int k;
		cin >> day >> k;
		memset(plan,0,sizeof(plan));
		for(int i=0;i<k;++i){
			int d,p;
			cin >> d >> p;
			plan[d] = p;
		}
		memset(dp,0,sizeof(dp));

		for(int i=1;i<=3;++i){
			if(plan[1] != 0)
				dp[1][plan[1]][1] = 1;
			else
				dp[1][i][1] = 1;
		}

		for(int d=2;d<=day;++d){//どの日から？
			for(int p=1;p<=3;++p){//どのパスタを？
				if(plan[d]){
					dp[d][plan[d]][1] = (dp[d-1][(plan[d]+1)%3+1][1] + dp[d-1][(plan[d]+1)%3+1][2] + dp[d-1][plan[d]%3+1][1] + dp[d-1][plan[d]%3+1][2])%MOD;
					dp[d][plan[d]][2] = dp[d-1][plan[d]][1] % MOD;
				}
				else{
					dp[d][p][1] = (dp[d-1][(p+1)%3+1][1] + dp[d-1][(p+1)%3+1][2] + dp[d-1][p%3+1][1] + dp[d-1][p%3+1][2])%MOD;
					dp[d][p][2] = dp[d-1][p][1] % MOD;
				}
			}
		}
		int ans = (dp[day][1][1] + dp[day][2][1] + dp[day][3][1] + dp[day][1][2] + dp[day][2][2] + dp[day][3][2])%MOD;
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s;
    cin >> s;
    int sum_of_digits = 0, ans = 0;
    int cnt[2019] = {0};
    cnt[0] = 1;
    int n = s.size(),d = 1;
    repi(i, n, 0)
    {
        sum_of_digits += (s.at(n - i - 1) - '0') * d;
        d*=10;
        d %= 2019;
        sum_of_digits %= 2019;
        cnt[sum_of_digits]++;
    }
    repi(i, 2019, 0)
    {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
#include <iostream>

using namespace std;

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool isOne = false;
	bool isNine = false;
	bool isSeven = false;
	bool isFour = false;
	if (a == 1 || b == 1 || c == 1 || d == 1)
	{
		isOne = true;
	}
	if (a == 9 || b == 9 || c == 9 || d == 9)
	{
		isNine = true;
	}
	if (a == 7 || b == 7 || c == 7 || d == 7)
	{
		isSeven = true;
	}
	if (a == 4 || b == 4 || c == 4 || d == 4)
	{
		isFour = true;
	}
	if (isOne && isNine && isSeven && isFour)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

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

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,x,y,z;
    cin >> n >> x >> y >> z;
    int mask = (1<<(x+y+z-1))-1;
    vector<vector<ll>> dp(n+1,vector<ll>(mask+1,0));
    dp[0][0] = 1;
    ll ans = 1;
    for (int i = 0;i < n;++i) {
        for (int j = mask;j >= 0;--j) {
            for (int k = 1;k < 11;++k) {
                bool ng = true;
                if (k > z) ng = false;
                else {
                    if (k < z && ((j>>(z-k-1))&1) == 0) ng = false;
                    if (((j>>(z+y-k-1))&1) == 0) ng = false;
                    if (((j>>(x+y+z-k-1))&1) == 0) ng = false;
                }
                if (!ng) (dp[i+1][((j<<k)|(1<<(k-1)))&mask] += dp[i][j]) %= mod;
            }
        }
        (ans *= 10) %= mod;
    }
    for (int i = 0;i <= mask;++i) (ans -= dp[n][i]) %= mod;
    cout << (ans+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 21888
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b

def f(N):
    return N - (N//C + N//D - N//lcm(C, D))

A, B, C, D = map(int, input().split())

print(f(B)-f(A-1))


Measured memory_bytes: 2940
A, B, C, X, Y = map(int, input().split())
C *= 2

ans = 0

if C <= A:
    ans += X * C
    Y -= X
    X = 0

if Y > 0 and C <= B:
    ans += Y * C
    X -= Y
    Y = 0

if X > 0 and Y > 0 and C <= A + B:
    cnt = min(X, Y)
    ans += cnt * C
    X -= cnt
    Y -= cnt

if X > 0:
    ans += X * A
    X = 0

if Y > 0:
    ans += Y * B
    Y = 0

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main(){
    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

ll count(ll X, int p) {
  ll t = (X&~((1LL<<p+1)-1));
  // cout << t << " " << bitset<3>(t) << endl;
  ll res = t/2;
  t |= 1LL<<p;
  res += max(0LL,X-t+1);
  return res;
}

int main() {
  int n;
  while(cin >> n, n) {
    ll k[n];
    REP(i,n) {
      cin >> k[i];
    }
    vector<pair<ll, ll> > ans;
    for (ll w=2*k[0]-1; w<=2*k[0]+1; ++w) {
      bool ng = 0;
      ll A=-1,B=0;
      for (int i=n-1; i>=0; --i) {
        if (k[i] == w) B |= 1LL<<i;
        else if (k[i] == 0) ;
        else if (k[i] > w) ng = 1;
        else {
          B |= 1LL<<i;
          B += k[i]-1;
          A = B-w+1;
          break;
        }
      }
      if (A == -1) {
        if (w != 1) continue;
        A = B;
      }
      if (A<=0 || A>1000000000000000000LL ||
          B<=0 || B>1000000000000000000LL) continue;
      // cout << w << " " << bitset<3>(A) << " " << bitset<3>(B) << " " << ng << endl;
      // cout << count(A-1,0) << endl;
      REP(i,n) {
        ng |= (count(B,i)-count(A-1,i)) != k[i];
      }
      if (!ng) {
        ans.push_back(make_pair(A,B));
      }
    }
    if (ans.size() == 0) puts("None");
    else if (ans.size() > 1) puts("Many");
    else {
      cout << ans[0].first << " " << ans[0].second << endl;
    }
  }
}

Measured memory_bytes: 1200
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	f := 0
	for i := n; i > 0; i /= 10 {
		f += i % 10
	}
	if n%f == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()
    print(sum(P[:k]))
resolve()

Measured memory_bytes: 62052
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int n=in.nextInt();
			if(n==0)break;
			int nmin=in.nextInt(),nmax=in.nextInt(),A[]=new int[n];
			for(int i=0;i<n;i++)A[i]=in.nextInt();
			int max=0,res=0;
			for(int i=nmin-1;i<nmax;i++) {
				if(A[i]-A[i+1]>=max) {
					max=A[i]-A[i+1]; res=i;
				}
			}
			System.out.println(res+1);
		}
	}

}


Measured memory_bytes: 56980
#include<stdio.h>
int main(void){
  int x,y;
  int n;
  int scox,scoy;
  int i;
  while(1){
    scox=0;
    scoy=0;
    scanf("%d",&n);
    if(n==0)
      break;
    for(i=0;i<n;i++){
      scanf("%d %d",&x,&y);
      if(x>y)
	scox=scox+x+y;
      else if(x<y)
	scoy=scoy+x+y;
      else{
	scox=scox+x;
	scoy=scoy+y;
      }
    }
    printf("%d %d\n",scox,scoy);
  }
  return 0;
}
	
      

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const map<T, S> m) { for (pair<T, S> p: m) s << p << endl; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int N; cin >> N;
  int P; cin >> P;
  int ans = 1;
  for (int a = 1; a * a <= P; a++) {
    if (P % a) continue;
    int b = P / a;
    dump(a, b);
    for (int t: {a, b}) {
      int num = 0;
      int tmp = P;
      if (t == 1) continue;
      while (tmp % t == 0) {
        num++;
        tmp /= t;
      }
      dump(num);
      if (num >= N) {
        ans = max(ans, t);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int a[3];
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    rep(i,2) cout << a[i] << ' ';
    cout << a[2] << endl;
}


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

int n, x, y;
long long sum;

int main(void) {
  scanf("%d", &n);
  int mi = 0x3f3f3f3f, flg = 0;
  for(int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if(x != y) flg = 1;
    sum += x;
    if(x > y) mi = min(mi, y);
  }
  printf("%lld\n", !flg ? 0 : sum - mi);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){
    // Your code here!
    string str1,str2;
    cin>>str1>>str2;
    str1=str1+str1;
    
    for(int i=0; i<=str1.size()-str2.size(); i++){
        int count=0;
        for(int j=0; j<=str2.size()-1; j++){
            if(str1[i+j]==str2[j]){
                count+=1;
            }
        }
        if(count==str2.size()){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 3224
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==10||n==100||n==1000||n==10000||n==100000){
    cout<<10<<endl;
  }
  else cout<<-9*(n/100000)-9*(n/10000)-9*(n/1000)-9*(n/100)-9*(n/10)+n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,W;
  cin >> n >> W;
  vec v(n),w(n);
  for(ll i=0;i<n;i++) cin >> v[i] >> w[i];
  vec dp(W+1);
  for(ll i=0;i<n;i++) {
    for(ll j=W;j>=0;j--) {
      if(j-w[i]>=0) {
        dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
      }
    }
  }
  cout << dp[W] << endl;
}


Measured memory_bytes: 3196
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m;

int main(){
    scanf("%ld%ld", &n, &m);
    if(n == m){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 256
Sa = input()
Sb = input()
Sc = input()
Sa += 'A'
Sb += 'B'
Sc += 'C'
player = 'a'
while True:
  if player == 'a':
    player = Sa[0]
    Sa = Sa[1:]
  elif player == 'b':
    player = Sb[0]
    Sb = Sb[1:]
  elif player == 'c':
    player = Sc[0]
    Sc = Sc[1:]
  else:
    print(player)
    break

Measured memory_bytes: 3064
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
L = []
for i, x in enumerate(X):
  if i == 0:
    prev = x
  else:
    L.append(x - prev)
    prev = x
L.sort(reverse=True)
ind = N -1
print(sum(L[ind:]))

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 10;
vector<int> T[N];
vector<int> id[N];
int pp[N];
int tin[N];
int tout[N];
int subt[N];

int tt;

void dfs(int u, int par){
  pp[u]=par;
  subt[u]=1;
  tin[u] = ++tt;
  for(auto x : T[u]){
    if(x==par) continue;
    dfs(x,u);
    subt[u]+=subt[x];
  }
  tout[u]=tt;
}

vector<int> Q[N];

bool is_anc(int a, int b){
  return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int main(){
  fastIO;
  int n;
  cin >> n;
  int c;
  for(int i = 1; i <= n; i ++ ){
    cin >> c;
    id[c].push_back(i);
  }
  int u, v;
  for(int i = 1; i < n; i ++ ){
    cin >> u >> v;
    T[u].push_back(v);
    T[v].push_back(u);
  }
  T[0].push_back(1);
  dfs(0,-1);
  ll cur;
  ll sb;
  int pi;
  for(int k = 1; k <= n; k ++ ){
    vector<pii> nod;
    nod.push_back(mp(tin[0],0));
    for(auto x : id[k]){
      nod.push_back(mp(tin[x],x));
    }
    sort(nod.begin(), nod.end());
    vector<int> st;
    for(auto x : nod){
      while(!st.empty() && !is_anc(st.back(), x.se)) st.pop_back();
      if(!st.empty()){
        Q[st.back()].push_back(x.se);
      }
      st.push_back(x.se);
    }
    cur = 0;
    for(auto x : nod){
      pi = 0;
      for(auto y : T[x.se]){
        if(y==pp[x.se]) continue;
        sb=subt[y];
        while(pi < Q[x.se].size() && tout[Q[x.se][pi]] <= tout[y]){
          if(is_anc(y,Q[x.se][pi]))
            sb-=subt[Q[x.se][pi]];
          pi ++ ;
        }
        cur+=sb*1ll*(sb+1)/2ll;
      }
    }
    cout << n*1ll*(n+1)/2ll-cur << "\n";
    for(auto x : nod) Q[x.se].clear();
    sort(nod.begin(),nod.end());
  }
  return 0;
}

Measured memory_bytes: 50316
n = [int(c) for c in input()]
for i in range(2 ** 3):
    os = format(i, "03b").replace("1", "+").replace("0", "-")
    temp = n[0]
    for i, c in enumerate(os):
        num = n[i + 1]
        temp += num if c == "+" else -num
    if temp == 7:
        ans = "{}{}{}{}{}{}{}=7".format(n[0], os[0], n[1], os[1], n[2], os[2], n[3])
        break
print(ans)

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

using namespace std;

#define endl '\n'

typedef long long ll;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define _rep3(i,p,n) for(int i=(p),i##_counter=(n); i<i##_counter;++i)
#define _rep2(i,n,_) _rep3(i,0,n)
#define _rep_call(a, b, c, name, ...) name(a, b, c)
#define rep(...) _rep_call(__VA_ARGS__, _rep3, _rep2)

#define dump(x)  cerr << #x << " = " << (x) << '\n'
#define debug(x) cerr << #x << " = " << (x) << " (at line " << __LINE__ << ")" << " " << __FILE__ << '\n'

void Main() {
    int N, K, X, Y; cin >> N >> K >> X >> Y;
    cout << (min(K, N) * X + max(0, N - K) * Y) << endl;
}

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

Measured memory_bytes: 256
/*
問題文
縦 2 マス、横 3 マスのマス目が与えられます。上から i 行目、左から j 行目のマスの色は、Cij で表されます。
このマス目を 180 度回転させたとき、元のマス目と一致するなら YES を、そうでないなら NO を出力するプログラムを作成してください。
*/

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

int main(){
    // for string reverse
    auto reversed = [](std::string s){
        std::reverse(begin(s), end(s));
        return s;
    };
    // input lines
    std::vector<std::string> lines{};
    // input
    { auto tmp = std::string{}; while ( std::cin >> tmp ) lines.push_back(tmp); }
    // for odd: middle check
    if ( (lines.size() % 2 == 1) && lines[lines.size()/2] != reversed(lines[lines.size()/2])) goto NO;
    // compare: toward the center of both sides
    for(size_t i{},last = lines.size()-1; i < lines.size()/2; ++i) if (reversed(lines[i]) != lines[last-i]) goto NO;
    
    std::cout << "YES\n";
    return 0;
NO:
    std::cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100001)
#define MOD (1000000007)


//Union Find
int uf[MAXN];
int ufSize[MAXN];
void UFinit(int n)
{
    for(int i=0;i<n;i++)
    {
        uf[i] = i;
        ufSize[i] = 1;
    }
}

int UFroot(int i)
{
    if(uf[i]==i) return i;
    uf[i] = UFroot(uf[i]);
    return uf[i];
}

// 元々根が同じならfalse 違うなら統合してtrue
bool UFunite(int i,int j)
{
    int ri = UFroot(i);
    int rj = UFroot(j);

    if(ri == rj) return false;
    ufSize[ri] += ufSize[rj];
    uf[rj] = ri;
    return true;
}


ll as[MAXN];
ll a[MAXN];
ll b[MAXN];
ll bs[MAXN];

typedef struct 
{
    ll a;
    ll b;
}s;
int acs_a(const void *a, const void *b){return ((s*)a)->a - ((s*)b)->a;} /* 1,2,3,4.. */
int acs_b(const void *a, const void *b){return ((s*)a)->b - ((s*)b)->b;} /* 1,2,3,4.. */

s ss[MAXN];

int main(void)
{
    ll n;
    scanf("%ld",&n);

    for(int i=0;i<n;i++) scanf("%ld",&a[i]);
    for(int i=0;i<n;i++) scanf("%ld",&b[i]);
    for(int i=0;i<n;i++)
    {
        as[i] = a[i];
        bs[i] = b[i];
        ss[i].a = a[i];
        ss[i].b = b[i];
    }
    qsort(as,n,sizeof(ll),acs);
    qsort(bs,n,sizeof(ll),acs);

    qsort(ss,n,sizeof(s),acs_a);
    for(int i=0;i<n;i++) ss[i].a = i;
    qsort(ss,n,sizeof(s),acs_b);


    bool ans = true;
    for(int i=0;i<n;i++) if(as[i]>bs[i]) ans =false;
    
    if(!ans)
    {
        printf("No\n");
        return 0;
    }

    UFinit(n);
    for(int i=0;i<n;i++) UFunite(i,ss[i].a);

    if(ufSize[UFroot(0)]==n)
    {
        ans = false;
        for(int i=0;i<n-1;i++)
        {
            if(as[i+1]<=bs[i])
            {
                ans = true;
                break;
            }
        }
    }else ans = true;

    printf("%s\n", ans?"Yes":"No");
    return 0;
}


Measured memory_bytes: 7832
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static int N, M, KEYSIZE, TOP, ENTRYPRE;
	static TreeMap<Dataa, Integer> map = new TreeMap<>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			int pre = sc.nextInt();
			int year = sc.nextInt();
			map.put(new Dataa(pre, year), ++KEYSIZE);
		}
		Dataa tempDa = null;

		for (Map.Entry<Dataa, Integer> entry : map.entrySet()) {
			tempDa = entry.getKey();
			int tempPre = tempDa.getPre();
			if (ENTRYPRE != tempPre) {
				TOP = 0;
				ENTRYPRE = tempPre;
			}
			tempDa.setYear(++TOP);
		}
		Comparator<Map.Entry<Dataa, Integer>> valueComparator = new Comparator<Map.Entry<Dataa, Integer>>() {
			public int compare(Entry<Dataa, Integer> o1, Entry<Dataa, Integer> o2) {
				return o1.getValue() - o2.getValue();
			}
		};
		List<Map.Entry<Dataa, Integer>> list = new ArrayList<Map.Entry<Dataa, Integer>>(map.entrySet());
		Collections.sort(list, valueComparator);
		for (Map.Entry<Dataa, Integer> entry : list) {

			System.out.println(forMatSize("" + entry.getKey().getPre()) + forMatSize("" + entry.getKey().getYear()));
		}

	}

	public static String forMatSize(String str) {
		int len = ("" + str).length();
		for (int i = 0; i < 6 - len; i++) {
			str = "0" + str;
		}
		return str;
	}

}

class Dataa implements Comparable<Dataa> {

	private int pre;
	private int year;

	public Dataa(int pre, int year) {
		super();
		this.pre = pre;
		this.year = year;
	}

	public int getPre() {
		return pre;
	}

	public void setPre(int pre) {
		this.pre = pre;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int compareTo(Dataa o) {
		// System.out.println("===");
		int val = this.pre - o.pre;
		if (val != 0) {
			return val;
		} else {
			return this.year - o.year;
		}
	}

	@Override
	public String toString() {
		return this.pre + "-" + this.year;
	}

	public int hashCode() {
		return this.year * 100;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == this)// 自己和自己比较
			return true;// 那就是同一个相等了
		// 传入的引用不为空，而且两个的类型一样
		if (obj != null && obj.getClass() == this.getClass()) {
			Dataa da = (Dataa) obj;// 类型转换
			return this.year == da.year;
			// 如果两个的编号一样，那就认为相等
		}
		return false;
	}
}

Measured memory_bytes: 104960
#ika tako
import sys 
 
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
 
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]
 
    def count(self, x):
        return -self.table[self._root(x)]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

n, m, k = map(int, sys.stdin.buffer.readline().split())
abcd = list(map(int, sys.stdin.buffer.read().split()))
uft = UnionFind(n)
friends = [0 for _ in range(n)]
blocks = [set() for _ in range(n)]
for a, b in zip(abcd[0:2 * m:2], abcd[1:2 * m:2]):
    a -= 1
    b -= 1
    uft.union(a, b)
    friends[a] += 1
    friends[b] += 1
for c, d in zip(abcd[2 * m::2], abcd[2 * m + 1::2]):
    c -= 1
    d -= 1
    blocks[c].add(d)
    blocks[d].add(c)
ans = []
for i in range(n):
    ans.append(uft.count(i) - 1 - friends[i] - sum(uft.find(i, j) for j in blocks[i]))
print(*ans)

Measured memory_bytes: 60724
#include<stdio.h>
    int main(){
        int x, a, b;
            scanf("%d%d%d", &x, &a, &b);
                if(x <= a){
                    a = a - x;
                }else{
                    a = x - a;
                }
                if(x <= b){
                    b = b - x;
                }else{
                    b = x - b;
                }
                    if(a <= b){
                        printf("A");
                    }else{
                        printf("B");
                    }
    }

Measured memory_bytes: 128
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 70
using namespace std;

int a[N];

int main(void)
{
    int n;
    int i, j, o;

    cin >> n;
    for(i = 0; i < n; i ++)
        cin >> a[i];
    for(i = o = 0; i < n; i ++)
        for(j = 0; j < i; j ++)
            o += a[i] * a[j];
    cout << o << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
c=s.count("9")
if c==len(s):
    print(c*9)
elif len(s)==1:
    print(s)
elif s[1:].count("9")==len(s)-1:
    print(s[1:].count("9")*9+int(s[0]))
else:
    print((len(s)-1)*9+int(s[0])-1)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,m;
  cin >> n >> m;
  UnionFind<int> tree(n);
  rep(i,m){
    ll l,r,d;
    cin >> l >> r >> d;
    l--;
    r--;
    if(tree.issame(l,r)){
      if(tree.diff(l,r)!=d){
        cout << "No"<< endl;
        return 0;
      }
    }
    tree.merge(l,r,d);
  }
  cout << "Yes"<<endl;
}


Measured memory_bytes: 1536
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    if(n%1000==0)cout<<0<<endl;
    else cout<<(n/1000+1)*1000-n<<endl;
}





























































































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

int main() {
  string s;
  cin >> s;
  vector<int> counter(3);
  for(int i=0;i<3;i++) {
    if(s[i] == 'a') {
      counter[0]++;
    } else if(s[i] == 'b') {
      counter[1]++;
    } else {
      counter[2]++;
    }
  }

  if(counter[0]==1&&counter[1]==1&&counter[2]==1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
function *main() {
  let n = Number(yield);
  for(let i=1; i<=10; i++){
    if(n<=i*1000){
      console.log(i*1000-n);
      return;
    }
  }
}
const iter = main();
iter.next();
require("readline").createInterface(
  {input: process.stdin, output: process.stdout}
).on("line", line => iter.next(line));

Measured memory_bytes: 30052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int h, w, K;
	cin >> h >> w >> K;
	string s[h];
	for(int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int ans = inf;
	for(int i = 0; i < (1LL << (h - 1)); i++) {
		vi v, prv;
		for(int j = 0; j < h - 1; j++) {
			if(i & (1LL << j)) {
				v.pb(j);
			}
		}
		v.pb(h - 1);
		bool ok = 1;
		int sum[v.size()] = {0};
		for(int j = 0; j < w; j++) {
			for(int k = 0; k < v.size(); k++) {
				if(k == 0) {
					for(int l = 0; l <= v[k]; l++) {
						sum[k] += (s[l][j] == '1');
					}
				}
				else {
					for(int l = v[k - 1] + 1; l <= v[k]; l++) {
						sum[k] += (s[l][j] == '1');
					}
				}
			}
			bool flag = 0;
			for(int k = 0; k < v.size(); k++) {
				if(sum[k] > K) {
					if(!prv.empty() && (prv.back() == j - 1)) {
						ok = 0;
					}
					else if(prv.empty() && (j == 0)) {
						ok = 0;
					}
					flag = 1;
				}
			}
			if(!ok) {
				break;
			}
			if(flag) {
				memset(sum, 0, sizeof(sum));
				prv.pb(j - 1);
				j--;
			}
		}
		if(!ok) {
			continue;
		}
		ans = min(ans, (int)v.size() + (int)prv.size() - 1);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int s = N / 1000;
  if(N % 1000 > 0) {
    cout << (s + 1) * 1000 - N << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3632
n=int(input())
L=[chr(i) for i in range(97, 97+26)]


temp=26
count=1
while True:
    if n<=temp:
        break
    else:
        count+=1
        temp+=26**count

unthink=temp-26**count
think=n-unthink

ans=''
think-=1
for i in range(count)[::-1]:
    now=think//(26**i)
    ans+=L[now]
    think=think%(26**i)

print(ans)






Measured memory_bytes: 9052
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) begin(c), end(c)
template<class T> void read(T& x){ cin>>x; }
void read(int& x){ scanf("%d", &x); }
void read(int64_t& x){ scanf("%lld", &x); }
void read(double& x){ scanf("%lf", &x); }
template<class T, class U, class... V>
void read(T& x, U& y, V&... z){ read(x); read(y, z...); }

int main(){
    string s; read(s);
    int n = s.size();
    vector<int> v(n);
    REP(i,n){
        switch(s[i]){
            case '0': v[i]=0; break;
            case '1': v[i]=1; break;
            case '2': v[i]=2; break;
            case '3': v[i]=3; break;
            case '4': v[i]=4; break;
            case '5': v[i]=5; break;
            case '6': v[i]=6; break;
            case '7': v[i]=7; break;
            case '8': v[i]=8; break;
            case '9': v[i]=9; break;
        }
    }
    int64_t ans=0;
    int i,j=0;
    for(int bit=(1<<(n-1)); bit<(1<<n); ++bit){
        for(i=0; i<n; ++i){
            ans+=v[n-1-i]*pow(10,j);
            if(bit&(1<<i)) j=0;
            else ++j;
        }
    }
    printf("\n%lld",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
map<char,int>a[50];
int main(){
    int n;
    cin >> n;
    string s;
    rep(i,n){
        cin >> s;
        rep(j,s.size()){
            a[i][s[j]]++;
        }
    }
    string ans = "";
    rep(i,26){
        char c = (char)('a'+i);
        int k = 100;
        rep(j,n){
            k = min(k,a[j][c]);
        }
        rep(j,k){
            ans+=c;
        }
    }
    cout << ans << endl;
    
}

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


int main(){
	
	int H,N;
	cin>>H>>N;
	
	vector<int> A(N),B(N);
	
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i];
	}
	
	vector<vector<int>> dp(N+1,vector<int>(H+1,Inf));
	
	dp[0][0] = 0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=H;j++){
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
			int next = min(j + A[i],H);
			dp[i][next] = min(dp[i][next],dp[i][j] + B[i]);
		}
	}
	
	cout<<dp.back().back()<<endl;
	
	
	return 0;
}

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

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		char c = 0;


		ArrayList<Double> al = new ArrayList<Double>();
		ArrayList<Integer> al2 = new ArrayList<Integer>();

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			if(tes.equals("")){
				break;
			}
//			try{
				String[] fruit = tes.split(" ", 0);
				al.add(Double.parseDouble(fruit[0])/Double.parseDouble(fruit[1]));
				al2.add(Integer.parseInt(fruit[2]));
//			}catch(NumberFormatException e){
//				break;
//			}

			
			//al.add(a);
		}
		
		for(int r=0;r<al.size();r++){
			String sss = String.valueOf(al.get(r));
			int e = -1;
			int pri = 0;
			for(int i=0;i<sss.length();i++){
				if(e == al2.get(r)){
					break;
				}
				if(e >= 0){
					pri += Integer.parseInt(String.valueOf(sss.charAt(i))); 
					e++;
				}
				if(sss.charAt(i) == '.'){
					e = 0;
				}
			}
			
			System.out.println(pri);
		}
		
		
	}

}

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

int main()
{
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > c) swap(a, c);
    cout <<(a == 5 && b == 5 && c == 7 ? "YES" : "NO");
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
int n,k;
int ans=0;
int tri(int n){
    return n*(n+1)/2;
}
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3&&i%5)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  vector<int> nums = {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};

  int K;
  cin >> K;

  cout << nums[K - 1] << endl;
}

Measured memory_bytes: 768
package main

import (
	"fmt"
	"math"
)

var O, E, ans string

func main() {
	fmt.Scan(&O, &E)

	m := make([]string, len(O)+len(E))

	var i, j, k int
	for i < len(O)+len(E) {
		if i%2 == 1 {
			m[i] = string(E[j])
			j++
		} else {
			m[i] = string(O[k])
			k++
		}
		i++
	}

	for _, value := range m {
		fmt.Printf("%s", value)
	}

}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512