akhauriyash/Code-Regression huggingface dataset:
# include<cstdio>
# include<iostream>
# include<algorithm>
# include<cmath>
# include<cstring>
# include<string>
using namespace std;
typedef long long ll;
ll a[101000],b[101000];
bool cmp(ll a,ll b){
    return a>b;
}

int main()
{
    int n;
    ll h;
    cin>>n>>h;
    ll ma=-1;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
        ma=max(a[i],ma);
    }
    sort(b+1,b+n+1,cmp);
    int ans=0;
    for(int i=1;;i++){
        if(i>n) i=n+1;
        if(h<=0) break;
        if(b[i]>ma){
            h-=b[i];
            ans++;
        }
        else{
            int t=h/ma;
            ans+=t;
            h-=ma*t;
            if(h==0) break;
            else{
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int a,b,c;

int main() {
  cin >> a >> b >> c;
  if(a%2==1&&b%2==1&&c%2==1)
  cout << 0 << endl;
  else if(a==b&&c==a)
  cout << -1 << endl;
  else {
    int ans=0;
    while(a%2==0&&b%2==0&&c%2==0){
      int x=a/2,y=b/2,z=c/2;
      a=y+z,b=z+x,c=z+y;
      ans++;
    }
    cout << ans << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;
int main(){

  ll k;cin>>k;
  string s;cin>>s;

  if(s.size()>k){
    string t="";
    rep(i,0,k)t+=s[i];
    out(t+"...");
  }else out(s);


  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
public class Main {
    public static void main (String args []){
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        String S = sc.next();
        int sum = 0;
        for(int i=0;i<N-2;){
            if(S.charAt(i)=='A'&&S.charAt(i+1)=='B'&&S.charAt(i+2)=='C'){
                sum++;
                i+=3;
            }
            else i++;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000001
#define VMAX 10000

int partition(int *,int ,int );

int main(){
unsigned short *B;
 int i,j,k,n,p=0,q;
 int A[MAX];
int C[VMAX+1];
k=VMAX;
  scanf("%d",&n);

  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

    
    q=partition(A, p, n);
 
  for(i=0;i<n-1;i++){
    if(i==q) printf("[%d] ",A[i]);
    else
      printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);

  return 0;
}

int partition(int A[], int p, int r)
{
  int x,i,f,j;
  x = A[r-1];
  i = p-1;
  for (j = p; j<r-1;j++){
    if (A[j] <= x){
      i = i+1;

      /*A[i] と A[j] を交換*/
      f=A[j];
      A[j]=A[i];
      A[i]=f;
    }
  }
  /*A[i+1] と A[r] を交換*/
        f=A[r-1];
	A[r-1]=A[i+1];
	A[i+1]=f;
	return i+1;
}



Measured memory_bytes: 2144
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>

using namespace std;

int a[100];

int top = 0;

void push(int x){
  top++;
  a[top] = x;
}

int pop(){
  top--;
  return a[top + 1];
}

int main(){

  char s[1000000];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      int y = pop() + pop();
      push(y);
    }
    else if(s[0] == '-'){
      int a = pop();
      int b = pop();
      push(b - a);
    }
    else if(s[0] == '*'){
      int y = pop() * pop();
      push(y);
    }
    else{
      int x = 0;
      int y = 1;
      for(int i = strlen(s) - 1; i >= 0; i--){
        x += (s[i] - '0') * y;
        y = y * 10;
      }
      push(x);
    }

  }

  cout << a[1] << endl;



  return 0;

}



Measured memory_bytes: 3248
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = [105,135,165,189,195]

if a[0] > n: print(0)
elif a[0] <= n < a[1]: print(1)
elif a[1] <= n < a[2]: print(2)
elif a[2] <= n < a[3]: print(3)
elif a[3] <= n < a[4]: print(4)
elif a[4] <= n: print(5)

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  int sum = a+b+c;
  string ans = sum >=22 ? "bust" : "win";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	string s, t;
	
	cin>>s;
	cin>>t;
	int ans = 0;
	if (s[0] == t[0]) {
		ans += 1;
	}
	if (s[1] == t[1]) {
		ans += 1;
	}
	if (s[2] == t[2]) {
		ans += 1;
	}
	

	cout<< ans;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対グラフ

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

int main(){
    int a,b,c;
    cin >> a>>b>>c;
    cout<< (c/a)*b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n=0;
	cin>>n;
if(n==2){
	int a=0;
	int b=0;
	int c=0;
	cin>>a>>b;
	for(;;){	
		c++;
		if(a%c==0&&b%c==0){
			cout<<c<<endl;
		}
		if(c==a || c==b){
		break;
		}
	}
}
if(n==3){
	int a=0;
	int b=0;
	int c=0;
	int d=0;
	cin>>a>>b>>c;
	for(;;){
		d++;
		if(a%d==0&&b%d==0&&c%d==0){
			cout<<d<<endl;
		}
		if(a==d||b==d||c==d){
			break;
		}
	}
}
return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin >> N;
    int x[N], y[N];
    rep(i, 0, N) cin >> x[i];
    memcpy(y, x, sizeof(int) * N);
    sort(&y[0], &y[N]);
    rep(i, 0, N)
    {
        if (x[i] >= y[N / 2])
            printf("%d\n", y[N / 2 - 1]);
        else
        {
            printf("%d\n", y[N / 2]);
        }
    }
}
int main()
{
    func();
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    int N,K;
    cin >> N >> K;
    vi a(N);
    in(N,a);
    
    ve<bool> dp(K+1,false);
    
    rep(i,K+1){

        bool f = false;
        rep(j,N){
            if(i-a[j] >= 0){
                if(!dp[i-a[j]]) f = true;
            }
        }
        if(f) dp[i] = true;
        
    }

    //outve(dp);
    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
c1, c2, c3 = 0, 0, 0
for i in range(n):
    s = input()
    ans += s.count('AB')
    l = len(s)
    if (s[0] == 'B') & (s[l - 1] == 'A'):
        c3 += 1
    elif s[0] == 'B':
        c1 += 1
    elif s[l - 1] == 'A':
        c2 += 1
if (c1 == 0) & (c2 == 0):
    ans += max(0, c3 - 1)
else:
    ans += min(c1, c2) + c3
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

int w,h;
char a[1005][1005];
int dp[1005][1005];

int solve(int i,int j){
    if(i==(h-1)and j==(w-1))
        return 1;
    if(i>=h or j>=w)
        return 0;
    int &ret=dp[i][j];
    if(~ret)return ret;
    ret=0;
    if((i+1)<h and a[i+1][j]!='#'){
        ret+=solve(i+1,j)%mod;
    }
    if((j+1)<w and a[i][j+1]!='#'){
        ret+=solve(i,j+1)%mod;
    }
    return ret%mod;
}


int main(){
    cin>>h>>w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0)<<endl;

    return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B;
    }else if((A <= 12) && (A >= 6)){
        cout << B/2;
    }else{
        cout << 0;
    }
    return 0;
};


Measured memory_bytes: 256
def root(x):
    path_to_root = []
    while x != P[x]:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node]=x
    return x

def unite(x,y):
    P[root(x)] = root(y)

def is_same_set(x,y):
    return root(x) == root(y)

n = int(input())
P = [i for i in range(n)]
length=[]
points=[]
for i in range(n):
    length.append(list(map(int,input().split())))
for i in range(n):
    for j in range(i,n):
        if length[i][j] != -1:
            points.append((i,j,length[i][j]))
	
points.sort(key=lambda x:x[2])

totalweight = 0
for p in points:
    i,j,w = p
    if not is_same_set(i,j):
       totalweight += w
       unite(i,j)

print(totalweight)


Measured memory_bytes: 6252
# -*- coding: utf-8 -*-
"""
Created on Thu May  3 22:47:34 2018
ALDS1_6_A
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n+1)]

def counting_sort(a, b, k):
    c = [0 for _ in range(k+1)]
    
    for aj in a:
        c[aj] += 1
    
    for i in range(1, k+1):
        c[i] += c[i-1]
        
    for j in reversed(range(n)):
        #print(j, a[j], c[a[j]])
        b[c[a[j]]] = a[j]
        c[a[j]] -= 1
    
k = max(a)    
counting_sort(a, b, k)
print(b[1],end='')
for i in range(2,n+1):
    print(' {}'.format(b[i]), end='')
print()


Measured memory_bytes: 224396
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int):
    res = A*B if A*B > C*D else C*D
    print(res)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
─────────▄▄▄▄▄▄▄▄▄▄▄▄─────────
─────▄▄▀▀░░░░░░░░░░░░▀▀▄▄─────
───▄▀░░░░░░░░░░░░░░░░░░░░▀▄───
──█░░░░░▄▄▄▄▄░░░░▄▄▄▄▄░░░░░█──
─█░░░░░██░█░██▄▄██░█░██░░░░░█─
█░░░░░░░▀▀▀▀▀░░░░▀▀▀▀▀░░░░░░░█
█░░░░▄▄▄░░░░░░░░░░░░░░▄▄▄░░░░█
█░░░░██▀█▄▄▄▄▄▄▄▄▄▄▄▄██▀█░░░░█
─█░░░▀██▄████████▄▄▄▄██▄▀░░░█─
──█░░░░▀██▀▀▀▀████████▀░░░░█──
───▀▄░░░░▀▄▄▄▄██████▀░░░░▄▀───
─────▀▀▄▄░░░░░░░░░░░░▄▄▀▀─────
─────────▀▀▀▀▀▀▀▀▀▀▀▀─────────
*/
#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;
	double ans = 0;
	cout << fixed << setprecision(10);
	for (int i = 0; i < n; ++i) {
		double x;
		cin >> x;
		ans += 1 / x;
	}
	cout << 1 / ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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(){
  cout << fixed << setprecision(15);

  int a, b, c; cin >> a >> b >> c;

  //ll ans = 0;
  string ans;

  if (a + b + c >= 22) ans = "bust";
  else ans = "win";

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

Measured memory_bytes: 256
//abc114_b.cpp
//Sun Dec  2 20:52:38 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = INTINF;
	for (int i=0;i<s.length()-2;i++){
		string temp = s.substr(i,3);
		int num = atoi(temp.c_str());
		if (abs(num-753) < ans){
			ans = abs(num-753);
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define debug(var) do{cout << #var << " : "; print(var); } while(0)
using namespace std;
typedef long long ll;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }
const int INF = 1e9;
const int MOD = 1e9+7;

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

	while (true) {
		int n; cin >> n;
		if (!n) break;

		vector<int> vec(n);
		rep(i, n) cin >> vec[i];
		sort(all(vec));

		int ans = INF;
		rep(i, n-1) ans = min(ans, vec[i+1]-vec[i]);

		cout << ans << endl;
	}
}


Measured memory_bytes: 3196
#include<iostream>
#include<string>

using namespace std;


int main() {
	long long a=1,mod=1000*1000*1000+7, n,i;

	cin >> n;
	for (i = 1; i <= n; i++) {
		a *= i;
		a %= mod;
	}

	cout << a << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long n,m;
	cin >> n >> m;
	long long a;
	for(int i = 1;i <= m;i++)cin >> a,n-=a;
	if(n < 0)cout << -1; else cout << n;
	return 0;
}
 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    map<char, int> m;
    m['R'] = 0;
    m['G'] = 1;
    m['B'] = 2;

    vector<vector<int>> c(3, vector<int>(n+1));
    rep(i, n){
        c[m[s[i]]][i+1]++; 
        rep(j, 3) c[j][i+1] += c[j][i];
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(s[i] == s[j]) continue;
            rep(k, 3){
                if(m[s[i]] != k && m[s[j]] != k){
                    ans += c[k][n] - c[k][j];
                    int dist = j-i;
                    if(j+dist < n && m[s[j+dist]] == k) ans--;
                } 
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
#define sign(a) ((a>0)-(a<0))
#define LL long long
#define INF (LL)(1LL<<60)

void solve(long long N, std::vector<long long> p){
    LL ans=0, i=0;
    while(i<N){
        if(p[i]==i+1){
            ans++;
            if(i+1<N && p[i+1]==i+2)
                i+=2;
            else
                i++;
        }else
            i++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iostream>
#include <vector> 
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<int> state(n);

    for(int i = 1; i < n; i++){
        vector<int> ans(0);
        int st = max(0,i-k);
        int hi = h[i];
        for(int j = st; j < i; j++){
            ans.push_back(state[j] + abs(hi-h[j]));
        }
        
        state[i] = *min_element(ans.begin(),ans.end());
    }
    cout << state.back() << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n;
    cin >> n;
    int in;
    VI p(n + 1, 0);
    FOR(i, 0, n){
        cin >> in;
        p[in] = p[--in] + 1;
    }
    int ans = 0;
    eFOR(i, 0, n)chmax(ans, p[i]);
    cout << n - ans << "\n";
}


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

const long M = 1046527;
const long NIL = -1;
const long L = 14;

string H[M];

long getChar(char ch){
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(string str){
	long long sum = 0, p = 1, i;
	for (long i = 0; i < str.size(); i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

long h1(long key){return key % M;}
long h2(long key){return 1 + (key % (M - 1));}

long find(string str){
	long long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0) return 0;
	}
	return 0;
}

long insert(string str){
	long long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0){
			H[h] = str;
			return 0;
		}
	}
	//return 0;
}

int main(){
	long n, h;
	string str, com(9, 'a');
	cin >> n;
	for (long i = 0; i < n; i++){
		cin >> com >> str;
		if (com[0] == 'i') insert(str);
		else {
			if (find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25880
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
static const long long INF = 100000000;
int main(){
    int n,k;
    cin >> n >> k;
    vector<long long> monster(n);
    rep(i,n){
        cin >> monster[i];
    }
    sort(monster.begin(),monster.end());
    long long ans;
    ans = 0;
    int x = n-k;
    if (x < 1){
        cout << 0 << endl;
        return 0;
    }
    else{
        rep(i,x){
            ans += monster[i];
        }
        cout << ans << endl;
        return 0;
    }
}

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

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
    lli x,a,b;
    cin >> x >> a >> b;
    x -= a;
    cout << (x % b) << endl;
	return 0;
}










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

#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

// 4
// 5 6 8 10

bool isAllEven(int size, int* array) {
  for(int i = 0; i < size; i++)
    if (array[i] % 2 != 0)
      return false;

  return true;
}

void divide2All(int size, int* array) {
  for(int i = 0; i < size; i++)
    array[i] = array[i] / 2;

  return;
}


int main() {
  int size, out = 0;
  cin >> size;
  int* array = new int[size];

  for(int i = 0; i < size; i++)
    cin >> array[i];

  while(isAllEven(size, array)) {
    out++;
    divide2All(size, array);
  }

  cout << out << endl;
}


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

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

    ll ans = 0;
    int index = 0;
    bool flag = true;
    for(int i=0; i<m; i++){
        if(flag){
            int count = 0;
            for(int j=index; j<index+cb[i].second; j++){
                if(a[j] >= cb[i].first){
                    flag = false;
                    break;
                }
                count++;
                a[j] = cb[i].first;
            }
            index += count;
        }else{
            break;
        }
    }

    for(int i=0; i<n; i++){
        ans += a[i];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 2560
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    IO;
    ll k;
    cin>>k;
    if(k%2==0||k%5==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll sum=0,len=1,p=1;
    while(true)
    {
        sum=(sum+7*p)%k;
        if(sum==0) 
        {
            cout<<len<<endl;
            break;
        }
        len++;
        p=p*10%k;
    }
    return 0;
}


Measured memory_bytes: 3664
B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

inv_t = [0]+[1]
inv_2 = [0]+[magick]
for i in range(2,B+W+1):
  inv_t += [inv_t[Mod % i] * (Mod - int(Mod / i)) % Mod]
  inv_2 += [inv_2[-1]*magick % Mod]

consts_B, consts_W = [0]*(B-1)+ [1], [0]*(W-1)+[1]
for i in range(B+W):
  if i >= B: consts_B += [consts_B[-1]*(i)*inv_t[i-B+1]%Mod]
  if i >= W: consts_W += [consts_W[-1]*(i)*inv_t[i-W+1]%Mod]

p, q = 0, 0
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  p += consts_B[i]*inv_2[i+1]
  q += consts_W[i]*inv_2[i+1]

Measured memory_bytes: 30528
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
using vec = vector<vector<vector<vector<int>>>>;


int main(){
  in n,k,s;
  cin>>n>>k>>s;
  
  if(s==1000000000ll){
   rep(i,k){
    cout<<s<<" ";
  }
  for(in i=k;i<n;i++){
    cout<<1<<"  ";
  }
    return 0;
  }
  
  rep(i,k){
    cout<<s<<" ";
  }
  for(int i=k;i<n;i++){
    cout<<s+1<<"  ";
  }
  
}


Measured memory_bytes: 1280
import java.util.*;
public class Main{
  public static long[] memo;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] h = new int[N];
    memo = new long[N];
    Arrays.fill(memo, -1L);
    for(int i = 0; i < N; i++){
      h[i] = sc.nextInt();
    }
    System.out.println(solve(h));
  }
  
  public static long saiki(int[] array, int index, int lastIndex){
    if(index >= array.length){
      return 1000000000;
    }
    if(index == array.length-1){
      return Math.abs(array[index] - array[lastIndex]);
    }
    if(memo[index] != -1){
      return memo[index] + Math.abs(array[index] - array[lastIndex]);
    }
    
    long tmp = Math.abs(array[index] - array[lastIndex]);
    long min = Math.min(saiki(array, index+1, index), saiki(array, index+2, index));
    memo[index] = min;
    return tmp + min;
  }
  
  public static long solve(int[] array){
    return Math.min(saiki(array, 1, 0), saiki(array, 2, 0));
  }
}

Measured memory_bytes: 70484
import java.io.* ;
import java.lang.reflect.Array;
import java.util.* ;
import java.math.* ;
public class Main
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input)
    {
        reader = new BufferedReader(new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException
    {
        while (!tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static long nextInt() throws IOException
    {
        return Long.parseLong(next());
    }

    public static int ri() throws IOException
    {
        return (int) nextInt();
    }

    public static long rl() throws IOException
    {
        return nextInt();
    }

    public static double rd() throws NumberFormatException, IOException
    {
        return Double.parseDouble(next());
    }

    static void print_a(int[] arr)
    {
        for (int i = 0; i < arr.length; i++)
        {
            print(arr[i] + " ");
        }
        println();
    }

    public static int[] ria(int n) throws IOException
    {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = ri();
        }
        return a;
    }

    public static long[] rla(int n) throws IOException
    {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = rl();
        }
        return a;
    }

    public static int p(int i)
    {
        return (int) Math.pow(2, i);
    }

    static PrintWriter writer;

    static void outit(OutputStream outputStream)
    {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    static void print(Object... objects)
    {
        for (int i = 0; i < objects.length; i++)
        {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    static void println(Object... objects)
    {
        print(objects);
        writer.println();
    }

    static void close()
    {
        writer.close();
    }

    static void flush()
    {
        writer.flush();
    }

    public static void main(String[] args) throws IOException
    {
        init(System.in);
        outit(System.out);
//        int t = (int) nextInt();
//        for (int i = 0; i < t; i++)
        output();
        flush();
        close();
    }
    static ArrayList<Integer> [] ar;
    static ArrayList<Integer> [] fg ;
    static long [][] cost ;
    static boolean [] visited ;
    public static void output() throws IOException
    {
        int r = ri() ;
        int g = ri() ;
        int b = ri() ;
        int no = 100*r+10*g+b ;
        if(no%4==0)
        {
            println("YES") ;
        }
        else
        {
            println("NO") ;
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll a,b,c,k;cin>>a>>b>>c>>k;
        ll ans=0;
        if(k>=a){
        	ans+=a;
        	k=k-a;
        	if(k>=b){
        		k=k-b;
        		ans+=(-k);
        	}
        }
        else{
        	ans+=k;
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3648
n,l = map(int,input().split())
if l<=0 and 0<=l+n-1:
    print(n*l+n*(n-1)//2)
elif 0<=l:
    print(n*l+n*(n-1)//2-l)
else:
    print(n*l+n*(n-1)//2-l-n+1)

Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

bool check(int x){
  for(int i = 1; i * i <= x; i++){
    if(i * i == x) return true;
  }

  return false;
}

int main(){
  int N, D;
  cin >> N >> D;
  int x[N][D];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> x[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      int A = 0;
      for(int k = 0; k < D; k++){
        A += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }

      if(check(A)) ans++;
    }
  }

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


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

int main() {
    for(int H, W; cin >> H >> W, !(H == 0 && W == 0);) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H-1 || j == 0 || j == W-1)
                    cout << '#';
                else
                    cout << '.';
            }
            cout << '\n';
        }
        cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
enum Char{A,C,G,T};
long N,memo[111][6][6][6][6],mod=1e9+7;
// b3は3文字前,b2は2文字前,b1は1文字前
long rec(int now,int b3,int b2,int b1,int b){
  // printf("%d %d %d %d %d\n",now,b3,b2,b1,b);
  if(memo[now][b3][b2][b1][b]!=-1)return memo[now][b3][b2][b1][b];
  if(b3==A&&b2==G&&b==C)return 0;// AG?Cの場合
  if(b3==A&&b1==G&&b==C)return 0;// A?GCの場合
  if(b2==A&&b1==G&&b==C)return 0;// ?AGCの場合
  if(b2==A&&b1==C&&b==G)return 0;// ?ACGの場合
  if(b2==G&&b1==A&&b==C)return 0;// ?GACの場合
  if(now==N)return 1;
  long ans=0;
  for(int i=0;i<4;i++)ans+=rec(now+1,b2,b1,b,i);
  return memo[now][b3][b2][b1][b]=ans%mod;
}
int main(){
  cin>>N;
  memset(memo,-1,sizeof(memo));
  cout<<rec(0,T,T,T,T)<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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 gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,a;
  cin >> N;
  int x=0,y=0,z=0;
  rep(i,N){
    cin >> a;
    if(a%4==0) y++;
    else if(a%2==0) z++;
    else x++;
  }
  if(z==0){
    if(x<=y+1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(x<=y) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V l(n);rep(i,n)cin>>l[i];
    sort(RALL(l));
    int sum=0;
    for(int i=1;i<n;i++){
        sum+=l[i];
    }
    if(l[0]<sum){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}




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

a = [arr[i] for i in range(0,n,2)]
b = [arr[y] for y in range(1,n,2)]

import collections
acnt = collections.Counter(a)
bcnt = collections.Counter(b)

lsacnt = sorted(acnt.items(), key=lambda x: x[1],reverse=True)
lsbcnt = sorted(bcnt.items(), key=lambda j: j[1],reverse=True)

def val(abcnt, ablscnt):
	if len(list(abcnt)) < 2:
		return 0
	else:
		return ablscnt[1][1]

if lsacnt[0][0] != lsbcnt[0][0]:
	ans = n - lsacnt[0][1] - lsbcnt[0][1]
elif lsacnt[0][0] == lsbcnt[0][0]:
	if lsacnt[0][1] > lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - val(bcnt,lsbcnt)
	elif lsacnt[0][1] < lsbcnt[0][1]:
		ans = n - val(acnt,lsacnt) - lsbcnt[0][1]
	elif lsacnt[0][1] == lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - max(val(acnt,lsacnt),val(bcnt,lsbcnt))

print(ans)

Measured memory_bytes: 21776
let cnt = ref 0

let bubble_sort a n =
  let rec bubble i flag =
    if i = 0 then doit flag
    else if a.(i-1) <= a.(i) then bubble (i - 1) flag
    else (let tmp = a.(i) in a.(i) <- a.(i-1); a.(i-1) <- tmp; incr cnt; bubble (i - 1) true)
  and doit flag =
    if flag then bubble (n - 1) false
  in doit true

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  bubble_sort a n;
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 2344
#include<bits/stdc++.h>
using namespace std;
int main(){

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

int n,t,cnt=0;
int a[100010],b[100010];
cin>>n>>t;
for(int i=0; i<n; i++){
    cin>>a[i];
    cin>>b[i];
    if(b[i]>t){
        cnt++;
        a[i]=0;
    }
}
sort(a,a+n);
if(cnt==n){
    cout<<"TLE"<<'\n';
}else{
    cout<<a[cnt]<<'\n';
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
int t[5][5];
ll h,a,b,c,d,e;
int ans = 1;
bool memo[15][15] = {0};
int main(){
  ll n,k; cin >> n >> k;
  map<ll,ll> ma;
  for(int i=0 ; i<n ; i++){
    ll x; cin >> x;
    ma[x]++;
  }
  vector<ll> v;
  for(auto ite=begin(ma); ite!=end(ma); ite++){
    v.push_back(ite->second);
  }
  sort(v.begin(),v.end());
  ll ct = v.size();
  ll ans = 0;
  for(int i=0 ; i<=ct-k-1 ; i++){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14964
#include<bits/stdc++.h>
using namespace std;
int n,ans,A[30];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",&A[i]);
	for(int i=2; i<n; i++)
		if(A[i]==A[i-1]||A[i]==A[i+1]||((A[i]>A[i+1])^(A[i]>A[i-1])))ans++;

	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
s = input()
List = [['S','S'], ['S','W'], ['W','S'], ['W','W']]
for i in range(4):
    ans = List[i]
    for i in range(1,N):
        if i != N-1:
            if (ans[i-1] == ans[i] and s[i] == 'o') or (ans[i-1] != ans[i] and s[i] == 'x'):
                ans.append('S')
            else:
                ans.append('W')
        else:
            if ((((ans[N-1] == 'S' and s[N-1] == 'o') or (ans[N-1] == 'W' and s[N-1] == 'x')) and (ans[N-2] == ans[0])) or (((ans[N-1] == 'S' and s[N-1] == 'x') or (ans[N-1] == 'W' and s[N-1] == 'o')) and (ans[N-2] != ans[0]))) and ((((ans[0] == 'S' and s[0] == 'o') or (ans[0] == 'W' and s[0] == 'x')) and (ans[N-1] == ans[1])) or (((ans[0] == 'S' and s[0] == 'x') or (ans[0] == 'W' and s[0] == 'o')) and (ans[N-1] != ans[1]))):
                print(''.join(ans))
                sys.exit()
print(-1)

Measured memory_bytes: 6648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
int main () {
	int a, b;
	scanf ("%d%d", &a, &b);
	if (a > 9 || b > 9) printf ("-1");
	else printf ("%d\n", a * b);
	return 0;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int val;
	int num;
	char tmp;
	int sum = 0;
	double average_num = 0;
	int counter = 0;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	while(ifs >> val >> tmp >> num){
#else
	while(std::cin >> val >> tmp >> num){
#endif
		sum += val * num;
		average_num += num;
		counter++;
	}
	
	average_num = std::round(average_num / counter);

	std::cout << sum << std::endl;
	std::cout << average_num << std::endl;
	return 0;
}



Measured memory_bytes: 3340
import itertools

a = int(input())
b = int(input())
c = int(input())
x = int(input())
y = x//50

p = 0

list_s = list(range(a+1))
list_t = list(range(b+1))
list_u = list(range(c+1))

for s,t,u in itertools.product(list_s,list_t,list_u):
    m = 10*s + 2*t + u
    if m == y:
        p += 1

print(p)

Measured memory_bytes: 8872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++);
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}
map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	int k, x;
	cin >> k >> x;
	if (500 * k < x) cout << "No";
	else cout << "Yes";
	return 0;
}









Measured memory_bytes: 256
# include <iostream>
using namespace std;
int N, ans[100010];

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int a; cin >> a;
    ans[a] = i;
  }
  
  for (int i = 1; i < N; i++) cout << ans[i] << " ";
  cout << ans[N] << endl;
  
  return 0;
}

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

int ans[100010],N,a;

int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>a;
		ans[a] = i;
	}
	for(int i=1;i<=N;i++) cout<<ans[i]<<" ";
	return 0;
} 

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll res1 = 0, res2 = 0;
    ll sum = 0;
    rep(i, n){
        if (i % 2 == 0 && sum + a[i] <= 0){
            res1 += abs(sum + a[i]) + 1;
            sum = 1;
        }else if (i % 2 == 1 && sum + a[i] >= 0){
            res1 += abs(sum + a[i]) + 1;
            sum = -1;
        }else{
            sum += a[i];
        }
    }
    sum = 0;
    rep(i, n){
        if (i % 2 == 0 && sum + a[i] >= 0){
            res2 += abs(sum + a[i]) + 1;
            sum = -1;
        }else if (i % 2 == 1 && sum + a[i] <= 0){
            res2 += abs(sum + a[i]) + 1;
            sum = 1;
        }else{
            sum += a[i];
        }
    }
    cout << min(res1, res2) << endl;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> a(N);
    Rep (i, N) cin >> a[i];
    // cout << a.size() << endl;
    // Rep (i, 3) cout << a[i] << " ";
    // cout << endl;
    map<ll, ll> bugget;
    for (auto e : a) {
        bugget[e]++;
    }

    vector<ll> buggetv, num;
    for (auto e : bugget) {
        buggetv.push_back(e.second);
        num.push_back(e.first);
    }

    // for (auto e : num) cout << e << " "; cout << endl;
    // for (auto e : buggetv) cout << e << " "; cout << endl;
    // cout << (num[0] ^ num[1] ^ num[2]) << endl;

    // cout << bugget.size() << endl;
    if (buggetv.size() > 3) cout << "No" << endl;
    else if (buggetv.size() == 3) {
        if (buggetv[0] == buggetv[1] && buggetv[1] == buggetv[2] && (num[0] ^ num[1] ^ num[2]) == 0) {
            cout << "Yes" << endl;
        } else cout << "No" << endl;
    }
    else if (buggetv.size() == 2) {
        if (buggetv[0] > buggetv[1]) {
            reverse(buggetv.begin(), buggetv.end());
            reverse(num.begin(), num.end());
        }
        if (buggetv[0] * 2 == buggetv[1] && num[0] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if (num[0] == 0) {
            cout << "Yes" << endl;
        } else cout << "No" << endl;
    }
}

Measured memory_bytes: 7412
using System;

namespace BeginnerContest_100_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] hoge = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(hoge[i]);
            }
            int cnt = 0;
            for(int j = 0; j < n; j++)
            {
                while (a[j] % 2 == 0)
                {
                    a[j] /= 2;
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13920