akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

int num[2001][2001],n,m,q;
bool ok[2002][2002];

int to[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
bool vis[2001][2001];
int fa[2001][2001];
void dfs(int i,int j)
{
    vis[i][j]=1;
    for(int k=0,x,y;k<4;++k)
	if(ok[x=i+to[k][0]][y=j+to[k][1]]&&!vis[x][y])
	    fa[x][y]=num[i][j],dfs(x,y);
}

int s[2001][2001],u[2002][2001],d[2001][2001],l[2001][2002],r[2001][2001];

int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1,c=0;i<=n;++i)
    {
	scanf("\n");
	for(int j=1;j<=m;++j)
	{
	    ok[i][j]=getchar()=='1';
	    num[i][j]=++c;
	}
    }
    
    for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	    if(ok[i][j]&&!vis[i][j])dfs(i,j);

    for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	{
	    s[i][j]=s[i][j-1]+s[i-1][j]-s[i-1][j-1]+(ok[i][j]&!fa[i][j]);
	    u[i][j]=u[i][j-1]+(num[i][j]==fa[i-1][j]);
	    d[i][j]=d[i][j-1]+(num[i][j]==fa[i+1][j]);
	    l[i][j]=l[i-1][j]+(num[i][j]==fa[i][j-1]);
	    r[i][j]=r[i-1][j]+(num[i][j]==fa[i][j+1]);
	}

    for(int t=1,i,j,x,y;t<=q;++t)
    {
	scanf("%d%d%d%d",&i,&j,&x,&y);
	printf("%d\n",
	       s[x][y]-s[x][j-1]-s[i-1][y]+s[i-1][j-1]+
	       u[x+1][y]-u[x+1][j-1]+
	       d[i-1][y]-d[i-1][j-1]+
	       l[x][y+1]-l[i-1][y+1]+
	       r[x][j-1]-r[i-1][j-1]);
    }
    
    return 0;
}


Measured memory_bytes: 119680
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String k = sc.next();
		int i = 0;
		char ans = '2';
		while(i < s.length()){
			ans = s.charAt(i);
			if(ans != '1')break;
			i++;
		}
		
		if(k.length()>3||Integer.parseInt(k)>i)System.out.println(ans);
		else System.out.println(1);
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
long long pow5(long long x){
  return x * x * x * x * x;
}
int main(){
  long long X;
  cin >> X;
  for (long long i = -120; i <= 120; i++){
    for (long long j = -120; j <= 120; j++){
      if (pow5(i) - pow5(j) == X){
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
}

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

struct Edge {
    int to, coin;
    int64_t cost;
    Edge(int _to, int _coin, int64_t _cost) : to(_to), coin(_coin), cost(_cost) {}
};

const int MAX = 2525;
const int64_t INF = 1e18;

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<Edge>> G(N);
    for(int i = 0; i < M; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }
    vector<int> C(N), D(N);
    for(int i = 0; i < N; ++i) cin >> C[i] >> D[i];

    using T = tuple<int64_t, int, int>; // cost, coin, v
    priority_queue<T, vector<T>, greater<T>> que;
    vector<vector<int64_t>> dist(N, vector<int64_t>(MAX + 1, INF));
    S = min(S, MAX);
    que.emplace(0, S, 0);
    dist[0][S] = 0;

    auto push = [&](int64_t cost, int coin, int v) -> void {
        if(coin < 0 or dist[v][coin] <= cost) return;
        dist[v][coin] = cost;
        que.emplace(cost, coin, v);
    };
    while(!que.empty()) {
        auto[cost, coin, v] = que.top(); que.pop();
        for(auto &e : G[v]) push(cost + e.cost, coin - e.coin, e.to);
        push(cost + D[v], min(MAX, coin + C[v]), v);
    }

    for(int i = 1; i < N; ++i) cout << *min_element(dist[i].begin(), dist[i].end()) << '\n';
    return 0;
}


Measured memory_bytes: 6348
N, K = map(int, input().split())
A = tuple(map(int, input().split()))

if K <= 200000:
  i = 1
  for _ in range(K):
    i = A[i-1]
  print(i)
  exit()

visited = {1}
order = [1]

i = 1
for count in range(1, 200001):
  i = A[i-1]
  if i in visited:
    break
  else:
    visited.add(i)
  order.append(i)

idx = order.index(i)
order2 = order[idx:]
# print(order2)
mod = (K+1-idx) % len(order2)

print(order2[mod-1])

Measured memory_bytes: 32388
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int s[]={a,b,c};
    int x=0,y=0;
    for(int i=0;i<3;i++){
        if(s[i]==5)
            x++;
        else if(s[i]==7)
            y++;
    }

    if(x==2&&y==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll a, b, c, d, e, f, g; cin >> a >> b >> c >> d >> e >> f >> g;
	
	ll ans = 0;
	rep(it, 2){
		ll tmp = b * 2;
		if(it == 1 && a && d && e){
			a--; d--; e--;
			tmp += 6;
		}
		tmp += a / 2 * 4 + d / 2 * 4 + e / 2 * 4;
		ans = max(ans, tmp);
	}
	cout << ans / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
 
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e4 + 2;
const int M = 4e5;
const ll mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

char k[N];
int d, n, dp[N][102][2];
 
int add(int a, int b) {
	a += b;
	if (a >= mod)
		a -= mod;
	if (a < 0)
		a += mod;
   	return a;
}

void add_self(int &a, int b) {
	a += b;
	if (a >= mod)
		a -= mod;
	if (a < 0)
		a += mod;
}

int main() {
	data();  	
	scanf("%s", &k);
	scanf("%d", &d);
	n = strlen(k);
	dp[0][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			for (int l = 0; l < 10; ++l) {
				if (l < k[i] - '0') {
					add_self(dp[i + 1][(j + l) % d][1], dp[i][j][0]);
					add_self(dp[i + 1][(j + l) % d][1], dp[i][j][1]);
				}
				if (l == k[i] - '0') {
					add_self(dp[i + 1][(j + l) % d][0], dp[i][j][0]);	
					add_self(dp[i + 1][(j + l) % d][1], dp[i][j][1]);
				}
				if (l > k[i] - '0') {
					add_self(dp[i + 1][(j + l) % d][1], dp[i][j][1]);
				}
			}
		}
	}
	printf("%d", add(dp[n][0][0], add(dp[n][0][1], -1)));
}
 
/*
	Timus: 288481RF
	CodeForces: fractal
*/

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


int main() {
  long long N, K, min, max;
  long long ans = 0;
  cin >> N >> K;
  for(long long i = K; i <= N + 1; i++){
    min = i * (i - 1) / 2;
    max = i * (2 * N - i + 1) / 2;
    ans += max - min + 1;
  }
  cout << ans % 1000000007 << endl; 
}
  

Measured memory_bytes: 3632
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(a) printf(a ? "Yes\n" : "No\n");
#define printYN(a) printf(a ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
//#include <vector>

using namespace std;

int main() {

	ll a, b, x, plusalpha = 0;
	scanf("%lld%lld%lld", &a, &b, &x);
	if (a % x == 0)++plusalpha;
	printf("%lld\n", b / x - a / x + plusalpha);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 14396
import math
 
a, b, C = map(int, input().split())
 
h = b * math.sin(math.radians(C))
S = a * h * 0.5
L = a + b + math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b *math.cos(math.radians(C)))
 
print(S)
print(L)
print(h)


Measured memory_bytes: 5716
n,a,b = map(int, input().split())

ans = 0
for i in range(1,n+1):
  j = 0
  l = list(str(i))
  for k in range(len(l)):
    j += int(l[k])
  if a <= j <= b:
    ans += i
    
    
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(){
	int N,M;
	int A[55],B[55],C[55],D[55];
	cin>>N>>M;
	for(int i=0;i<N;++i){
		cin>>A[i]>>B[i];
	}
	for(int i=0;i<M;++i){
		cin>>C[i]>>D[i];
	}
	for(int i=0;i<N;++i){
		int an=0;
		int ans=500000000;
		for(int j=0;j<M;++j){
			if(ans>abs(A[i]-C[j])+abs(B[i]-D[j])){
				an=j+1;
				ans=abs(A[i]-C[j])+abs(B[i]-D[j]);
			}

		}
		cout<<an<<endl;
	}

	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int count = 0;
            for(int i = ab[0]; i <= ab[1]; i++)
            {
                if (i.ToString() == string.Join("",i.ToString().ToCharArray().Reverse().ToArray()))
                {
                    Console.ReadLine();
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 17472
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;


main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(nullptr);
    int n;
	cin>>n;
	vector<int>cnt(n);
	for(int i=1;i<n;i++)
    {
        int p;
        cin>>p;
        p--;
        cnt[p]++;
    }
    for(int i=0;i<n;i++) cout<<cnt[i]<<'\n';
}


Measured memory_bytes: 4792
import Control.Monad
import Data.List
import Data.Maybe

main = sol <$> readLn <*> readLn >>= print . fromMaybe (-1)

sol n s
  | n == s    = Just (n+1)
  | n < s     = Nothing
  | otherwise = find (liftM2 (&&) (>1) ((s==) . flip f n)) $
  	  [2..n'+1] ++ fmap (\p -> (n-s) `div` p + 1) [n',n'-1..1]
  where
  n' = floor . sqrt $ fromIntegral n

f b n
  | n < b     = n
  | otherwise = n `mod` b + f b (n `div` b)

Measured memory_bytes: 2044
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main() {
	string S;
	cin >> S;
	int coR = 0, coL = 0;

	int count = 0;
	int p = 0, q = S.length() - 1;
	while (1) {
		coR = 0;
		coL = 0;
		while (p < S.length() && S[p] == 'x') {
			coL++;
			p++;
		}
		while (q >= 0 && S[q] == 'x') {
			coR++;
			q--;
		}
		count += (coR > coL ? coR - coL : coL - coR);
		if (p >= q) {
			cout << count;
			return 0;
		}
		if (S[p] != S[q]) {
			cout << "-1";
			return 0;
		}
		p++;
		q--;

	}
	return 0;
}

Measured memory_bytes: 512
N,M = map(int,input().split())
H = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()]for i in range(M)]
good = [-1]*N   
for j in range(M):
  if H[AB[j][0]-1] > H[AB[j][1]-1]:
    good[AB[j][0]-1] *= 1
    good[AB[j][1]-1] *= 0
  elif H[AB[j][0]-1] < H[AB[j][1]-1]:
    good[AB[j][0]-1] *= 0
    good[AB[j][1]-1] *= 1
  else:
    good[AB[j][0]-1] *= 0
    good[AB[j][1]-1] *= 0
print(good.count(-1)+good.count(1))

Measured memory_bytes: 93208
import java.util.*;

public class Main{

    static double x;

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		x = sc.nextDouble();

        double ok = Math.PI / 2.0;
        double ng = 0;
        for(int i = 0; i < 1000000 ; i++){
            double mid = (ok + ng) / 2.0;
            if(f(a, b, mid) < x) ok = mid;
            else ng = mid;
        }

        System.out.println(Math.toDegrees(ok));

    }

    static double f(double a, double b, double t){

        if(t > Math.PI / 2.0){
            return 0.0;
        }
        double ans;
        if(x >= a * a * b / 2){
            ans = a * a * b - a * a * a * Math.tan(t) / 2.0;
        }else{
            ans = a * b * b / Math.tan(t) / 2.0;
        }

        return ans;

    }

}


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 long long a,b,c,s,t,x,y,z;
 long long A,B,C,S,T,X,Y,Z;

 long long cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>a>>b>>x>>y;

	t=max(a*x,b*y);
	t=max(t,a*y);
	t=max(t,b*x);

	cout<<t;


	return 0;

}


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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};  // バケット
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    int res = 0;  // 答えを格納
    for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
        if (num[i]) {  // 0 より大きかったら
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int n, t;
vector<P> v;
int dp[3010][3010];
bool vis[3010][3010];

int solve(int N, int T)
{
    if (vis[N][T])
        return dp[N][T];
    vis[N][T] = true;
    if (N == n)
        return 0;
    int res = solve(N + 1, T);
    if (T + v[N].first < t)
        res = max(res, solve(N + 1, T + v[N].first) + v[N].second);
    return dp[N][T] = res;
}

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

    cin >> n >> t;
    v.resize(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    sort(all(v));
    reverse(all(v));
    int ans = 0;
    rep(i, n) ans = max(ans, solve(i + 1, 0) + v[i].second);
    cout << ans << endl;
}

Measured memory_bytes: 79872
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s / 3600;
        int m = s % 3600 / 60;
        s = s % 60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin >>a>>b>>c;
    if(a<b&&b<c){
        cout<<"Yes"<<endl;
    }

    else{
        cout<<"No"<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3096
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll cnt[10][10];
int main(){
   ll N;
   cin >> N;
   ll ans = 0;
   
   for(int i = 1; i <= N; i++){
       int a = i;
       int b = a%10;
       while(a/10 != 0){
           a /= 10;
       }
       cnt[a][b]++;
   }
   
   for(int i = 1; i <= 9; i++){
       for(int j = i; j <= 9; j++){
           if(i == j) ans += cnt[i][j]*cnt[i][j];
           else ans += 2*cnt[i][j]*cnt[j][i];
       }
   }
   cout << ans << endl;
}


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

int main() {
	// your code goes here
int x,y;
while(1){
	cin>>x;
	cin>>y;
		if(x==0&&y==0){break;}
	if(x>y){
	cout<<y<<" "<<x<<endl;
	}
	if(x<=y){
	cout<<x<<" "<<y<<endl;
	}

}
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

// nをある偶数としたときn^n+1=1となる性質を用いて、0からxまでの排他的論和0^1^...^xを求める
ll func(ll x){
    // 2のn乗なので必ずn^n+1偶数セット+ x(このとき常に100...0の形) ⇒ 000...と100...の排他的論理和
    if(x%4==0) return x;
    // n^n+1奇数セット ⇒ 1
    if(x%4==1) return 1;
    // n^n+1奇数セット + x(このとき常に111...10の形) ⇒ 0とxの排他的論理和
    if(x%4==2) return x+1;
    // 2のn乗の一つ手前なので必ずn^n+1偶数セットのみ ⇒ 0
    return 0;
}

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

    ll a,b; cin >> a >> b;

    // func(b)=0^1^...^a-1^a^a+1^...^b=func(a-1)^f(a,b)からf(a,b)=～に変形
    ll ans = func(a-1)^func(b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
H, W, N = map(int, input().split())
A = defaultdict(int)

for i in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for j in range(-1, 2):
        for k in range(-1, 2):
            if 1 <= a + j < H - 1 and 1 <= b + k < W - 1:
                A[(a + j, b + k)] += 1
                
print((H - 2) * (W - 2) - len(A))
                
for i in range(1, 10):
    cnt = 0
    for v in A.values():
        if v == i:
            cnt += 1
    print(cnt)

Measured memory_bytes: 166868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a=0;
    string s,s1;
    cin>>s;
    cin>>s1;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]!=s1[i]){a++;}
    }
    cout<<a;
}


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

using namespace std;

const int N = 123456;

int n, a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int type = 1;
  while (1) {
    int even = 0;
    for (int i = 1; i <= n; ++i) {
      if (!(a[i] & 1)) {
        ++even;
      }
    }
    if (even & 1) {
      cout << (type == 1 ? "First" : "Second") << '\n';
      exit(0);
    } else if (!(even & 1) && n - even >= 2) {
      cout << (type == 1 ? "Second" : "First") << '\n';
      exit(0);
    } else {
      for (int i = 1; i <= n; ++i) {
        if (a[i] & 1) {
          if (a[i] == 1) {
            cout << (type == 1 ? "Second" : "First") << '\n';
            exit(0);
          } else {
            --a[i];
          }
        }
      }
      int gcd = 0;
      for (int i = 1; i <= n; ++i) {
        gcd = __gcd(gcd, a[i]);
      }
      for (int i = 1; i <= n; ++i) {
        a[i] /= gcd;
      }
    }
    type = !type;
  }
  return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)]
p=["f"]*n
p[0]="t"
q=[1]*n
for i in range(0,m):
  q[a[i][0]-1]-=1
  q[a[i][1]-1]+=1
  if p[a[i][0]-1]=="t":
    p[a[i][1]-1]="t"
    if q[a[i][0]-1]==0:
      p[a[i][0]-1]="f"
print(p.count("t"))


Measured memory_bytes: 22692
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool f(string s){
    rep(i,0,s.size()/2){
        if(s[i]!=s[s.size()-i-1])return false;
        
    }
    return 1;
}

signed main (){
    int a,b;
    cin>>a>>b;
    int ans=0;
    rep(i,a,b+1){
        string s=to_string(i);
        ans+=f(s);

    }
    cout<<ans<<endl;


}
/*
1-2
0.5-2

010
01110
00111
000000111
*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int an, l;
    while( cin >> an >> l, an||l ) {
        vector<int> xs;
        
        int i=1;
        for(;;) {
            xs.push_back( an );
            auto const as = to_string( an );
            auto lhs = string( l - as.size(), '0' ) + as;
            auto rhs = lhs;

            sort( lhs.begin(), lhs.end(), greater<char>() );
            sort( rhs.begin(), rhs.end() );

            an = stoi( lhs ) - stoi( rhs );
            
            auto const it = find( xs.cbegin(), xs.cend(), an );
            if ( it != xs.cend() ) {
                auto const j = distance( xs.cbegin(), it );
                cout << j << " " << an << " " << ( i - j )<< endl;
                break;
            }

            ++i;
        }
    }
}

Measured memory_bytes: 1272
#include<stdio.h>
int main()
{
    int s;
    scanf("%d", &s);
    int p[1000006] = {};
    p[s] = 1;
    int ans;
    for (ans=2;;ans++)
    {
        if (s % 2 == 0)s /= 2;
        else s = 3 * s + 1;
        if (p[s] == 1)break;
        else p[s] = 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol n,m,k;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>k;
  int x[100010];
  for(int i=0;i<n;i++){
    cin >>x[i];
  }
  lol ans=INF;
  k--;
  for(int i=0;i<n-k;i++){
    lol o;
    if(x[i]<0&&x[i+k]>0) o=2*min(-x[i],x[i+k])+max(-x[i],x[i+k]);
    else o=max(-x[i],x[i+k]);
    ans=min(ans,o);
  }
  cout <<ans<<'\n';
  return (0);
}


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

void solve() {
    double N;
    cin >> N;

    int X = ceil(N / 1.08);
    if((int)(X * 1.08) == N)
        cout << X << endl;
    else
        cout << ":(" << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t;
    //cin >> t;
    //for(auto i = 0; i < t; ++i)
        solve();
}


Measured memory_bytes: 256
N, K = map(int,input().split())

c = []
for i in range(K, N+2, 1):
  minimum = 1 / 2 * (i - 1) * i
  maximum = 1 / 2 * N * (N + 1) - 1 / 2 * (N - i) * (N - i + 1)
  c.append(int(maximum - minimum + 1))
else:
  answer = 0
  for i in c:
  	answer += i
  else:
  	print(answer % (10 ** 9 + 7))

Measured memory_bytes: 16920
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const long long INF=200000000000000000LL;
typedef pair<int,int> P;
int main(){
	int N,A,ans=0,B=0;
	cin>>N;
	for(int i=1;i<=N;++i){
		cin>>A;
		if(A==i){
			++ans;
			if(B==1){
				ans--;
				B=0;
			}else B++;
		}else B=0;
	}
	cout<<ans<<endl;
	return 0;
}


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

string s;
int k;

int main()
{
	cin>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='a') continue;
		if('a'+26-s[i] <= k)
		{
			k -= 'a'+26-s[i];
			s[i]='a';
		}
	}
	k%=26;
	for(int i=0;i<k;i++)
		s[s.size()-1]=(s[s.size()-1]-'a'+1)%26+'a';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<P> A(N);
  cin>>A;

  sort(A.begin(), A.end(), [](P a,P b){return a.first+a.second<b.first+b.second;});

  Int ans = 0;
  for(Int i=0;i<N;i++){
    auto a = A[N-1-i];
    if(i%2 == 0) ans += a.first;
    else ans -= a.second;
  }
  cout<<ans<<endl;  

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  int num1, num2 = 0;
  scanf("%d %d", &num1, &num2);
  if (num1 < num2) {
    printf("a < b\n");
  }else if(num1 > num2){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
vector<ll> visit,lg;
vector<string> adj;
ll r,c,ans;

// void dfs(ll i,ll j)
// {
// 	if(i==r-1&&j==c-1)
// 	{
// 		ans+=1;
// 		ans%=mod;
// 		return;
// 	}
// 	if(j+1<c&&adj[i][j+1]=='.')
// 		dfs(i,j+1);
// 	if(i+1<r&&adj[i+1][j]=='.')
// 		dfs(i+1,j);
// }
void solve()
{
	rl2(r,c);
	adj.assign(r,"");
	fr(i,0,r)
		cin>>adj[i];

	vector<VL> dp(r,VL(c,0));
	fr(i,0,r)
	{
		if(adj[i][0]=='#')
			break;
		dp[i][0]=1;
	}
	fr(i,0,c)
	{
		if(adj[0][i]=='#')
			break;
		dp[0][i]=1;
	}
	fr(i,1,r)
	{
		fr(j,1,c)
		{
			if(adj[i][j]=='.')
			{
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}
	//visit.assign()
	// dfs(0,0);
	cout<<dp[r-1][c-1]<<endl;
	return;
}
int main()
{
	
	ll t=1;
	//rl(t);

	//cin>>t;
	//scanf()
	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<tuple>
#include<utility>

using namespace std;



int main() {

	int n;
	cin >> n;
	int w[101];
	int sum = 0;

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

	int mini = sum;

	int fixsum = 0;

	for (int i = 0; i < n; i++) {
		fixsum += w[i];

		mini = min(mini, abs(sum - 2 * fixsum));
	}

	
	cout << mini << endl;

	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
    bool IsSq(int n)
    {
      int i;
      for(i = 0; i*i < n; i++)
      {
      }
      return i * i == n;
    }
     
    int main()
    {
      int N;
      int D;
      int pos[20][10];
      int n, d;
      scanf("%d%d", &N, &D);
      int i, j;
      for(n = 0; n < N ; n++)
      {
        for(d = 0; d < D ; d++)
        {
          scanf("%d", pos[n]+d);
        }
      }
      int sum = 0;
      for(i = 0; i < N; i++)
      {
        for(j = i+1; j < N; j++)
        {
          int d2 = 0;
          for(d = 0; d < D; d++)
          {
            d2 += (pos[i][d] - pos[j][d]) * (pos[i][d] - pos[j][d]);
          }
          if(IsSq(d2))
          {
            sum++;
          }
        }
      }
      printf("%d\n", sum);
      return 0;
    }

Measured memory_bytes: 128
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func readInt(sc *bufio.Scanner) (res int) {
	res, _ =strconv.Atoi(readLine(sc))
	return
}

func readInts(sc *bufio.Scanner, n int) []int {
	ns := strings.Split(readLine(sc), " ")
	res := make([]int, n)

	for i, n := range ns {
		res[i], _ = strconv.Atoi(n)
	}
	return res
}

func readInt64s(sc *bufio.Scanner, n int) []int64 {
	ns := strings.Split(readLine(sc), " ")
	res := make([]int64, n)

	for i, n := range ns {
		res[i], _ = strconv.ParseInt(n, 10, 64)
	}
	return res
}

func readMatrix(sc *bufio.Scanner, rows, cols int) [][]int {
	res := make([][]int, rows)
	for i := 0; i < rows; i ++ {
		res[i] = readInts(sc, cols)
	}
	return res
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	xs := strings.Split(readLine(sc), " ")
	a := xs[0]
	b := xs[1]

	if a == "H" {
		fmt.Println(b)
	} else {
		if b == "H" {
			fmt.Println("D")
		} else {
			fmt.Println("H")
		}
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

vector<P> D[100010];

int main(){
    ll N; cin>>N;
    vector<P> d,x,y;
    rep(i,N){
        ll a,b; cin>>a>>b;
        d.pb(mp(a,b));
        x.pb(mp(a,i));
        y.pb(mp(b,i));
    }
    sort(ALL(x));
    sort(ALL(y));
    rep(i,N-1){
        ll A=x[i].second, B=x[i+1].second;
        ll cost=min(abs(d[A].first-d[B].first),abs(d[A].second-d[B].second));
        D[A].pb(mp(cost,B));
        D[B].pb(mp(cost,A));
    }
    rep(i,N-1){
        ll A=y[i].second, B=y[i+1].second;
        ll cost=min(abs(d[A].first-d[B].first),abs(d[A].second-d[B].second));
        D[A].pb(mp(cost,B));
        D[B].pb(mp(cost,A));
    }
    ll ans=0;
    vector<bool> used(N,false);
    used.at(0)=true;
    P_queue Q;
    rep(i,D[0].size()) Q.push(D[0].at(i));
    while(!Q.empty()){
        ll cost=Q.top().first, A=Q.top().second;
        Q.pop();
        
        if(!used[A]){
            ans+=cost;
            used[A]=true;
            rep(i,D[A].size()){
                ll B=D[A].at(i).second;
                if(!used[B]) Q.push(D[A].at(i));
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 19284
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int n,k;
    vector<P> v;   //<１か0か、サイズ>
    int t=0;
    int cnt=0;
    int ans=0;
    string s;
    
    cin >> n>> k;
    cin >> s;
    
    rep(i,n+1){
        
        if(i==0){
           t = (s[0]=='1')? 1:0;
        }
        
        if(i==n){
            v.push_back(P(t,cnt));
            break;
        }
        
        if(i>0&&s[i]!=s[i-1]){
            v.push_back(P(t,cnt));
            cnt = 1;
            t=(t+1)%2;
        }else{
            cnt++;
        }
    }
    
    
    int subans=0;
    int usedk=0;
    int e=0;
    
    rep(i,v.size()){
        if(i>0){
            subans=subans-v[i-1].second;
            if(v[i-1].first==0)usedk--;
        }
        
        //加える
        
        while(usedk<=k&&e<v.size()){
            if(v[e].first==0&&usedk<k){
                subans+=v[e].second;
                usedk++;
            }else if(v[e].first==1){
                subans+=v[e].second;
            }else{
                break;
            }
            
            e++;
        }
        //cout << i<<' '<<subans<<endl;
        ans=max(subans,ans);
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1528
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001



H,W = map(int,input().split())

table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]


for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]


for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]


for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6220
a,b,c,d,e,f = map(int,input().split())
w = []
for i in range(f//100//a+1):
    for j in range(f//100//b+1):
        if (i*a + j*b)*100 <= f:
            w.append(i*100*a + j*100*b)
w = set(w)
w.remove(0)
s = []
for i in range(e*f//100//c+1):
    for j in range(e*f//100//d+1):
        if i*c + j*d <= e*f//100:
            s.append(i*c + j*d)
s = sorted(set(s))

ans = []
for i in w:
    for j in s:
        if i != 0 and j <= e* i//100 and i+j <= f:
            ans.append([j/(i+j), j+i, j])
ans.sort()
print(ans[-1][1], ans[-1][2])

Measured memory_bytes: 12456
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
using namespace std;
const int N = 1000000;


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

    vector<int> c(n);
    vector<int> t(n);
    rep(i, n) cin >> c[i] >> t[i];

    int c_min = N;

    for (int i = 0; i < n; ++i) {
        if(t[i] <= T && c[i] < c_min){
            c_min = c[i];
        }
    }
    if (c_min == N)print("TLE");
    else print(c_min);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];

		for(int i = 0; i < n; i++) {
			a[i] = stdin.nextInt();
			b[i] = stdin.nextInt();
			c[i] = stdin.nextInt();
		}

		for(int i = 0; i < n; i++) {

			if(a[i] * a[i] + b[i] * b[i] == c[i] * c[i]) {
				System.out.println("YES");
			} else if(b[i] * b[i] + c[i] * c[i] == a[i] * a[i]) {

				System.out.println("YES");
			} else if(c[i] * c[i] + a[i] * a[i] == b[i] * b[i]) {
				System.out.println("YES");

			}else {
				System.out.println("NO");

			}


		}
	}
}

Measured memory_bytes: 33436
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;

void main() {
    int n, k;
    scan(n, k);

    auto x = new int[](n), y = new int[](n);

    foreach (i ; 0 .. n) {
        scan(x[i], y[i]);
    }

    long ans = long.max;

    if (k == 2) {
        foreach (i ; 0 .. n) {
            foreach (j ; i + 1 .. n) {
                int xl = min(x[i], x[j]), xr = x[i] + x[j] - xl;
                int yb = min(y[i], y[j]), yt = y[i] + y[j] - yb;

                ans = min(ans, 1L * (xr - xl) * (yt - yb));
            }
        }
    }
    else if (k == 3) {
        foreach (i ; 0 .. n) {
            foreach (j ; i + 1 .. n) {
                foreach (l ; j + 1 .. n) {
                    int xl = [x[i], x[j], x[l]].reduce!min, xr = [x[i], x[j], x[l]].reduce!max;
                    int yb = [y[i], y[j], y[l]].reduce!min, yt = [y[i], y[j], y[l]].reduce!max;

                    ans = min(ans, 1L * (xr - xl) * (yt - yb));
                }
            }
        }
    }
    else {
        foreach (i ; 0 .. n) {
            foreach (j ; i + 1 .. n) {
                foreach (l ; j + 1 .. n) {
                    foreach (m ; l + 1 .. n) {
                        int xl = [x[i], x[j], x[l], x[m]].reduce!min;
                        int xr = [x[i], x[j], x[l], x[m]].reduce!max;
                        int yb = [y[i], y[j], y[l], y[m]].reduce!min;
                        int yt = [y[i], y[j], y[l], y[m]].reduce!max;

                        int cnt;

                        foreach (a ; 0 .. n) {
                            if (xl <= x[a] && x[a] <= xr && yb <= y[a] && y[a] <= yt) cnt++;
                        }

                        if (cnt >= k) {
                            ans = min(ans, 1L * (xr - xl) * (yt - yb));
                        }
                    }
                }
            }
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	double A, B;
	cin >> A >> B;
	int l = 0;
	repd(i, 1, 1200)
	{
		if(floor(i*0.08)==A && floor(i*0.1)==B)
		{
			cout << i << endl;
			l=1;
			break;
		}
	}
	if(l==0) cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

ans = sys.maxsize
for i in range(1, n, 1):
    if i > math.sqrt(n):
        break

    if n % i ==0:
        ans = min(ans, n//i -1 + i - 1)

print(ans)




Measured memory_bytes: 5572
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,a,b;
int main()
{
	/*freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);*/
	n=read(),a=read(),b=read();
	cout<<min(a,b)<<' '<<max(0,a+b-n);
	return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [str(i) for i in input().split()]
    ans = "".join(a)

    if int(ans) % 4 ==0:
        print("YES")
    else:
        print("NO")
        


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

int  main () {
  string N;
  cin >> N;
  int I = N.size();
  long long sum;
  for (int i = 0; i < I; i++){
    int n = 0;
    n = (int) (N.at(i) - '0');
    sum += n;
  }
  if (sum%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PB push_back
#define MP make_pair
#define F first
#define S second
int c[100005];
int main()
{      
    int t,ans;
    for(int i=1;i<=5;i++)
    {
        cin>>t;
        if(t==0)
        {
            ans=i;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(void){
int n;
while(1){
	cin>>n;
	if(n==0)break;
	int b;
	priority_queue<int> a;
	for(int i=0;i<n;i++){
		cin>>b;
		a.push(b);
	}
	a.pop();
	int ans=0,c;
	while(a.size()!=1){
ans+=a.top();
a.pop();
	}
	ans/=n-2;
	cout<<ans<<endl;
}
	return 0;
}

Measured memory_bytes: 2964
#include <stdio.h>

int N, W;
int wv[102][2];
long long int x[102][100004];

long long int getBest(int i, int w) {
	if (i >= N)
		return 0;
	if (x[i][w] != 0)
		return x[i][w];
	long long int a = getBest(i + 1, w);
	if (w - wv[i][0] >= 0) {
		long long int b = getBest(i + 1, w - wv[i][0]) + wv[i][1];
		if (b > a)
			a = b;
	}
	x[i][w] = a;
	return a;
}

int main()
{
	scanf("%d %d", &N, &W);
	for (int i = 0; i < N; i++)
		scanf("%d %d", &wv[i][0], &wv[i][1]);

	printf("%lld", getBest(0, W));
}

Measured memory_bytes: 76288
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;

int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

// bool isPrime(int x){
//     int i;
//     if(x<2)return 0;

// }

int X,Y;
int main(){
    cin>>X>>Y;
    if(4*X>=Y && Y%2==0 && 2*X-Y/2 <= X){
        int num=2*X-Y/2;
        if(2*num+4*(X-num)==Y){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
T,A = map(float, input().split())
H = list(map(float, input().split()))

Tave = [0 for _ in range(N)]
gap = [0 for _ in range(N)]
gapmin = 10000
Tmin = 0
for i in range(N):
    Tave[i] = T-0.006*(H[i])
    gap[i] = abs(Tave[i]-A)
    if gapmin>gap[i]:
        Tmin = i
        gapmin = gap[i]

print(Tmin+1)

Measured memory_bytes: 3064
from collections import deque

def bfs(s, dist):
    visited = [False] * (N+1)
    q = [(s, 1)]
    visited[s] = True

    while q:
        u, c = q.pop()
        for v in graph[u]:
            if not visited[v]:
                visited[v] = True
                dist[v] = c
                q.append((v, c+1))


N = int(input())
graph = [deque() for i in range(N+1)]
dist = [[0] * (N+1) for i in range(2)]

for i in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

bfs(1, dist[0])
bfs(N, dist[1])

b = w = 0
for i in range(2, N):
    if dist[0][i] <= dist[1][i]:
        b += 1
    else:
        w += 1
if b <= w:
    print('Snuke')
else:
    print('Fennec')

Measured memory_bytes: 81252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    ll N, K; cin >> N >> K;
    vector<ll> A(N), F(N); cin >> A >> F;
    sort(A.begin(), A.end(), greater<ll>());
    sort(F.begin(), F.end());
    vector<ll> AxF(N); for (int i = 0; i < N; i++) AxF[i] = A[i] * F[i];

    ll l = -1, r = A.front() * F.back(), c, k;
    while (r - l > 1) {
        c = l + (r - l) / 2;
        k = K;
        for (int i = 0; i < N; i++) {
            ll d = AxF[i] - c;
            if (d > 0) {
                k -= (d + F[i] -1) / F[i];
                if (k < 0) break;
            }
        }
        if (k >= 0) {
            r = c;
        } else {
            l = c;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 4992