akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int ix=x/100;
		int jx=x/101;
		int kx=x/102;
		int lx=x/103;
		int mx=x/104;
		boolean f=false;
LABEL:	for (int i = 0; i <= x; i+=100) {
			for (int j = 0; j <= x-i; j+=101) {
				for (int k = 0; k <= x-i-j; k+=102) {
					for (int l = 0; l <= x-i-j-k; l+=103) {
						for (int m = 0; m <= x-i-j-k-l; m+=104) {
							int tmp = x-i-j-k-l-m;
							if(tmp>=0 && tmp%105==0) {
								f=true;
								break LABEL;
							}
						}
					}
				}
			}
		}
		out.println(f?1:0);
	}
}


Measured memory_bytes: 22736
#include <stdio.h>
int main()
{
    int a,c,x,y;
    for(a=1;;a++)
    {
        scanf("%d %d",&x,&y);
        if(x!=0||y!=0)
            {
                if(x<y){printf("%d %d\n", x,y); }
                else{printf("%d %d\n",y,x);}

        }
        else break;
    }
    return 0;
}



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

int result(long long value){
    int count = 0;
    long long  deposit = 100;
    
    while(value > deposit)
    {
        deposit += deposit * 0.01;
        count++;
    }
    
    return count;
}

int main(void){
    long long x;
    cin >> x;
    cout << result(x) << endl;
}


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

using namespace std;

typedef long long ll;

const int maxn=1e6+5,mod=1e4+7;
const double pi=acos(-1);

int ispl(int l,int r,string s)
{
    int i;
    for(i=l;i<r;i++)
        if(s[i]!=s[r-i-1])
        return 0;
    return 1;
}

int main()
{
    string s;
    while(cin>>s)
    {
        int len;
        len=s.length();
        if(ispl(0,len,s)&&ispl(0,(len-1)/2,s)&&ispl((len+3)/2,len,s))
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = N * 2;

int n;
int h[N], e[M], w[M], ne[M], idx;
int dist[N], q[M];

void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int fa, int d)
{
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (j == fa) continue;
		
		dist[j] = dist[u] + w[i];
		dfs(j, u, dist[j]);
	}
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b, c), add(b, a, c);
	}
	
	dfs(1, -1, 0);
	
	// memset(dist, -1, sizeof dist);
	// int hh = 0, tt = -1;
	// dist[1] = 0;
	// q[ ++ tt] = 1;
// 	
	// while (hh <= tt)
	// {
		// int t = q[hh ++ ];
// 		
		// for (int i = h[t]; ~i; i = ne[i])
		// {
			// int j = e[i];
			// if (dist[j] >= 0) continue;
// 			
			// q[ ++ tt] = j;
			// dist[j] = dist[t] + w[i];
		// }
	// }
	
	for (int i = 1; i <= n; i ++ ) printf("%d\n", dist[i] & 1);
    return 0;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

template<typename T> T& updMin(T& a, T const& b) { if (b < a) a = b; return a; }
template<typename T> T& updMax(T& a, T const& b) { if (a < b) a = b; return a; }

// ========================================================================= //

int main() {
    ios::sync_with_stdio(false);

    int sx, sy;
    cin >> sx >> sy;
    int n;
    cin >> n;
    vector<set<int>> o(sy);
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        o[y].insert(x);
    }

    if (sx == 1 || o[0].count(1)) {
        cout << 1 << "\n";
        return 0;
    }

    int ans = sx;
    int x = 1, y = 0;
    while (true) {
        auto it = o[y].lower_bound(x);
        if (it != o[y].end())
            updMin(ans, *it);
        if (ans == x + 1)
            break;
        if (y != sy - 1 && !o[y + 1].count(x)) {
            ++y;
            if (o[y].count(x + 1) || x + 1 == sx) {
                updMin(ans, x + 1);
                break;
            }
            ++x;
        } else {
            ++x;
        }
    }
    cout << ans << "\n";

    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {


            String line =br.readLine();
            
            
        int cnt =0;
        
        if(line.contains("a")){
            cnt++;
        }
        if(line.contains("b")){
            cnt++;
        }
        if(line.contains("c")){
            cnt++;
        }
        
        if(cnt==3){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
            
            






        }
    }
}

Measured memory_bytes: 25044
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
vector<int> tre[100010];

int T[100010];//1-indexed
int A[100010];//1-indexed
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int N,u,v;cin>>N>>u>>v;
  for(int i = 0; N-1 > i; i++){
    //uからvの直線距離を求める
    int a,b;cin>>a>>b;
    tre[a].push_back(b);
    tre[b].push_back(a);
  }
  queue<P> t;
  t.push({u,1});
  while(!t.empty()){
    P k = t.front();
    t.pop();
    if(T[k.first]){
      continue;
    }
    T[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      t.push({tre[k.first][i],k.second});
    }
  }


  queue<P> a;
  a.push({v,1});
  while(!a.empty()){
    P k = a.front();
    a.pop();
    if(A[k.first]){
      continue;
    }
    A[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      a.push({tre[k.first][i],k.second});
    }
  }
  int ans = 0;
  int nya = 0;
  for(int i = 1; N >= i; i++){
    if(T[i] < A[i]){
      if(A[i]%2 == T[i]%2){
        ans = max(ans,A[i]-2);
        //cout << A[i]-2 << endl;
      }else{
        ans = max(ans,A[i]-1);
        //cout << A[i]-1 << endl;
      }
      //ans = max(ans,T[i]);
      
    }
    //cout << i << ":" << T[i] << " " << A[i] << endl; 
  }
  //距離が偶数の場合
  if((T[v]%2)){
    ans++;
  }
  {
    cout << ans-1 << endl;
  }
}


Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct items{
    ll a,b,s;
};

bool asc( const items& left, const items& right ) {
    return left.s == right.s ? left.a < right.a : left.s < right.s;
}
int main(){
    

    ll n;
    cin >> n;
    vector <items> v;
    for (ll i=0;i<n;i++){
        items p;
        cin >> p.a >> p.b;
        p.s = p.a + p.b;
        v.push_back(p);
    }
    sort(v.begin(), v.end(), asc);
    reverse(v.begin(), v.end());
    ll taka = 0;
    ll ao = 0;
    for (ll i=0;i<v.size();i++){
        if(i%2 == 0){
            taka += v[i].a;
        }else{
            ao += v[i].b;
        }
    }
    cout << taka - ao << endl;

}


Measured memory_bytes: 4724
N=int(input())
S=''

if N==0 or N==1:
  S=str(N)
else:
  while N!=1:
    if N%(-2)==-1:
      N=N//(-2)+1
      remainder=1
    else:
      N=N//(-2)
      remainder=0
    S=str(remainder)+S
    if N==1:
      S='1'+S

print(S)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int dp[100100];
    dp[0] = 0;
    for (int n = 1; n <= 100000; ++n){
        dp[n] = 1 << 30;
        int power = 1;
        while (power <= n)
        {
            dp[n] = min(dp[n], dp[n - power] + 1);
            power = power * 6;
        }
        power = 1;
        while (power <= n)
        {
            dp[n] = min(dp[n], dp[n - power] + 1);
            power = power * 9;
        }
    }
    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main {
    public void kami() {
        		Scanner sc = new Scanner(System.in);
		int x = 0;
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		
		while(!op.equals("?")){
			if(op.equals("+")){
				x = a + b;
				System.out.println(x);
			}else if(op.equals("-")){
				x = a - b;
				System.out.println(x);
			}else if(op.equals("*")){
				x = a * b;
				System.out.println(x);
			}else if(op.equals("/")){
				x = a / b;
				System.out.println(x);
			}
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
		}

    }
	public static void main(String[] args) {
    new Main().kami();
	}

}

Measured memory_bytes: 18184
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a[10];int k;
	rep(i,5) cin>>a[i];cin>>k;
	if(a[4]-a[0]>k) cout<<":("<<endl;else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0 for _ in range(N)]

    a = A[0]
    max_profit = 0
    for i in range(N):
        a = min(a, A[i])
        B[i] = A[i] - a
        max_profit = max(max_profit, A[i] - a)

    cnt = 0
    for b in B:
        if b == max_profit:
            cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())


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

int main() {
  int n;
  string s,t;
  cin >> n >> s >> t;
  rep(i,0,n){
    if(s.substr(i) == t.substr(0,n-i)){
      cout << n+i << endl;
      return 0;
    }
  }
  cout << 2*n << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main() {
	int a[10],n,count=0;
	while(scanf("%d", &n) != EOF) {
		if (n == 0) {
			printf("%d\n", a[count - 1]);
			count--;
		}
		else {
			a[count] = n;
			count++;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define int long long 
#define mod 1000000007 
using namespace std ;

int32_t main(){

	 ios::sync_with_stdio(false) ; cin.tie(NULL) ; 
	 
	 int k;
	 string s;
	 cin>>k;
	 cin>>s;
	 if(s.size()<=k)
	 cout<<s;
	 else
	 {
	 	string x="";
	 	for(int i=0;i<k;i++)
	 	x=x+s[i];
	 	x=x+"...";
	 	cout<<x;
	 }
	 
	 



}

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

using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define INF 1e9

struct edge{
    int to;
    int length;
    int cost;
    bool operator>(const edge &e)const{
        if(length != e.length) return length > e.length;
        return cost > e.cost;
    }
};

void dijkstra(vector<vector<edge> > &g, vector<int> &dist, vector<int> &cost, vector<int> &prev, int s){
    priority_queue<edge, vector<edge>, greater<edge>> pq;
    int V = g.size();

    for(int i=0;i<V;i++){
        cost[i] = (i==s) ? 0 : INF;
        dist[i] = (i==s) ? 0 : INF;
    }
    pq.push((edge){s,0,0});

    while(!pq.empty()){
        auto v = pq.top(); pq.pop();
        if(dist[v.to] < v.length) continue;

        if(dist[v.to] != INF and v.to != 0){
            cost[v.to] = min(cost[v.to], v.cost);
        }

        for(auto next_v:g[v.to]){
            if(next_v.to != v.to and next_v.length + dist[v.to] <= dist[next_v.to]){
                dist[next_v.to] = next_v.length + dist[v.to];
                pq.push((edge){next_v.to,dist[next_v.to], next_v.cost });
            }
        }
    }
}


int main(){
    while(true){
        int N,M;
        cin >> N >> M ;

        if(N == 0 and M == 0)
            break;
        vector<vector<edge> > vertices(N);
        FOR(i,0,M){
            int u,v,d,c;
            cin >> u >> v >> d >> c ;
            u--;
            v--;

            vertices[v].push_back((edge){u,d,c});
            vertices[u].push_back((edge){v,d,c});
        }
        vector<int> dist(N);
        vector<int> cost(N);
        vector<int> prev(N);

        dijkstra(vertices,dist,cost,prev,0);
        cout << accumulate(begin(cost),end(cost),0) << endl;
    }

    return 0;
}

Measured memory_bytes: 2460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define PI 3.14159265359
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
//============================================================================
void enter(FILE *file)
{
    int m,f,r; char res;

    while(1){
        fscanf(file, "%d", &m);
        fscanf(file, "%d", &f);
        fscanf(file, "%d", &r);
        if (m==-1 && f==-1 &&r==-1)
            return;
        if (m==-1 || f==-1)
           res='F';
        else
        if (r==-1){
            r=m+f;
            if (80<=r) res='A';
            else
            if (65<=r) res='B';
            else
            if (50<=r) res='C';
            else
            if (30<=r) res='D';
            else
               res='F';
        }else{
            res='D';
            if (m+f<30) res='F';
            else
            if (50<=r) res='C';
        }
        printf("%c\n", res);
    }
}
//============================================================================
             
#ifndef DESKTOP
int main(void)
{
    enter(stdin);
    return 0;
}
#endif

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int taka_cnt = a / d + 1;
	if (a % d == 0) taka_cnt--;
	int aoki_cnt = c / b + 1;
	if (c % b == 0) aoki_cnt--;


	if (taka_cnt >= aoki_cnt) cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	
	return 0;
	
}



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

int main() {
    int N,S=1;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; i++){
    cin >> d.at(i);
  }
    sort(d.begin(), d.end());
    for (int i=1; i<N; i++){
    if (d.at(i) > d.at(i-1))
      S++;
  }
  cout << S << endl;
    
}


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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<llint> march(5, 0);
  for (int i = 0; i < n; i++) {
    if (s[i][0] == 'M') march[0]++;
    if (s[i][0] == 'A') march[1]++;
    if (s[i][0] == 'R') march[2]++;
    if (s[i][0] == 'C') march[3]++;
    if (s[i][0] == 'H') march[4]++;
  }
  llint ans = 0;
  for (int i = 0; i + 2 < 5; i++) {
    for (int j = i + 1; j + 1 < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        if (march[i] == 0 || march[j] == 0 || march[k] == 0) continue;
        ans += march[i] * march[j] * march[k];
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(a.begin(), a.end());

    ll b;
    if(n&1){
        b = a[(n-1)/2];
    }else{
        b = (a[n/2] + a[n/2 -1])/2;
    }

    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += abs(a[i] - b);
    }
    cout << sum << endl;
}



Measured memory_bytes: 1792
N, P = map(int, input().split())
ans = 1

if N >= 45:
  print(ans)
elif N == 1:
  print(P)
  

  
else:
  i = 1
  while(i**N <= P):
    if P % (i**N) == 0:
      ans = i
    i += 1
  print(ans)

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

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

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

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

    sort(a.begin(), a.end());

    int cnt = 0;
    int c = -1, b = -1;
    for (int i = n - 2; i >= 0; i--) {
        if (a[i] == a[i + 1] && c == -1) {
            c = a[i];
            i--;
        } else if (a[i] == a[i + 1]) {
            b = a[i];
            break;
        }
    }

    if (c == -1 || b == -1) {
        cout << 0 << endl;
    } else {
        LL d = (LL)c * b;
        cout << d << endl;
    }

    return 0;
}


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

int main() {

  int N = 0;
  cin >> N;

  int64_t sum = 0;
  for(int i = 1; i < N+1; i++){
    if(i % 3 == 0){
//            cout << i << endl;
    }
    else if(i % 5 == 0){
//            cout << i << endl;
    }
    else{
     sum += i;
    }
  }
  
  cout << sum << endl;
  
}


Measured memory_bytes: 3636
a,b,c = map(int,input().split())

ch = 1
for i in a,b,c:
    if(i%2==0):
        ch = 0

ans = 0
 
if(ch!=0):
    if(a == max(a,b,c)):
        ans = b*c
    elif(b == max(a,b,c)):
        ans = a*c
    else:
        ans = a*b
        
print(ans)

Measured memory_bytes: 38384
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, t = map(int, readline().split())
    a = list(map(int, readline().split()))
    ans = 0
    end = 0
    for x in a:
        if end <= x:
            ans += t
            end = x + t
        else:
            ans += (t - (end - x))
            end = x + t
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 103728
fun main(args : Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val sd = mutableMapOf<Char, Int>()
    val td = mutableMapOf<Char, Int>()

    var dummy = 0

    for (i in s.indices) {
        val si = sd[s[i]] ?: dummy
        val ti = td[t[i]] ?: dummy

        if (si != ti) {
            println("No")
            return
        }

        sd[s[i]] = si
        td[t[i]] = ti
        dummy++
    }

    println("Yes")
}

Measured memory_bytes: 40696
#include <iostream>
#define zmin(a,b) a=(a<b&&a>0?a:b)
using namespace std;
int main(){
	int i,j,n,k,s,d,c,f;
	while(cin>>n>>k,n){
		int boat[101][101]={0};
			while(k--){
			cin>>f>>s>>d;
			if(f){
				cin>>c;
				zmin(boat[s][d],c);
				boat[d][s]=boat[s][d];
			}else{
				int D[101]={0},v[101]={0};
				while(!v[d]){
					int m=-1;
					for(i=1;i<=n;i++) if(boat[s][i]) zmin(D[i],D[s]+boat[s][i]);
					v[s]=1;
					for(i=1;i<=n;i++) if(!v[i]&&D[i]&&(m<0||D[i]<D[m])) m=i;
					if(m<0)break;
					s=m;
				}
				cout<<(v[d]?D[d]:-1)<<endl;
			}
		}
	}
}

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

const int MAX_V=100;
int V;
vector<pair<int,ll>> G[MAX_V];
ll d[MAX_V];
bool check[105][105];
ll edge[105][105];

void dijkstra(int s){
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que;
  rep(i,V) d[i]=1e18;
  d[s]=0;
  que.emplace(0,s);

  while (!que.empty()) {
    pair<ll,int> p=que.top(); que.pop();
    int v=p.second;
    if (d[v]<p.first) continue;
    for (auto e: G[v]) {
      if (d[e.first]>d[v]+e.second) {
	d[e.first]=d[v]+e.second;
	que.emplace(d[e.first],e.first);
      }
    }
  }
}

int main(){
  int m;
  cin>>V>>m;
  rep(i,m){
    int a,b;
    ll c;
    cin>>a>>b>>c;
    a--; b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
    edge[a][b]=c;
    edge[b][a]=c;
  }
  int ans=0;
  rep(i,V){
    dijkstra(i);
    rep(j,V) rep(k,V){
      if(edge[j][k]==0) continue;
      if(d[j]==d[k]+edge[j][k]){
	check[j][k]=true;
	check[k][j]=true;
      }
    }
  }
  rep(i,V) rep(j,i) {
    if(edge[i][j]!=0&&check[i][j]==false)
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 384
#include <iostream>

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

struct Node {
  long long data;
  Node *prev;
  Node *next;
};

Node *nil;

void printList(Node *node) {
  Node *next = node->next;

  std::cout << next->data;
  if (next->next == nil) {
    std::cout << '\n';
    return;
  } else {
    std::cout << ' ';
    printList(next);
  }
}

void insertNode(long long key) {
  Node *x = new Node{key, nil, nil};
  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;
}

Node *searchNode(long long key, Node *node) {
  Node *next = node->next;

  if (next == nil) {
    return nil;
  } else {
    if (next->data == key)
      return next;
    else
      return searchNode(key, next);
  }
}

void deleteNode(long long key) {
  Node *x = searchNode(key, nil);
  if (x == nil)
    return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
  delete x;
}

void deleteFirst() {
  nil->next->next->prev = nil;
  nil->next = nil->next->next;
}

void deleteLast() {
  Node *last = nil->prev;
  last->prev->next = nil;
  nil->prev = last->prev;
}

int main() {
  int n;
  std::cin >> n;
  std::string com;
  long long key;

  nil = new Node();
  nil->prev = nil;
  nil->next = nil;

  rep(i, n) {
    std::cin >> com;
    if (com == "insert") {
      std::cin >> key;
      insertNode(key);
    } else if (com == "delete") {
      std::cin >> key;
      deleteNode(key);
    } else if (com == "deleteFirst") {
      deleteFirst();
    } else if (com == "deleteLast") {
      deleteLast();
    }
  }

  printList(nil);

  return 0;
}


Measured memory_bytes: 43792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = "";
		int sum = 0;
		while(sc.hasNext()){
			S = sc.nextLine();
		}
		char[] temp = S.toCharArray();
		char[] right = "CODEFESTIVAL2016".toCharArray();
		for(int i=0;i<temp.length;i++){
			if(temp[i]!=right[i]){
				sum+=1;
			}
		}
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 10068
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define lld long long
#define pi pair<lld,lld>
#define mod 1000000007
#define N 2000005
#define pb push_back
lld fact[N],ifact[N];
lld expo(lld a,lld b)
{
    if(b==0) return 1; if(b==1) return a%mod;
    lld z=expo(a,b/2);
    z=(z%mod*z%mod)%mod;
    if(b%2) z=(z*a)%mod;
    return z;
}
lld ncr(lld n,lld r)
{
    if(r>n) return 0;
    if(r==n) return 1;
    lld mm=fact[n]*ifact[n-r]%mod;
    mm=mm*ifact[r]%mod;
    return mm;
}
void pre(){
    fact[0] = 1;
    ifact[0] = 1;
    rep(i,1,N){
        fact[i] = i;
        fact[i] *= fact[i-1];
        fact[i] %= mod;;
        ifact[i] = expo(fact[i],mod - 2);
    }
}
vector < int > z_function ( string s ) {
    int n = (int)s.length();
    vector<int> z(n);
    for (int i = 1,l=0,r=0;i<n;++i){
        if (i<=r)
            z[i] = min(r-i+1,z[i-l]);
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]])
            ++z[i];
        if(i+z[i]-1>r)
            l=i,r=i+z[i]-1;
    }
    return z ;
}

lld max(lld a,lld b){return a>b?a:b;}

int main()
{
   // pre();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("/home/ankit/input_10.txt","r",stdin);
    // freopen("/home/ankit/out10.txt","w",stdout);
    lld r;
    cin>>r;
    cout<<r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int a, b, c; cin >> a >> b >> c;
  bool flag = false;
  int limit = 0;
  for(int i = 0; limit <= b ; i += a) {
    if(i%b == c) flag = true;
    ++limit;
  }
  cout << (flag ? "YES" : "NO") << '\n';
  return 0;
}


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

using namespace std;

long n, k, a;

int main() {
  scanf("%ld %ld", &n, &k);
  a = k;
  for (int i = 0; i < n - 1; i++) {
    a *= k - 1;
  }
  printf("%ld\n", a);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
int N;

int main() {
  INCANT;
  cin >> N;
  int ans = N==0;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
MOD = 998244353
sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sum_ie = (86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543, 109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 0, 0, 0, 0, 0, 0, 0, 0, 0)
class Convolution:
    # ROOT = 3
    def __init__(self):
        pass
        # global MOD
        # MOD = mod
        # # self.MOD = mod

    def __butterfly(self, arr):
        n = len(arr)
        h = (n - 1).bit_length()
        # MOD = self.MOD

        for ph in range(1, h + 1):
            w = 1 << (ph - 1)
            p = 1 << (h - ph)
            now = 1
            for s in range(w):
                offset = s << (h - ph + 1)
                for i in range(p):
                    l = arr[i + offset]
                    r = arr[i + offset + p] * now
                    arr[i + offset] = (l + r) % MOD
                    arr[i + offset + p] = (l - r) % MOD
                now *= sum_e[(~s & -~s).bit_length() - 1]
                now %= MOD

    def __butterfly_inv(self, arr):
        n = len(arr)
        h = (n - 1).bit_length()
        # MOD = self.MOD

        for ph in range(1, h + 1)[::-1]:
            w = 1 << (ph - 1)
            p = 1 << (h - ph)
            inow = 1
            for s in range(w):
                offset = s << (h - ph + 1)
                for i in range(p):
                    l = arr[i + offset]
                    r = arr[i + offset + p]
                    arr[i + offset] = (l + r) % MOD
                    arr[i + offset + p] = (MOD + l - r) * inow % MOD
                inow *= sum_ie[(~s & -~s).bit_length() - 1]
                inow %= MOD

    def __call__(self, a, b):
        n = len(a)
        m = len(b)
        # MOD = self.MOD
        if not n or not m: return []
        if min(n, m) <= 50:
            if n < m:
                n, m = m, n
                a, b = b, a
            res = [0] * (n + m - 1)
            for i in range(n):
                for j in range(m):
                    res[i + j] += a[i] * b[j]
                    res[i + j] %= MOD
            return res
        z = 1 << (n + m - 2).bit_length()
        a += [0] * (z - n)
        b += [0] * (z - m)
        self.__butterfly(a)
        self.__butterfly(b)
        for i in range(z):
            a[i] *= b[i]
            a[i] %= MOD
        self.__butterfly_inv(a)
        a = a[:n + m - 1]
        iz = pow(z, MOD - 2, MOD)
        for i in range(n + m - 1):
            a[i] *= iz
            a[i] %= MOD
        return a




def atcoder_practice2_f():
    import sys
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    convolution = Convolution()
    print(*convolution(A, B))


if __name__ == "__main__":
    atcoder_practice2_f()


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int pow_int(int a, int n)
{
    int i;
    int ans = 1;
    for(i = 0;i < n;++i){
        ans *= a;
    }
    return ans;
}

int main()
{
    int i,j;
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<ll> p(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i);
        cin >> y.at(i);
        cin >> p.at(i);
    }
    int bit = 0;

    vector<vector<int>> xmiti((1 << n), vector<int>(15, 0));
    vector<vector<int>> ymiti((1 << n), vector<int>(15, 0));
    for(bit = 0;bit < (1ll << n);++bit){
        set<int> yy;
        set<int> tt;
        for(i = 0;i < n;++i){
            if(bit & (1 << i)){
                yy.insert(x.at(i));
                tt.insert(y.at(i));
            }
        }
        yy.insert(0);
        tt.insert(0);
        vector<int> yoko;
        vector<int> tate;
        for(auto xx:yy){
            yoko.push_back(xx);
        }
        for(auto xx:tt){
            tate.push_back(xx);
        }

        for(i = 0;i < n;++i){
            int xa = lower_bound(all(yoko), x.at(i)) - yoko.begin();
            int ya = lower_bound(all(tate), y.at(i)) - tate.begin();
            int xd, yd;

            if(xa >= yoko.size()){
                xd = abs(x.at(i) - yoko.back());
            }else if(xa == 0){
                xd = abs(x.at(i) - yoko.front());
            }else{
                xd = min(abs(x.at(i) - yoko.at(xa)), abs(x.at(i) - yoko.at(xa-1)));
            }

            if(ya >= tate.size()){
                yd = abs(y.at(i) - tate.back());
            }else if(ya == 0){
                yd = abs(y.at(i) - tate.front());
            }else{
                yd = min(abs(y.at(i) - tate.at(ya)), abs(y.at(i) - tate.at(ya-1)));
            }

            xmiti.at(bit).at(i) = xd;
            ymiti.at(bit).at(i) = yd;
        }
    }
    
    vector<ll> ans(n+1, (1ll << 60));

    int INF = pow_int(3, n);
    for(bit = 0;bit < INF;++bit){
        int waru = INF/3;
        int tmpbit = bit;
        int m = 0;
        int bit1 = 0;
        int bit2 = 0;
        for(i = 0;i < n;++i){
            int tmp = tmpbit/waru;
            tmpbit -= tmp*waru;
            waru /= 3;

            if(tmp) ++m;
            if(tmp == 1) bit1 += (1 << i);
            else if(tmp == 2) bit2 += (1 << i);
        }

        ll tmpans = 0;
        for(i = 0;i < n;++i){
            ll xd = xmiti.at(bit1).at(i);
            ll yd = ymiti.at(bit2).at(i);
            tmpans += p.at(i)*min(xd, yd);
        }
        ans.at(m) = min(ans.at(m), tmpans);
    }

    for(i = 0;i <= n;++i){
        cout << ans.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 9748
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  ll n,m;
  string s,t;
  cin>>n>>m>>s>>t;
  if(n>m){
    swap(n,m);
    swap(s,t);
  }
  ll ans=lcm(n,m);
  ll p=ans/n,q=ans/m;
  for(int i=0;i<n;i++){
    if((i*p)%q==0){
      if(s.at(i)!=t.at((i*p)/q)){
      cout<<-1<<endl;
      return 0;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	vector<int>p(n);
	rep(i,n)cin>>p.at(i);
	rep(i,n){
		if(i==0||i==n-1)continue;
		if(p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1))ans++;
		if(p.at(i+1)<p.at(i)&&p.at(i)<p.at(i-1))ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
def dfs(n):
    if n not in memo:
        ans = min(dfs(n//2) + a + d*(n%2), dfs((n+1)//2) + a + d*(n%2), n*d)
        ans = min(ans, dfs(n//3) + b + d*(n % 3), dfs((n+2)//3) + b + d*(3 - n%3))
        ans = min(ans, dfs(n//5) + c + d*(n % 5), dfs((n+4)//5) + c + d*(5 - n%5))
        memo[n] = ans
    return memo[n]


t = int(input())

for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: 0, 1: d}
    print(dfs(n))

Measured memory_bytes: 88936
from sys import stdin, stderr
from bisect import bisect_right, bisect_left


def main():
    N = int(input())
    L = sorted([int(x) for x in input().split()])
    ret = 0

    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            c = L[i] + L[j] - 1
            k = bisect_right(L, c)
            # print(L[i], L[j], k, ret, file=stderr)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3188
#include<stdio.h>

int main(){
  
  int n,a,b;
  int temp,c;
  int count = 0;
  scanf("%d %d %d",&n,&a,&b);

  for(int i=1; i<=n; i++){
    c = i;
    for(int j=0; j<5; j++){
      temp += c % 10;
      c = c/10;
    }
//    printf("%d\n",temp);
    if(temp>=a && temp<=b){
      count += i;
    }
    temp = 0;
  }

  printf("%d",count);

}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a > c)
	{
		cout << c << endl;

	}
	else { cout << b / a << endl; }
	return 0;
}


Measured memory_bytes: 256
from collections import deque

def f(x):
    return num.count(x)

n = int(input())
a = list(map(int, input().split()))
num = deque([])
for i in a:
    if i%4==0:
        num.append(4)
    elif i%2==0:
        num.append(2)
    else:
        num.append(0)

if len(a)%2==1:
    if f(4)>=len(a)//2 or f(2)>=2*(n//2-f(4))+1:
        print('Yes')
        exit(0)
if len(a)%2==0:
    if f(2)>=2*(n//2-f(4)):
        print('Yes')
        exit(0)
print('No')


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> A[i];
    }

    vector<int> C(N);
    for (int i = 0; i < N - 1; i++)
    {
        C[A[i] - 1]++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4856
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //N<10^9なので、N はintに入るけど、その大体２乗であるMはintでは足りない
        int N = sc.nextInt();
        long M = (long)N * ((long)N - 1) / 2; //Nをlong型にキャストしないと、Mがintの判定で計算されるので注意
        System.out.println(M);


    }
}





Measured memory_bytes: 23124
N = int(input())
A = [int(x) for x in input().split()]

result = 1

if A.count(0) == 0:
    for x in range(N):
        result = result * A[x]
        if result >= 10**18 + 1:
            print(-1)
            exit()
    print(result)
else:
    print(0)


Measured memory_bytes: 21424
def bis_right(lis,dev):
    a=0
    b=len(lis)-1
    while a<b:
        c=(a+b)//2
        if lis[c]>dev:
            b=c
        else:
            a=c+1
    if lis[a]<=dev:
        return a
    return a-1



n=int(input())
l=[int(x) for x in input().split()]
l.sort()
s=0
for a in range(n-2):
    for b in range(a+1,n-1):
        c=bis_right(l[b+1:],l[a]+l[b]-1)
        s+=c+1
print(s)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin>>s;
  ll n=s.size();

  ll cur0=n;
  ll cur1=n;
  for(ll i=0; i<=n; i++){
    if(s[i]-'0'==0)
      cur0=min(cur0, max(i,n-1-i));

    if(s[i]-'1'==0)
      cur1=min(cur1, max(i,n-1-i));
  }

  cout<< max(cur0,cur1) <<endl;
}


Measured memory_bytes: 512
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,r;
  cin >> n >> r;
  if(n>=10){
    cout << r << endl;
  }else{
    cout << r + 100*(10-n)<<endl;
  }
}


Measured memory_bytes: 256
n = input()
s = list(map(str,input().strip().split()))

from collections import deque

d = deque()

for i,_s in enumerate(s):
  if i % 2 == 0:
    d.appendleft(_s)
  else:
    d.append(_s)
if len(s) %2 != 0:
  print(" ".join(list(d)))
else:
  print(" ".join(list(deque(reversed(d)))))

Measured memory_bytes: 28228
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long Int;

string s, t;
Int n, m;
Int dp[3300][3300];

int main() {
  cin >> s >> t;
  n = s.length();
  m = t.length();

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
      }
    }
  }

  string ans = "";
  while (0 < n && 0 < m) {
    if (dp[n][m] == dp[n][m - 1]) {
      m--;
    } else if (dp[n][m] == dp[n - 1][m]) {
      n--;
    } else {
      n--;
      m--;
      ans += s[n];
    }
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 80976
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];

    vector<ll> c(2*n);
    c[0]=min(a[0],b[0]);
    c[1]=min(a[1],b[0]-c[0]);
    for(int i=1;i<n;++i){
        c[2*i]=min(a[i]-c[2*i-1],b[i]);
        c[2*i+1]=min(a[i+1],b[i]-c[2*i]);
    }
    ll sum=0;
    rep(i,2*n){
        sum+=c[i];
    }
    cout<<sum<<endl;
}

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

int main(void){
  int r,d,x;
  cin >> r >> d >> x;
  vector<int> arr(10);
  arr[0] = r * x - d;
  for(int i = 1; i != 10; i++){
    arr[i] = arr[i - 1] * r - d;
  }
  for(int i = 0; i != 10; i++)cout << arr[i] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            String[] data = line.split(" ");
            int a = Integer.parseInt(data[0]);
            int b = Integer.parseInt(data[2]);
            if (data[1].equals("+")) {
                System.out.println(a + b);
            } else if (data[1].equals("-")) {
                System.out.println(a - b);
            } else if (data[1].equals("*")) {
                System.out.println(a * b);
            } else if (data[1].equals("/")) {
                System.out.println(a / b);
            } else if (data[1].equals("%")) {
                System.out.println(a % b);
            } else if (data[1].equals("?")) {
                break;
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26048
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int a[] = {0,2,0,1,0,1,0,0,1,0,1,0};
    int x,y;
    cin >> x >> y;
    if (a[x-1] == a[y-1]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
#include<string>

const int HMAX = 10;
const int WMAX = 1000;


/*
横のラインの引き方 2^(H-1)通り. Hが小さいのでこれはbit全探索.
あと縦にどう引くかであるが, これは
- 最後に縦をおラインを引いた地点からKを超えないギリギリのところでラインを引く
とすれば最小になる. これで計算量はO(2^H * HW)
*/


int main(){
    int H, W, K;
    std::cin >> H >> W >> K;
    std::vector<std::string> Choco(H);
    for(int i = 0; i < H; i++){
        std::cin >> Choco[i];
    }

    int res = INT_MAX;
    for(int bit = 0; bit < (1 << (H - 1)); bit++){
        int N = 0; // 横線の数
        std::vector<int> ord(H, 0); // 同じブロックごとに数字付け
        for(int i = 0; i < H - 1; i++){
            // bitが立っている
            if(bit & (1 << i)){
                ord[i + 1] = ord[i] + 1;
                N++;
            }else{
                // 立っていない
                ord[i + 1] = ord[i];
            }
        }


        int add = 0; // 縦線を何度引いたか
        bool gok = true; // これがfalseになればどんな風に縦線引いてもK超えていることになる
        std::vector<int> nums(N + 1, 0);
        for(int w = 0; w < W; w++){
            // wを固定
            std::vector<int> one(N + 1, 0);
            bool ok = true;
            // 白のブロック計算
            for(int h = 0; h < H; h++){
                one[ord[h]] += Choco[h][w] - '0';
                nums[ord[h]] += Choco[h][w] - '0';
                if(one[ord[h]] > K) gok = false;
                if(nums[ord[h]] > K) ok = false;
            }

            if(!gok) break; // どのように切ってもK超えるのでbreak
            if(!ok){
                // 今の縦線ではKを超えてしまった
                add++; // 縦線を引く
                nums = one; // 直前のデータ保存
            }
        }
        if(gok){
            res = std::min(res, N + add);
        }
    }

    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);


  int n,r;
  cin>>n>>r;
  if(n>=10){
    cout<<r<<endl;
  }else{
    cout<<r+(10-n)*100<<endl;
  }

  return 0;
}




Measured memory_bytes: 256