akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

char buf[100000+10];
int n;
const int MOD = 1000000007;
ll hist[30];

int main(void) {
  scanf("%d%s", &n, buf);
  REP(i, n) {
    hist[buf[i]-'a']++;
  }
  ll res = 1;
  REP(i, 26) {
    res = (res * (hist[i] + 1)) % MOD;
  }

  res = (res - 1 + MOD) % MOD;
  cout << res << endl;
  
  return 0;
}


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

if a != b != c and a != c:
    print(3)
if a == b and a != c and b != c: 
    print(2)
if b == c and b != a and c != a:
    print(2)
if a == c and a != b and c != b:
    print(2)
if a == b == c:
    print(1)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int i = in.nextInt();
            out.println(N - i + 1);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    int n; cin >> n;
    vector<int> clis(n);
    vector<int> anslis(n);
    vector<vector<int> > tree(n);
    vector<vector<int> > p(n-1, vector<int>(2, 0));
    REP(i, 0, n-1){
        int a, b; cin >> a >> b;
        a--; b--;
        p[i][0] = a; p[i][1] = b;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    ll sum = 0;
    REP(i, 0, n){cin >> clis[i];}
    sort(ALL(clis), greater<>());
    REP(i, 1, n){sum += clis[i];}
    cout << sum << endl;
    stack<ll> st;
    vector<int> used(n, -1);
    st.push(0);
    used[0] = 1;
    int ind = 0;
    while(!st.empty()){
        int k = st.top();
        st.pop();
        anslis[k] = clis[ind];
        ind++;
        REP(l, 0, tree[k].size()){
            if(used[tree[k][l]] == -1){
                used[tree[k][l]] = 1;
                st.push(tree[k][l]);
            }else{
                continue;
            }
        }
    }
    REP(i, 0, n){cout << anslis[i] << " ";}
}

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

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

    return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $k);

$flg = true;
for ($i = 0; $i < strlen($s); ++$i) {
    if ($s[$i] != 1) {
        $flg = false;
        break;
    }
}

if ($flg) {
    echo 1, PHP_EOL;
    return;
}

if ($k <= $i) {
    echo 1, PHP_EOL;
} else {
    echo $s[$i], PHP_EOL;
}



Measured memory_bytes: 4728
a = list(map(int, input().split()))
b = [i for i in range(1010)]
c = 0
for f in b:
  if f * 8 // 100 == a[0] and f * 10 // 100 == a[1]:
    print(f)
    c += 1
    break
if c == 0:
  print(-1)

Measured memory_bytes: 3060
fun main(array: Array<String>) {
    val s = readLine()!!.toInt()
    var list = mutableListOf<Int>()
    list.add(s)
    var ans = 0
    var temp = 0
    for(i in 1 until 100000) {
        if(list[i-1] % 2 == 0) {
            temp = list[i-1] / 2
        }
        else {
            temp = 3 * list[i-1] + 1
        }
        list.add(temp)
        repeat(i-1) {
            if(temp == list[it]) {
                ans = it
                print(i+1)
                return
            }
        }
    }
}

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

int D;
vector<int> c(26);
vector<vector<int>> s;

struct Data{
	vector<int> t;
	vector<vector<int>> penalty;
	int score;
	
	Data(){
		t.resize(D,0);
		penalty.resize(D+1,vector<int>(26,0));
		score = 0;
	}
};

void init(){
	cin>>D;
	for(int i=0;i<26;i++)scanf("%d",&c[i]);
	
	s.resize(D,vector<int>(26));
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++)scanf("%d",&s[i][j]);
	}
}

void Print(Data &d){
	for(int i=0;i<D;i++)printf("%d\n",d.t[i]+1);
}

Data generate(vector<int> t){
	Data ret;
	ret.t = t;
	vector<int> last(26,0);
	for(int i=0;i<t.size();i++){
		int temp = t[i];
		ret.score += s[i][temp];
		last[temp] = i+1;
		
		for(int j=0;j<26;j++){
			ret.penalty[i+1][j] = ret.penalty[i][j] + c[j];
			if(temp==j)ret.penalty[i+1][j] = 0;
			ret.score -= ret.penalty[i+1][j];
		}
	}
	return ret;
}

int change(Data &d,int ind,int nv){
	int o_score = d.score;
	int ov = d.t[ind];
	d.score += s[ind][nv];
	d.score -= s[ind][ov];
	d.t[ind] = nv;
	for(int i=ind+1;i<=D;i++){
		d.score += d.penalty[i][nv];
		d.score += d.penalty[i][ov];
		if(i==ind+1){
			d.penalty[i][nv] = 0;
			d.penalty[i][ov] = d.penalty[i-1][ov] + c[ov];
		}
		else{
			if(d.penalty[i][nv]!=0){
				d.penalty[i][nv] = d.penalty[i-1][nv]+c[nv];
			}
			if(d.penalty[i][ov]!=0){
				d.penalty[i][ov] = d.penalty[i-1][ov]+c[ov];
			}
		}
		d.score -= d.penalty[i][nv];
		d.score -= d.penalty[i][ov];
	}
	
	return d.score - o_score;
}

int main(){
	
	init();
	
	
	vector<int> t(D);
	for(int i=0;i<D;i++){
		int maxi = -10000000;
		int ind = 0;
		for(int j=0;j<26;j++){
			if(c[j]==0)continue;
			if(maxi < s[i][j]){
				maxi = s[i][j];
				ind = j;
			}
		}
		t[i] = ind;
	}
	Data d = generate(t);

	auto start = chrono::system_clock::now();
	while(true){
		if(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() > 1950){
			break;
		}
		for(int i=0;i<D;i++){
			for(int j=0;j<26;j++){
				if(c[j]==0)continue;
				int temp = d.t[i];
				if(temp==j)continue;
				int ts = d.score;
				if(change(d,i,j)<0)change(d,i,temp);
			}
		}
	}
	
	
	Print(d);
	
	return 0;
}

Measured memory_bytes: 3880
using System;

namespace ConsoleApplication2
{
	using System;

	public class Dice
	{

		public static void Main(String[] args)
		{

			string yesNo = "No";
			string dataA = Console.ReadLine();
			string dataB = Console.ReadLine();
      		string[] diceA = dataA.Split();
     		string[] diceB = dataB.Split();
     		
           	int i = 0;
			int j = 0;
			do {
				do {
                  
					for (int k = 0; k < diceA.Length; k++) {
						if (!diceA[k].Equals(diceB[k])) {
							yesNo = "No";
							break;
						}
						if (k == diceA.Length - 1) {
							yesNo = "Yes";
						}
					}
					if (yesNo == "Yes") {
						break;
					}
					turn(3, 5, 2, 0, diceB);                   
					j++;
				} while (j < 4);

				if (yesNo == "Yes") {
					break;
				}
				
				j = 0;
				
				if (i == 3) {
                   
					turn(4, 5, 1, 0, diceB);//????????§?????????
					turn(2, 5, 3, 0, diceB);

				
				} else if (i == 4) {
					//??????????????§diceB[1]=east
					//west ???south????????????????????????                   
					turn(4, 5, 1, 0, diceB);                       
				}

				turn(4, 5, 1, 0, diceB);
				
				i++;
			} while (i < 6);
			
			Console.WriteLine(yesNo);
		}

		public static void turn(int a, int b, int c, int d, string[] dice)
		{
			string temp = dice[a];
			dice[a] = dice[b];
			dice[b] = dice[c];
			dice[c] = dice[d];
			dice[d] = temp;
            
		}
	}
}

Measured memory_bytes: 8932
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  ll n;
  cin >> n;
  ll a[5] = {};
  REP(i,n){
    string s;
    cin >> s;
    if(s[0] == 'M')
      a[0]++;
    if(s[0] == 'A')
      a[1]++;
    if(s[0] == 'R')
      a[2]++;
    if(s[0] == 'C')
      a[3]++;
    if(s[0] == 'H')
      a[4]++;
  }
  ll sum = 0;
  REP(i,5){
    rep(j,i+1,5){
      rep(k,j+1,5){
	sum += a[i]*a[j]*a[k];
      }
    }
  }
  cout << sum << 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);
		String S = sc.next();
		int answer = 0;

		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == '+') {
				answer++;
			} else {
				answer--;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 20692
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;

    ll a,b;
    if (n==1)
        cout << "Hello World" << endl;
    else if (n==2)
        cin >> a >> b, cout << a+b << endl;

    return 0;
}


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

int main() {
    vector<bool> v(30, false);
    for (int i = 0; i < 28; i++) {
        int n;
        cin >> n;
        v[n-1] = true;
    }
    for (int i = 0; i < 30; i++)
        if (!v[i]) cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 112;
const int MV = 100012;
const ll inf = 1e18;
ll n,c,w[MN],v[MN],dp[MV][MN];
ll ds (ll val, ll i) {
    if (val < 1) return 0;
    if (i == n) return inf;
    if (dp[val][i] != -1) return dp[val][i];
    return dp[val][i] = min(ds(val,i+1), w[i]+ds(val-v[i],i+1));
}
int main (void) {
    memset(dp,-1,sizeof(dp));
    cin >> n >> c;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    for (ll val = MV-1; val >= 0; val--) {
        if (ds(val,0) <= c) {
            cout << val << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 87936
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define real udnasjkd
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int now[100005],now1[100005];
vector<pair<int,pii> > g[100005];
int dep[100005],asc[100005][20];
map<pii,int> cnt,sum;
vector<int> ask[100005];
int n,m;
pair<pii,pii> in[100005];
ll real[100005];
void dfs(int u,int lst){
    dep[u]=dep[lst]+1;
    asc[u][0]=lst;
    for(int i=1;i<20;i++) asc[u][i]=asc[asc[u][i-1]][i-1];
    for(int i=0;i<(int)g[u].size();i++){
        int v=g[u][i].fi;
        if(v!=lst) dfs(v,u);
    }
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    int i=19;
    while(dep[u]>dep[v]){
        for(;i>=0 && dep[asc[u][i]]<dep[v];i--);
        u=asc[u][i];
    }
    i=19;
    while(u!=v){
        for(;i>=0 && asc[u][i]==asc[v][i];i--);
        if(i==-1) i++;
        u=asc[u][i];
        v=asc[v][i];
    }
    return u;
}
void dfs1(int ind,int pa,int c,int d){
    now[c]+=d;
    now1[c]++;
    real[ind]=real[pa]+d;
    for(int i=0;i<ask[ind].size();i++){
        int nc=ask[ind][i];
        cnt[mp(ind,nc)]=now1[nc];
        sum[mp(ind,nc)]=now[nc];
    }
    for(int i=0;i<(int)g[ind].size();i++){
        int ha=g[ind][i].fi;
        if(ha!=pa)
            dfs1(ha,ind,g[ind][i].se.fi,g[ind][i].se.se);
    }
    now[c]-=d;
    now1[c]--;
}
int main(){
    scanf("%d %d",&n,&m);
    for(int i=1;i<n;i++){
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        g[a].pb(mp(b,mp(c,d)));
        g[b].pb(mp(a,mp(c,d)));
    }
    dfs(1,0);
    for(int i=1;i<=m;i++){
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        int ha=lca(c,d);
        ask[c].pb(a);
        ask[d].pb(a);
        ask[ha].pb(a);
        in[i]=mp(mp(a,b),mp(c,d));
    }
    dfs1(1,0,0,0);
    ll ans=0;
    for(int i=1;i<=m;i++){
        int x=cnt[mp(in[i].se.fi,in[i].fi.fi)]*in[i].fi.se-sum[mp(in[i].se.fi,in[i].fi.fi)]+real[in[i].se.fi];
        int y=cnt[mp(in[i].se.se,in[i].fi.fi)]*in[i].fi.se-sum[mp(in[i].se.se,in[i].fi.fi)]+real[in[i].se.se];
        int ha=lca(in[i].se.fi,in[i].se.se);
        int z=cnt[mp(ha,in[i].fi.fi)]*in[i].fi.se-sum[mp(ha,in[i].fi.fi)]+real[ha];
        //cout<<x<<" "<<y<<" "<<z<<endl;
        cout<<x+y-2*z<<endl;
        ans+=x+y-2*z;
    }
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

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

    i64 R = max(max(b * c, b * d), max(a * c, a * d));
    cout << R << endl;



    return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
from operator import itemgetter

import sys
sys.setrecursionlimit(10000)

def inpl(): return tuple(map(int, input().split()))

V, E = inpl()
edges = []
graph = [[] for _ in range(V)]  # [target, cost]
total_cost = 0

for _ in range(E):
    edges.append(inpl())

gw = itemgetter(2)
edges = sorted(edges, key = gw)

tree = [[-1, 1]  for _ in range(V)] # [next, rank]

def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0])    
    return group
 
def unite(x, y):
    px = find(x)
    py = find(y)
     
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
 
for s, t, w in edges:
    if find(s) != find(t):
        unite(s, t)
        total_cost += w
        graph[s].append([t, w])
        graph[t].append([s, w])

print(total_cost)
    

Measured memory_bytes: 29020
n = input()
for x in range(1 << 3):
    opr = ["-"] * 3
    for i in range(3):
        if x & (1 << i):
            opr[i] = "+"
    shiki = "%s%s%s%s%s%s%s" % (n[0], opr[0], n[1], opr[1], n[2], opr[2], n[3])
    if eval(shiki) == 7:
        print("%s=7" % shiki)
        break

Measured memory_bytes: 9124
#include <iostream>
#include <cstdlib>
#define ll long long
#define f(i, n) for (int i=1; i <= n; i++)
// sort(bb, bb+n);

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    if(n>=k){
        n%=k;
    }
    cout<<min(n,k-n);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    while(H){
        int minh, minw, mind = INF;
        rep(i,1,151)rep(j,i+1,151){
            int d = i * i + j * j;
            if(d > H * H + W * W || (d == H * H + W * W) && (H < i)){
                if(d < mind || (d == mind && i < minh)){
                    mind = d;
                    minh = i;
                    minw = j;
                }
            }
        }
        cout << minh << " " << minw << endl;
        cin >> H >> W;
    }
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) reps(i, 0, n)
#define P pair<int, int>

const ll mod = 1000000007;

int main(){
    int k;
    cin >> k;
    string ans, s = "ACL";
    rep(i, k){
        ans += s;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;


int main(int argc, char* argv[]){
	int N;
	scanf("%d",&N);
	long long A[N];
	for(int i=0; i<N; i++){
		scanf("%lld",&A[i]);
	}

	long long front=0;
	long long sum_dai=0;
	for(int i=0; i<N; i++){
		if(A[i]<front){
			sum_dai+=front-A[i];

		}else{
			sum_dai+=0;
			front = A[i];
		}
	}
	printf("%lld\n",sum_dai);



}


Measured memory_bytes: 5308
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll t[100001];
int main() {

	ll n,c,k;
	ll total=0;

	cin>>n>>c>>k;

	rep(i,n){
		cin>>t[i];
	}
	sort(t,t+n);

	ll t2=0,t3=0;
	t2=t[0]+k;
	t3=1;
	for(int i=1; i<n; i++){
		if(t2<t[i]){
			total++;
			t2=t[i]+k;
			t3=1;
		}else{
			if(t3==c){
				total++;
				t2=t[i]+k;
				t3=1;
			}else t3++;
		}
	}
	cout<<total+1<<endl;
	return 0;

}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    int N,T;
    cin >> N >> T;
    int ans = 20000;
    REP(i,N){
        int c,t;
        cin >> c >> t;
        if(t<=T)ans = min(ans,c);
    }
    if(ans==20000){
        cout << "TLE" << endl;
        return 0;
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==-1){
				break;
			}
			println(Integer.toString(n, 4));
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int Maxn=10;
int n,c[5];
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		char s[Maxn];
		scanf("%s",s);
		if(s[0]=='A')++c[1];
		if(s[0]=='W')++c[2];
		if(s[0]=='T')++c[3];
		if(s[0]=='R')++c[4];
	}
	printf("AC x %d\n",c[1]);
	printf("WA x %d\n",c[2]);
	printf("TLE x %d\n",c[3]);
	printf("RE x %d\n",c[4]);
	return 0;
}

Measured memory_bytes: 3816
program yutori
  implicit none
  integer :: n, k, c, i, j, l(200000) = 0, r(200000) = 0, v = 0
  character(200000) :: s
  read(*,*) n, k, c
  read(*,*) s
  j = 1
  do i = 1, n
    if (s(i:i) == "x" .or. v > 0) then
      v = v-1
    else
      l(j) = i
      j = j+1
      if (j > k) exit
      v = c
    end if
  end do
  v = 0
  j = k
  do i = n, 1, -1
    if (s(i:i) == "x" .or. v > 0) then
      v = v-1
    else
      r(j) = i
      j = j-1
      if (j < 1) exit
      v = c
    end if
  end do
  do i = 1, k
    if (l(i) == r(i)) write(*,'(i0)') l(i)
  end do
end program yutori

Measured memory_bytes: 3596
object Main extends App {
  import scala.collection.mutable.PriorityQueue
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val Vs = List.fill(N)(sc.nextInt)
  val pq = new PriorityQueue[Float]()(Ordering.Float.reverse)
  Vs.foreach(pq += _)
  for(_ <- 1 to N - 1){pq += (pq.dequeue + pq.dequeue)/2}
  println(pq.head)
}

Measured memory_bytes: 25524
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;

int solve(int n) {
    long long dp[40];
    rep(i,40) dp[i]=0;
    dp[0]=1;

    rep(i,n+1) {
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
        dp[i+3] += dp[i];
    }

    return dp[n]/10/365 + 1;

}

int main()
{
    int n;
    while(true) {
        cin>>n;
        if(!n) return 0;
        cout<<solve(n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
gets.chomp.to_i.times do
  y, m, d = gets.split.map(&:to_i)

  ans = 0

  while y < 1000
    d += 1

    if d == (m%2 == 0 && y%3 != 0 ? 20 : 21)
      d = 1
      m += 1
    end

    if m == 11
      m = 1
      y += 1
    end

    ans += 1
  end

  puts ans
end

Measured memory_bytes: 2396
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX
#define pi = 3.14159265358979323846

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);
int n;
cin>>n;
string s;
cin>>s;
int r=0;
int w=0;
for(auto a: s)
{
	if(a=='R')
	{
		r++;

	}
	else
	{
		w++;
	}
}
int wrong=0;
fr(i,r)
{
	if(s[i]=='W')
	{
		wrong++;
	}
}
cout<<wrong<<endl;
cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 3868
k = int(input())

l = [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]

print(l[k-1])

Measured memory_bytes: 38256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	cnt := 0
	for _, r := range s {
		if r == 'x' {
			cnt++
		}
	}
	if cnt >= 8 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 1768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AAtCoderGroupContest {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(3 * n);
            Arrays.sort(a);
            long sum = 0;
            for (int i = 1; i <= n; i++) {
                sum += a[3 * n - i * 2];
            }
            out.println(sum);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 59704
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

const long long int MAX = 5000010;
const long long int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long int n,long long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){

    COMinit();
    long long int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long int result = 0;
    long long int tmp;
    FOR(i,r1,r2+1){
        tmp = i + 1;
        //cout << COM(tmp + c2, c2)<<" " << COM(tmp + c1 - 1, c1 - 1) << endl;
        result += COM(tmp + c2, c2) - COM(tmp + c1-1, c1-1);
        result %= mod;
    }
    if(result<0){
        result += mod;
    }
    cout << result << endl;



    return 0;
}


Measured memory_bytes: 117504
import java.io.*;

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

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i % 2 == 0){
					for(int n = 0; n < W; n++){
				 	 	if(n % 2 == 0){
						 sb.append("#");
					        }else{
						 sb.append(".");
						}
					}
				}
			 	if(i % 2 == 1){
					for(int n = 0; n < W; n++){
				 	 	if(n % 2 == 0){
						 sb.append(".");
					        }else{
						 sb.append("#");
						}
					}
				}
			sb.append("\n");
			}
		sb.append("\n");
		}
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
}

Measured memory_bytes: 21380
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b, a%b);
}

int main()
{
  int R,G,B,N,count=0;
  cin >> R >> G >> B >> N;
  for(int i=N/R;i>=0;i--){
    for(int j=(N-i*R)/G;j>=0;j--){
      if((N-i*R-j*G)%B == 0) count++;
      
    }
  }
  cout << count;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

string S;
int k;

int main() {
	cin >> S >> k;
	int N = S.size();
	vector<string> str;

	for (int i = 0; i < N; ++i) {
		string temp;
		for (int j = 0; j < k&&i + j < N; ++j) {
			temp.push_back(S[i + j]);
			str.push_back(temp);
		}
	}

	sort(str.begin(), str.end());
	str.erase(unique(str.begin(), str.end()), str.end());
	
	cout << str[k - 1] << endl;

	return 0;
}

Measured memory_bytes: 1660
import heapq

N,M = (int(i) for i in input().split())
A = [int(i) * (-1) for i in input().split()]
heapq.heapify(A)

for i in range(M):
  tmp = heapq.heappop(A)
  tmp = ((tmp * -1)//2) * -1
  heapq.heappush(A,tmp)

print((-1)*sum(A))


Measured memory_bytes: 14180
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 2e3 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;

long long ds[MaxN][MaxN], xx;
int n, a[2 * MaxN], mn[2 * MaxN][2 * MaxN];
set < pair < long long, pair < int, int > > > st;

int main() {
//  freopen("input.txt", "r", stdin);
  cin >> n >> xx;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i + n] = a[i];
  }
  for (int i = 0; i < 2 * n; ++i) {
    mn[i][i] = a[i];
    for (int j = i + 1; j < 2 * n; ++j) {
      mn[i][j] = min(mn[i][j - 1], a[j]);
    }
  }
  long long ans = 8e18;
  for (int shift = 0; shift < n; ++shift) {
    long long cur = 0;
    for (int i = 0; i < n; ++i) {
      cur += mn[i + n - shift][i + n];
    }
    ans = min(ans, cur + xx * shift);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 45568
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define fr(i,n) for(ll i=0;i<n;i++)
#define pii pair <ll ,ll>
#define ppi pair < pii , int > 
#define x first
#define y second

#include <bits/stdc++.h> 
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];fr(i,n)cin>>a[i];
    sort(a,a+n);
    int dp1[k+1];fr(i,k+1)dp1[i]=0;// 1 wins
    int dp2[k+1];fr(i,k+1)dp2[i]=0;// 2 wins
    fr(j,k+1)
    {
        int wins = 0;
        fr(i,n)
        {
            if(j<a[i])continue;
            if(dp2[j-a[i]]==0)wins=1;
        }
        if(j<a[0])continue;
        dp1[j]=wins;
        dp2[j]=wins;
    }
    // fr(i,k+1)cout<<dp1[i]<<" ";
    if(dp1[k]==0)cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}

Measured memory_bytes: 1024
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i==0 or j==0 or i==h-1 or j==w-1:
                print("#",end="")
            else:
                print(".",end="")
        print("")
    print("")


Measured memory_bytes: 7012
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int k, s, ans;
  cin >> k >> s;

  for (int i = 0; i <= k; i++) { // x = i
    // condition: s - i = y + z (0 <= y, z <= k)
    for (int j = 0; j <= k; j++) if (s - (i + j) <= k && s - (i + j) >= 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a=input().split()
b=input().split()
c=input().split()
lista=[int(d) for d in a]
listb=[int(e) for e in b]
listc=[int(f) for f in c]
b1=lista[0]
b2=lista[1]
b3=lista[2]
a2=listb[0]-b1
a3=listc[0]-b1
if a2+b2==listb[1] and a2+b3==listb[2] and a3+b2==listc[1] and a3+b3==listc[2]:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, char *argv[])
{
    unsigned long a, b, n;
    unsigned long count = 0;
    scanf("%lu %lu %lu", &n, &a, &b);

    long sum = a+b;
    long tmp = n/sum;
    long amari = n%sum;

    count += tmp*a;
    if(amari > a){
        count += a;
    }
    else
        count += amari;

    printf("%lu", count);
    return 0;
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int A, B;
    int c = 0;

    cin >> A >> B;
    for(int i = 0; i < 2; i++) {
        if(A > B) {
            c += A;
            A--;
        } else {
            c += B;
            B--;
        }
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc145/tasks/abc145_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();

		if(N%2==0) {
			String str = S.substring(0, N/2);
			if(str.contentEquals(S.substring(N/2,N))) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m = 103;
    cin >> n;
    while (n--){
        string sa, sb;
        VI a(m), b(m);
        cin >> sa >> sb;
        REP(i,sa.length()) a[i] = sa[sa.length()-i-1] - '0';
        REP(i,sb.length()) b[i] = sb[sb.length()-i-1] - '0';
        int p = 0;
        REP(i,m){
            a[i] += b[i] + p;
            if (a[i] >= 10){
                a[i] -= 10;
                p = 1;
            }else{
                p = 0;
            }
        }
        int h = 0;
        REP(i,m) if (a[i] > 0) h = i;
        if (h >= 80){
            cout << "overflow" << endl;
        }else{
            FORR(i,h,0) cout << a[i];
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3056
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int P = GetInt();
		int Q = GetInt();
		int R = GetInt();
		Console.WriteLine(P + Q + R - Math.Max(P, Math.Max(Q, R)));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


string s, t, ans;
int dp[3005][3005];
signed main() {
	cin >> s >> t;
	rep(i, s.size()) {
		rep(j, t.size()) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	for (int i = s.size(), j = t.size(); i > 0 && j > 0;) {
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else {
			i--; j--;
			ans = s[i] + ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 70656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    // ll prev = 1;
    // ll now = 1;

    // rep(i, K) { now *= A[i]; }
    // prev = now;

    reps(i, K, N) {
        if (A[i - K] < A[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

        // now = prev * A[i] / A[i - K];
        // cout << i << ":" << now << ", " << prev << endl;
        // if (prev < now) {
        //     cout << "Yes" << endl;
        // } else {
        //     cout << "No" << endl;
        // }
        // prev = now;
    }

    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    map<string,int> count;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        
        count[s]+=1;
    }
    
        int max_count = 0;
    for(const auto&x:count){
        int maxv = x.second;
        if(max_count < maxv) max_count = maxv;
    }
    
    for(auto i=count.begin();i!=count.end();i++){
        if(i->second == max_count){
            cout << i->first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 19084
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int a,b;
    string ans="Impossible";
    cin >> a >> b;
    vector<int> A={a,b,a+b};
    for (auto &ai:A) {
        if (ai%3==0) { ans = "Possible"; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N;
	cin >> N;
	lint ans = 0;
	if (N & 1)
	{
		cout << 0 << endl;
		return;
	}

	for (lint i = 5; i * 2 <= N; i *= 5)
	{
		ans += N / i / 2;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)

def main():
    
    n,z,w,*a=map(int,open(0).read().split())
    if n==1:
        print(abs(a[n-1]-w))
    else:
        print(max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
list <int> ans;
bool vis[50] = {0};
int main()
{
    LL n;
    scanf("%lld" , &n);
    ++n;
    int p = 0 , q = 0;
    while(n)
    {
        vis[p++] = n & 1;
        n >>= 1;
    }
    for(int i = p - 2 ; i >= 0 ; --i)
    {
        ans.push_back(++q);
        if(vis[i])
            ans.push_front(++q);
    }
    printf("%d\n" , q + q);
    for(int i = 1 ; i <= q ; ++i)
        printf("%d " , i);
    for(int i = 1 ; i <= q ; ++i)
    {
        printf("%d" , ans.front());
        putchar(" \n"[i == q + 1]);
        ans.pop_front();
    }
}


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

using namespace std;

const int maxN = 100000;
const int maxh = 17;

int N;
int x[maxN];
int L;
int nxt[maxN];
int f[maxN][maxh];

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

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

	for (int i = 0; i < N; i++)
		nxt[i] = upper_bound(x + i + 1, x + N, x[i] + L) - 1 - x;

	for (int h = 0; h < maxh; h++) {
		for (int i = 0; i < N; i++)
			f[i][h] = h == 0 ? nxt[i] : f[f[i][h - 1]][h - 1];
	}

	int Q;
	cin >> Q;
	for (int QN = 0; QN < Q; QN++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		if (a > b)
			swap(a, b);

		int ans = 0;
		for (int h = maxh - 1; h >= 0; h--) {
			if (f[a][h] < b) {
				a = f[a][h];
				ans += 1 << h;
			}
		}
		ans++;

		cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 8320
import math

N = int(input())
x = list()
for i in range(N):
	x.append(list(map(int, input().split())))

ans = 0
cities = [x for x in range(N)]
for i in range(N):
	tmp = 0
	cities.remove(i)
	for j in cities:
		tmp += math.sqrt((x[i][0]-x[j][0])**2+(x[i][1]-x[j][1])**2) * math.factorial(N-1) * 2
	ans += tmp
	
print(ans/math.factorial(N))
	

Measured memory_bytes: 3064