akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)  for(long long i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

ll power(ll Y){
    return Y*Y*Y*Y*Y;
}

int main(){
    ios;
    ll X;
    cin >> X;
    for(ll i = -1000; i <= 1000; i++){
        for(ll j = -1000; j <= 1000; j++){
            if(power(i) - power(j) == X){
                cout << i << ' ' << j;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

map<string,ll> mp;
int n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll res=0;
	for(auto i=mp.begin();i!=mp.end();i++){
		ll t=i->second;
		res+=t*(t-1)/2;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
int main() {
	int a, b, k; cin >> a >> b >> k;
	for (int i = min(a, b); i >= 1; i--) {
		if (a % i == 0 && b % i == 0) {
			k--;
			if (k == 0) {
				cout << i << endl;
				return 0;
			}
		}
	}
	assert(false);
}

Measured memory_bytes: 256
import math
A, B, H, M = [float(i) for i in input().split()]
C = float(abs(30.0*H + 0.50*M - 6.0*M))
if C > 180:
    C = 360.0 - C
c2 = A*A + B*B - 2*A*B*(math.cos((C/180.0)*math.pi))
c2 = math.sqrt(c2)
print(f'{c2:.{15}f}')

Measured memory_bytes: 9444
#include<iostream>


using namespace std;
int main(void){

	int n,m;
	int a;
	int b[1000]={0};
	int c[1000]={0};
	int v=0;
	int i,j;
	for(;;){

	cin >> n;
	cin >> m;
	for(i =0;i<1000;i++){
	    b[i]=0;
	    v=0;
	}
	if(n==0&&m==0)break;
	for( i=0;i<n;i++){
        for( j=0;j<m;j++){

            cin >> a;
            b[j]+=a;

        }
    }
    for( i=n;i>=0;i--){
        for(j=0;j<m;j++){

            if(b[j]==i){
                c[v]=j;
                v++;
            }
        }
    }
    for(j=0;j<m;j++){

        cout << c[j]+1  ;
        if(j==m-1)cout << endl;
        else cout << " ";
        }

	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main()
{
    int n;
    int a, b, c;

    cin >> n;
    while (n--) {
        cin >> a >> b >> c;
        a *= a;
        b *= b;
        c *= c;

        if ((a + b - c == 0) || (a + c - b == 0) || (b + c - a == 0))
            cout << "YES\n";
        else
            cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 1120
from queue import Queue

N,u,v= map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]
for a,b in ab:
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

inf = 1<<30
du = [inf]*N
dv = [inf]*N
du[u-1] = 0
dv[v-1] = 0

visited = [False]*N
visited[u-1] = True

que = Queue()
que.put(u-1)
while not(que.empty()):
    nxt = que.get()    
    for nv in edge[nxt]:
        if not visited[nv]:
            que.put(nv)
            du[nv] = du[nxt]+1
            visited[nv] = True
visited = [False]*N
visited[v-1] = True
del que
que = Queue()
que.put(v-1)
while not(que.empty()):
    nxt = que.get()    
    for nv in edge[nxt]:
        if not visited[nv]:
            que.put(nv)
            dv[nv] = dv[nxt]+1
            visited[nv] = True

idx=0
maxd = 0
for i in range(N):
    if du[i]<dv[i]:
        if maxd<dv[i]:
            maxd=dv[i]
            idx = i

ans = dv[idx]-1
print(ans)



Measured memory_bytes: 98388
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
a,b,c,d = [],[],[],[]
for i in range(q):
  a.append(abcd[i][0])
  b.append(abcd[i][1])
  c.append(abcd[i][2])
  d.append(abcd[i][3])

def score(A):
  tmp = 0
  for ai, bi, ci, di in zip(a, b, c, d):
      if A[bi] - A[ai] == ci:
          tmp += di
  return tmp

def dfs(A):
  if len(A)==n+1:
    return score(A)
  ans = 0
  for i in range(A[-1],m):
    A.append(i)
    ans = max(ans,dfs(A))
    A.pop()
  return ans

print(dfs([0]))

Measured memory_bytes: 9236
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prt3(var1, var2, var3) cout << var1 << " " << var2 << " " << var3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(l,n);

  sort(all(l));

  ll ans=0;
  rep(i,n-2){
    REP(j,i+1,n-1){
      REP(k,j+1,n){
        //prt3(i,j,k);
        if(l[i]+l[j]>l[k]){
          ans++;
        } else {
          break;
        }
      }
    }
  }

  prt(ans);

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int H,W;
	void solve(){
		Scanner sc=new Scanner(System.in);
		H=sc.nextInt();
		W=sc.nextInt();
		String[] s=new String[H];
		for(int i=0;i<H;i++){
			s[i]=sc.next();
		}
		for(int i=0;i<W+2;i++)System.out.print("#");
		System.out.println();
		
		for(int i=0;i<H;i++){
			System.out.print("#");
			System.out.print(s[i]);
			System.out.println("#");
		}
		
		for(int i=0;i<W+2;i++)System.out.print("#");
		System.out.println();
		
	}
	
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A,B,K; cin >> A >> B >> K;
    int cnt = 0;    
    for (int i=min(A,B);i>=1;i--){
        if (A%i==0&&B%i==0){
            cnt++;
            if (cnt==K) {
                cout << i << endl;
                return 0;
            }
        }
    }
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n;
	cin >> n;
	long long nodes = 0;
	long long edges = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		edges += (long long)u * (n - v + 1);
	}
	for (int i = 0; i < n; i++) nodes += (long long)(i + 1) * (n - i);
	cout << nodes - edges << endl;
	return (0);
}


Measured memory_bytes: 3632
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	int A=sc.nextInt();
    	int B=sc.nextInt();

    	if(B-A<=0) {
    		System.out.println("delicious");
    	}else if(B-A<=X) {
    		System.out.println("safe");
    	}else {
    		System.out.println("dangerous");
    	}
    }
}


Measured memory_bytes: 21844
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])


ans,j=0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans =max(ans,i+j)

print(ans)

Measured memory_bytes: 134100
#include<cstdio>
#include<cstring>
using namespace std;
char a[200][200], ans[200][200];

int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	for(int i = 0; i < 200; i++) {
		for(int j = 0; j < 200; j++) {
			a[i][j] = '#';
		}
	}
	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			scanf(" %c", &a[i][j]);
		}
	}
	for(int i = 0; i < (h + 2); i++) {
		for(int j = 0; j < (w + 2); j++) {
			printf("%c", a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
double ans;

int main() {
	scanf("%d %d", &n, &k);
	if(n >= k) ans += 1.0 * (n - k + 1) / n;
	for(int i = 1; i <= min(n, k - 1); i++) {
		int s = i;
		for(int j = 1; j <= 20; j++) {
			s *= 2;
			if(s >= k) {
				double t = 1.0;
				for(int k = 1; k <= j; k++) t *= 0.5;
				ans += t * 1.0 / n;
				break;
			}
		}
	}
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int alphabet[27];

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    string s; cin >> s;
    for(auto ch : s)
    {
        alphabet[ch - 'a'] += 1;
    }
    for(int i = 0; i < 27; i++)
    {
        if(alphabet[i] % 2 == 1)
        {
            cout << "No"; return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
long long n, sum=0;
vector<long long> arr;
long long lucas(long long l){
	if(l == n+1){
		if(l==0)
			return 2;
		else if(l==1)
			return 1;
		else
			return sum;
	}
	else{
		if(l==0){
			arr.push_back(2);
			sum=2;
		}
		else if(l==1){
			arr.push_back(1);
			sum=1;
		}
		else{
			sum=arr[l-2]+arr[l-1];
			arr.push_back(sum);
		}
		lucas(l+1);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	
 	cin>>n;
 	cout<<lucas(0);
 	
	return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val steps = new BufferedReader(new InputStreamReader(System.in)).readLine().toCharArray

    System.out.println(
      if (steps.zipWithIndex.forall { case (step, index) =>
        index % 2 == 0 && Array('R', 'U', 'D').contains(step) || index % 2 == 1 && Array('L', 'U', 'D').contains(step)
      }) {
        "Yes"
      } else {
        "No"
      }
    )
  }
}


Measured memory_bytes: 25544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int ans[110000];
int treesize[110000];

struct Unionfind {
  vector<int> par;

  Unionfind(int n) : par(n) {
    rep(i,n) par[i] = i;
  }

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

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx==ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  Unionfind tree(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree.unite(a,b);
    ans[a]--; ans[b]--;
  }
  rep(i,k) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    if(tree.root(c)==tree.root(d)) {
      ans[c]--; ans[d]--;
    }
  }
  rep(i,n) treesize[tree.root(i)]++;
  rep(i,n) {
    int r = tree.root(i);
    ans[i] += (treesize[r] - 1);
  }
  rep(i,n) {
    cout << ans[i];
    if(i!=n-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  msi m;
  rep(i, n) m[s[i]]++;
  int mx = 0;
  for (auto it : m)
    mx = max(mx, it.second);
  for (auto it : m)
    if (it.second == mx)
      cout << it.first << endl;
  return 0;
}


Measured memory_bytes: 26752
package main

import "fmt"

func main() {
	var n, cnt int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	for i := 0; i <= n-3; i++ {
		if s[i:i+3] == "ABC" {
			cnt++
		}
	}
	fmt.Println(cnt)
}


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

typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> t;
  t.push_back(1);
  while (true) {
    int a = t[t.size() - 1];
    if (a > K) break;
    else {
      t.push_back(a * 2);
    }
  }
  double p = 0.0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < t.size(); j++) {
      if (i * t[j] >= K) {
        double b = N * t[j];
        p += 1 / b;
        break;
      }
    }
  }
  printf("%.10f\n", p);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
count = 1
A = []
B = []
for a in l:
    if count % 2 == 1:
        A.append(a)
    else:
        B.append(a)
    count += 1
print(sum(A) - sum(B))


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;
static const int MAX = 1400;
int H, W;
int dp[MAX][MAX], imap[MAX][MAX];



int getLargestSquare() {
    int maxw = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            dp[i][j] = (imap[i][j] + 1) % 2;
            maxw |= dp[i][j];
        }
    }


    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (imap[i][j]) dp[i][j] = 0;
            else {
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                maxw = max(maxw, dp[i][j]);
            }
        }
    }


    return maxw*maxw;
}

int main() {
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) scanf("%d", &imap[i][j]);
    }
    printf("%d\n", getLargestSquare());
    return 0;
}



Measured memory_bytes: 18028
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
ll dp[10005]; // dp[i] := HPをi減らす時の最小の魔力消費量
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    rep(i,1e4+5)dp[i] = 1e18;
    dp[0] = 0;
        for(int j=0;j<=1e4;j++){
            rep(i,N){
                if(j-A[i]>=0)dp[j] = min(dp[j],dp[j-A[i]]+B[i]);
                else if(j<=A[i]) dp[j] = min(dp[j], dp[0] + B[i]);
            }
        }

    ll ans = 1e18;
    for(int i=1e4+4;i>=H;i--){
        ans = min(ans,dp[i]);
    }
    cout << ans << endl;
}


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

int main() {
  int N , M;
  cin >> N >> M;
  vector<int> city(N);
  
  for (int i = 0; i < M; i++){
  	int a , b;
    cin >> a >> b;
    city.at(a - 1) += 1;
    city.at(b - 1) += 1;
  }
  
  for (int i = 0; i < N; i++){
  	cout << city.at(i) << endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100001

typedef struct
{
  char name[15];
  int time;
}job;

job J[N+1]={};
int head;
int tail;

int isEmpty();
int isFull();
void enqueue(job);
job dequeue();
int min(int, int);

int main()
{
  int n,q;
  int i;
  scanf("%d%d",&n,&q);
  
  for(i=0;i < n;i++){
    scanf("%s%d",J[i].name, &J[i].time);
  }
  head = 0;
  tail = n;

  job process;
  int jobtime = 0;
  int t;
  
  while( !isEmpty() ){
    process = dequeue(n);
    t = min(process.time, q);
    process.time -= t;
    jobtime += t;
    
    if(process.time > 0){
      enqueue(process);
    }
    else{
      printf("%s %d\n", process.name, jobtime);
    }
  }
  return 0;
}

void enqueue(job j)
{
  J[tail] = j;
  tail = (++tail)%N;
}

job dequeue()
{
  job j = J[head];
  head = (++head)%N;
  return j;
}

int isFull()
{
  return head == (tail+1)%N;
}

int isEmpty(){
  return head == tail;
}

int min(int a, int b)
{
  if(a < b) return a;
  else return b;
}




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

int main()
{
  int a,b;
  cin >> a >> b;
  
  int ans = 0;
  for(int i = a; i <= b; i++){
    string s = to_string(i);
    string t = s;
    reverse(t.begin(),t.end());
    if(s == t){
      ans++;
    }
  }
  
  cout << ans << endl;
       
}

Measured memory_bytes: 3616
# -*- coding:utf-8 -*-
N = int(input())
K = int(input())
x_list = list(map(int,input().split()))

sum_distance = 0

for x in x_list:
    if x < K - x:
        sum_distance += 2*x
    else:
        sum_distance += 2*(K-x)

print(sum_distance)

Measured memory_bytes: 9036
r,g,b,n = map(int,input().split(" "))

c = 0

for i in range(n//r + 1):

	n1 = n-r*i


	for j in range(n1//g + 1):

		n2 = n1 - g * j


		if(n2%b == 0):
			c += 1


print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int takacnt=0;
    int aocnt = 0;
    while(a>0){
        a-=d;
        aocnt++;
    }
    while (c>0)
    {
        c-=b;
        takacnt++;
    }
    if (takacnt<=aocnt)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#define mod 1000000007
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	ll a, b, c;
	cin >> a  >> b >> c;
	if (a < b && b < c)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int H, W, N;
    cin >> H >> W >> N;
    map<P, ll> mp;
    for(int i = 0; i < N; ++i){
        int x, y;
        cin >> x >> y;
        for(int dx = -2; dx <= 0; ++dx){
            int nx = x + dx;
            if(nx < 1 || nx > H - 2)    continue;
            for(int dy = -2; dy <= 0; ++dy){
                int ny = y + dy;
                if(ny < 1 || ny > W - 2)    continue;
                ++mp[P(nx, ny)];
            }
        }
    }
    vector<ll> ans(10, 0);
    ll S = 0;
    for(auto it : mp){
        ++ans[it.second];
        ++S;
    }
    ans[0] = (ll)(H - 2) * (W - 2) - S;
    for(int i = 0; i < 10; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 59820
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

vector<int>X[2222];
vector<int>Y[2222];

signed main(){
	int h,w;
	string s[2222];
	cin>>h>>w;

	r(i,h)cin>>s[i];

	r(i,h)r(j,w){
		if(s[i][j]=='#'){
			Y[j].push_back(i);
			X[i].push_back(j);
		}
	}

	r(i,2009){
		sort(X[i].begin(),X[i].end());
		sort(Y[i].begin(),Y[i].end());
	}

	int ans=0;

	r(i,h)r(j,w){
		//cout<<i<<j<<endl;
		if(s[i][j]=='#')continue;
		int rx;
		auto AA=lower_bound(X[i].begin(),X[i].end(),j);
		if(AA==X[i].end())rx=w;
		else{
			rx=*AA;
		}
		auto A=lower_bound(X[i].begin(),X[i].end(),j);
		int lx;
		if(A==X[i].begin())lx=-1;
		else{
			A--;
			lx=*A;
		}

		int ry;
		auto BB=lower_bound(Y[j].begin(),Y[j].end(),i);
		if(BB==Y[j].end())ry=h;
		else{
			ry=*BB;
		}
		//cout<<i<<j<<endl;
		auto B=lower_bound(Y[j].begin(),Y[j].end(),i);
		int ly;
		if(B==Y[j].begin())ly=-1;
		else{
			B--;
			ly=*B;
		}

		//cout<<i<<' '<<j<<' '<<(rx-lx-1)<<' '<<(ry-ly-1)-1

		ans=max(ans,(rx-lx-1)+(ry-ly-1)-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 71168
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

int main() {

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

	int A, B, C;
	cin >> A >> B >> C;

	if (A <= C && C <= B) cout << "Yes";
	else cout << "No";

	return 0;
}

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

const int maxn = 105;
char g[maxn][maxn];

int main() {
    int a, b; cin >> a >> b;
    for (int i = 1; i <= 50; ++i) {
        for (int j = 1; j <= 100; ++j) g[i][j] = '.';
    } 
    for (int i = 51; i <= 100; ++i) {
        for (int j = 1; j <= 100; ++j) g[i][j] = '#';
    }
    int c = 1, d = 1;
    if (c < a) {
        for (int i = 100; i > 50 && c < a; i -= 2) {
            for (int j = 1; j <= 100 && c < a; j += 2) g[i][j] = '.', ++c;
        }
    }
    if (d < b) {
        for (int i = 1; i <= 50 && d < b; i += 2) {
            for (int j = 100; j >= 1 && d < b; j -= 2) g[i][j] = '#', ++d;
        }
    }
    cout << 100 << ' ' << 100 << endl;
    for (int i = 1; i <= 100; ++i) {
        for (int j = 1; j <= 100; ++j) cout << g[i][j];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;
template <typename T>
class Combination {
  vector<T> fact, ifact;

 public:
  Combination(int nMax) : fact(nMax + 1), ifact(nMax + 1) {
    fact[0] = 1;
    for (int i = 0; i < nMax; ++i) fact[i + 1] = fact[i] * (i + 1);
    for (int i = 0; i < nMax + 1; ++i) ifact[i] = fact[i].inverse();
  }

  T factorial(int n) const { return fact[n]; }
  T inverseFactorial(int n) const { return ifact[n]; }

  T P(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k);
  }

  T C(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k) * inverseFactorial(k);
  }

  T H(int n, int k) const {
    if (n < 0 || k < 0) return 0;
    return k == 0 ? 1 : C(n + k - 1, k);
  }
};

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  Combination<ModInt> comb(r2 + c2 + 2);

  auto g = [&](int i, int j) {
    return (comb.C(i + j + 2, j) * (i + 2) - j - 1) / (j + 1);
  };

  cout << g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1) << endl;

  return 0;
}


Measured memory_bytes: 31488
class UnionFindTree():
    def __init__(self, values=[]):
        self.parent_of = {}
        self.rank_of = {}
        self.cnt = {}
        for value in values:
            self.add(value)

    def add(self, value):
        if value in self.parent_of:
            raise RuntimeError("Dupulicated Value Added")
        self.parent_of[value] = None
        self.rank_of[value] = 0
        self.cnt[value] = 1

    def __root(self, value):
        if self.parent_of[value] is None:
            return value
        else:
            self.parent_of[value] = self.__root(self.parent_of[value])
            return self.parent_of[value]

    def unite(self, a, b):
        r1 = self.__root(a)
        r2 = self.__root(b)
        if r1 != r2:
            if self.rank_of[r1] < self.rank_of[r2]:
                self.parent_of[r1] = r2
                self.cnt[r2] += self.cnt[r1]
            else:
                self.parent_of[r2] = r1
                self.cnt[r1] += self.cnt[r2]
                if self.rank_of[r1] == self.rank_of[r2]:
                    self.rank_of[r1] += 1

    def is_same(self, a, b):
        return self.__root(a) == self.__root(b)

    def count_group(self, a):
        return self.cnt[self.__root(a)]


def main():
    N, M = map(int, input().split())
    bridges = [tuple(map(int, input().split())) for _ in range(M)]
    bridges.reverse()
    uft = UnionFindTree(list(range(1, N+1)))
    prev = N*(N-1)//2
    answers = [prev]
    for i in range(M):
        a, b = bridges[i]
        if not uft.is_same(a, b):
            prev -= uft.count_group(a) * uft.count_group(b)
        uft.unite(a, b)
        answers.append(prev)
    answers.reverse()
    for i in range(1, M+1):
        print(answers[i])


if __name__ == "__main__":
    main()


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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for (int j = 0; j < n; j++) {
		cin >> l[j];
	}
	vector<int> d;
	int i = 0;
	d.push_back(0);
	while (i < n) {
		d.push_back(d[i] + l[i]);
		i++;
	}
	int ans = 0;

	for (int a = 0; a < n+1; a++) {
		if (d[a] <= x) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<double, int> P;
const ll INF = 1LL << 50;
const double EPS = 1e-12;

int dy[] = {1, 0, -1, 0};
int dx[] = {0, -1, 0, 1};
int W, H;
char field[600][600];
ll a[600][600];
ll b[600][600];

void bfs(char start, ll dist[][600]){
  queue<int> que;
  fill(&dist[0][0], &dist[0][0] + 600 * 600, INF);
  rep(i, H)rep(j, W){
    if(field[i][j] == start){
      dist[i][j] = 0;
      que.push(i * W + j);
    }
  }
  while(!que.empty()){
    int p = que.front(); que.pop();
    int x = p % W;
    int y = p / W;
    rep(i, 4){
      int y2 = y + dy[i];
      int x2 = x + dx[i];
      if((field[y2][x2] == '.' || field[y2][x2] == 's') && dist[y2][x2] == INF){
	dist[y2][x2] = dist[y][x] + 1;
	que.push(y2 * W + x2);
      }
    }
  }
}

int main(){
  while(cin >> W >> H){
    int sy = 0, sx = 0;
    rep(i, H)rep(j, W){
      cin >> field[i][j];
      if(field[i][j] == 's'){
	sy = i, sx = j;
      }
    }
    bfs('*', a);
    bfs('g', b);
    long double ub = 1e15;
    long double lb = 0;
    rep(i, 1000){
      long double mb = (ub + lb) / 2;
      long double sum = 0;
      int cnt = 0;
      rep(j, H)rep(k, W){
	if(field[j][k] == 's' || field[j][k] == '.'){
	  cnt++;
	  sum += min((long double)b[j][k], a[j][k] + mb);
	}
      }
      if(mb > sum / cnt) ub = mb;
      else lb = mb;
    }
    cout << fixed << setprecision(15) << min(lb+a[sy][sx],(long double)b[sy][sx])<< endl;
  }
  return 0;
}

Measured memory_bytes: 6924
MOD = 10**9+7
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse = True)
ans = 1
if A[-1] >= 0:
    for i in range(K):
        ans *= A[i]
        ans %= MOD
elif A[0] < 0:
    if K % 2 == 0:
        for i in range(K):
            ans *= A[N-1-i]
            ans %= MOD
    else:
        for i in range(K):
            ans *= A[i]
            ans %= MOD
else:
    r,l = N-1,0
    n = 0
    while n < K:
        if K-n == 1:
            ans *= A[l]
            ans %= MOD
            n += 1
        else:
            if A[r]*A[r-1] > A[l]*A[l+1]:
                ans *= (A[r]*A[r-1])
                ans %= MOD
                r -= 2
                n += 2
            else:
                ans *= A[l]
                ans %= MOD
                l += 1
                n += 1
print(ans)


Measured memory_bytes: 104680
import sys
import math
from collections import defaultdict, deque
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))
  
n=r()
s=''
while True:
    if n<=26:
        s+=chr(96+n)
        break
    z=(26 if n%26==0 else n%26)
    s+=chr(96+z)
    n-=z
    n//=26
print(s[::-1])

Measured memory_bytes: 65280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,s,c;
  int result = -1;
  bool end = false;
  vector<bool> check(3,false);
  cin >> N >> M;
  vector<int> num(N,-1);
  for(int i = 0;i < M;i++){
  	cin >> s >> c;
    if(s == 0){
      	end = true;
    	break;
    }
    if(!check.at(s-1)){
   		check.at(s-1) = true;
    }else if(check.at(s-1) && !(num.at(s-1) == c)){
      	end = true;
    	break;
    }
    num.at(s-1) = c;
  }
  if(!(end)){
    result = 0;
    if(N == 1){
      if(num.at(0) != -1){
          result += num.at(0);
      }else if(num.at(0) == -1){
      	result = 0;
      }
      cout << result << endl;
      
    }else if(N == 2){
      if(num.at(0) == 0){
      	result = -1;
      }else if(num.at(0) != -1){
          result += num.at(0) * 10;
      }else if(num.at(0) == -1){
      	result += 10;
      }
      if(num.at(1) != -1 && result != -1){
      	result += num.at(1);
      }
      cout << result << endl;
    
    }else if(N == 3){
      if(num.at(0) == 0){
      	result = -1;
      }else if(num.at(0) != -1){
          result += num.at(0) * 100;
      }else if(num.at(0) == -1){
      	result += 100;
      }
      if(num.at(1) != -1 && result != -1){
      	result += num.at(1) * 10;
      }
      if(num.at(2) != -1 && result != -1){
      	result += num.at(2);
      }
      cout << result << endl;
    }
  }else if(end == true){
  	cout << result << endl;
  }
      
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] color = new int[8];
		int free =0;
		int min=0;
		int max=0;

		for (int i=1; i<=n; i++){
			int rate = sc.nextInt();
			if (1 <= rate && rate <= 399){
				color[0]++;
			} else if (400 <= rate && rate <= 799){
				color[1]++;
			} else if (800 <= rate && rate <= 1199){
				color[2]++;
			} else if (1200 <= rate && rate <= 1599){
				color[3]++;
			} else if (1600 <= rate && rate <= 1999){
				color[4]++;
			} else if (2000 <= rate && rate <= 2399){
				color[5]++;
			} else if (2400 <= rate && rate <= 2799){
				color[6]++;
			} else if (2800 <= rate && rate <= 3199){
				color[7]++;
			} else {
				free++;
			}
		}

		for (int i=0; i < color.length; i++){
			if (color[i] > 0 ){
				min++;
			}
		}
		max = min + free;
		if (min == 0){
			min = 1;
		}
		System.out.println(min + " " + max);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int T;
	//scanf("%d", &T);
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		string s;
		int n;
		cin >> n >> s;
		vector<set<int> > st(26);

		for (int i = 0; i < n; i++) {
			st[s[i] - 'a'].insert(i);
		}
		int q;
		cin >> q;
		while (q--) {
			int x;
			cin >> x;
			if (x & 1) {
				int pos;
				char ch;
				cin >> pos >> ch;
				--pos;
				st[s[pos] - 'a'].erase(pos);
				s[pos] = ch;
				st[s[pos] - 'a'].insert(pos);
			}
			else {
				int l, r;
				cin >> l >> r;
				--l;
				--r;
				int cnt = 0;
				for (int t = 0; t < 26; t++) {
					auto it = st[t].lower_bound(l);
					if (it != st[t].end() && *it <= r) cnt++;
				}
				cout << cnt << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 26268
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int LCS(string a, string b)
{
    int ret;
    int i, j;
    int len1, len2;
    int result[1001][1001] = {0};

    len1 = a.length();
    len2 = b.length();

    a = ' ' + a;
    b = ' ' + b;

    for (i = 1; i <= len1; i++) {
        for (j = 1; j <= len2; j++) {
            if (a[i] == b[j]) {
                result[i][j] = result[i - 1][j - 1] + 1;
            }
            else {
                result[i][j] = max(result[i][j - 1], result[i - 1][j]);
            }
        }
    }

    return result[len1][len2];
}

int main(void)
{
    int i;
    int num;
    int ret;
    string a, b;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        cin >> a;
        cin >> b;
        ret = LCS(a, b);
        printf("%d\n", ret);
    }

    return 0;
}

Measured memory_bytes: 5164
n,c = gets.split.map(&:to_i)
x = []
v = []

r_max = 0
r_max_arr = []
r_back_max = 0
r_back_max_arr = []

r_sum = 0
n.times do |i|
  x[i],v[i] = gets.split.map(&:to_i)
  r_sum += v[i]
  if r_max < r_sum - x[i]
    r_max = r_sum - x[i]
  end
  if r_back_max < r_sum - 2*x[i]
    r_back_max = r_sum - 2*x[i]
  end
  r_max_arr[i] = r_max
  r_back_max_arr[i] = r_back_max
end

l_max = 0
l_max_arr = []
l_back_max = 0
l_back_max_arr = []

l_sum = 0
n.times do |i|
  l_sum += v[(n-1)-i]
  if l_max < l_sum - (c-x[(n-1)-i])
    l_max = l_sum - (c-x[(n-1)-i])
  end
  if l_back_max < l_sum - 2*(c-x[(n-1)-i])
    l_back_max = l_sum - 2*(c-x[(n-1)-i])
  end
  l_max_arr[(n-1)-i] = l_max
  l_back_max_arr[(n-1)-i] = l_back_max
end

max = 0
max = [r_max_arr[n-1],l_max_arr[0]].max
(n-1).times do |i|
  if max < r_max_arr[i]+l_back_max_arr[i+1]
    max = r_max_arr[i]+l_back_max_arr[i+1]
  end
  if max < l_max_arr[i+1]+r_back_max_arr[i]
    max = l_max_arr[i+1]+r_back_max_arr[i]
  end
end
printf("%d\n",max)

Measured memory_bytes: 7116
#include <vector>
#include <iostream>
using namespace std;
int N, G[10009], vis[10009], x, y;
int rec(int pos, int e) {
	if (vis[pos] == e) return 1;
	if (vis[pos] != -1) return 0;
	return rec(G[pos], vis[pos] = e);
}
int main() {
	while (cin >> N, N) {
		for (int i = 0; i < N * N; i++) {
			cin >> x >> y;
			G[i] = y * N + x;
			vis[i] = -1;
		}
		int ret = 0;
		for (int i = 0; i < N * N; i++) ret += rec(i, i);
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
//4182_543_731 is vegetable
#include<cstdio>
using namespace std;
#define N 3005
#define mod 1000000007
#define inv 500000004
int n,dp[N][N],v[N],q,a,b;
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)dp[i][j]=(v[i]<v[j]);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&a,&b);
		int tp=dp[a][b]+dp[b][a];
		for(int j=1;j<=n;j++)
		{
			dp[j][a]=dp[j][b]=1ll*(dp[j][a]+dp[j][b])*inv%mod;
			dp[a][j]=dp[b][j]=1ll*(dp[a][j]+dp[b][j])*inv%mod;
		}
		dp[a][b]=dp[b][a]=1ll*tp*inv%mod;
	}
	int as=0;
	for(int i=2;i<=n;i++)
	for(int j=1;j<i;j++)as=(as+dp[i][j])%mod;
	for(int i=1;i<=q;i++)as=as*2%mod;
	printf("%d\n",as);
}

Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	ll a;
	cin >> n;
	int ki=0;
	rep(i,n) {
		cin >> a;
		if (a%2) ki++;
	}

	if(n==1&&ki==1) {
		cout << "YES" << endl;
	}
	else if (ki%2==1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int A = nextInt() + nextInt() + nextInt();
  cout << (A >= 22 ? "bust" : "win") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N,T; cin>>N>>T;
    int ans = INF;
    REP(i,N) {
        int c,t; cin>>c>>t;
        if (t<=T) ans = min(ans,c);
    }
    if (ans==INF) {
        cout<<"TLE"<<endl;
        return 0;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}

vector<ll> calc_divisor(ll n) {
    vector<ll> res;
    for (long long i=1LL; i*i<=n; ++i) {
        if (n%i==0) {
            res.push_back(i);
            ll j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n; cin >> n;
    // 素数判定
    if (is_prime(n)) cout << (int)to_string(n).size() << endl;
    else {
        auto facts = calc_divisor(n);
        int ans = to_string(n).size();
        rep(i, facts.size()) {
            int tmp = max(to_string(facts[i]).size(), to_string(n/facts[i]).size());
            chmin(ans, tmp);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll x, y;
	cin >> x >> y;
	REP(i, x+1) if (2*i +  4*(x-i) == y) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		
		Scanner scan = new Scanner(System.in);
		
		int one[];
		int i;
		
		int a = scan.nextInt();
		one = new int[a];
		
		for(i=0; i<a; i++){
			int num = scan.nextInt();
			one[i] = num;
		}

		for(i=a-1; i>=0; i--){
			System.out.print(one[i]);
			if(i != 0){
				System.out.print(" ");
			}
		}
		System.out.println();
		
	}
}

Measured memory_bytes: 19640
A = [tuple(map(int, input().split())) for _ in range(3)]
N = int(input())
B = set()
for _ in range(N):
    B.add(int(input()))

X = [
    set(A[0]),
    set(A[1]),
    set(A[2]),
    set([A[0][0], A[1][0], A[2][0]]),
    set([A[0][1], A[1][1], A[2][1]]),
    set([A[0][2], A[1][2], A[2][2]]),
    set([A[0][0], A[1][1], A[2][2]]),
    set([A[0][2], A[1][1], A[2][0]]),
]

for x in X:
    if x <= B:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

//前日にjをしたときのi日目の満足度
int dp[100010][3];

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

  for( int i = 1; i <= N; i++ ){
    for( int j = 0; j < 3; j++ ){
      int now = A[i-1][j];
      for( int k = 0; k < 3; k++ ){
        if( j == k ) continue;
        dp[i][j] = max(dp[i][j], dp[i-1][k]+now);
      }
    }
  }

  int ans = max({dp[N][0], dp[N][1], dp[N][2]});
  cout << ans << endl;

}


Measured memory_bytes: 11160
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p,x;
//map<string,int>mp;
//vector<int>v;
ll a[N];
vector<ll>v;
int main()
{
    ft
    ll t,i,j,n,m,l,r,c;
    cin>>m>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        v.pb(a[i]-a[i-1]);
    }
    v.pb(m-a[n-1]+a[0]);
    sort(v.begin(),v.end());
    n=v.size();
    c=0;
    for(i=0;i<(n-1);i++)
    {
        c+=v[i];
    }
    cout<<c<<"\n";
    return 0;
}



Measured memory_bytes: 3956
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int n;
  cin >> n ;
  if (n % 2 == 0){
    cout << (n/2);
  } else {
    cout << (n/2)+1;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m, f, r, n;
	for (n = 0; n < 50; n = n + 1) {
		cin >> m >> f >> r;
		if (m < 0 && f < 0 && r < 0) {
			return 0;
		}
		if (m < 0 || f < 0) {
			cout << "F" <<endl;
		}
		if (m >= 0 && f >= 0) {
			if (m < 0) {
				m = 0;
			}
			if (f < 0) {
				f = 0;
			}
			if (m + f >= 80) {
				cout << "A";
			}
			if (m + f >= 65 && m + f < 80) {
				cout << "B";
			}
			if (m + f >= 50 && m + f < 65) {
				cout << "C";
			}
			if (m + f >= 30 && m + f < 50 && r < 50) {
				cout << "D";
			}
			if (m + f >= 30 && m + f < 50 && r >= 50) {
				cout << "C";
			}
			if (m + f < 30) {
				cout << "F";
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3088