akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

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

#define N 200005

ll i=0,j=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll n,w;
    cin>>n>>w;
    ll sum=0;
    ll wt[n+1];
    ll val[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
        sum+=val[i];
    }
    ll dp[sum+1];
    for(i=1;i<=sum;i++)
    {
        dp[i]=4e18;
    }
    dp[0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=sum-val[i];j>=0;j--)
        {
            dp[j+val[i]]=min(dp[j+val[i]],dp[j]+wt[i]);
        }
    }
    ll ans=0;
    for(i=0;i<=sum;i++)
    {
        if(dp[i]<=w)
            ans=i;
    }
    cout<<ans<<endl;
}



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

int main()
{
	int n;
	cin >> n;
	n %= 10;
	if ((n == 2) || (n == 4) || (n == 5) || (n == 7) || (n == 9)) {
		cout << "hon" << endl;
	}
	else if ((n == 0) || (n == 1) || (n == 6) || (n == 8)) {
		cout << "pon" << endl;
	}
	else {
		cout << "bon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
int n;
int main(){
    cin>>n;
    if(n>=400&&n<=599) printf ("8\n");
    else if(n>=600&&n<=799) printf ("7\n");
    else if(n>=800&&n<=999) printf ("6\n");
    else if(n>=1000&&n<=1199) printf ("5\n");
    else if(n>=1200&&n<=1399) printf ("4\n");
    else if(n>=1400&&n<=1599) printf ("3\n");
    else if(n>=1600&&n<=1799) printf ("2\n");
    else if(n>=1800&&n<=1999) printf ("1\n");

}

Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int paintedRows = sc.nextInt();
        int paintedCols = sc.nextInt();
        int square = h*w;

        System.out.println(square - (paintedRows*w) - (paintedCols*h - paintedRows*paintedCols));
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int K;
map<string, int> mp;
string s, t;
const int INF = 1 << 28;

int calc(string S, string T) {
    int ret = 0;
    for(int i=0; i<K; i++) {
        ret = (ret << 1) | (S[i] == T[i]);
    }
    return ret;
}

void solve() {
    mp[s] = 0;
    queue<string> que;
    que.push(s);
    while(que.size()) {
        string cur = que.front(); que.pop();
        // printf("cur = %s (%d)\n", cur.c_str(), mp[cur]);
        if(cur == t) {
            cout << mp[cur] << endl;
            return;
        }

        for(int l=0; l<K; l++) {
            if(cur[l] != t[l]) {
                for(int b=1; b<=K-l; b++) {
                    int r = l+b;
                    for(int rot=1; rot<10; rot++) {
                        string nxt = cur;
                        int nxt_pos = INF;
                        for(int i=l; i<r; i++) {
                            int val = ((nxt[i] - '0') + rot) % 10;
                            nxt[i] = (char)('0' + val);
                            if(nxt[i] != t[i]) nxt_pos = min(nxt_pos, i);
                        }
                        if(nxt_pos == l) continue;
                        if(mp.count(nxt) && mp[nxt] <= mp[cur] + 1) continue;
                        mp[nxt] = mp[cur] + 1;
                        que.push(nxt);
                    }
                }
                break;
            }
        }
    }
}

int main() {
    while(cin >> K) {
        if(!K) break;
        cin >> s >> t;
        mp.clear();
        solve();
    }
    return 0;
}


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

ll f(ll n) { return n*(n+1)/2;}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<int> d(n+1);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) d[j]++;
    // ll r = n/i;
    // ans += f(r)*i;
  }
  for (int i = 1; i <= n; i++) ans += ll(i)*d[i];
  cout << ans << endl;
  return 0;
}


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

using namespace std;
int N;
int C;
int D[30][30];
int c[500][500];
int n[3][30];

int main()
{
	cin >> N >> C;
	for (int i = 0; i < C; i++) 
		for (int j = 0; j < C; j++) 
			cin >> D[i][j];
	for (int i = 0; i < N; i++) 
		for (int j = 0; j < N; j++) {
			int t;
			cin >> t;
			c[i][j] = t - 1;
		}
	for (int i = 0; i < N; i++)  {
		for (int j = 0; j < N; j++) {
			int t = (i+j) % 3;
			n[t][c[i][j]]++;
		}
	}
	long mi = 250000*1000;
	for (int i = 0; i < C; i++)  {
		for (int j = 0; j < C; j++) {
			if (i == j) continue;
			for (int k = 0; k < C; k++) {
				if (k == i || k == j) continue;
				long t = 0;
				for (int l = 0; l < C; l++) {
					t += n[0][l] * D[l][i];
				}
				for (int l = 0; l < C; l++) {
					t += n[1][l] * D[l][j];
				}
				for (int l = 0; l < C; l++) {
					t += n[2][l] * D[l][k];
				}
				mi = min(t, mi);
			}
		}
	}	
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1280
#横にn個入力
n, k = map(int, input().split())

#n...普通、a...横で入力された複数の要素を配列で取得
a = input().split()

x = [int(m) for m in a]
lx = []
mx = []
rx = []
for i in range(n):
    if x[i] < 0:
        lx.append(x[i])
    elif x[i] == 0:
        mx.append(x[i])
    else:
        rx.append(x[i])

lx.sort(reverse=True)
rx.sort()
lmx = lx + mx
lmx.sort(reverse=True)
ans1 = float("INF")
if len(lmx) >= k:
    ans1 = abs(lmx[k - 1])

mrx = mx + rx
mrx.sort()
ans2 = float("INF")
if len(mrx) >= k:
    ans2 = abs(mrx[k - 1])

p = 1
ans3 = float("INF")
while p <= len(rx):
    if len(rx) >= p and len(lx) >= k - p - len(mx) and k - p - len(mx) > 0:
        if ans3 > abs(2 * rx[p - 1]) + abs(lx[k - p - len(mx) - 1]):
            ans3 = abs(2 * rx[p - 1]) + abs(lx[k - p - len(mx) - 1])
    p += 1

q = 1
ans4 = float("INF")
while q <= len(lx):
    if len(lx) >= q and len(rx) >= k - q - len(mx) and k - q - len(mx) > 0:
        if ans4 > abs(2 * lx[q - 1]) + abs(rx[k - q - len(mx) - 1]):
            ans4 = abs(2 * lx[q - 1]) + abs(rx[k - q - len(mx) - 1])
    q += 1

print(min(ans1,ans2,ans3,ans4))

Measured memory_bytes: 15844
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l;
   char c;
cin>>c;
if(c=='A')
     cout<<"T"<<endl;
else if(c=='C')
     cout<<"G"<<endl;
else if(c=='T')
     cout<<"A"<<endl;
else if(c=='G')
    cout<<"C"<<endl;
    


    return 0;
}





Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,l,r) for(int i=l;i<r;i++)
const int inf=2e9+10;
const ll INF=9e18+10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const ll MOD=1e9+7;

int main(){
    int n,k;cin>>n>>k;
    int a[n];
    rep(i,n)scanf("%d",&a[i]);
    set<pair<int,int> > s;
    set<pair<int,int> >::iterator it;
    s.insert(make_pair(-1,0));
    for(int i=1;i<n;i++){
        for(it=s.begin();it!=s.end();it++){
            if(abs(a[(*it).second]-a[i])<=k){
                s.insert(make_pair((*it).first-1,i));
                break;
            }
        }
        s.insert(make_pair(-1,i));
    }
    cout<<-(*s.begin()).first<<endl;
    return 0;
}

Measured memory_bytes: 33000
//
//  main.cpp
//  D - IntegerotS
//
//  Created by Charles on 2017/10/1.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
using namespace std;
#define ll long long
const int maxn=1e5+5;
int n,k,a[maxn],b[maxn];
int main(int argc, const char * argv[]) {
    scanf("%d%d",&n,&k);
    k++;
    for(int i=0;i<n;++i) scanf("%d%d",&a[i],&b[i]);
    int cur=0;
    ll tmp=0;
    ll ans=0;
    for(int bit=30;bit>=0;--bit){
        if(k&(1<<bit)){
            tmp=0;
            cur^=1<<bit;
            for(int i=0;i<n;++i){
                if((a[i]&cur)==0) tmp+=b[i];
                ans=max(ans,tmp);
            }
            cur^=1<<bit;
        }
        else cur^=1<<bit;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a; x<b; x++)
#define rep(x,a) FOR(x,0,a)

using namespace std;

int main(){
  int N, ans=0;
  scanf("%d",&N);
  int a[N];
  for (int i=0; i<N; i++) {
    scanf("%d",&a[i]);
  }
  map<int, int> m;
  rep(i,N) m[a[i]]+=1;
  for(auto itr=m.begin(); itr!=m.end(); itr++) {
    if (itr->first==itr->second) continue;
    if (itr->first<itr->second) ans+=itr->second-itr->first;
    if (itr->first>itr->second) ans+=itr->second;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 5120
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(void)
{
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	string S; cin >> S;
	bool flag = true;


	rep(i, B - 1, D - 1)if (S[i] == '#' && S[i + 1] == '#') {
		flag = false;
		break;
	}
	rep(i, A - 1, C - 1)if (S[i] == '#' && S[i + 1] == '#') {
		flag = false;
		break;
	}

	if (D < C) {
		bool three = false;
		rep(i, B - 2, D - 1)
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
				three = true;
				break;
			}
		if (!three)flag = false;
	}

	cout << (flag ? "Yes" : "No") << endl;


	return 0;
}


Measured memory_bytes: 644
D = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(input()) for _ in range(D)]
score = 0
last = [0] * 26
for d, t in enumerate(T, 1):
    score += S[d - 1][t - 1]
    last[t - 1] = d
    for c, l in zip(C, last): score -= c * (d - l)
    print(score)

Measured memory_bytes: 9256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;

//start of 0uts1de's library

int cin_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}


int cout_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}


int max_int_arr(std::vector<int>& arr){    //data mode
    int maxVal = INT_MIN;       //min of int
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_int_arr(std::vector<int>& arr, int mode){    //overload index mode
    int maxVal = INT_MIN;       //min of int
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

double max_double_arr(std::vector<double>& arr){    //data mode
    double maxVal = -DBL_MAX;       //min of double
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_double_arr(std::vector<double>& arr, int mode){    //overload index mode
    double maxVal = -DBL_MAX;       //min of double
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

//end of 0uts1de's library

int main(){
    int n, k;
    cin >> n >> k;
    if (n % k){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n;
	string s;
	cin>>s;
	n=s.length();
	for(int i=0;i<((n-1)/2)/2;i++)
	{
		if(s[i]!=s[(n-1)/2-1-i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	int a=(n+3)/2-1;
	for(int i=(n+3)/2-1;i<=(n+3)/2-1+(n-3)/4;i++)
	{
		if(s[i]!=s[n-1-(i-a)])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=0;i<n/2;i++)
	{
		if(s[i]!=s[n-1-i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
a, b, h, m = map(int, input().split())

theta_a = math.pi * float(h + m / 60) / float(6)
theta_b = math.pi * float(m) / float(30)

theta = theta_a - theta_b
if theta > math.pi or theta < 0:
    theta = theta_b - theta_a

square_l = - float(2) * math.cos(theta) * float(a*b) + a * a + b * b
print(math.sqrt(square_l))


Measured memory_bytes: 62376
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 13;
int n, a[maxN], lvl[maxN], ans, k;
vector<int> adj[maxN];
void dfs (int x, int par) {
    lvl[x] = 1;
    for (auto a : adj[x]) {
	if (a != par) {
	    dfs(a, x);
	    lvl[x] = max(lvl[x], lvl[a] + 1);
	}
    }
    if (lvl[x] >= k && par != 0) {
	ans++;
	lvl[x] = 0;
    }
}

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

    if (a[0] != 0)
	ans++;
    for (int i = 1; i < n; i++)
	adj[a[i]].push_back(i);

    dfs(0, 0);
    cout << ans << endl;
}
   


Measured memory_bytes: 12800
using System.Linq;
using System;
using System.Collections.Generic;

class Hello
{
    static void Main()
    {
        //var ss = Console.ReadLine().Split();
        var n = new string[2];
        for (int i = 0; i < 2; i++)
        {
            n[i] = Console.ReadLine();
        }
        string s = "EQUAL";
        int l = n[0].Length, m = n[1].Length;
        if (l != m)
        {
            if(l>m)s = "GREATER";
            if(l<m)s = "LESS";
        }
        else
        {
            if (n[0] == n[1]) {
                s = "EQUAL";
                Console.Write(s);
                return;
            }
            for (int i = 0; i < l; i++)
            {
                int a = n[0][i], b = n[1][i];
                if (a > b)
                {
                    s = "GREATER";break;
                }
                if (a < b)
                {
                    s = "LESS";break;
                }
            }
        }
        if (n[0] == n[1]) s = "EQUAL";
        Console.Write(s);
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;

	int size = a.size();
	REP(i, a.size()) {
		a = a[size - 1] + a;
		a.pop_back();
		if (a == b) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

}

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

kabu = 0
money = 1000
for i in range(n-1):
    if al[i] < al[i+1]:
        # 全部売る
        money += kabu * al[i]
        kabu = 0
        # 全部買う
        kabu += money // al[i]
        money = money % al[i]
    else:
        # 全部売る
        money += kabu * al[i]
        kabu = 0

print(money+ kabu*al[-1])

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  char c;
  cin >> c;

  cout << char(c + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] ball = new int[10];
		boolean flag = true;
		int N = scan.nextInt();
		for(int i = 0; i < N; i++){
			for(int j = 0; j < 10; j++){
				ball[j] = scan.nextInt();
			}
			int min1 = 0;
			int min2 = 0;
			for(int j = 0; j < 10; j++){
				if(min1 < ball[j]){
					min1 = ball[j];
				} else if(min2 < ball[j]){
					min2 = ball[j];
				} else{
					flag = false;
					break;
				}
			}
			System.out.printf("%s\n", flag? "YES" : "NO");
		}
	}
}

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

using namespace std;
int dr[] = {1,0,-1, 0}; // S,SE,E,NE,N,NW,W,SW
int dc[] = {0,1, 0,-1}; // neighbors

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h, w, ch, cw, dh, dw;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--;
	cw--;
	dh--;
	dw--;
	int dist[h][w];
	char s[h][w];
	for (int i=0; i<h; ++i){
		for (int j=0; j<w; ++j){
			cin>>s[i][j];
			dist[i][j] = 1e9;
		}
	}
	int cost = 0;
	dist[ch][cw] = 0;
	deque<pair<int, int> > q; q.push_back(pair<int,int>(ch, cw) );   
	while (!q.empty()) {
    	pair<int,int> u = q.front(); q.pop_front();                        // queue: layer by layer!
    	int x = u.first;
    	int y = u.second;
    	cost = dist[x][y];
//    	cout<<x<<" "<<y<<" "<<cost<<endl;
		for (int i=0; i<4; ++i){
    		int r = x + dr[i];
    		int c = y + dc[i];
    		if (r<0 || r>=h || c<0 || c>=w) continue; // outside
    		if(s[r][c] == '#')	continue;
    		if(dist[r][c] <= cost) continue;
    		dist[r][c] = cost;
//    		cout<<r<<" "<<c<<" "<<cost<<endl;
    		q.push_front(pair<int,int>(r, c));
		}	
		cost++;
		for (int i=-2; i<=2; ++i){
			for (int j=-2; j<=2; ++j){
				int r = x + i;
				int c = y + j;
    			if (r<0 || r>=h || c<0 || c>=w) continue; // outside
    			if(s[r][c] == '#')	continue;
    			if(dist[r][c] <= cost) continue;
    			dist[r][c] = cost;
    			q.push_back(pair<int, int> (r, c));
			}
		}
	}
	dist[dh][dw] == 1e9 ? cout<<"-1":cout<<dist[dh][dw];
}


Measured memory_bytes: 8532
#include <stdio.h>
#define N 1112
main(){
  int x[N];
  int z, i, j, ans, tmp, t;

  for(i=0;i<=N;i++){
    x[i]=i*i*i;
  }

  while(1){
    scanf("%d", &z);
    if(z==0) break;
    t=z*z*z;
    ans=-1;
    for(i=0;i<z;i++){
      for(j=0;j<z;j++){
        tmp=x[i]+x[j];
        if(t<tmp) continue;
        if(ans<tmp) ans=tmp;
      }
    }

    printf("%d\n", t-ans);

  }
  return 0;
}

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

namespace ABC157 {
    public class B {
        static void Main(string[] args) {
            var values = Console.ReadLine().Split(' ')
                .Concat(Console.ReadLine().Split(' '))
                .Concat(Console.ReadLine().Split(' '))
                .Select(int.Parse).ToArray();

            var bingos = new List<int[]> {
                new[]{ values[0], values[1], values[2]},
                new[]{ values[3], values[4], values[5]},
                new[]{ values[6], values[7], values[8]},
                new[]{ values[0], values[3], values[6]},
                new[]{ values[1], values[4], values[7]},
                new[]{ values[2], values[5], values[8]},
                new[]{ values[0], values[4], values[8]},
                new[]{ values[2], values[4], values[6]}
            };

            var num = int.Parse(Console.ReadLine());
            var targets = new int[num];
            for(int i = 0; i < num; i++) {
                targets[i] = int.Parse(Console.ReadLine());
            }

            var isBingo = bingos.Any(x => {
                return x.Intersect(targets).Count() == 3;
            });
            Console.WriteLine(isBingo ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13532
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    double n,k,j;
    ll t;
    cin>>n>>k>>t;
    ll i=ceil(n/k);
    cout<<(ll)(i*t);
    
    
    
    
    
    return 0;
}

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


int main(){
     int n;
     cin>>n;
     int arr[n-1];
     for(int i=0;i<n-1;i++) cin>>arr[i];

     int ans = 0;
     int prev = INT_MAX;

     for(int i=0;i<n-1;i++){
          ans = ans + min(prev, arr[i]);
          prev = arr[i];
     }
     ans = ans + arr[n-2];
     cout<<ans;
}

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

typedef long long ll;

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

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i,1,n+1){
    ll end = n-n%i;
    ans += (i+end)*(end/i)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    # abc全てK//2か全て0のどちらか
    num_0 = N // K
    if K % 2 == 0:
        num_K_half = N // K + (1 if N % K >= K // 2 else 0)
    else:
        num_K_half = 0

    ans = num_0 ** 3 + num_K_half ** 3
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10032
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        cnt += 2
    elif a[i] == b[i] == c[i]:
        cnt += 0
    else:
        cnt += 1
print(cnt)

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

template <class T>
inline void read(T &x) {
	static char ch; 
	static bool opt; 
	while (!isdigit(ch = getchar()) && ch != '-'); 
	x = (opt = ch == '-') ? 0 : ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
	if (opt)
		x = ~x + 1; 
}

template <class T>
inline void putint(T x) {
	static char buf[45], *tail = buf; 
	if (!x) {
		putchar('0'); 
	} else {
		if (x < 0)
			putchar('-'), x = ~x + 1; 
		for (; x; x /= 10) *++tail = x % 10 + '0'; 
		for (; tail != buf; --tail) putchar(*tail); 
	}
}

using namespace std; 

const int MaxN = 1e6 + 5; 

int n; 
int a[MaxN], sum[MaxN]; 

int main() {
	read(n); 

	for (int i = 1; i <= n; ++i) {
		read(a[i]); 
		++sum[a[i]]; 
	}

	int all = a[1]; 
	for (int i = 2; i <= n; ++i) {
		all = std::__gcd(a[i], all); 
	}
	
	if (all != 1) {
		puts("not coprime"); 
	} else {
		int m = 1000000; 

		for (int i = 2; i <= m; ++i) {
			int cur = 0; 
			for (int j = i; j <= m; j += i)
				cur += sum[j]; 
			
			if (cur > 1) {
				puts("setwise coprime"); 
				return 0; 
			}
		}

		puts("pairwise coprime"); 
	}

	return 0; 
}

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

using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int sum,co=0;
		for(int i=1;i<n;i++){
			sum=0;
//			cout<<i<<" ";
			for(int j=i;sum<n;j++){
				sum+=j;
//				cout<<j<<" ";
				if(sum==n)co++;
			}
//			cout<<endl;
		}
		cout<<co<<endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){

  char a;
  scanf("%c", &a);

  if((a >= 'a') && (a <= 'z')){
    printf("%c\n", 'a');
  } else if((a >= 'A') && (a <= 'Z')) {
    printf("%c\n", 'A');
  }

  return 0;

}


Measured memory_bytes: 1608
n=int(input())
d=dict()

for i in range(n):
  a=input()
  d.setdefault(a,0)
  d[a] += 1

mx=0
result=[]
for key,value in d.items():
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

for i in range(len(result)):
  print(result[i])

Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int c[3][3];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>c[i][j];
  if(c[0][0]-c[0][1]==c[1][0]-c[1][1]&&c[0][0]-c[0][1]==c[2][0]-c[2][1]&&c[0][0]-c[0][2]==c[1][0]-c[1][2]&&c[0][0]-c[0][2]==c[2][0]-c[2][2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    int x = accumulate(all(b), 0ll) - accumulate(all(a), 0ll);
    if (x < 0) {
      cout << "No" << endl;
      return 0;
    }

    int cnt_a = 0;
    int cnt_b = 0;
    rep(i, n) {
      if (a[i] < b[i]) {
        cnt_a += (b[i] - a[i] + 1) / 2;
        a[i] = ((b[i] - a[i]) & 1 ? b[i] + 1 : b[i]);
      }
      if (a[i] > b[i]) {
        cnt_b += a[i] - b[i];
      }
    }

    int rem_a = x - cnt_a;
    int rem_b = x - cnt_b;

    if (rem_a < 0 || rem_b < 0 || rem_b != 2 * rem_a) {
      cout << "No" << endl;
      return 0;
    }

    cout << "Yes" << endl;
}


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

typedef long long ll;

int main(){
  int N, M;
  int P[100000], Y[100000];
  vector<int> yd[100001];

  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }
  for(int i=0;i<N;i++){
    sort(yd[i+1].begin(),yd[i+1].end());
  }

  for(int i=0;i<M;i++){
    printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
  }

}


Measured memory_bytes: 7808
n, m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
C = []
if m <= n:
	print(0)
	exit()
for i in range(1, m):
	C.append(abs(X[i] - X[i-1]))
C.sort()
for i in range(n-1):
	C[m-2-i] = 0
print(sum(C))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (ll)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,A,B,C,D;
string S;
int main(){
    cin >> N >> A >> B >> C >> D >> S;
    A--,B--,C--,D--;
    int ct = 0;
    bool flag = true;
    repi(i,A,max(C,D)) if(i+1 <= max(C,D)) if(S[i] == '#' && S[i+1] == '#') flag = false;
    repi(i,B,min(C,D)) if(i <= min(C,D)) if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') ct++;
    
    if(C < D && flag) pr(yes);
    else if(C > D && flag && ct != 0) pr(yes);
    else pr(no);

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n>>m;
	vi a(n,0);
	REP(i,m){
    	cin >> k;
    	REP(j,k){
        	cin >> sum;
        	a[sum-1]=1;
        }
    }
    cout << count(ALL(a),0) << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

int solve(const vector<string>& a) {
	int n = a.size();

	vector<int> hor_cnt(n), ver_cnt(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (a[i][j] == '#') {
				hor_cnt[i] += 1;
				ver_cnt[j] += 1;
			}
		}
	}

	if (accumulate(all(hor_cnt), 0) == 0) {
		puts("-1");
		exit(0);
	}

	int pre_cnt = n;
	int post_cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (ver_cnt[i]) {
			pre_cnt = min(pre_cnt, n - hor_cnt[i]);
		} else {
			pre_cnt = min(pre_cnt, n - hor_cnt[i] + 1);
		}
		if (ver_cnt[i] < n) {
			post_cnt += 1;
		}
	}

	return pre_cnt + post_cnt;
}

vector<string> go(vector<string> a, int x, int y) {
	auto tmp = a[x];
	for (int i = 0; i < (int)a.size(); ++i) {
		a[i][y] = tmp[i];
	}
	return a;
}

int stupid(const vector<string>& a) {
	set<vector<string>> S;
	S.insert(a);
	vector<string> dest(a.size(), string(a.size(), '#'));
	vector<vector<string>> s1 = {a}, s2;
	int ans = 0;
	int n = a.size();
	while (S.find(dest) == S.end()) {
		for (const auto& x : s1) {
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					auto tmp = go(x, i, j);
					if (S.find(tmp) != S.end()) {
						continue;
					}
					s2.push_back(tmp);
					S.insert(tmp);
				}
			}
		}
		s1.swap(s2);
		s2.clear();
		++ans;
	}
	return ans;
}

int main(){

	/*while (true) {
		int n = 3;
		vector<string> a(n, string(n, '.'));
		int cnt = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (rand() & 1) {
					a[i][j] = '#';
					++cnt;
				}
			}
		}
		if (cnt == 0) {
			continue;
		}
		int ans = stupid(a);
		int res = solve(a);
		if (ans != res) {
			cerr << a << "\n";
			cerr << ans << " " << res << "\n";
			return 0;
		} else {
			cerr << "ok ";
		}
	}
*/
	int n = nxt();
	vector<string> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	printf("%d\n", solve(a));

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, long long C, long long D, std::string S){
    for(long long i = A-1; i < C-1; i++){
      if(S[i]=='#'&&S[i+1]=='#'){
        goto no;
      }
    }
    for(long long i = B-1; i < D-1; i++){
      if(S[i]=='#'&&S[i+1]=='#'){
        goto no;
      }
    }
  if((A<B)==(C<D)){
    goto yes;
  }else{
    for(long long i = B-1; i < D; i++){
      if(S[i-1]=='.'&&S[i]=='.'&&S[i+1]=='.'){
        goto yes;
      }
    }
    goto no;
  }
  yes:
  cout<<YES<<endl;
  return ;
  no:
  cout<<NO<<endl;
  return ;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    std::string S;
    std::cin >> S;
    solve(N, A, B, C, D, S);
    return 0;
}


Measured memory_bytes: 772
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <unordered_map>
using namespace std;


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

  vector<int> lp(n);
  vector<bool> used(n);
  vector<bool> same(n);
  priority_queue<int> pq;
  priority_queue<int, vector<int>, greater<int>> qp;
  for (int i = 0; i < n; ++i) {
    cin >> lp[i];
    if (i < k) {
      pq.push(lp[i]);
      qp.push(lp[i]);
    }
    used.push_back(false);
    same.push_back(false);
  }
  int best = lp[0];
  int cnt = 0;
  for (int i = 1; i < n; ++i) {
    if (lp[i] > best) ++cnt;
    else { cnt = 1; }
    best = lp[i];
    if (cnt >= k) { 
      // cout << i-k+1 << " " << cnt << endl;
      same[i-k+1] = true;
    }
  }

  int ans = 1;
  bool has_same = same[0];
  for (int i = 0; i < n-k; ++i) { 
    pq.push(lp[i+k]);
    qp.push(lp[i+k]);
    int max = pq.top();
    int min = qp.top();
    while (used[max]) {
      pq.pop();
      max = pq.top();
    }
    while (used[min]) {
      qp.pop();
      min = qp.top();
    }
    bool last_is_max = false;
    if (max == lp[i+k]) {
      last_is_max = true;
    }
    bool first_is_min = false;
    if (min == lp[i]) {
      qp.pop();
      first_is_min = true;
    }
    // cout << min << " " << max << " " << (last_is_max && first_is_min) << " " << same[i+1] << endl;
    used[lp[i]] = true;
    if (same[i+1]) {
      if (has_same) continue;
      has_same = true;
    }
    if (last_is_max && first_is_min) continue;
    ++ans;
  }
  cout << ans << endl;
}



Measured memory_bytes: 2884
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pb push_back
#define nmax 200011
#define lld long long
#define inf 9999999999999999LL
using namespace std;
int a[nmax];
lld dp[nmax], st[nmax];
int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;++i){
        cin>>a[i];
    }
    st[1] = a[1];
    for (int i=2;i<=n;++i){
        st[i] = st[i-2] + a[i];
    }
    for (int i=2;i<=n;++i){
        if (i % 2){
            dp[i] = max(dp[i-1], dp[i-2] + a[i]);
        } else {
            dp[i] = a[i] + dp[i-2];
            dp[i] = max(dp[i], st[i-1]);
        }
    }
    cout<<dp[n]<<'\n';
    return 0;
}


Measured memory_bytes: 7544
/**
*    created: 23.06.2020 23:18:25
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, t;
    cin >> n >> t;
    vector<int> c;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if (b <= t) c.push_back(a);    
    }
    sort(all(c));
    if (c.size() == 0) cout << "TLE" << endl;
    else cout << c[0] << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int X,N;
    cin>>X>>N;
    if(N==0){
        cout<<X<<endl;
        return 0;
    }
    vector<int>P(N);
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        if(X==P[i]){
            break;
        }
        else if(i==N-1){
            cout<<X<<endl;
            return 0;
        }
    }
    sort(P.begin(),P.end());
    int ans=X;
    int count=1;
    while(1){
        if(count%2==1){
            ans=X-(count/2+1);
        }
        else{
            ans=X+count/2;
        }
        count++;
        for(int i=0;i<N;i++){
            if(ans==P[i]){
                break;
            }
            else if(i==N-1){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
        int vacation,japanese,math,japanese_max,math_max;
        cin >> vacation ;
        cin >> japanese >> math;
        cin >> japanese_max >> math_max;
        int japanese_day= japanese/japanese_max;
        if( japanese%japanese_max )
                japanese_day++;
        int math_day = math/math_max;
        if( math%math_max )
                math_day++;
        int ans;
        math_day > japanese_day?ans=math_day:ans=japanese_day;
        cout << vacation-ans << endl;
        return 0;
}

Measured memory_bytes: 3092
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    m = 26
    ans = ''
    n = N
    while n:
        ans += chr((n-1) % m + 97)
        n = (n-1) // 26
    print(ans[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MAX_N = 2 * (1e5) + 5;
vector<int> par;
vector<int> r;

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    r[i] = 0;
  }
  return;
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite (int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (r[x] < r[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (r[x] == r[y]) r[x]++;
  }
  return;
}

bool same (int x, int y) {
  return find(x) == find(y);
}


int main() {
  int N, M;
  cin >> N >> M;
  par.resize(N);
  r.resize(N);
  vector<int> x(M), y(M);
  for (int i = 0; i < M; i++) {
    cin >> x[i] >> y[i];
    --x[i]; --y[i];
  }
  init(N);
  for (int i = 0; i < M; i++) {
    unite(x[i], y[i]);
  }
  map<int, int> s;
  for (int i = 0; i < N; i++) {
    s[find(i)]++;
  }
  int ans = -1; 
  for (auto a : s) {
    ans = max(ans,a.second);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int dp[3001][3001];
int main()
{
  // #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    string s, t;
	cin >> s >> t;
	for(int i=1; i<=s.size(); ++i) 
	{
		for(int j=1; j<=t.size(); ++j) 
		{
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}

	int i=s.size(), j=t.size();
	string ans;
	while(i&&j) 
	{
		if(s[i-1]==t[j-1]) 
		{
			ans=s[i-1]+ans;
			--i;
			--j;
			continue;
		}
		if(dp[i-1][j]>dp[i][j-1])
			--i;
		else
			--j;
	}
	cout << ans;

 
  
   
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define F first
#define S second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const ll N = 1e5+10, inf = 1e3+5, mod = 1e9+7, NN = 1e5+10;
int a ;
int main()
{
    Tsetso ;
    int n  , mn = 1e9 ;
    cin >> n ;
    for ( int i = 0 ; i  <n ; i++)
    {
        int cnt = 0 ;
        cin >> a ;
        while (a%2 == 0)
                a /= 2 , cnt++ ;
        mn = min(cnt,mn) ;
    }
    cout << mn ;
}


Measured memory_bytes: 3616
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
see = [0 for i in range(n)]
ans = 1
for i in range(n):
  x = a[i]
  if x == 0:
    ans = ans*(3-see[x])%mod
  else:
    ans = ans*(see[x-1]-see[x])%mod
  see[x]+=1
print(ans)

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

int main() 
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P.at(i);
    }

    set<int> st;
    int sum = 10e5;
    for (int i = 0; i < N; i++) {
        sum = min(sum, P.at(i));
        st.insert(sum);
    }
    
    cout << st.size() << endl;
}

Measured memory_bytes: 10368
N = int(input())
a = list(map(int, input().split()))

d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
  
ans = 0
for key in d:
  if d[key] >= key:
    ans += (d[key] - key)
  else:
    ans += d[key]
print(ans)


Measured memory_bytes: 17780
#include <stdio.h>

typedef long long ll;

/////////////         modの計算
constexpr ll mod = 1000000007;
constexpr ll M = mod * mod;

constexpr int K = 16;

constexpr ll v_e[] = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
constexpr ll v_o[] = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

int main() {
	int T; scanf("%d", &T);
	for (int _t = 0; _t < T; _t++) {
		ll N; scanf("%lld", &N);
		ll ans = 0, x = 1;

		if (N & 1) {// odd
			for (int i = 0; i < K; i++) {
				ans += x * v_o[i];
				x *= N;
				if (ans >= M) { ans -= M; }
				if (x >= mod) { x %= mod; }
			}
		}
		else {// even
			for (int i = 0; i < K; i++) {
				ans += x * v_e[i];
				x *= N;
				if (ans >= M) { ans -= M; }
				if (x >= mod) { x %= mod; }
			}
		}
		printf("%lld\n", ans % mod);
	}
	fflush(stdout);

	return 0;
}


Measured memory_bytes: 1732
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    loop{
        let h = iter.next().unwrap().parse().unwrap();
        let w = iter.next().unwrap().parse().unwrap();
        if h==0 {break}
        for y in 0..h {
            for x in 0..w {
                let c = if (x+y)%2==0 {b"#"} else {b"."};
                out.write(c).unwrap();
            }
            out.write(b"\n").unwrap();
        }
        out.write(b"\n").unwrap();
    }
}



Measured memory_bytes: 5016
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int a, b; cin >> a >> b;
    cout << (a + b - 1) / b << endl;

    return 0;
}


Measured memory_bytes: 3580
#include"bits/stdc++.h"
using namespace std;

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

    vector<int> min_hist(26, INT_MAX);
    for (int i = 0; i < n; i++) {
        vector<int> hist(26, 0);
        for (char c : S[i]) {
            hist[c - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            min_hist[j] = min(min_hist[j], hist[j]);
        }
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < min_hist[i]; j++) {
            printf("%c", 'a' + i);
        }
    }
    printf("\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a, b, c, d;
  cin >> n;
  
  a = n / 1000;
  b = (n % 1000) / 100;
  c = (n % 100) / 10;
  d = n % 10;
  
  if (((a == b) && (b == c)) || ((b == c) && (b == d))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256