akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations

ABC = [input().rstrip(), input().rstrip(), input().rstrip()]

cache = [-1] * (3 * 3)


def canMatchShifted(index1, index2, shift):
    # Whether ABC[index1] can match with ABC[index2] shifted to the right by `shift`
    k = 3 * index1 + index2
    if cache[k] == -1:
        S1 = ABC[index1]
        S2 = ABC[index2]
        temp = [True] * (4001)
        for s in range(len(S1)):
            temp[s] = all(x == y or x == "?" or y == "?" for x, y in zip(S1[s:], S2))
        cache[k] = temp

    return cache[k][shift]


# Try all permutation orders of ABC
best = float("inf")
for a, b, c in permutations(range(3)):
    A = ABC[a]
    B = ABC[b]
    C = ABC[c]
    # Match A with `('?' * i) + B`
    for i in range(2001):
        if not canMatchShifted(a, b, i):
            continue
        # Match B with `('?' * j) + C`
        # Match A with `('?' * (i + j)) + C`
        for j in range(2001):
            if canMatchShifted(b, c, j) and canMatchShifted(a, c, i + j):
                l = max(len(A), i + len(B), i + j + len(C))
                best = min(best, l)
print(best)


Measured memory_bytes: 57436
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define inf pow(10, 9)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  st S;
  ci(S);
  S =="ABC" ? co("ARC") : co("ABC");
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	map<Int, Int> num;
	Int temp;
	for (Int i = 0; i < N; i++) {
		cin >> temp;
		num[temp]++;
	}

	Int ans = 0;
	for (auto itr = num.begin(); itr!=num.end(); ++itr) {
		
		if (itr->first > itr->second) {
			ans += itr->second;
		}
		else {
			ans += itr->second - itr->first;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 6272
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  int a[50],b[50];
  int j,i,head=1,temp;
  a[0]=2;b[0]=1;
  bool isPrime;
  for (i=3;i<=n;i++){
    isPrime=true;
    temp=i;
    for (j=0;j<head;j++){
      while (temp%a[j]==0){
        isPrime=false;
        temp/=a[j];
        b[j]++;
      }
    }
    if (isPrime){
      a[head]=i;
      b[head]=1;
      head++;
    }
  }
  int a3=0,a5=0,a15=0,a25=0,a75=0,ans;
  for (i=0;i<head;i++){
    if (b[i]>73)a75++;
    if (b[i]>23)a25++;
    if (b[i]>13)a15++;
    if (b[i]>3)a5++;
    if (b[i]>1)a3++;
  }
  ans=a75+a25*(a3-1)+a15*(a5-1)+a5*(a5-1)*(a3-2)/2;
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,c,k = na()

if k < a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-a-b))

Measured memory_bytes: 9196
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {

    int x,a,b,n;
    cin>>x>>a>>b;
    n=x-a;
    while(n>=b){
        n-=b;
    }
    cout<<n<<endl;
}


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

int main(){
  long long N;
  string S;
  cin >> N >> S;
  vector<long long> A(N);
  bool two = false;
  for(int i=0;i<N;i++){
    A[i] = S[i] - '0';
    if(A[i]==2) two = true;
  }
  
  if(two==false){
    for(int i=0;i<N;i++){
      if(A[i]==3) A[i]=0;
    }
  }
  
  vector<long long> V(N,0);
  for(int i=1;i<N;i++){
    int x = i;
    while(x%2==0){
      x /= 2;
      V[i]++;
    }
  }
  for(int i=2;i<=N;i++) V[i] += V[i-1];
  
  vector<long long> nC(N,V[N-1]);
  for(int i=0;i<N;i++){
    nC[i] -= V[i];
    nC[i] -= V[N-i-1];
    nC[i] = min(nC[i],(long long)1);
  }
  
  long long ans = 0;
  for(int i=0;i<N;i++){
    if(nC[i]==0) ans += A[i];
  }
  ans %= 2;
  
  if(two==false && ans==1) cout << 2 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 24836
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,ans = LLONG_MAX;
void check(ll sum[],ll i,ll j,ll k){
	if(i<0 || i>j || j>k || k>n-1){
		return;
	}
	ll a = sum[i];
	ll b = sum[j]-sum[i];
	ll c = sum[k]-sum[j];
	ll d = sum[n-1]-sum[k];
	ll mx = max(max(a,b),max(c,d));
	ll mn = min(min(a,b),min(c,d));
	if(ans > (mx-mn)){
		//cout<<ans<<" ";
		ans = mx-mn;
		//cout<<ans<<"\n";
	}
}

int main()
{
	cin>>n;
	ll seq[n];
	ll sum[n];
	for(int i=0;i<n;i++){
		cin>>seq[i];
		if(i==0){
			sum[i] = seq[i];
		}
		else sum[i] = sum[i-1] + seq[i];
	}

	for(int j=1;j<n-1;j++){
		ll i = lower_bound(sum,sum+n,(sum[j]+1)/2)-sum;
		ll k = lower_bound(sum,sum+n,(sum[n-1]+sum[j]+1)/2)-sum;
		//cout<<i<<" "<<j<<" "<<k<<"\n";
		check(sum,i-1,j,k-1);
		check(sum,i,j,k-1);
		check(sum,i-1,j,k);
		check(sum,i,j,k);
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  ll x;
  cin >> x;
  ll cur = 100;
  int result = 0;
  while (cur < x) {
    cur += cur / 100;
    result++;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1(1),v2;
		
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
//			v2.insert(v2.end(),ity-v1.begin()&1?1:2,0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back())++it,v2.pop_back();
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it){
			m=*it,
			x+=*++it-m;
		}
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

#define int long long

signed main() {
    int n, weight;
    cin >> n >> weight;
    vector<int> w(n);
    vector<int> v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<int>> dp(n+1, vector<int>(weight+1, 0));
    for (int i = 0; i < n; i++) {
        for (int sum_w = 0; sum_w <= weight; sum_w++) {
            if (sum_w - w[i] >= 0)
                chmax(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[n][weight] << endl;
    return 0;
}

Measured memory_bytes: 80256
N, K = map(int,input().split())
p = list(map(int, input().split()))

maxSum = 0
sum = 0
prevSum = 0

for i in range(K):
  maxSum += p[i]

prevSum = maxSum;
for i in range(N - K):
  sum = prevSum - p[i] + p [i + K]
  if maxSum < sum:
    maxSum = sum
  prevSum = sum

ans = (maxSum + K) / 2.0
print('{:.7f}'.format(ans))


Measured memory_bytes: 24548
#include <stdio.h>
int main(void){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0&&W == 0)break;
		for(i = 0;i < H;i++){
			for(j = 0;j < W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 572
n,time=input().split()


n=int(n)
time=int(time)

l=[]
ltim=[]
res=[]
restim=[]

for i in range(n):
    p,t=input().split()
    l.append(p)
    ltim.append(int(t))

ot=0
qhead=0
qtail=n

while qhead<qtail:
    cl=l[qhead]
    ct=ltim[qhead]
    if ct<=time:
        ot+=ct
        res.append(cl)
        restim.append(ot)
        qhead+=1
    else:
        ot+=time
        ct-=time
        l.append(cl)
        ltim.append(ct)
        qhead+=1
        qtail+=1


for o in range(n):
    print(res[o],restim[o])



Measured memory_bytes: 17540
A, B =map(int, input().split())
S = input()
NUM = list(range(10))
X = 0
while X != A+B+1:
    if X == A:
        if S[X] != "-":
            print("No")
            quit()
        X += 1
    else:
        if S[X] == "-":
            print("No")
            quit()
        if int(S[X]) in NUM:
            X += 1
        else:
            print("No")
            quit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define V vector
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

int main(){
    ins(a);ins(b);
    print((a+b)%24);
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    while (H != 0 || W !=0) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i == 0 || i == H-1) || (j == 0 || j == W-1)) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
}


Measured memory_bytes: 3092
n = int(input())
f_list = [int("".join(input().split()), 2) for _ in range(n)]
p_list = [[int(x) for x in input().split()] for _ in range(n)]
ans = -(10 ** 10)
for i in range(1, 2 ** 10):
    temp = 0
    for j in range(n):
        temp += p_list[j][bin(i & f_list[j]).count("1")]
    if temp > ans:
        ans = temp
print(ans)

Measured memory_bytes: 3188
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    final long mod = 1000000000+7;
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
        out.flush();
//        System.out.println(main.solve());
    }
    // segment tree to record minimum value
    // Each point has a infinite distance from 0 (except itself)
    void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        double[] p = new double[n];
        for(int i=0;i<n;i++) p[i]=sc.nextInt();
        double res = 0.0;
        for(int i=0;i<k;i++) res += (p[i]+1.0)/2.0;
        double ans = res;
        for(int end = k;end<n;end++){
            res -= (p[end-k]+1.0)/2;
            res += (p[end]+1)/2.0;
            ans = Math.max(ans,res);
        }
        out.println(ans);
    }
}



Measured memory_bytes: 81396
n = int(input())
n2 = list(str(n))

for i in range(len(n2)):
    if n2[i] == '1':
        n2[i] = '9'
    elif n2[i] == '9':
        n2[i] = '1'

n2 = ''.join(n2)
print(int(n2))

Measured memory_bytes: 3060
N = int(input())
S =list(input())

if N%2 == 1 :
    print("No")
else:
    l =S[:N//2]
    r = S[N//2:]


    for e1,e2 in zip(l,r):
        if e1 == e2:
            pass
        else:
            print("No")
            exit()
    
    print("Yes")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int c[101][101];
int t[101][101];//d[u][v]??????e=(u,v)????????????(?????¨???????????´??????INF,??????d[i][i]=0??¨??????)
int V;//????????°
const int INF=10000000;

void warshall_floyd(){
	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
				t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
			}
		}
	}
}

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		V=m;
		if(n+m==0) break;
		rep(i,0,V){
			rep(j,0,V){
				if(i==j){
					c[i][j]=0;
					t[i][j]=0;
				}else{
					c[i][j]=INF;
					t[i][j]=INF;
				}
			}
		}
		int a,b,cost,time;
		rep(i,0,n){
			cin>>a>>b>>cost>>time;
			a--; b--;
			c[a][b]=cost;
			c[b][a]=cost;
			t[a][b]=time;
			t[b][a]=time;
		}
		warshall_floyd();
		int kazu,p,q,r;
		cin>>kazu;
		rep(i,0,kazu){
			cin>>p>>q>>r;
			p--; q--;
			o((r==0?c[p][q]:t[p][q]));
		}
	}
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
ll a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,m,h,p,df[51];
string t,x,q,s;
double w;
vector<ll>dv[101],v,z;
vector<string>u;
map<string,ll>n;
set<ll>y;
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(dv[x][i]==0){
            dfs(dv[x][i]);
            df[dv[x][i]]=1;
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>s;
    d=0;
    for(i=0;i<s.size();i++){
        d+=(s[i]-48);
    }
    if(d%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3752
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        if(sc.nextInt() % 2 == 0||sc.nextInt() % 2 == 0) System.out.println("No");
        else System.out.println("Yes");
    }

}




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

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> b[i];
	for(int i=0; i<n-1; i++) a[i+1] += a[i];
	for(int i=n-1; i>0; i--) b[i-1] += b[i];
	int ans = 0;
	for(int i=0; i<n; i++){
		ans = max(ans, a[i]+b[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long
using namespace std;
lint n;
int a[20];
int main(){
	int i,j,ans = 0;
	cin>>n;
	for(i = 0;i < 20;++i) {
		a[i] = n % 10;
		n /= 10;
		if(!n) break;
	}
	int as = 0;
	for(;i >= 0;--i){
		ans = max(ans,as + a[i] - 1 + 9 * i);
		as += a[i];
	}
	cout<<max(as,ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			str = br.readLine();
			String[] s = str.split(" ",0);
			boolean[] count = new boolean[N+1];
			Arrays.fill(count, false);
			for(int i=0; i< N;i++) {
				if(i+1 == Integer.parseInt(s[i])) {
					count[i] = true;
				}
			}
			int x = 0;
			int conti = 0;
			for(int i = 0; i < N ; i++) {
				if(count[i]==true && count[i+1]==true) {
					conti++;
				}else {
					// 2 -> 1 3 -> 2  4 -> 2  5->3 6->3
					if(conti > 0){//true (true false)
						x -=(conti+1)/2;
						conti = 0;
					}
				}
				if(count[i]==true) x++;
			}
			System.out.println(x);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


Measured memory_bytes: 35540
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int H, W, CH, DH, CW, DW;
    cin >> H >> W >> CH >> CW >> DH >> DW;
    CH--; CW--; DH--; DW--;
    string S[1000];
    REP(i, H) cin >> S[i];

    bool visited[1000][1000] = {};
    deque<pair<int, pii>> que;
    que.push_front({0, {CH, CW}});
    while (!que.empty()) {
        auto f = que.front(); que.pop_front();
        int phase = f.first, h = f.second.first, w = f.second.second;
        visited[h][w] = true;
        if (h == DH && w == DW) {
            cout << phase << endl;
            return 0;
        }

        int dh[4] = {0, 1, 0, -1}, dw[4] = {1, 0, -1, 0};
        REP(i, 4) {
            int nh = h + dh[i], nw = w + dw[i];
            if (nh < 0 || H <= nh || nw < 0 || W <= nw || S[nh][nw] == '#' || visited[nh][nw]) continue;
            que.push_front({phase, {nh, nw}});
        }
        FOR(dh, -2, 3) FOR(dw, -2, 3) {
            int nh = h + dh, nw = w + dw;
            if (nh < 0 || H <= nh || nw < 0 || W <= nw || S[nh][nw] == '#' || visited[nh][nw]) continue;
            que.push_back({phase + 1, {nh, nw}});
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 12364
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char** argv) {
    int N, K;
    cin >> N >> K;

    vector<int> cost(N);

    for (int i = 0; i < N; i++) {
        cin >> cost[i];
    }

    vector<int> DP(N);
    DP[0] = 0;
    int i = 1;
    while (i < N) {
        int min_jump = INT_MAX;
        for (int j = max(0, i - K); j < i; j++) {
            min_jump = min(min_jump, DP[j] + abs(cost[j] - cost[i]));
        }
        DP[i] = min_jump;
        i++;
    }
    cout << DP[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	S string
	d [20]int
	N int
)

func readVariables() {
	S = nextStr()
	N = len(S)
	for i := 0; i < N; i++ {
		d[i], _ = strconv.Atoi(string(S[i]))
	}

}

func main() {
	readVariables()
	answer := 0
	for i := 0; i < N; i++ {
		answer += d[i]
	}
	c := d[0] - 1
	c += 9 * (N - 1)
	// fmt.Println(d[0:N], N, c, answer)
	answer = MaxInt(c, answer)
	fmt.Println(answer)
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=1000;
static const int VMAX=10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
    int ans=0;
    bool V[MAX];
    for(int i=0;i<n;i++){
        B[i]=A[i];
        V[i]=false;
    }   
    sort(B,B+n);        
    for(int i=0;i<n;i++)T[B[i]]=i;
    for(int i=0;i<n;i++){
        if(V[i])continue;
        int S=0;
        int cur=i;
        int m=VMAX;
        int an=0;
        while(1){
            V[cur]=true;
            an++;
            m=min(m,A[cur]);
            S+=A[cur];
            cur=T[A[cur]];
            if(V[cur])break;                                              
        }   
        ans+=min(S+(an-2)*m,m+S+(an+1)*s);
    }   
    return ans;

}
int main(){
    cin>>n;
    s=VMAX;
    for(int i=0;i<n;i++){
        cin>>A[i];
        s=min(s,A[i]);
    }   
    int ans=solve();
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 3136
S, T = gets.split(" ").map(&:chomp)
A, B = gets.split(" ").map(&:chomp).map(&:to_i)
U = gets.chomp

if U == S
  res_a = A - 1
  res_b = B
else
  res_a = A
  res_b = B - 1
end

puts "#{res_a} #{res_b}"

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    map<ll, int> mp;
    rep (i, n) {
        ll x;
        cin >> x;
        mp[x]++;
        if (mp[x] > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    return 0;
}



Measured memory_bytes: 12800
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        String E = sc.next();
        char[]e = E.toCharArray();
        
        if(S.length() == E.length()) {
        	for(int i=0; i<S.length(); i++) {     	
        		System.out.print(ss[i]);    
        		System.out.print(e[i]);
        	}
        	}else {
        	for(int i=0; i<E.length(); i++) {     	
        		System.out.print(ss[i]);    
        		System.out.print(e[i]);	
        	}
        		System.out.print(ss[S.length()-1]);
        }
    }
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

#define INF 1e9

int main() {
  int N, K;
  cin >> N >> K;
  // height, cost
  vector<vector<int>> dp (N + K - 1, vector<int>(2, 0));
  rep(i, 0, K - 1) {
    dp[i][0] = INF;
  }
  rep(i, K - 1, N + K - 1) {
    cin >> dp[i][0];
  }
  rep(i, K, N + K - 1) {
    int m = INF;
    rep(j, 1, K + 1) {
      m = min(m, abs(dp[i - j][0] - dp[i][0]) + dp[i - j][1]);
    }
    dp[i][1] = m;
  }

  cout << dp[N + K - 2][1] << endl;
};


Measured memory_bytes: 5760
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int hMax = sn.nextInt();
        int wMax = sn.nextInt();
        int h = sn.nextInt();
        int w = sn.nextInt();
        
        System.out.println(hMax * wMax - (h * wMax + hMax * w - h * w));
        
    }
}

Measured memory_bytes: 21844
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

A = [int(v) for v in input().split()]
L = [[int(v) for v in input().split()] for _ in range(M)]

l = []
for v in A:
     l.append((v * -1, 1))
for x, y in L:
     l.append((y * -1, x))
heapify(l)

ans = 0
while N != 0:
     x, y = heappop(l)
     x *= -1
     if N <= y:
          ans += x * N
          N = 0
     else:
          ans += x * y
          N -= y

print(ans)

Measured memory_bytes: 47372
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s,t;
  cin >> s >> t;
  vector<string> ans;
  rep(i, (int)s.length()) {
    bool ok = true;
    string res = s;
    rep(j, (int)t.length()) {
      if (s[i+j] != t[j] && s[i+j] != '?') {
        ok = false; break;
      }
      else res[i+j] = t[j];
    }
    if (ok) {
      rep(j, (int)res.length()) {
        if (res[j] == '?') res[j] = 'a';
      }
      ans.emplace_back(res);
      debug(res);
    }
  }
  if (ans.size() == 0) {
    cout << "UNRESTORABLE\n";
    return 0;
  }
  sort(all(ans));
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<lint> a_list(3 * N);
    range(i, 0, 3 * N) cin >> a_list.at(i);
    sort(a_list.begin(), a_list.end());
    deque<lint> available_ones;
    range(i, 0, 3 * N) available_ones.emplace_back(a_list.at(i));
    lint ans = 0;
    while (!available_ones.empty()) {
        available_ones.pop_front();
        available_ones.pop_back();
        ans += available_ones.back();
        available_ones.pop_back();
    }
    cout << ans << "\n";
}

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

int main() {
  int A, B, K;
  int count = 0;
  
  cin >> K;
  cin >> A >> B;
  
  for(int i=A; i<B+1; i++) {
    if(i%K == 0) {
      count = 1;
      break;
    }
  }
  
  if(count==1) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
  return 0;
}
    

Measured memory_bytes: 3624
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int a[7]={160,140,120,100,80,60,0};
int b[7]={25,20,15,10,5,2,0};
int c[7]={0,1600,1400,1200,1000,800,600};
int n;
while(cin>>n,n){
int sum=0;
rep(i,n){
int x,y,h,w;
cin>>x>>y>>h>>w;
rep(j,7)if(x+y+h>a[j]||w>b[j]){sum+=c[j];break;}
}
cout<<sum<<endl;
}
}

Measured memory_bytes: 1160
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  //f(x) => (-1,0,1)
  @tailrec
  def binarySearch(f: Int => Int,l: Int, r: Int): Int = {
    if(r-l<=1)f(l)
    else if(f((l+r)/2) < 1)binarySearch(f,(l+r)/2,r)
    else binarySearch(f,l,(l+r)/2)
  }
/*
  def loop(n: Int,in: Int, q: Int, cnt:Int,f: Int => Int => Int):Int = {
    if(q==0)cnt
    else loop(n,readInt,q-1,cnt+(if(0==binarySearch(f(in),0,n)) 1 else 0),f )
  }
*/
  def main(args: Array[String]): Unit = {
    val n = readInt
    val list = readLine.split(" ").map(_.toInt)//.toList

    val f = (ar: Seq[Int]) => (a: Int) => (x: Int) => ar(x)-a

    val q = readInt
    val qlist = readLine.split(" ").map(_.toInt)
    //var res:Int = 0
    //for(e <- qlist)res=res+(if(0 == binarySearch(f(list)(e),0,n)) 1 else 0)
    //println(res)
    val res = for(e <- qlist)yield(0 == binarySearch(f(list)(e),0,n))
    println(res.map(if(_) 1 else 0).sum)
    //println(loop(n,readInt,q,0,f(list)))
  }
}

Measured memory_bytes: 90068
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, N;
    scan(H, N);
    auto A = aryread();
    writeln(H <= A.sum() ? "Yes" : "No");
}


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

int main() {
  int a, b, c, d ,e, f;

  cin >> a >> b >>c;

  f = a + b + c;

  d = min({a,b,c});
  e = max({a, b, c});
  f = f - (d+e);

  
  cout << e * 10 + f + d;

  
  return 0;
}

Measured memory_bytes: 256
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int a, b;
    cin >> a >> b;
    a += b;
    if(a < 10){
        cout << a << endl;
    } else {
        cout << "error" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin>>n>>m;
	vector<int> k(m);
	vector<vector<int> > s(m,vector<int>());
	for(int i = 0; i < m; i++){
		cin >> k[i];
		s[i].resize(k[i],0);
		for(int j = 0; j < k[i]; j++){
			cin>>s[i][j];
		}
	}
	vector<int> p(m);
	for(int i = 0; i < m; i++){
		cin>>p[i];
	}

	int ans = 0;
	for(int bit = 0; bit < (1<<n); bit++){
		vector<int> on(n,0);
		for(int i = 0; i < n; i++){
			if(bit & (1<<i)) on[i]++;
		}
		int cnt = 0;
		for(int i = 0; i < m; i++){
			int sw = 0;
			for(int j = 0; j < k[i]; j++){
				if(on[s[i][j]-1]) sw++;
			}
			if(sw%2==p[i])cnt++;
		}
		if(cnt == m) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int H, W;
  string S, smap;
  cin >> H >> W;

  vector<string> map ( H + 2 );
  for ( int w = 0; w < W + 2; w++ ) 
    smap += '*';
  map.at( 0 ) = smap;
  for ( int h = 1; h <= H; h++ ) {
    cin >> S;
    map.at( h ) = '*' + S + '*';
  }
  map.at( H + 1 ) = smap;

  for ( int h = 1; h < H + 1; h++ ) {
    for ( int w = 1; w < W + 1; w++) {
      int num = 0;
      if( map.at( h ).at( w ) != '#' ) {
        if ( map.at( h - 1 ).at( w - 1 ) == '#' )
            num++;
        if ( map.at( h - 1 ).at( w ) == '#' )
            num++;
        if ( map.at( h - 1 ).at( w + 1 ) == '#' )
            num++;
        if ( map.at( h ).at( w - 1 ) == '#' )
          num++;
        if ( map.at( h ).at( w + 1 ) == '#' )
          num++;
        if ( map.at( h + 1 ).at( w - 1 ) == '#')
          num++;
        if ( map.at( h + 1 ).at( w ) == '#')
          num++;
        if ( map.at( h + 1 ).at( w + 1 ) == '#' )
          num++;     
        cout << num;
      }
      else {
        cout << '#';
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
// splits and replaces string
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<string> split(const string &str, char delim){
	vector<string> res;
	size_t current = 0, found;
	while((found = str.find_first_of(delim, current)) != string::npos){
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

void replaceStr(string& str, const string& from, const string& to)
{
  string::size_type pos = 0;

  while(pos = str.find(from, pos), pos != string::npos) {
    str.replace(pos, from.length( ), to);
    pos += to.length();
  }
}

int main(){
	bool first = true;
	string s;
	getline(cin, s);
	replaceStr(s, ",", "");
	replaceStr(s, ".", "");
	vector<string> strings = split(s,' ');
	for (int i = 0; i < strings.size(); i++) {
		if (strings[i].size() > 2 && strings[i].size() < 7) {
			if (first) {
				first = false;
				cout << strings[i];
			}else {
				cout << " " << strings[i];
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
// Created by sz
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;

const int N = 1e5 + 5;
typedef pair<int, int> pii;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    vector<vector<int>> groups;
    if(n&1){
        int m = (n-3)* (n-1)/2 + n-1;
        cout<<m<<endl;
        for (int i = 1; i <= n; i++){
            if(i<n-i)groups.push_back(vector<int>{i, n-i});
            else break;
        }
        groups.push_back(vector<int>{n});

    }else{
        int m = n * (n-2)/2;
        cout<<m<<endl;
        for (int i = 1; i <= n; i++){
            if(i<n-i+1)groups.push_back(vector<int>{i, n-i+1});
            else break;
        }

    }
    
    for (int i= 0 ;i <groups.size();  i++) {
        for (int j = i+1;j <groups.size(); j++) {
                for (auto x : groups[i]) {
                    for (auto y : groups[j]) {
                        cout<<x<<' '<<y<<endl;
                    }
                }
            }
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>

#define INF 1000000000;
#define MOD 1000000007;
typedef long long ll;
using namespace std;

int main()
{
    string s; cin >> s;
    sort(s.begin(), s.end());
    string ans = "No";
    if (s == "abc") {
        ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
int main(){
	int n,t;
	cin >> n >> t;

	auto ct = vector<p>(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ct[i].first >> ct[i].second;
	}
	
	sort(ct.begin(),ct.end());
	
  	bool flag = true;
	for (auto i : ct)
	{
		if(i.second<=t){
			cout << i.first;
          	flag = false;
			break;
		}
	}
  
	if(flag)cout << "TLE";
  

	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(v) v.begin(),v.end()
#define vi vector<int> 
#define mod 1000000007
#define inf 1e17
#define fs first
#define ss second

template <typename T> 
void amax(T& x, T y) 
{ 
    if( x < y) x = y;
} 

template <typename T> 
void amin(T& x, T y) 
{ 
    if( x > y) x = y;
} 



int main(){
    
    int a,b,c;
    cin >> a >> b;
    cout << 6 - a - b << endl; 
    

}


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

int main(){
    int h,w;
    cin>>h>>w;

    string s[h];
    for (int i=0;i<h;i++){
        cin>>s[i];
    }
    for (int i=0;i<h;i++){
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
#include <utility>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < t.size() - 1; i++)
    {
        if (s[i] != t[i])
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

#define ll long long

using namespace std;

bool isPal(string s) {
//    cout << s << "\n";
    string s2 = s;
    reverse(s.begin(), s.end());
    if (s2 == s) {
        return true;
    } else {
        return false;
    }
}

int a[3100];
int d[3100][3100];

int main() {

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

    string s;
    cin >> s;

    if (isPal(s) && isPal(s.substr(0, (s.length() - 1)/2)) && isPal(s.substr((s.length() + 3) / 2 - 1, s.length() - (s.length() + 3) / 2 + 1))) {
        cout << "Yes";
    } else {
        cout << "No";
    }

//    int n, m;
//    cin >> n >> m;
//
//    for (int i = 0; i < n; i ++) {
//        cin >> a[n - 1 - i];
//    }
//
//
//
//    for (int i = 0; i <= n; i ++) {
//        for (int j = 0; j <= m; j ++) {
//            d[i][j] = 0;
//        }
//
//    }
//
//    d[0][0] = 1;
//
//
//
//    for (int i = 0; i < n ;i ++) {
//        for (int j = 0; j <= m; j ++) {
//            d[i + 1][j] += d[i][j];
//            if (j + a[i] <= m) {
//                d[i + 1][j + a[i]] += d[i][j];
//            }
//        }
//    }
//
//    for (int i = 0; i <= m; i ++) {
//        cout << i << " " << d[n][i] << "\n";
//    }
//
//    cout << "---\n";
//    for (int i = 0; i <= n; i ++) {
//        cout << d[i][m] << " ";
//    }
//
//

}


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

using namespace std;

const int M = 1e5 + 5;
long long n, t[M], dp[M];

long long solve (int id) {
    if (id >= n) return 2e9;
    if (id == n-1) return 0;
    long long &ret = dp[id];
    if (ret != -1) return ret;
    ret = min (solve(id+1)+abs(t[id]-t[id+1]), solve(id+2)+abs(t[id]-t[id+2]));
    return ret;
}

int main () {
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) scanf("%lld", &t[i]);
    t[n] = 2e9;
    memset(dp, -1, sizeof dp);
    printf("%lld", solve (0));
}


Measured memory_bytes: 3328
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define maxn 300005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

typedef pair<int,int>pi;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const ll mx = 1000000000000;
#define PI 3.14159265
vector<pi>af;
ll k;
int n , a[maxn] , f[maxn];
bool check(ll t)
{
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
        ll dif = 1LL*a[i]*f[i] - t;
        if(dif<=0)continue;
        cnt+= dif/f[i];
        if(dif%f[i]!=0)
            cnt+=1;
    }
    if(cnt>k)
        return false;
    return true;
}
int main()
{
    fastio;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>f[i];

    sort(a,a+n);sort(f,f+n);
    reverse(f,f+n);
    ll ti=-1;
    for(ll j=inf;j>=1;j/=2)
    {
        while(ti+j<=inf)
        {
            bool f = check(ti+j);
            if(!f)
                ti+=j;
            else break;
        }
    }
    cout<<ti+1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    char c;
    cin>>c;
    if(c=='a' || c=='i' || c=='u' || c=='e'|| c=='o')
        printf("vowel\n");
    else
        printf("consonant\n");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 110;
const int MOD = 1000000007;
ll n;vll res(MAX);
void factorize(ll k) {
    for (ll i = 2; i * i <= k; i++) {
        if (k % i != 0) continue;
        while (k % i == 0) {
            k /= i;
            res[i]++;
        } 
    }
    if (k != 1) res[k]++;
    return;
}
int main(){
  cin>>n;
  REP(i,n){
    factorize(i+1);
  }
  vll prime(5);
  REP(i,n+1){
    if(res[i]>=2){prime[0]++;}
    if(res[i]>=4){prime[1]++;}
    if(res[i]>=14){prime[2]++;}
    if(res[i]>=24){prime[3]++;}
    if(res[i]>=74){prime[4]++;}
  }
  ll ans=0;
  if(prime[0]>0){ans+=(prime[0]-1)*prime[3];}
  if(prime[1]>0){ans+=(prime[1]-1)*prime[2];}
  if(prime[0]>0&&prime[1]>1){ans+=(prime[0]-2)*(prime[1]*(prime[1]-1))/2;}
  ans+=prime[4];
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> D(N);
  rep(i,N)
  {
    cin >> D[i];
  }
  set<int> S;
  rep(i,N)
  {
    S.insert(D[i]);
  }

  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, A, B, C, X;
	while (true) {
		cin >> N >> A >> B >> C >> X;
		if (N + A + B + C + X == 0)break;
		vector<int> Y(N);
		for (int i = 0; i < N;i++) cin >> Y[i];
		int ans = 0;
		while (!Y.empty()) {
			if (Y[0] == X) {
				Y.erase(Y.begin());
				if (Y.empty()) break;
			}
			if (ans == 10000) { ans = -1; break; }
			X = (A*X + B) % C;
			ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3120