akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
class data{
public:
    int gohyaku,hyaku,goju,ju;
    void cal(int n){
        gohyaku=n/500;
        n-=gohyaku*500;
        hyaku=n/100;
        n-=hyaku*100;
        goju=n/50;
        n-=goju*50;
        ju=n/10;
    }
};
int main(){
    int n;
    int hogehoge=0;
    while(cin>>n,n){
        int gohyaku,hyaku,goju,ju;
        cin>>ju>>goju>>hyaku>>gohyaku;
        int hoge=500*gohyaku+100*hyaku+50*goju+10*ju;
        data a;
        a.cal(hoge-n);
        if(hogehoge++)cout<<endl;
        
        if(ju-a.ju>0)cout<<10<<" "<<ju-a.ju<<endl;
        if(goju-a.goju>0)cout<<50<<" "<<goju-a.goju<<endl;
        if(hyaku-a.hyaku>0)cout<<100<<" "<<hyaku-a.hyaku<<endl;
        if(gohyaku-a.gohyaku>0)cout<<500<<" "<<gohyaku-a.gohyaku<<endl;
    }
}

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

const int N = (int) 60 + 5 ;
const int inf = (int) 2e9 ;

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

int r , c ;
int vis[N][N] , cnt = 0;
char str[N][N] ;

bool valid( int x , int y ) {
//    cout << "==== Called " << x << " " << y << endl ;
    return ( x < r && y < c && x >= 0 && y >= 0 && vis[x][y] == 0 && str[x][y] == '#' ) ;
}

void dfs( int x , int y ) {
    cout << "visited " << x << " " << y << endl ;
//    vis[x][y] = 1 ;
    cnt += 1 ;
    for( int i = 0 ; i < 4 ; i++ ) {
        int xx = x + dx[i] ;
        int yy = y + dy[i] ;
        if( valid( xx , yy ) ) {
            vis[x][y] = 1 ;
            dfs( xx , yy ) ;
        }
    }
}

int bfs( int sx , int sy ) {
    queue< pair< int , int > > qu ;
    qu.push( {sx , sy} ) ;
    vis[sx][sy] = 1 ;

    cnt = 0 ;

    while ( !qu.empty() ) {
        cnt += 1 ;
        pair< int , int > p = qu.front() ; qu.pop() ;
        int x = p.first , y = p.second ;
        for( int i = 0 ; i < 4 ; i++ ) {
            int xx = x + dx[i] ;
            int yy = y + dy[i] ;
            if( valid( xx , yy ) ) {
                vis[xx][yy] = 1 ;
                qu.push( {xx , yy} ) ;
            }
        }
    }

}

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    scanf("%d %d" , &r , &c ) ;
    for( int i = 0 ; i < r ; i++ ) {
        scanf("%s" , &str[i] ) ;
    }
    memset( vis , 0 , sizeof(vis) ) ;
    int f = 1 ;
    for( int i = 0 ; i < r ; i++ ) {
        for( int j = 0 ; j < c ; j++ ) {
            if( valid( i , j) ) {
                cnt = 0 ;
                vis[i][j] = 1 ;
                bfs( i , j ) ;
                if( cnt == 1 ) {
                    f = 0 ; break ;
                }
            }
        }
        if( f == 0 ) break ;
    }
    printf("%s\n" , f == 1 ? "Yes" : "No" ) ;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

struct edge {int to,cost;};
vector<edge> G[100010];

signed main() {
    int N; cin >> N;
    rep(i,N-1){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    queue<int> que;
    bool vis[N]; rep(i,N) vis[i]=false;
    bool col[N];
    col[0]=false;
    que.push(0);
    while(!que.empty()){
        int q = que.front(); que.pop();
        vis[q]=true;
        for(auto d:G[q]) if(!vis[d.to]){
            col[d.to]=(d.cost%2)^(col[q]);
            que.push(d.to);
        }
    }
    bool frag = true;
    rep(i,N) if(col[i]==1) frag = false;
    if(frag) col[0]=1;
    rep(i,N) cout << col[i] << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1234567;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>s(N);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> s[i];
        sum+=s[i];
    }
    if(sum%10 != 0) {
        cout << sum << endl;
    }
    else {
        sort(s.begin(),s.end());
        for(int i = 0; i < s.size(); i++) {
            if(s[i]%10 != 0) {
                cout << sum-s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner(System.in);
        

    while (sc.hasNextLine()) {
        
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        
         if(op.equals("+")){
            System.out.println(a+b);
            
         }else if(op.equals("-")){
            System.out.println(a-b);
             
         }else if(op.equals("*")){
             System.out.println(a*b);

        }else if(op.equals("/")){
             System.out.println(a/b);
        }else{
             break;
        }
    }
    }
}




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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }



int main(){
  int N; cin>>N;
  vector<int> nexts[N+1];
  pair<int,int> edge[N];
  int use[N+1]; FILL(use,N+1,0);
  REP(i,N-1){
      int a,b;
      scanf("%d %d",&a,&b);
      nexts[a].push_back(b);
      nexts[b].push_back(a);
      edge[i] = make_pair(a,b);
  }
  
  int color_p[N+1]; FILL(color_p,N+1,0);
  FILL(color_p,N+1,0);
  map< pair<int,int> , int> mp;
  queue<int> q;
  q.push(1);
  use[1] = 1;
  int s = 0;
  while(!q.empty()){
      int base = q.front(); q.pop();
      chmax(s, (int)nexts[base].size() );
      int cur = 1;
      for(int next: nexts[base]){
          if( use[next] ){ continue;}
          if(color_p[base]==cur){ ++cur; }
          color_p[next] = cur;
          mp[ make_pair(base,next) ] = cur;
          mp[ make_pair(next,base) ] = cur;
          ++cur;
          use[next] = 1;
          q.push(next);
      }
  }
  
  cout << s <<"\n";
  REP(i,N-1){
      printf("%d\n",mp[edge[i]]);
  }
}

Measured memory_bytes: 20096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> tree(20000);

int whatisroot(int x){
	if(x == tree[x]){
		return x;
	}
	else{
		int ref;
		ref = whatisroot(tree[x]);
		tree[x] = ref;
		return ref;
	}
}

int root(int x, int y){
	if(x == tree[x]){
		tree[x] = y;
		return y;
	}
	else{
		int ref;
		ref = root(tree[x], y);
		tree[x] = ref;
		return ref;
	}
}

void unite(int x, int y){
	int temp;
	if(x > y){
		temp = x;
		x = y;
		y = temp;
	}
	temp = whatisroot(x);
	tree[y] = root(tree[y],temp);
	return;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0;i<n;i++){
		tree[i] = i;
	}
	int q, com, x, y;
	cin >> q;
	for(int i = 0;i<q;i++){
		cin >> com >> x >> y;
		if(com == 0){
			unite(x,y);
		}
		else{
			if(whatisroot(x) == whatisroot(y)) cout << 1;
			else cout << 0;
			cout << endl;
		}
	}
	return 0;
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)
#define MOD 1000000007

int n,x;


int main(){
  cin >> n >> x;
  vector<int> l(n);
  REP(i,n)cin>>l[i];

  int ans=0;
  int d=0;
  REP(i,n){
    d+=l[i];
    ans++;
    if (d>x){
      break;
    }
  }
  if (d<=x)ans++;

  cout<<(ans)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int n,m;
vector<vector<int>> g,t;

vector<bool> checked;
set<pair<int,int>> inTree;
vector<int> cnt;
vector<pair<int,int>> ans;

void makeTree(int now){
    checked[now]=true;
    for(auto x:g[now])if(!checked[x]){
        t[now].push_back(x);
        t[x].push_back(now);
        inTree.insert(make_pair(x,now));
        inTree.insert(make_pair(now,x));
        makeTree(x);
    }
}

void dfsTree(int pre,int now){
    for(auto x:t[now])if(x!=pre){
        dfsTree(now,x);
    }
    //帰るときに
    if(pre>=0){
        if(cnt[now]%2==0){
            ans.push_back(make_pair(pre,now));
            cnt[pre]++;
        }else{
            ans.push_back(make_pair(now,pre));
            cnt[now]++;
        }
    }
}

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

    cin>>n>>m;
    if(m%2==1){
        cout<<-1<<endl;
        return 0;
    }
    g.resize(n);t.resize(n);checked.resize(n,false);cnt.resize(n,0);
    vector<pair<int,int>> edges(m);
    rep(i,m){
        int u,v;cin>>u>>v;u--,v--;
        edges[i]=make_pair(u,v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    makeTree(0);
    //全域木に入ってない辺はテキトーに決めちゃって構わない
    for(auto x:edges)if(!inTree.count(x)){
        ans.push_back(x);
        cnt[x.first]++;
    }
    dfsTree(-1,0);
    //assert(ans.size()==m);
    rep(i,ans.size()){
        cout<<ans[i].first+1<<' '<<ans[i].second+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 31608
function main(arg) {
    arg = arg.split("\n")
    arg = arg[0].split(" ")
    arg[0] = parseInt(arg[0], 10)
    arg[1] = parseInt(arg[1], 10)
    var n1 = Math.abs(arg[0]%arg[1])
    if (n1 >= 2) {
        n1 = 1
    }
    console.log(n1)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    S = list(_ for _ in input())
    K = int(input().rstrip())
    c = S[K-1]
    for i in range(N):
        if(S[i]!=c):
            S[i] = '*'
        
    print(''.join(S))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <stdio.h>

int main(void){
int a;
int aa;
int b;
scanf("%d%d",&a,&b);
while(1){
if(a > b){
printf("%d %d\n",b,a);}
else{
printf("%d %d\n",a,b);}
scanf("%d%d",&a,&b);
if(a==0 && b==0)break;
}}


Measured memory_bytes: 2036
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 1500000;
const int K = 20 ;
vector < int > g[N];
int dp[N], a[N];
void dfs(int v, int p = -1){
    for (auto u: g[v]){
        if (u == p) continue;
        dfs(u, v);
        if (a[u] < a[v] && dp[u] == 0) dp[v] = 1;
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++) dp[j] = 0;
        dfs(i);
        if (dp[i]){
            cout << i << " ";
        }
    }
}


Measured memory_bytes: 38656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> times(n);
  rep2(i, 1, n) {
    string tmp;
    tmp.push_back(s[i - 1]);
    tmp.push_back(s[i]);
    if (tmp == "AC") {
      if (i == 0)
        times[i]++;
      else
        times[i] = times[i - 1] + 1;
    }
    times[i + 1] = times[i];
  }
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << times[r] - times[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 3736
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()

t2 = [[] for _ in range(k)]
score = [0]*n
for i,c in enumerate(t):
  t2[i%k].append(c)
score = {'r':p,'s':r,'p':s}
total = 0
for t3 in t2:
  if len(t3)==0: continue
  if len(t3)==1:
    total += score[t3[0]]
    continue  
  for i in range(len(t3)-1):
    if t3[i] == 'e': continue
    total += score[t3[i]]
    if t3[i] == t3[i+1]:
      t3[i+1]='e'
  if t3[-1] != 'e':
    total += score[t3[-1]]
print(total)


Measured memory_bytes: 18612
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);

    int n = sc.nextInt();
    long k = sc.nextLong();

    long[] p = new long[n];
    for (int i = 0; i < n; i++) {
        p[i] = k;
    }

    int q = sc.nextInt();
    for (int i = 0; i < q; i++) {
        int a = sc.nextInt();
        p[a-1] += 1;
    }

    for (int i = 0; i < n; i++) {
        pw.println(p[i] - q > 0 ? "Yes" : "No");
    }

    pw.flush();
  }
}

Measured memory_bytes: 48736
#include<stdio.h>
int main(void){
  int h,n,i,a[100000],s=0;
  scanf("%d%d",&h,&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    s=s+a[i];
  }
    if(h>s)
      printf("No");
    else
      printf("Yes");
  return 0;
}
    
  


Measured memory_bytes: 512
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<int> g[100111];
int msk[100111][20],ans[100111],n;
void dfs(int x,int f=0)
{
	for(int i=0;i<(int)g[x].size();i++)
		if(g[x][i]!=f)
		{
			dfs(g[x][i],x);
			ans[x]=max(ans[g[x][i]],ans[x]);
			for(int j=0;j<20;j++)msk[x][j]+=msk[g[x][i]][j];
		}
	int cur=ans[x];
	while(cur>=0&&msk[x][cur]<2)cur--;
	cur++;
	for(int i=0;i<cur;i++)msk[x][i]=0;
	while(msk[x][cur]==1)
		msk[x][cur++]=0;
	msk[x][cur]=1;
	ans[x]=max(ans[x],cur);
//	for(int i=0;i<ans[x];i++)printf("%d ",msk[x][i]);puts("");
}
int main()
{
	get1(n);
	for(int i=1,u,v;i<n;i++)
	{
		get2(u,v);
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1);
	printendl(ans[1]);
	return 0;
}

Measured memory_bytes: 19584
n=int(input())
a=list(map(int,input().split()))
a.sort()
negative=[]
positive=[]
for ele in a:
    if ele<0:
        negative.append(ele)
    else:
        positive.append(ele)
if len(negative)==0:
    print(sum(a))
else:
    if len(negative)%2==0:
        print(-sum(negative)+sum(positive))
    else:
        if len(positive)==0:
            print(-sum(negative)+2*negative[-1])
        elif -negative[-1]>positive[0]:
            print(-sum(negative)+sum(positive[1:])-positive[0])
        else:
            print(-sum(negative[:-1])+sum(positive)+negative[-1])


Measured memory_bytes: 14492
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef pair<int, int> P;

int main(){
    int n;
    while(cin >> n && n > 0){
        if(n == 1){
            cout << 0 << endl;
            continue;
        }
        if(n == 2) {
            int p1, t1, p2, t2;
            cin >> p1 >> t1 >> p2 >> t2;
            cout << abs(p1 - p2) << endl;
            continue;
        }
        vector<int> p1;
        vector<int> p2;
        p2.reserve(n * n);
        vector<P> pv;
        REP(i, n) {
            int p, t;
            cin >> p >> t;
            if(t == 1){
                p1.push_back(p);
            }else{
                pv.push_back(P(p, t));
            }
        }

        sort(pv.begin(), pv.end());
        REP(i, pv.size() - 1) pv[i].second --;
        REP(i, pv.size() - 1) pv[i + 1].second --;
        REP(i, pv.size()){
            REP(_, pv[i].second){
                p2.push_back(pv[i].first);
            }
        }

        int n1 = p1.size();
        int n2 = p2.size();

        if(n1 > n2) {
            cout << -1 << endl;
            continue;
        }

        sort(p1.begin(), p1.end());
        sort(p2.begin(), p2.end());

        long long ans = *max_element(p2.begin(), p2.end()) - *min_element(p2.begin(), p2.end());
        // cout << ans << endl;
        // cout << "p1 : "; REP(i, p1.size()) cout << p1[i] << " "; cout << endl;
        // cout << "p2 : "; REP(i, p2.size()) cout << p2[i] << " "; cout << endl;

        vector<long long> dp(2 * n1, 0);
        int last_base2 = -1;

        for(int i1 = 0; i1 < n1; i1++){
            vector<long long> next(2 * n1, LLONG_MAX);

            int base2 = lower_bound(p2.begin(), p2.end(), p1[i1]) - p2.begin();

            for(int di = 0; di < 2 * n1; di++){
                int i2 = di - n1 + base2;
                if(i2 < 0) continue;
                if(i2 >= n2) break;

                if(i1 == 0) {
                    next[di] = abs(p1[i1] - p2[i2]);
                    continue;
                }

                int lastdi = di + (base2 - last_base2) - 1;
                if(lastdi < 0) continue;

                long long last = (lastdi < 2 * n1 ? dp[lastdi] : dp.back());
                if(last == LLONG_MAX) continue;

                next[di] = last + abs(p1[i1] - p2[i2]);
                // printf("i1 = %d i2 = %d di = %d base = %d lastdi = %d last = %lld next[%d] <- %lld + %lld = %lld\n", i1, i2, di, base2, lastdi, last, di, last, abs(p1[i1] - p2[i2]), next[di]);
            }

            for(int j = 1; j < 2 * n1; j++){
                next[j] = min(next[j], next[j - 1]);
            }

            last_base2 = base2;
            dp.swap(next);
        }

        cout << ans + (n1 != 0 ? dp.back() : 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 68000
#include <stdio.h>

int main(){
    char s[200001];
    int n=0,i,temp=0;
    long sum=0;

    scanf("%s",s);

    while(s[n]!='\0'){
        n++;
    }

    for(i=n-1;i>=0;i--){
        if(s[i]=='B'){
            sum+=n-1-temp-i;
            temp++;
        }
    }
    printf("%ld",sum);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


 int main(){
   int N, a;
   cin >> N;
   map<int, int>p;
   rep(i, N){
     cin >> a;
   p[a-1] = i+1;}
   
 rep(i, N){
   if(i != 0) cout << " ";
   cout << p[i];
 }
   cout << endl;
   
     
  
  
}

Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;


int main(){
	ll N;
	cin >> N;
	vll T, X, Y;
	ll i, j;
	T.push_back(0);
	X.push_back(0);
	Y.push_back(0);
	for (i = 0; i < N; i++){
		ll t, x, y;
		cin >> t >> x >> y;
		T.push_back(t);
		X.push_back(x);
		Y.push_back(y);
	}
	bool flg = true;
	for (i = 1; i <= N; i++){
		ll dt = T[i] - T[i - 1];
		ll d = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);
		if (dt % 2 != d % 2 || d > dt){
			flg = false;
			break;
		}
	}
	if (flg){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 2912
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
//const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans = 0;

void solve(){
	map<LL,LL> num;
	for(int i=0;i<N;i++) num[A[i]]++;
	//数iを割り切るような数が存在するかどうかをdivisible[i]とする
	vector<int> divisible(1000001,0);
	for(auto iter=num.begin();iter!=num.end();iter++){
		LL a = iter->first;
		LL numof_a = iter->second;
		if(numof_a==1 && divisible[a]==0) ans++; 
		for(LL i=1;i*a<=1000000;i++) divisible[i*a] = 1;
	}
}

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

    solve();

	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20604
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
div = []
A_sum = sum(A)
i = 1
while i ** 2 < A_sum:
    if A_sum % i == 0:
        div.append(i)
        div.append(A_sum // i)
    i += 1

div.sort(reverse=True)

for j in div:
    mod = [a % j for a in A]
    mod.sort()
    s = sum(mod)
    if sum(mod[:-s // j]) <= K:
        print(j)
        break


Measured memory_bytes: 41948
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << n/3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
    lli n,m;
    cin>>n>>m;
    lli h[n+1];
    for(lli i=0;i<n;i++)
    {
        cin>>h[i];
    }
    
    vector<vector<lli>>v;
    v.assign(n+1,{});
    
    for(lli i=0;i<m;i++)
    {
        lli x,y;
        cin>>x>>y;
        v[x-1].push_back(y-1);
        v[y-1].push_back(x-1);
    }
    lli cnt=n;
    for(lli i=0;i<n;i++)
    {
        lli flag=1;
        for(lli j: v[i])
        {
           // cout<<i<<":"<<v[i][j]<<" ";
            if(h[j]>=h[i])
            {
                cnt--;
                break;
            }
        }
        
      
       //cout<<endl; 
    }
    
    cout<<cnt<<endl;

}

Measured memory_bytes: 9788
public class Main {


  private static void solve() {
    int n = ni();
    
    int[][] p = ntable(n, 3);
    int max = -1;
    int maxArg = 0;
    for (int i = 0; i < n; i ++) {
      if (max < p[i][2]) {
        max = p[i][2];
        maxArg = i;
      }
    }
    for (int cx = 0; cx <= 100; cx ++) {
      outer: for (int cy = 0; cy <= 100; cy ++) {
        int h = max + Math.abs(p[maxArg][0] - cx) + Math.abs(p[maxArg][1] - cy);
        for (int[] q : p) {
          int x = Math.max(h - Math.abs(cx - q[0]) - Math.abs(cy - q[1]), 0);
          if (x != q[2]) {
            continue outer;
          }
        }
        
        System.out.println(cx + " " + cy + " " + h);
        return;
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23252
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            StringBuilder S = new StringBuilder(reader.readLine());
            final String T = reader.readLine();

            boolean flg = false;
            for (int i = 0; i < S.length(); i++) {
                if (T.contentEquals(S)) {
                    flg = true;
                    break;
                }
                S = S.insert(0, S.charAt(S.length() - 1));
                S.setLength(S.length() - 1);
            }

            System.out.println(flg ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 22228
#include <iostream>

using namespace std;

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

  while (n--) {
    bool base[3] = {false, false, false};
    int out = 0;
    int point = 0;
    char c[8];

    while (out < 3) {
      cin >> c;

      if (c[0] == 'O')  out++;
      if (c[0] == 'H')
        if (c[1] == 'I') {
          for (int i = 0; i < 3; i++) {
            if (!base[i]) {
              base[i] = true;
              break;
            } else if (i == 2) {
              point++;
            }
          }
        } else {
          for (auto& b : base) {
            if (b) {
              point++;
              b = false;
            }
          }
          point++;
        }
    }
    cout << point << endl;
  }
}

Measured memory_bytes: 1164
fun main(args: Array<String>) {
    val N = nextInt()
    val e = IntArray(N + 1)
    for (i in 2 .. N) {
        var cur = i
        for (j in 2 .. i) {
            while (cur % j == 0) {
                e[j] += 1
                cur /= j
            }
        }
    }
    fun num(m: Int) = e.reduce { acc, x -> acc + (if (x >= m - 1) 1 else 0) }
    val l75 = num(75)
    val l25 = num(25)
    val l15 = num(15)
    val l5 = num(5)
    val l3 = num(3)
    val r5x5x3 = (l5 * (l5 - 1) * (l3 - 2)) / 2
    val r15x5 = l15 * (l5 - 1)
    val r25x3 = l25 * (l3 - 1)
    val r75 = l75
    println(r75 + r25x3 + r15x5 + r5x5x3)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())


Measured memory_bytes: 33812
#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;
const int mod=1e9+7;

const int N=1e6+5;
int n,x,y,ca[N],cb[N];
vector<int>col[N];
pii order[N];

int Power(int x,int n)
{
    if(n==0) return 1;
    if(n%2) return Power(x,n-1)*x%mod;
    int tmp=Power(x,n/2);
    return tmp*tmp%mod;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
        int c,h;
        cin>>c>>h;
        col[c].push_back(h);
    }
    for(int i=1;i<=n;i++)  sort(col[i].begin(),col[i].end());
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(col[i].empty()) continue;
        cnt++;
        order[cnt]=mp(col[i][0],i);
    }
    sort(order+1,order+cnt+1);
    int m=0;
    for(int id=1;id<=cnt;id++)
    {
        int i=order[id].se;
        int a=0;
        int b=0;
        while(a<col[i].size()&&col[i][0]+col[i][a]<=x) a++;
        if(id>1)
        {
            while(b<col[i].size()&&col[order[1].se][0]+col[i][b]<=y) b++;
        }
        else if(cnt>1)
        {
            while(b<col[i].size()&&col[order[2].se][0]+col[i][b]<=y) b++;
        }
        ca[id]=a;
        cb[id]=b;
        if(b) m=id;
    }
    int val=0;
    for(int i=1;i<=m;i++) val+=max(ca[i],cb[i]);
    vector<int>gt(val+1),igt(val+1);
    gt[0]=igt[0]=1;
    for (int i=1;i<=val;i++)
    {
        gt[i]=(gt[i-1]*i)%mod;
        igt[i]=Power(gt[i],mod-2);
    }
    int res=gt[val];
    for(int i=1;i<=m;i++) res=res*igt[max(ca[i],cb[i])]%mod;
    cout<<res;
}


Measured memory_bytes: 42112
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	a := nextInts(n)

	s := make([]int, n)
	for i := 0; i < n; i++ {
		s[i] = a[i]
		if i > 0 {
			s[i] += s[i-1]
		}
	}
	b := make([]int, 0)
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			x := s[j]
			if i > 0 {
				x -= s[i-1]
			}
			b = append(b, x)
		}
	}

	x := 0
	m := 40
	bit := 1 << uint(m-1)
	for i := m; i > 0; i-- {
		c := 0
		for j := range b {
			if (x+bit)&b[j] == x+bit {
				c++
			}
		}
		if c >= k {
			x += bit
		}
		bit >>= 1
	}

	puts(x)
}


Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,i,s,m;m=0;cin>>n;vector<long long> a(n);for(i=0;i<n;i++){cin>>a[i];if(a[i]<0){m++;a[i]=-a[i];}s+=a[i];}sort(a.begin(), a.end());cout<<s-(m%2?2*a[0]:0)<<endl;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;int main() {
    /*int t;
    cin >> t;
    while (t--) {*/
        long long int n;
        cin >> n;
        vector<long long int> v;
        // Note that this loop runs till square root
        for (int i = 1; i <= sqrt(n); i++) {
            if (n % i == 0) {
                // If divisors are equal, print only one
                if (n / i == i)
                    v.push_back(i);

                else {
                    v.push_back(i);
                    v.push_back(n / i);
                }
            }
        }
        sort(v.begin(), v.end());
        long long int result = n-1;
        for (int i = 0; i < v.size(); i++) {
            long long int ans = v[i] + n / v[i] - 2;
            if (ans < result)
                result = ans;

        }
        cout << result << endl;
    }






Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define of(i,a,b) for(register int (i)=(a);(i)>=(b);--(i))
#define rd read()
#define maxn 500001
#define fre(a) freopen("a.in","r",stdin);freopen("a.out","w",stdout);
int read() {int x=0,f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*f;}
void print(int x) { if(x<0){putchar('-');x=-x;}if(x>9)print(x/10);putchar(x%10+'0');}
int qp(int a, int  b) {int ans = 1;for(; b; b >>= 1, a *= a) if(b & 1) ans *= a;return ans;}
int ok;
int main() {
    int a=rd,b=rd,c=rd;
    fo(i,1,b){
    	if((a*i)%b==c){
    		ok=1;break;
		}
	}
	puts(ok?"YES":"NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
  {
  string str;
  cin>>str;
  ll c=0;
  ll n=str.length();
  for(ll i=0;i<n;i++)
    {
    c+=(str[i]-'0');
    
    }
  if(c%9)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  }


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  bool check = true;
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 0){
      if(S.at(i) != 'h'){
        check = false;
        break;
      }
    }
    if(i % 2 == 1){
      if(S.at(i) != 'i'){
        check = false;
        break;
      }
    }
  }
  if(S.size() % 2 == 1)
    check = false;
  if(check)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 305;
const int P = 998244353;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN]; int n;
int dp[MAXN][MAXN][MAXN];
int vis[MAXN][MAXN][MAXN];
bool res[MAXN][MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
bool check(int x, int y, int z) {
	return res[x][y][z];
}
int main() {
	scanf("%s", s + 1), n = strlen(s + 1), dp[n][0][0] = 1;
	for (int i = n; i >= 1; i--)
	for (int j = 0; j + (n - i) <= n - 1; j++)
	for (int k = 0; j + k + (n - i) <= n - 1; k++)
		if (s[i] == '0') {
			update(dp[i - 1][j][k], dp[i][j][k]);
			update(dp[i][j][k + 1], dp[i][j][k]);
		} else {
			update(dp[i - 1][j][k], dp[i][j][k]);
			update(dp[i][j + 1][k], dp[i][j][k]);
		}
	memset(vis, -1, sizeof(vis));
	vis[0][0][0] = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= i / 2; j++)
	for (int k = 0; j + k <= i / 2; k++) {
		if (vis[i][j][k] == -1) continue;
		int tmp = vis[i][j][k];
		if (i + 1 <= n && tmp != 0) {
			if (s[i + 1] == '0') chkmax(vis[i + 1][j + 1][k], tmp - 1);
			if (s[i + 1] == '1') chkmax(vis[i + 1][j][k + 1], tmp - 1);
		    chkmax(vis[i+1][j][k],tmp);
		}
		if (i + 2 <= n) {
			if (s[i + 1] == '0' || s[i + 2] == '0') chkmax(vis[i + 2][j + 1][k], tmp);
			if (s[i + 1] == '1' || s[i + 2] == '1') chkmax(vis[i + 2][j][k + 1], tmp);
			chkmax(vis[i + 2][j][k], tmp + 1);
			chkmax(vis[i+1][j][k],tmp);
		}
	}
	for (int i = 0; i <= n; i++)
	for (int j = n; j >= 0; j--)
	for (int k = n; k >= 0; k--) {
		res[i][j][k] = vis[i][j][k] != -1;
	/*	if (i != 0) res[i][j][k] |= res[i - 1][j][k];
		res[i][j][k] |= res[i][j + 1][k];
		res[i][j][k] |= res[i][j][k + 1];*/
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j + (n - i) <= n; j++)
	for (int k = 0; j + k + (n - i) <= n; k++)
		if (dp[i][j][k] && (n - i) + j + k != 0) {
			if (check(i, j, k)) {
				//cout<<"i j k "<<i<<" "<<j<<" "<<k<<endl;
				update(ans, dp[i][j][k]);
			}
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 196272
program hrn;
 var
  a,b:longint;
 begin
  read(a,b);
  if(a<=0)and(b>=0)then writeln('Zero');
  if(a>0)and(b>0)then writeln('Positive');
  if(a<0)and(b<0)then
   if (abs(a-b))mod 2=1 then writeln('Positive')
    else writeln('Negative');
 end.


Measured memory_bytes: 128
using System;
 
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            if((a * b) % 2 == 1)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, t;
    cin >> n >> t;
    ll ans = LONG_LONG_MAX;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if (b <= t) {
            ans = min(ans, a);
        }
    }
    if (ans == LONG_LONG_MAX) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define pr pair<int,int>
signed main()
{
    SPEED;
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    if(n%2)
    {
        cout<<b[n/2]-a[n/2]+1;
    }
    else
    {
        cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
    }
}

Measured memory_bytes: 6768
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if (s == "RRR") cout << 3;
    else if (s == "SSS") cout << 0;
    else if (s == "RSS" || s == "SSR" || s == "SRS" || s == "RSR") cout << 1;
    else cout << 2;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vector<string> S(N);
  rep(i,0,N) cin>>S[i];
  int ans=0;
  bool flag=1;
  rep(i,0,N){
    vi F(N,-1);
    F[i]=0;
    queue<int> Q;
    Q.push(i);
    Q.push(-1);
    int count=1;
    while(Q.size()>1){
      int X=Q.front();
      Q.pop();
      if(X==-1){
        count++;
        Q.push(-1);
      }
      else{
        rep(j,0,N){
          if(S[X][j]=='1'){
            if(F[j]==-1){
              F[j]=count;
              Q.push(j);
            }
            else{
              if((count-F[j])%2==1) flag=0;
            }
          }
        }
      } 
    }
    rep(j,0,N) ans=max(ans,F[j]+1);
  }
  if(flag) cout<<ans<<endl;
  else cout<<-1<<endl;
  }


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

using namespace std;

int main(){
    double r;
    double menseki, ensyu;

    cin >> r;

    menseki = M_PI*r*r;
    ensyu = M_PI*(2*r);

    cout << fixed << setprecision(6) << menseki << " " << ensyu << endl;

    return 0;
}


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

using i64 = long long;

int main() {
#ifdef HOME
	freopen("agc4a.in", "r", stdin);
	freopen("agc4a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant, a, b, c;

	cin >> a >> b >> c;
	if (!(a & b & c & 1)) {
		cout << "0\n";
		return 0; }

	ant = min(a * b, a * c);
	ant = min(ant, b * c);

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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; }

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

    int N;
    cin >> N;

    vector<double> x(N);
    vector<string> u(N);

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

    double ans = 0;

    for(int i = 0; i < N; i++){
        if(u[i] == "JPY"){
            ans += x[i];
        }else{
            ans += 380000.0 * x[i];
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i{}; i < N; ++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end(), greater<int>());
  int ans{};
  for (int i{}; i < K; ++i) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define LL long long
#define maxn 200005
#define mod 1000000007
#define INF (LL)1e18
using namespace std;
typedef pair<LL,int> PLI;
LL n,ans,c[maxn],Siz,cnt[maxn],fact[maxn],inv[maxn],mnp[maxn],Mnp2,Mnp;
LL w[maxn],x,y,Mn=INF,Mn2=INF,mn[maxn];
bool vis[maxn];
vector<PLI> cw[maxn];
struct node { LL v; node *nxt; } edge[maxn*75],*head[maxn],*ncnt;
void addedge(LL u,LL v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(LL u)
{
	vis[u]=true;
	cnt[c[u]]++,Siz++;
	for(node *p=head[u];p;p=p->nxt)
	{
		LL v=p->v;
		if(!vis[v]) dfs(v);
	}
}
int main()
{
	scanf("%lld%lld%lld",&n,&x,&y);
	fact[0]=1;
	for(LL i=1;i<=n;i++) fact[i]=1ll*fact[i-1]*i%mod;
	inv[1]=1;
	for(LL i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	inv[0]=1;
	for(LL i=1;i<=n;i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
	ncnt=&edge[0];
	for(LL i=1;i<=n;i++) mn[i]=INF;
	for(LL i=1;i<=n;i++)
	{
		scanf("%lld%lld",&c[i],&w[i]);
		if(mn[c[i]]>w[i]) mn[c[i]]=w[i],mnp[c[i]]=i;
		if(Mn>w[i]) Mn=w[i],Mnp=i;//Mn=min(Mn,w[i]);
	}
	for(LL i=1;i<=n;i++)
		if(c[i]!=c[Mnp]&&Mn2>w[i]) Mn2=w[i],Mnp2=i;
	for(LL i=1;i<=n;i++)
		if(i!=mnp[c[i]]&&mn[c[i]]+w[i]<=x) { addedge(i,mnp[c[i]]); addedge(mnp[c[i]],i); }
	for(LL i=1;i<=n;i++)
	{
		if(i==Mnp) continue;
		else if(c[i]!=c[Mnp]&&Mn+w[i]<=y) { addedge(i,Mnp); addedge(Mnp,i); }
		else if(c[i]==c[Mnp]&&Mn2+w[i]<=y) { addedge(i,Mnp2); addedge(Mnp2,i); }
	}
	dfs(Mnp);
	ans=fact[Siz];
	for(LL i=1;i<=n;i++) ans=1ll*ans*inv[cnt[i]]%mod;
	printf("%lld\n",ans);
}


Measured memory_bytes: 26752
N = int(input())
A_list= []
for _ in range(N):
    A_list.append(int(input()))

sorted_A_list = sorted(A_list, reverse=True)

for a in A_list:
    if a == sorted_A_list[0]:
        ans = sorted_A_list[1]
    else:
        ans = sorted_A_list[0]
    print(ans)

Measured memory_bytes: 14112
import itertools
lst = []
for i in range(6):
    lst.append(int(input()))
k = lst.pop(-1)
comb = list(itertools.combinations(lst, 2))
c = 0
ans = 'Yay!'
for l in range(len(comb)):
    a = comb[l][0]
    b = comb[l][1]
    if a < b:
        if b - a > k:
            c += 1
    else:
        if a - b > k:
            c += 1
if c != 0:
    ans = ':('
print(ans)

Measured memory_bytes: 3064