akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int** make2dArray(int x,int y){
	int** array = (int**)malloc(sizeof(int*) * x);
	for (int i = 0; i < x; i++) {
		array[i] = (int*)malloc(sizeof(int) * y);
	}
	return array;
}
void printArray(int* a, int length) {
	for (int i = 0; i < length; i++) {
		printf("%d ", a[i]);
	}
}
void print2dIntArray(int** a,int x,int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%d\n", a[i][j]);
			}
			else {
				printf("%d ", a[i][j]);
			}
		}
	}
}
void print2dLongArray(long long** a, int x, int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%llu\n", a[i][j]);
			}
			else {
				printf("%llu ", a[i][j]);
			}
		}
	}
}
int* getColFromArray(int** array, int x, int j) {
	int* a = (int*)malloc(sizeof(int) * x);
	for (int i = 0; i < x; i++) {
		a[i] = array[i][j];
	}
	return a;
}
long long int arrayTimes(int* a1, int* a2, int length) {
	long long int res = 0;
	for (int i = 0; i < length; i++) {
		res = res + a1[i] * a2[i];
	}
	return res;
}
void call(int n) {
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
			continue;
		}
		do{
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}
			x /= 10;
		} while (x);
	}
}
char change(char ch) {
	if (ch >= 'a' && ch <= 'z') {
		ch = ch - 'a' + 'A';
	}
	else if (ch >= 'A' && ch <= 'Z') {
		ch = ch - 'A' + 'a';
	}
	return ch;
}
int main() {
	char str[1200];
	fgets(str, 1200, stdin);
	for (int i = 0; str[i] != '\0'; i++) {
		printf("%c", change(str[i]));
	}
}




Measured memory_bytes: 2100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static class Vector implements Comparable<Vector> {
        long x, y;
        double length, angle;

        public Vector(long x, long y) {
            this.x = x;
            this.y = y;
            length = Math.sqrt(x * x + y * y);
            if (x == 0 && y == 0) angle = 0;
            else if (x == 0) angle = y > 0 ? Math.PI / 2 : (3 * Math.PI) / 2;
            else if (y == 0) angle = x > 0 ? 0 : Math.PI;
            else if (x > 0 && y > 0) angle = Math.acos(x / length);
            else if (x < 0 && y > 0) angle = Math.PI / 2 + Math.asin(-x / length);
            else if (x < 0 && y < 0) angle = Math.PI + Math.acos(-x / length);
            else if (x > 0 && y < 0) angle = (3 * Math.PI) / 2 + Math.asin(x / length);
        }

        @Override
        public int compareTo(Vector other) {
            if (this.angle < other.angle) return -1;
            if (this.angle > other.angle) return 1;
            return 0;
        }

        @Override
        public String toString() {
            return "Vector{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

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

        int N = sc.nextInt();
        Vector[] vectors = new Vector[N];

        for (int i = 0 ; i < N; i++) {
            vectors[i] = new Vector(sc.nextLong(), sc.nextLong());
        }

        Arrays.sort(vectors);

        double best = 0;

        for (int i = 0; i < N; i++) {
            for (int j = i; j < i + N; j++) {
                long x = 0;
                long y = 0;
                for (int k = i; k <= j; k++) {
                    x += vectors[k % N].x;
                    y += vectors[k % N].y;
                }
                best = Math.max(Math.sqrt(x * x + y * y), best);
            }
        }

        System.out.println(best);
    }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc[3];

int main(){
    cin>>a>>b>>c;
    C b/c+1-(a==0 ? 0:(a-1)/c+1) E;
}

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

s=0
for i in range(n):
  s+=l+i
cnt=0  
m=100000000
for i in range(n):
  u=m
  m=min(abs(l+i),m)
 
  if u!=m:
    cnt=i
    
    
print(s-(l+cnt))




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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

struct Mystruct
{
    int count;
    string name;

    Mystruct(string input_a, int input_b)
    {
        name = input_a;
        count = input_b;
    }
    bool operator<(const Mystruct &another) const
    {
        if (name == another.name)
        {
            return count < another.count;
        }
        return name < another.name; //年齢を比較
    };
};

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

    map<string, int> mp;

    REP(i, n)
    {
        string tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    int m=0;

    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        string name = itr->first;
        int count = itr->second;
        m=max(m,count);
    }

    vector<string> v;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if(itr->second == m){
            v.push_back(itr->first);
        }
    }
    SORT(v);

    REP(i,v.size()){
        ANS(v[i]);
    }

    return 0;
}


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

int main(void)
{
    int N;
    cin >> N;
    vector<int> s(N);
    vector<vector<int>> dig1s(10, vector<int>(0));
    vector<int> nondeci;

    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        sum += s[i];
        dig1s[s[i]%10].push_back(s[i]);
        if(s[i] % 10 != 0) nondeci.push_back(s[i]);
    }

    if(sum % 10 == 0 && nondeci.size() > 0){
        int min = *min_element(nondeci.begin(), nondeci.end());
        sum -= min;
    }

    cout << ((sum % 10 == 0) ? 0 : sum) << endl;

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................


   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  //int n=int_v(read());
	        		 char[] c=read().toCharArray();
	        		 int[] r=new int[200005];
	        		 r[0]=1; int j=1;
	        		 for(int i=1;i<200005;i++){
	        		 	j=(j*10)%2019;
	        		 	r[i]=j; 
	        		 }
	        		 int n=c.length; j=0;
	        		 long res=0;
	        		 Map<Integer,Integer> map=new HashMap<>();
	        		 map.put(0,1);
	        		 for(int i=0;i<n;i++){
	        		 	int k=r[n-i-1];
	        		 	j+=(k*(c[i]-'0'));
	        		 	j=j%2019;
	        		 	res+=map.getOrDefault(j,0);
	        		 	//if(map.getOrDefault(j,0)>0){out.write(i+" ");}
	        		 	map.put(j,map.getOrDefault(j,0)+1);
	        		 }
	        		 out.write(res+"");
                      out.flush();
	        		 
	}
}
	       
	          



	
  





Measured memory_bytes: 52168
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
X=many_int()

sort_X=sorted(X)

med_min1 = sort_X[(len(sort_X)//2)-1]
med_plus1 = sort_X[(len(sort_X)//2)]


for i in X:
    if i >= med_plus1:
        print(med_min1)
    else:
        print(med_plus1)


Measured memory_bytes: 93652
N,M = map(int,input().split())
A = list(map(int,input().split()))
tot = sum(A)
if tot%(4*M)==0:
    a = tot//(4*M)
else:
    a = tot//(4*M)+1
cnt = 0
for i in range(N):
    if A[i]>=a:
        cnt += 1
if cnt>=M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[101010],B[101010],C[101010],E[101010];

int SB[101010];
ll SC[101010];
int iscycle[101010];

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<101010> uf;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	int P=0,X=0,Y,Z;
	FOR(i,M) {
		cin>>A[i]>>B[i]>>C[i];
		A[i]--;
		B[i]--;
		E[A[i]]++;
		E[B[i]]++;
		if(uf[A[i]]!=uf[B[i]]) {
			SB[uf[A[i]]]=SB[uf[B[i]]]=SB[uf[A[i]]]+SB[uf[B[i]]];
			SC[uf[A[i]]]=SC[uf[B[i]]]=SC[uf[A[i]]]+SC[uf[B[i]]];
			uf(A[i],B[i]);
		}
		if(A[i]!=B[i]) P++;
		SB[uf[A[i]]]++;
		SC[uf[A[i]]]+=C[i]-1;
	}
	
	FOR(i,N) iscycle[i]=1;
	FOR(i,N) {
		if(E[i]!=2) iscycle[uf[i]]=0;
	}
	
	
	vector<ll> shortc,O;
	ll Tin=0,Tout=0;
	
	FOR(i,N) if(uf[i]==i) {
		if(uf.count(i)!=SB[i]) iscycle[i]=0;
		// long cycle
		//cout<<"!"<<i<<" "<<uf.count(i)<<" "<<SB[i]<<" "<<iscycle[i]<<" "<<SC[i]<<endl;
		if(iscycle[i]) {
			if(SB[i]==1) {
				if(SC[i]>1) shortc.push_back(SC[i]-1);
			}
			else {
				X++;
				Tin+=SC[i];
			}
		}
	}
	
	FOR(i,M) {
		if(iscycle[uf[A[i]]]==0) {
			//cout<<"!add"<<i<<" "<<A[i]<<" "<<B[i]<<" "<<C[i]<<endl;
			if(A[i]!=B[i]) Tout+=C[i]-1;
			else if(C[i]>1) O.push_back(C[i]-1);
		}
	}

	sort(ALL(shortc));
	sort(ALL(O));
	reverse(ALL(shortc));
	reverse(ALL(O));
	
	shortc.insert(shortc.begin(),0);
	O.insert(O.begin(),0);
	for(i=1;i<shortc.size();i++) shortc[i]+=shortc[i-1];
	for(i=1;i<O.size();i++) O[i]+=O[i-1];

	int mi=1<<30;
	int z;
	/*
	cout<<P<<" "<<X<<" "<<Tout<<" "<<Tin<<endl;
	FORR(s,shortc) cout<<s<<" ";
	cout<<endl;
	FORR(s,O) cout<<s<<" ";
	cout<<endl;
	*/
	FOR(y,shortc.size()) FOR(z,O.size()) if((X+y==0 || Tout+O[z]>0) && Tout+Tin+shortc[y]+O[z]>=X) {
		mi=min(mi,P+X+2*y+z);
	}
	
	if(mi==1<<30) mi=-1;
	cout<<mi<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8148
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    h, w = map(int, input().split())
    p = [h//2+w//3+1, h//3+w//2+1, h, w]
    if h % 3 == 0 or w % 3 == 0:
        p += [0]
    if h % 2 == 0:
        p += [h//2]
    if w % 2 == 0:
        p += [w//2]
    print(min(p))

if __name__ == '__main__':
    main()


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

int main() {
    int a,b;
    cin >> a >> b;
    if(a<=5){
        cout << 0 << endl;
    }else if(a>5&&a<=12){
        cout << b/2 << endl;
    }else{
        cout << b << endl;
    }
}

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

int main() {
	string s,t;
	cin>>s>>t;
	long long dp[s.size()+1][t.size()+1],str[s.size()+1][t.size()+1];
	for(long long i=0;i<=s.size();i++){
	    dp[i][0]=0;
	    str[i][0]=0;
	}
	for(long long i=0;i<=t.size();i++){
	    dp[0][i]=0;
	    str[0][i]=0;
	}for(long long i=1;i<=s.size();i++){
	    for(long long j=1;j<=t.size();j++){
	        if(s[i-1]==t[j-1]){
	            dp[i][j]=dp[i-1][j-1]+1;
	            str[i][j]=1;
	        }else if(dp[i-1][j]>dp[i][j-1]){
	            dp[i][j]=dp[i-1][j];
	            str[i][j]=2;
	        }
	        else{
	            dp[i][j]=dp[i][j-1];
	            str[i][j]=3;
	        }
    	}
	}long long i=s.size(),j=t.size();
	long long l=dp[i][j];
	char ans[l+1];
	ans[l]='\0';
	l--;
	while(i and j){
	    if(str[i][j]==3){
	        j--;
	    }else if(str[i][j]==2){
	        i--;
	    }else if(str[i][j]==1){
	        ans[l]=s[i-1];
	        l--,i--,j--;
	    }
	}cout<<ans;
	
}


Measured memory_bytes: 140928
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[0] != '7' && s[1] != '7' && s[2] != '7') {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

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

ll a;
cin>>a;
string s;
cin>>s;
if(a>=3200)
cout<<s;
else
cout<<"red";


}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=0
for i in range(n-1):
    left=set([])
    right=set([])
    for x in range(n):
        if x <= i :
            left.add(s[x])
        else:
            right.add(s[x])
    ans=max(ans,len(left & right))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    double a,b;
    cin>>a>>b;
    a=(a+b)/2;
    cout<<ceil(a)<<endl;
    
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[2][300];

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    for (int i = 0; i < 2; i++)
        for (int j = 1; j <= n; j++) {
            int tmp;
            cin >> tmp;
            a[i][j] = a[i][j-1] + tmp;
        }

    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, a[0][i] + (a[1][n] - a[1][i-1]));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    sort(a.rbegin(),a.rend());
    int ans = 0;
    REP(i,N){
        if(i&1) ans -= a[i];
        else ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;
struct edge{
    int from;
    int to;
    int cost;
    int id;
};
int color[MAX];
int dis[2*MAX];

struct node{
    int id;
    int color;
    int cost;
};

vector<pair<int,int>> G[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<node> P(N);
    vector<edge> E(M);
    for(int i=0;i<N;i++){
        P[i].id=i;
        cin>>P[i].cost;
    }
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        E[i].from=a;
        E[i].to=b;
        E[i].cost=max(P[a].cost,P[b].cost);
        E[i].id=i;
        
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    
    sort(all(E),[](edge a,edge b){
        return a.cost<b.cost;
    });
    
    for(int i=0;i<M;i++){
        int a=E[i].from,b=E[i].to;
        
        if(color[a]==0&&color[b]==0){
            color[a]=1;
            color[b]=2;
        }else if(color[a]==0){
            color[a]=3-color[b];
        }else if(color[b]==0){
            color[b]=3-color[a];
        }
        
        dis[E[i].id]=E[i].cost;
    }
    
    bool ok=true;
    int cnt1=0,cnt2=0;
    
    for(int i=0;i<N;i++){
        if(color[i]==1) cnt1++;
        else if(color[i]==2) cnt2++;
        int mini=INF;
        
        for(pair<int,int> to:G[i]){
            if(color[to.first]+color[i]==3){
                mini=min(mini,dis[to.second]);
            }
        }
        
        if(mini!=P[i].cost) ok=false;
    }
    
    if(cnt1==0||cnt2==0||cnt1+cnt2!=N) ok=false;
    
    if(ok){
        string ans;
        for(int i=0;i<N;i++){
            if(color[i]==1) ans+='B';
            else ans+='W';
        }
        cout<<ans<<endl;
        
        sort(all(E),[](edge a,edge b){
            return a.id<b.id;
        });
        
        for(int i=0;i<M;i++){
            cout<<E[i].cost<<endl;
        }
    }
    else cout<<-1<<endl;
    
}



Measured memory_bytes: 16000
N, T = map(int, input().split())

t = list(map(int, input().split()))

discount = 0
for i in range(N - 1):
    if t[i + 1] - t[i] < T:
        discount += (T - (t[i + 1] - t[i]))

X = N * T - discount

print(X)

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

int main(){
    int n,m;
    cin >> n >> m;
    int a[51],b[51];
    for(int i=0;i<m;++i){
        cin >> a[i] >> b[i];
    }
    int num[51];
    for(int i=0;i<=n;++i) num[i] = 0;
    for(int i=0;i<m;++i){
        num[a[i]]++;
        num[b[i]]++;
    }
    for(int i=1;i<=n;++i){
        cout << num[i] << "\n";
    }
    return 0;
}

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

#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)

int main() {
#ifdef __APPLE__
    freopen("main.in", "r", stdin);
#endif
    int n, k; cin >> n >> k;
    int ans = 0;
    while (n) {
        ++ans;
        n /= k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import os
import time

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    key = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
    time.sleep(1.98)
    print(7 - key.index(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import math

a, b, C = map(float, input().split())

h = b * math.sin(math.radians(C))
S = a * h / 2
t = a*a + b*b - 2*a*b*math.cos(math.radians(C))
c = pow(t, 1/2)
L = a + b + c

print(S)
print(L)
print(h)


Measured memory_bytes: 5704
n=int(input())
for a in range(1,3*n//4+1):
    if n>=4*a:
        continue
    b = a
    while True:
        if n*(a+b)>=4*a*b:
            b+=1
            continue
        x = a*b*n
        y = 4*a*b-n*(a+b)
        if y>0 and x%y==0:
            c = x//y
            print("{} {} {}".format(a,b,c))
            exit(0)
        if x/y<b:
            break
        b+=1

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:35:42 2020

@author: Kanaru Sato
"""

n = int(input())
abc = []
for i in range(n):
    abc.append(list(map(int, input().split())))

dp = []
for i in range(n):
    dp.append([-1,-1,-1])

for i in range(n):
    if i == 0:
        for j in range(3):
            dp[0][j] = abc[0][j]
    else:
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+abc[i][0]
        dp[i][1] = max(dp[i-1][2],dp[i-1][0])+abc[i][1]
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+abc[i][2]

print(max(dp[n-1]))

Measured memory_bytes: 47384
import queue

N, K = map(int, input().split())
p = list(map(int, input().split()))

queue = queue.Queue()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i] + 1
    queue.put(p[i] + 1)
    if i >= K:
        currentSum = currentSum - queue.get()

    if i >= K - 1:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))


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

int main() {
	int n, m; cin >> n >> m;
	vector<pair<int, int>>ab(m);
	for (int i = 0; i < m; i++) {
		cin >> ab[i].second >> ab[i].first;
	}
	sort(ab.begin(), ab.end());

	int ans = 0, now = -1e9;
	for (int i = 0; i < m; i++) {
		if (now <= ab[i].second) {
			ans++; now = ab[i].first;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int n,k;
  cin>>n>>k;
  int v[n+1];
  memset(v,0,sizeof(v));
  int sum=0;
  int x=0;
  REP(i,n){
    int tmp;
    cin>>tmp;
    if(v[tmp]==0)x++;
    v[tmp]++;
  }
  sort(v,v+n+1);
  int i=1;
  while(x>k&&i<=n+1){
    if(v[i]!=0){
      sum+=v[i];
      x--;
    }
    i++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

int main() {
	double N;
	cin >> N;
	for (double n = 1; n <= N; n++) {
		lint cnt = 0;
		for (double x = 1; x * x <= N; x++) {
			for (double y = 1; y * y <= N; y++) {
				double a = x + y;
				double b = x * x + y * y + x * y - n;
				double z = ((-1) * a + sqrt(a * a - 4 * b)) / 2;
				if (z == int(z)&&z>=1) {
					cnt++;
				}
			}
		}
		cout << cnt << enld;
	}
}

Measured memory_bytes: 3808
// Problem : Virus Tree 2
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc133_e
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//#define int ll

int n,k;
vector<int> adj[(int)1e5+10];
ll ans=0;

void dfs(int cur,int p){
	int avail=p==-1?k-1:k-2;
	if(k<(int)adj[cur].size()){
		ans=0;
		return;
	}
	for(int nxt:adj[cur]){
		if(nxt==p) continue;
		(ans*=avail--)%=MOD;
		dfs(nxt,cur);
	}
}

signed main() {
	fast_io;
	cin>>n>>k;
	lp(i,0,n-1){
		int x,y; cin>>x>>y;
		x--,y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	//k for root
	//dfs func will give answer for all children
	ans=k;
	dfs(0,-1);
	cout<<ans;
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 14860
#include "bits/stdc++.h"

using namespace std;

int main()
{

  string S;
  cin >> S;

  vector<int> P(S.length());
  for (int i = 0; i < S.length() - 1; ++i) {
    if (S[i] == 'R' && S[i + 1] == 'L') {
      int j = i;
      while (j >= 0 && S[j] == 'R') {
        //if (j % 2 == 0) {
        if (abs(j-i) % 2 == 0) {
          P[i]++;
        }
        else {
          P[i + 1]++;
        }
        j--;
      }
      j = i + 1;
      while (j < S.length() && S[j] == 'L') {
        if (abs(j - i) % 2 == 0) {
          P[i]++;
        }
        else {
          P[i + 1]++;
        }
        j++;
      }
    }
  }

  for (int i = 0; i < P.size(); ++i) {
    cout << P[i] << " ";
  }
}



Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int count = 0;
        int target = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            target = a[i];
            while (target == a[i]) {
                count++;
                i++;
                if (i == n)
                    break;
            }
            i--;
            if (count < target) {
                ans += count;
            } else {
                ans += count - target;
            }
            count = 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 51096
#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,abm,fma,popcnt,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 186, L = 17;

int n, m;
string grid[N];
int pref[N][N];
short dp[N][N][N][L];

void init() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + (grid[i-1][j-1] == '#');
    }
  }
  for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) for (int k = 0; k < N; k++) for (int l = 0; l < L; l++) dp[i][j][k][l] = -3;
}

inline bool mono(int b, int t, int l, int r) {
  int area = pref[t+1][r+1] - pref[b][r+1] - pref[t+1][l] + pref[b][l];
  return area == 0 || area == (r-l+1)*(t-b+1);
}

int solve(int b, int t, int l, int k) {
  if (l < 0) return -2;
  if (l >= m) return m-1;
  if (dp[b][t][l][k] != -3) return dp[b][t][l][k];
  if (k == 0) {
    int lb = l, rb = m-1, ans = -1;
    while (lb <= rb) {
      int mid = (lb+rb)/2;
      if (mono(b, t, l, mid)) {
        ans = mid;
        lb = mid+1;
      } else rb = mid-1;
    }
    return dp[b][t][l][k] = ans;
  }
  int ans = solve(b, t, solve(b, t, l, k-1)+1, k-1);
  if (b < t) {
    int lb = b, rb = t-1, bsplit = t-1;
    while (lb <= rb) {
      int mid = (lb+rb)/2;
      ans = max(ans, min(solve(b, mid, l, k-1), solve(mid+1, t, l, k-1)));
      if (solve(b, mid, l, k-1) >= solve(mid+1, t, l, k-1)) {
        bsplit = mid;
        lb = mid+1;
      } else rb = mid-1;
    }
    ans = max(ans, min(solve(b, bsplit, l, k-1), solve(bsplit+1, t, l, k-1)));
    if (bsplit < t-1) {
      bsplit++;
      ans = max(ans, min(solve(b, bsplit, l, k-1), solve(bsplit+1, t, l, k-1)));
      bsplit--;
    }
    if (bsplit > b) {
      bsplit--;
      ans = max(ans, min(solve(b, bsplit, l, k-1), solve(bsplit+1, t, l, k-1)));
    }
  }
  return dp[b][t][l][k] = ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
  }
  init();
  for (int k = 0; k < L; k++) {
    if (solve(0, n-1, 0, k) >= m-1) {
      cout << k << nl;
      return 0;
    }
  }
  assert(0);
  cout << L << nl;
  return 0;
}


Measured memory_bytes: 214144
from collections import defaultdict
charnums=defaultdict(int)
N=int(input())
for _ in range(N):
    charnums[input()]+=1
ans=[]
m=max(charnums.values())
for key,value in charnums.items():
    if value==m:
        ans.append(key)
for an in sorted(ans):
    print(an)

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

using ll = long long;
using P = pair<int, int>;

const int MAX = 3e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt_w[MAX], cnt_e[MAX];

int main() {
  // 入力
  int n;
  string s;
  cin >> n >> s;

  for (int i = 1; i < n; i++) {
    cnt_w[i] = cnt_w[i-1];
    if (s[i-1] == 'W') cnt_w[i]++;
  }

  for (int i = n - 2; i >= 0; i--) {
    cnt_e[i] = cnt_e[i+1];
    if (s[i+1] == 'E') cnt_e[i]++;
  }

  int ans = MAX;
  for (int i = 0; i < n; i++) {
    ans = min(ans, cnt_w[i] + cnt_e[i]);
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  rep(i,10){
  out(a*c-b);
    c=a*c-b;
  }
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

class UnionFind {
public:
    vector<Int> _par, _siz;

    UnionFind(Int sz) : _par(sz), _siz(sz, 1LL) {
        for (Int i = 0; i < sz; i++) {
            _par[i] = i;
        }
    }

    Int root(Int x) {
        while (_par[x] != x) {
            x = _par[x] = _par[_par[x]];
        }
        return x;
    }

    bool merge(Int x, Int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }

        if (_siz[x] < _siz[y]) {
            swap(x, y);
        }
        _siz[x] += _siz[y];
        _par[y] = x;

        return true;
    }

    bool issame(Int x, Int y) {
        return root(x) == root(y);
    }

    Int size(Int x) {
        return _siz[root(x)];
    }

    ~UnionFind(){};
};

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

    Int n, m;
    cin >> n >> m;
    vector<Int> a(m), b(m);
    for (Int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    UnionFind uf(n);
    vector<Int> ans;
    ans.push_back(n * (n - 1) / 2);
    for (Int i = 0; i < m; i++) {
        if (uf.issame(a[i], b[i])) {
            ans.push_back(ans.back());
        } else {
            Int p = uf.size(a[i]) * uf.size(b[i]);
            ans.push_back(ans.back() - p);
        }

        uf.merge(a[i], b[i]);
    }

    ans.pop_back();
    reverse(ans.begin(), ans.end());
    for (Int i = 0; i < m; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5364
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 10000000000000000LL
using namespace std;

int main()
{
	int n;
  scanf("%d", &n);
  long long int a[100001];
  long long int sum[100001];
  sum[0]=0;
  vector<int> minus;
  for(int i=1; i<=n; i++){
    if(i<=n-1){
      char op;
      scanf("%lld ", &a[i]);
      sum[i]=sum[i-1]+a[i];
      scanf("%c ", &op);
      if(op=='-'){
        minus.push_back(i);
      }
    }else{
      scanf("%lld", &a[i]);
      sum[i]=sum[i-1]+a[i];
    }
  }
  long long int ans=-INF, sum1=sum[n];
  
  int m=minus.size();
  if(m==0){
    printf("%lld\n", sum[n]);
    return 0;
  }
  if(m==1){
    printf("%lld\n", sum[n]-2*a[minus[0]+1]);
    return 0;
  }
  for(int i=0; i<m; i++){
    if(i<m-1){
      long long int s=sum1-2*(sum[minus[i+1]]-sum[minus[i]]);
      if(ans<s) ans=s;
      sum1-=2*a[minus[i]+1];
    }else{
      sum1-=2*a[minus[i]+1];
      if(ans<sum1) ans=sum1;
    }
  }
  printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

vector<int> dp(100001, -1);
vector<int> ar(100);

int solve(int k, int n) {
    if(k < 0)
        return 0;
    if(dp[k] != -1)
        return dp[k];
    int flag = 0;
    for(int i = 0; i < n; i++) {
        if(k >= ar[i])
            flag = 1 - solve(k-ar[i], n);
        if(flag)
            break;
    }
    dp[k] = flag;
    return dp[k];
}

int main() {
    int n, k;
    cin >> n >> k;
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        cin >> ar[i];
        dp[ar[i]] = 1;
    }
    if(solve(k, n))
        cout << "First\n";
    else cout << "Second\n";
}

Measured memory_bytes: 6912
void main() {
    string s = readln.chomp;
    char[] acgt = ['A', 'C', 'G', 'T'];
    int cnt, ans;
    foreach (x; s) {
        if (acgt.canFind(x)) {
            ++cnt;
            ans = max(ans, cnt);
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

using ll=long long;

int main() {
  int N; cin >>N;
  vector<pair<int,int>> p;
  rep(i,0,N) {
    int A,B; cin >>A >>B;
    p.push_back(pair(A,B));
  }
  sort(p.rbegin(),p.rend());
  cout <<p[0].first+p[0].second <<endl;
  return 0;
}


Measured memory_bytes: 4300
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,T;
    cin >> N >> T;
    int mini = INF;
    rep(i,0,N){
        int a,b;
        cin >> a >> b;
        if(T >= b)mini = min(mini, a);
    }
    if(mini == INF)cout << "TLE" << endl;
    else cout << mini << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    ll n, m;
    cin >> n >> m;
    ll ans = (n-2) * (m-2);
    if(ans < 0) ans = -ans;

    cout << ans << endl;

    return 0;
}


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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	vector<int> a;
	int b,c,d;
	cin >> b >> c >> d;
	pb(a,b);
	pb(a,c);
	pb(a,d);
	sort(ben(a));
	if(a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "d.cpp"

int main() {
  ll n;
  cin >> n;
  vl a(n);
  cin >> a;
  ll q;
  cin >> q;
  vl b(q), c(q);
  rep(i, q) {
    cin >> b[i] >> c[i];
  }

  vl cnt(1e5+1);
  ll sum = 0;
  rep(i, n) {
    cnt[a[i]]++;
    sum += a[i];
  }

  rep(i, q) {
    sum -= cnt[b[i]]*b[i];
    sum += cnt[b[i]]*c[i];
    cnt[c[i]] += cnt[b[i]];
    cnt[b[i]] = 0;
    cout << sum << el;
  }
}


Measured memory_bytes: 6364
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

ll H, W, K;
ll sx, sy, gx, gy;
vector<ll> c[1010101];
ll DX[] = {0, 1, 0, -1};
ll DY[] = {1, 0, -1, 0};

int main() {
  cin >> H >> W >> K;
  cin >> sx >> sy >> gx >> gy;
  repe(i, 1, H) {
    string s;
    cin >> s;
    c[i].push_back(-1);
    for (auto e : s) {
      if (e == '@') {
        c[i].push_back(-1);
      } else {
        c[i].push_back(inf);
      }
    }
    c[i].push_back(-1);
  }
  repe(i, 0, W + 1) {
    c[0].push_back(-1);
    c[H + 1].push_back(-1);
  }

  queue<Pll> que;
  que.push(Pll(sx, sy));
  c[sx][sy] = 0;

  while (!que.empty()) {
    auto elem = que.front();
    que.pop();
    ll cx = elem.first;
    ll cy = elem.second;

    rep(i, 0, 4) {
      ll dx = DX[i];
      ll dy = DY[i];

      repe(j, 1, K) {
        ll nx = cx + dx * j;
        ll ny = cy + dy * j;

        // 移動中に蓮にあたった場合
        if (c[nx][ny] == -1) {
          break;
        }
        if (c[nx][ny] != inf) {
          if (c[nx][ny] <= c[cx][cy]) {
            break;
          }
          continue;
        }

        c[nx][ny] = c[cx][cy] + 1;
        que.push(Pll(nx, ny));
      }
    }
  }

  if (c[gx][gy] == inf) {
    cout << -1;
    return 0;
  }

  cout << c[gx][gy];
}


Measured memory_bytes: 56148
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        System.out.println(solve(A, B, C));
    }
    public static int solve(int A, int B, int C) {
        return Math.min(B / A, C);
    }
}


Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0 && N > 1) {
      cout << -1 << endl;
      return 0;
    }
    auto it = m.find(s);
    if (it != m.end() && it->second != c) {
      cout << -1 << endl;
      return 0;
    }
    m[s] = c;
  }

  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      for (int z = 0; z <= 9; z++) {
        const int n = 100 * x + 10 * y + z;
        if (N == 3 && n <= 99) continue;
        if (N == 2 && (n < 10 || n >= 100)) continue;
        if (N == 1 && (n >= 10)) continue;
        const auto str = to_string(n);
        auto pred = [&str](pair<const int, int>& p) {
          return str[p.first - 1] == p.second + '0';
        };
        if (all_of(m.begin(), m.end(), pred)) {
          cout << n << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256