akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    int table[101][101] = {0};
    int row, col;

    cin >> row >> col;
    for (int i = 0; i < row; i++)
    {
        for (int j = 0; j < col; j++)
        {
            cin >> table[i][j];
            table[i][col] += table[i][j];
            table[row][j] += table[i][j];
        }
        table[row][col] += table[i][col];
    }

    for (int i = 0; i < row + 1; i++)
    {
        for (int j = 0; j < col; j++)
        {
            cout << table[i][j] << " ";
        }
        cout << table[i][col] << endl;
    }

    return 0;
}

Measured memory_bytes: 3116
n = int(input())
ans = float('INF')
hand = []
tmp = 1
while tmp * 6 <= n:
    tmp *= 6
    hand.append(tmp)
tmp = 1
while tmp * 9 <= n:
    tmp *= 9
    hand.append(tmp)
 
hand.sort()
hand = hand[::-1]
dp = [i for i in range(n+1)]
for v in hand:
    for i in range(n+1-v):
        if dp[i] + 1 < dp[i+v]:
            dp[i+v] = dp[i] + 1
print(dp[n])


Measured memory_bytes: 44784
n, h =  map(int, input().split())
A = [0]*n
B = [0]*n 
for i in range(n):
  A[i], B[i] = map(int, input().split())
A.sort(reverse=True)
B.sort(reverse=True)

c = 0
for j in range(n):
  if B[j] >= A[0]:
    c += 1
    h -= B[j]
    if h <= 0:
      print(c)
      exit()
  else:
    break
if h%A[0] == 0:
  c += h//A[0]
else:
  c += h//A[0]+1
print(c)



Measured memory_bytes: 51288
#include<bits/stdc++.h>
using namespace std;
int head[100001],to[100001],nxt[100001],f[100001],degree[100001]={0},tot=0,n,m;
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int i)
{
	if(head[i]==0)
	{
		f[i]=0;
		return f[i];
	}
	if(f[i]>=0)
		return f[i];
	int k,v;
	for(k=head[i];k;k=nxt[k])
	{
		v=to[k];
		f[i]=max(f[i],dfs(v)+1);
	}
	//return f[i];
}
int main()
{
	int i,u,v,maxv=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	memset(f,0xff,sizeof(f));
	for(i=1;i<=n;i++)
		if(degree[i]==0)
			dfs(i);
	for(i=1;i<=n;i++)
		maxv=max(maxv,f[i]);
	printf("%d",maxv);
	return 0;
}

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

#define _LL long long
 
int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}
int *_p;
 
int main()
{
    int n;
    cin >> n;
    int *a = mallocint(n);
    int *l = mallocint(n);
    int *r = mallocint(n);
 
    for( int i = 0; i < n; i++ ) 
    {
        cin >> a[i];
        l[i] = a[i] + i;
        r[i] = -a[i] + i;
    }
 
    _p = l;
    sort(l, l + n);
    sort(r, r + n);

    
    int i = 0;
    int j = 0;
    _LL ans = 0;
    do
    {
        if( l[i] == r[j] )
        {
            _LL lcount = 1;
            while(i + lcount < n && l[i] == l[i + lcount] ) lcount++;
            _LL rcount = 1;
            while(j + rcount < n && r[j] == r[j + rcount] ) rcount++;
            ans += lcount * rcount;
            
            i += lcount;
            j += rcount; 
        }
        else
        {
            if( l[i] < r[j] )
            {
                i++;
            }
            else
            {
                j++;
            }
        }
        /* code */
    } while (i < n && j < n);
    cout << ans;
}

Measured memory_bytes: 5936
/**
 *    author:   K.R.Surrya  
 *    created:  10/05/2020 17:31:08
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() { 
    string one;
    cin >> one;
    string two;
    cin >> two;
    string chk=two.substr(0,one.size());
    if(chk.compare(one)==0) {
        cout << "Yes" << '\n';
    }else { 
        cout << "No" << '\n';
    }
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


     auto start = chrono::high_resolution_clock::now();
     solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>

using namespace std;

struct Union_find{
	vector<int> par;
	Union_find(int p){
		par = vector<int>(p + 1);
		for(int i = 1; i <= p; i++){
			par[i] = i;
		}
	}
	int find(int x){
		if(par[x] == x)
			return x;
		else{
			return par[x] = find(par[x]);
		}
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		par[y] = x;
	}
	bool solve(int x, int y){
		return (find(x) == find(y));
	}
};

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    Union_find t(n);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        t.unite(x, y);
    }
    for(int i = 0; i < n; i++){
        if(t.solve(i + 1, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<cstdio>
using namespace std;
vector<int>X[100003]; bool COLOR[100003];int N, M, Q1, A, B;
pair<int, int> R[100003]; vector<pair<int, int>>S[100003]; int T[100003];
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) { scanf("%d%d", &A, &B); X[A].push_back(B); }
	cin >> Q1;
	for (int i = 0; i < Q1; i++) {
		scanf("%d%d", &R[i].first, &R[i].second);
		S[R[i].first].push_back(make_pair(R[i].second, i));
		S[R[i].second].push_back(make_pair(R[i].first, i));
	}
	for (int i = 0; i < N; i++) {
		if (S[i].size() >= 1) {
			queue<int>Q;
			Q.push(i);
			for (int i = 0; i < N; i++) { COLOR[i] = false; }
			COLOR[i] = true;
			while (!Q.empty())
			{
				int B = Q.front(); Q.pop();
				for (int j = 0; j < X[B].size(); j++) {
					if (COLOR[X[B][j]] == false) {
						COLOR[X[B][j]] = true;
						Q.push(X[B][j]);
					}
				}
			}
			for (int j = 0; j < S[i].size(); j++) {
				int a1 = S[i][j].first, a2 = S[i][j].second;
				if (COLOR[a1] == 1) { T[a2]++; }
			}
		}
	}
	for (int i = 0; i < Q1; i++) {
		if (T[i] == 2) { printf("1\n"); }
		else { printf("0\n"); }
	}
	return 0;
}

Measured memory_bytes: 11720
#include <cstdio>
#include <map>
typedef long long ll; 
inline ll quick_pow(ll a, ll n, ll mod)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % mod; 
		a = a * a % mod;
		n >>= 1; 
	}
	return res; 
}
struct data
{
	ll arr[5]; 
	inline ll &operator [](const int &x)
	{
		return arr[x]; 
	}
	inline const ll &operator [](const int &x) const
	{
		return arr[x]; 
	}
	inline bool operator <(const data &x) const
	{
		for (int i = 0; i < 5; i++)
		{
			if (arr[i] != x[i])
				return arr[i] < x[i]; 
		}
		return false; 
	}
} hsh[300005], cur; 
std::map<data, int> app; 
const ll bs[] = {1234567, 500003, 500007, 800001, 19260817};
const ll md[] = {998244353, 1000000007, 1000000009, 998244353, 1234567891}; 
int idx[300005]; 
char str[300005]; 
ll pw[5][600005], inv[5][600005]; 
int main()
{
	// freopen("ARC099-F.in", "r", stdin); 
	int n; 
	scanf("%d%s", &n, str);
	for (int i = 0; i < 5; i++)
	{
		pw[i][0] = 1; 
		for (int j = 1; j <= 6e5; j++)
			pw[i][j] = pw[i][j - 1] * bs[i] % md[i];
		inv[i][0] = 1; 
		int x = quick_pow(bs[i], md[i] - 2, md[i]); 
		for (int j = 1; j <= 6e5; j++)
			inv[i][j] = inv[i][j - 1] * x % md[i]; 
	}
	int pos = n + 5; 
	for (int i = 0; i <= n; i++)
	{
		idx[i] = pos; 
		hsh[i] = cur; 
		if (str[i] == '+')
		{
			for (int j = 0; j < 5; j++)
				(cur[j] += pw[j][pos]) %= md[j];
		}
		else if (str[i] == '-')
		{
			for (int j = 0; j < 5; j++)
				(cur[j] += md[j] - pw[j][pos]) %= md[j];
		}
		else if (str[i] == '<')
			pos--;
		else
			pos++; 
	}
	ll ans = 0; 
	for (int i = n; i >= 0; i--)
	{
		data x; 
		int d = idx[i] - (n + 5); 
		if (d >= 0)
		{
			for (int j = 0; j < 5; j++)
				x[j] = (hsh[i][j] + cur[j] * pw[j][d]) % md[j]; 
		}
		else
		{
			for (int j = 0; j < 5; j++)
				x[j] = (hsh[i][j] + cur[j] * inv[j][-d]) % md[j];
		}
		ans += app[x]; 
		app[hsh[i]]++; 
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 106496
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.12lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
ll a[50];
int main()
{
    string s;
    cin>>s;
    ll ans=0;ll sum=0;
    for(int i=s.size()-1;i>=0;i--)
    {
        int u=s[i]-'a';
        ans+=(sum-a[u]);
        a[u]++;sum++;
    }
    cout<<ans+1LL<<endl;


    

    

    

}




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

long long mod = 1000000007;

long long pow_3[100001] = {};

long long p3(int idx){
    if(idx == -1){
        return 0;
    }
    if(pow_3[0] == 0){
        pow_3[0] = 1;
        for(int i = 0; i < 100000; i++){
            pow_3[i+1] = pow_3[i] * 3;
            pow_3[i+1] %= mod;
        }
    }
    return pow_3[idx];
}



long long calc(long long cnt_a, long long cnt_q_before, long long cnt_c, long long cnt_q_after){
    long long ret = 0;
    long long a_cnt = cnt_a * p3(cnt_q_before) + cnt_q_before * p3(cnt_q_before - 1);
    long long b_cnt = cnt_c * p3(cnt_q_after) + cnt_q_after * p3(cnt_q_after - 1);
    ret = (a_cnt % mod) * (b_cnt % mod);
    ret %= mod;
    //printf("%d, %d, %d, %d\n", cnt_a, cnt_q_before, cnt_c, cnt_q_after);
    return ret;
}


int main(){
    
    string S;
    cin >> S;
    long long ans = 0;
    long long s[4][100001] = {};
    for(int i = 0; i < S.length(); i++){
        for(int j = 0; j < 4; j++){
            s[j][i+1] = s[j][i];
        }
        if(S[i] == '?'){
            s[3][i+1]++;
        }else{
            s[S[i]-'A'][i+1]++;
        }
    }
    for(int b = 1; b < S.length() - 1; b++){
        if(S[b] == 'B' || S[b] == '?'){
            ans += calc(s[0][b], s[3][b], s[2][S.length()] - s[2][b+1], s[3][S.length()] - s[3][b+1]);
            ans %= mod;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}


int main()
{
	string s;
	cin >> s;
	cout << (s[1] == 'B' ? "ARC" : "ABC") << endl;
}

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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

fn Main() {
    u32 X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " "<< Y << endl;
}

fn main() -> int {
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main() {
    int n;
    scanf("%d", &n);
    while(n) {
        if (n<1000) break;
        n%=1000;
    }
    if (n==0) n=1000;
    printf("%d\n", 1000-n);
    return 0;
}

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

int main(){

  int INF=100000000;
  int i,j,k;
  string a,b;
  cin>>a>>b;

  vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,INF));
  for(i=0;i<=b.size();i++)
  dp.at(0).at(i)=i;
  for(i=0;i<=a.size();i++)
  dp.at(i).at(0)=i;
  dp.at(0).at(0)=0;
  for(i=0;i<a.size();i++){
    for(j=0;j<b.size();j++){
      if(a.at(i)==b.at(j)){
        dp.at(i+1).at(j+1)=dp.at(i).at(j);
      }else{
        int kari=min(dp.at(i).at(j+1)+1,dp.at(i+1).at(j)+1);
        dp.at(i+1).at(j+1)=min(dp.at(i).at(j)+1,kari);
      }
    }
  }
  /*for(i=0;i<=a.size();i++){
    for(j=0;j<b.size();j++){
      cout<<dp.at(i).at(j)<<" ";
    }
    cout<<dp.at(i).at(b.size())<<endl;
  }*/

  cout<<dp.at(a.size()).at(b.size())<<endl;

}



Measured memory_bytes: 6744
#include<stdio.h>
 int main()
 {
     int A1,A2,A3;
     scanf("%d %d %d", &A1,&A2,&A3);
     if((A1+A2+A3)>=22)
        printf("bust\n");
     else
        printf("win\n");
     return 0;

 }



Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)

typedef long long ll;

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

    sort(a.begin(), a.end());

    int ans = 0;
    int idx = 0;
    while (x > 0 && idx < N - 1) {
        if (a[idx] <= x) {
            ans++;
            x -= a[idx];
        } else {
            x = -1;
        }
        idx++;
    }   

    if (a.back() == x) {
        ans++;
    }

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


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

list=[a,b,c,d,e]
list.sort(reverse=True)

if list[0]-list[4]<=k:
  print("Yay!")
  
else:
  print(":(")

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

using namespace std;
const double inf = 1e100;

int n, m;
vector<int> G[600];
double P[600];
double E[600];
int main() {
  scanf("%d %d", &n, &m);
  for (int j = 0; j < m; ++j) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a; --b;
    G[a].push_back(b);
  }
  
  P[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j : G[i]) {
      P[j] += P[i] / G[i].size();
    }
  }
  
  for (int i = n - 2; i >= 0; --i) {
    double sum = 0;
    for (int j : G[i]) {
      sum += E[j];
    }
    E[i] = sum / G[i].size() + 1;
  }
  
  double mn = 0;
  for (int i = 0; i < n; ++i) {
    int d = G[i].size();
    if (d <= 1) continue;
    for (int j : G[i]) {
      double ans = P[i] * (E[i] - E[j] - 1) / (d - 1);
      mn = min(mn, ans);
    }
  }
  printf("%.16f", E[0] + mn);
}


Measured memory_bytes: 1408
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }
                                   
 
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=2e18+18;
  const int N=2e6+25;
  const int M=2e4;
  
  vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

 void fft()           
 { 
    int n,m; cin>>n>>m;

    cout<<(n*(n-1))/2+(m*(m-1))/2;
 }     

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

   
   int t=1;                         
//   cin>>t;

  rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<t)
   cout<<nl;
  }
  
  
 return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    string S, T;
    string new_str;
    
    cin >> N >> S >> T;
    for(int i = 0; i < N; i++)
    {
        new_str.push_back(S[i]);
        new_str.push_back(T[i]);
    }
    cout << new_str << endl;

    return 0;
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, t;
	cin >> n >> t;
	int ans = 2000;
	while (n--) {
		int c, ti;
		cin >> c >> ti;
		if (ti <= t) ans = min(ans, c);
	}
	if (ans == 2000) cout << "TLE\n";
	else cout << ans << ende;
  return 0;
}


Measured memory_bytes: 256
//26/04/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;


int main(){
    _fastio
    ll s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<en;
    else cout<<"safe"<<en;




    return 0;
}


Measured memory_bytes: 3664
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int f(int x) {
	int n = 0, i = 1;
	while(n + i <= x) {
		n += i;
		++i;
	}
	return i - 1;
}
int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long n;
	cin >> n;
	int count = 0;
	if(n % 2 == 0) {
		int k = 0;
		while(n % 2 == 0) {
			n >>= 1;
			++k; 
		}
		count += f(k);	
	}
	for(int i = 3; 1LL * i * i <= n; i += 2) {
		if(n % i == 0) {
			int k = 0;
			while(n % i == 0) {
				++k;
				n /= i;
			}
			count += f(k);
		}
	}
	if(n > 1) ++count;
	cout << count << '\n';
	return 0;
}

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

int main(){

    string S;
    cin >> S;
    long long ans = 0;
    for(int s = 0; s < (1 << (S.size() - 1)); s++){ 
        string now = "";
        now += S.at(0);
        for(int i = 0; i < S.size() - 1; i++){ 
            if(s & (1 << i)) now += "+";
            now += S.at(i + 1);
        }
        //cout << now << endl;
    long long sum = 0;
    int pos = 0;
        while(now.find("+",pos) != string::npos){
            int nextpos = now.find("+", pos);
            sum += stoll(now.substr(pos, nextpos - pos));
            pos = nextpos + 1;
        }
    sum += stoll(now.substr(pos));
    ans += sum;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
list(map(int, input().split()))
h = list(map(int, input().split()))
mh = min(h)
bmh = 0
while mh != bmh:
  bmh = mh
  h = list(map(lambda x: x % mh if x % mh != 0 else mh, h))
  mh = min(h)
print(mh)

Measured memory_bytes: 15020
/* ex 9_1
   アカウント名 */

#include <stdio.h>
#include <stdlib.h>


typedef struct node{
    char elem;
    struct node *next;
} node;

void push(node **first, char elem){
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}


int main(void){
    char str[100001];
    char tmp, *ptr;
    int removed_num = 0;
    node *first = NULL;
    scanf("%s", str);
    ptr = str;
    while(*ptr != '\0'){
        if(first == NULL){
            push(&first, *ptr);
        }
        else if((*first).elem != *ptr){
            tmp = pop(&first);
            removed_num += 2;
        }
        else{
            push(&first, *ptr);
        }
        ptr++;
    }
    printf("%d\n", removed_num);
    return 0;
}


Measured memory_bytes: 4912
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int array[] = new int[3];
        for(int i = 0; i < 3; i++){
            array[i] = sc.nextInt();
        }
        
        smallArray(array);
    }
    
    public static void smallArray(int array[]){
        Arrays.sort(array);
        for(int i = 0; i < 3; i++){
            if(i != 2){
                System.out.print(array[i] + " ");
                
            }else{
                System.out.println(array[i]);
            }
            
        }

    }
}


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

using namespace std;

int main() {
    long long n,m,tmp;
    cin >> n >> m;
    priority_queue<long long> a;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        a.push(tmp);
    }

    for (int i = 0; i < m; i++) {
        tmp = a.top();
        a.pop();
        a.push(tmp / 2);
    }

    tmp = 0;
    while(!a.empty()) {
        tmp += a.top();
        a.pop();
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int mark[401][401];
struct help{
    long long int ans;
    long long int real_ans;
};
help second[401][401];
help functions(long long int *arr,int i,int j){
    help first;
    if(i>j)
    //return 0;
    {
        //first.ans=0;
        //first.real_ans=0;
        second[i][j].ans=0;
        second[i][j].real_ans=0;
        mark[i][j]=1;
        return second[i][j];
    }
    if(mark[i][j]!=-1)
    return second[i][j];
    if(i==j)
    //return arr[i];
    {
        //first.ans=arr[i];
        //first.real_ans=0;
        mark[i][j]=1;
        second[i][j].ans=arr[i];
        second[i][j].real_ans=0;
        return second[i][j];
    }
    help fake,fake1;
    first.ans=1e14;
    first.real_ans=1e14;
    for(int k=i;k<j;k++){
        fake=functions(arr,i,k);
        fake1=functions(arr,k+1,j);
        //cout<<fake.ans<<" "<<fake.real_ans<<endl;
        fake.ans+=fake1.ans;
        fake.real_ans+=fake1.real_ans+fake.ans;
        if(fake.real_ans<first.real_ans)
        {
            first.ans=fake.ans;
            first.real_ans=fake.real_ans;
        }
        //cout<<ans<<endl;
    }
    mark[i][j]=1;
    second[i][j]=first;
    return first;
}
int main(void){
    memset(mark,-1,sizeof(mark));
    int n;
    cin>>n;
    long long int *arr=new long long int[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    help first=functions(arr,0,n-1);
    cout<<first.real_ans<<endl;
}

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

int main() {
	long long n,i,j,k,sum=0,count=0,ans=0,x;
	cin>>n;
	string s3,s4;
	vector<string >s[11];
	s[1].push_back("a");
	s[2].push_back("aa");
	s[2].push_back("ab");
	for(i=3;i<=10;i++)
	{
	    for(j=0;j<s[i-1].size();j++)
	    {
	        s3=s[i-1][j];
	        sort(s3.begin(),s3.end());
	        k=(s3[i-2]-'a');
	        for(x=0;x<(k+2);x++)
	        {
	            s4=s[i-1][j]+char('a'+x);
	            s[i].push_back(s4);
	        }
	        
	    }
	    
	}
	for(i=0;i<s[n].size();i++)
	cout<<s[n][i]<<"\n";
	return 0;
}

Measured memory_bytes: 9588
A,B,C=map(int,input().split())
count=0
if A%2==0 and A==B and A==C:
  print("-1")
  exit()
while True:
  if A%2==1 or B%2==1 or C%2==1:
    break
  a,b,c=A/2,B/2,C/2
  A,B,C=b+c,a+c,a+b
  count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream> 

  #include <iomanip>

using namespace std; 

  

int 

main () 

{ 

  

  int a ; 

  

  int b ; 

  cin>>a>>b; 

  double f = a; 

  double g = b; 

  int c= a/b; 

  int d=a % b; 

  double e=f/g; 

   
 std::cout << std::fixed;
    std::cout << std::setprecision(5);
    
  cout<< c << " "<<d << " " << e <<endl; 

  return 0; 

 
} 


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m)
    {
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    int range = x[m-1]-x[0];
    vector<int> dist(m-1);
    rep(i,m-1)
    {
        dist[i] = x[i+1]-x[i];
    }
    sort(dist.begin(),dist.end(),greater<int>());
    int sub = 0;
    int mn;
    mn = min(m-1,n-1);
    rep(i,mn)
    {
        sub += dist[i];
    }
    cout << range-sub << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;


// ---- コーディングはここから！ ('-')7
const lli MOD = 998244353;
void solve(){
	lli a,b,c; cin>>a>>b>>c;
	lli u = b%c;
	if(a<c){
		lli sum = 0;
		fore(i,0,a){
			sum+=b;
			b=(b*b)%c;
		}
		cout<<sum<<ENDL;
		return;
	}

		map<int,int>mark;
		vl sum(1,0);
		lli z,last;
		for(int i = 1; ;i++){
			if(mark.count(b)){
				z =i-mark[b];
				last = mark[b]-1;
				break;
			}
			mark[b]=i;
			sum.pb(sum.back()+b);
			b=(b*b)%c;
		}
		lli res = 0;
		lli aux = sum.back()-sum[last];
		lli h = (a - last)/z;
		res+= h*aux + sum[last+((a - last)%z)];
		cout<<res<<ENDL;

}
int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 5948
//Remainder Reminder

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,k,ans=0;cin>>n>>k;
    rep(i,1,n+1){
        int t=i-k;
        int r=n/i;
        int y=n%i-(k-(k>0?1:0));
        if(t>0)ans+=t*r+(y>0?y:0);
    }
    cout<<ans<<nnn;
    return 0;
}

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

const ll mod = 1e9+7;
ll INF = 1000;

ll n,k,a[100010],b[100010],ans;
int main(){
  cin>>n>>k;

  rep(i,n)cin>>a[i];

  if(a[0]>k){
    ans+=(a[0]-k);
    a[0]-=(a[0]-k);
  }

  for(int i=1;i<n;i++){
    for(int j=i-1;j<(i-1)+2;j++){
      b[i]+=a[j];
    }
  }


  for(int i=1;i<=n-1;i++){


    //cout<<b[i];
    // for(int i=1;i<=n-1;i++){
    //   cout<<b[i];
    // }


     if(b[i]>k && a[i]>=(b[i]-k)){
       ans+=(b[i]-k);
       b[i+1]-=(b[i]-k);
       b[i]-=(b[i]-k);
     }

  }
  cout<<ans<<endl;




  return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int x = in.ni();
        out.println(x>=30?"Yes":"No");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] != '#') continue;
            ll cnt = 0;
            rep(k, 4) {
                ll ny = i + d[k][0];
                ll nx = j + d[k][1];
                if ((nx < 0) || (nx >= w) || (ny < 0) || (ny >= h)) continue;
                if (s[ny][nx] == '#') cnt++;
            }
            if (cnt == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 998244353
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll bp(ll a,ll b,ll m=mod)
{
    ll res=1;
    if(b<0)
        return bp(bp(a,m-2),-b);
    while(b>0)
    {
        if(b&1)
        res=(a*res)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll n,k;
    cin>>n>>k;
    ll l[k],r[k];
    for(int x=0;x<k;x++)
        cin>>l[x]>>r[x];
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=1;
    for(int x=2;x<=n;x++)
        {for(int y=0;y<k;y++)
            {  //cout<<x-l[y]<<" "<<x-r[y]-1<<"\n";
            dp[x]=(dp[x]+dp[max(x-l[y],0ll)]-dp[max(x-r[y]-1,0ll)]+mod)%mod;}
            //cout<<dp[x]<<"\n";
           dp[x]+=dp[x-1];
        }
    cout<<(dp[n]-dp[n-1]+mod)%mod<<"\n";
}


Measured memory_bytes: 5168
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        // 整数の入力
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int ans = 0;
        double nearestGap = Integer.MAX_VALUE;

        for(int i = 0; i < n; i++) {
            double value = t - (sc.nextInt() * 0.006);
            double gap = Math.abs(value - a);
            if (gap < nearestGap) {
                nearestGap = gap;
                ans = i;
            }
        }

        // 出力
        System.out.println(++ans);
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

void solve()
{
    int a;cin>>a;
    int ans=pow(a,3);
    cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 4124
import numpy as np

N, K, Q = map(int, input().split())

scores = np.zeros(N, int)
for _ in range(Q):
    i = int(input()) - 1
    scores[i] = scores[i] + 1

for i in range(N):
    if Q - scores[i] < K:
        print('Yes')
    else:
        print('No')




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

const int MAXN = 1e6 + 10;

int n;
int a[MAXN], dp[MAXN];
int ans;

int main() {
  	cin >> n;
  	for (int i = 0; i < n; i++) {
     cin >> a[i];
      dp[a[i]] = dp[a[i] - 1] + 1;
    }
  ans = n - 1;
  for (int i = 0 ;i < n; i++)
   ans = min(ans, n - dp[a[i]]);
  cout << ans << '\n';
 	return 0; 
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  long long s=0;
  if(k<a){
    s+=k;
    k=0;
  }
  else{
    s+=a;
    k-=a;
  }
  if(k>0){
    if(k<b)
      k=0;
    else
      k-=b;
  }
  if(k>0)
    s-=k;
  cout<<s;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {												
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/wjex/cp/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


void solve(){
	int k ; 
	string s ; 
	re(k,s);
	if(k>=s.length()){
		cout << s << endl;
	}
	else if (s.length()>k){
		rep(i,0,k) cout << s[i];
		cout << "...";
	}
}

signed main() {
	unsyncIO();
	int tt =1 ;
	//cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

count=0
for i in range(n):
  m=min(a[i],b[i])
  b[i]-=m
  r=min(a[i+1],b[i])
  a[i+1]-=r
  count+=m+r
print(count)

Measured memory_bytes: 82020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}


void solve(){
  int N,L; cin >> N >> L;
  vector<string> S(N); rep(i,N) cin >> S[i];
  sort(all(S));
  rep(i,N) cout << S[i];
  cout << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int maxN = -1000;
  int minN = 1000;
  int maxM = -1000;
  int minM = 1000;
  int tmp = 0;
  rep (i, n) {
    cin >> tmp;
    maxN = max(tmp, maxN);
    minN = min(tmp, minN);
  }
  rep (i, m) {
    cin >> tmp;
    minM = min(tmp, minM);
    maxM = max(tmp, maxM);
  }
  if (minM > maxN && maxN > x && minM <= y) P("No War");
  else P("War");

  return 0;
}



Measured memory_bytes: 256
# 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = [None] + a

    in_or_not = [0 for _ in range(n+1)]
    for i in range(n, 0, -1):
        count = sum(in_or_not[2*i:n+1:i])  
        in_or_not[i] = a[i] ^ count % 2
    
    print(in_or_not.count(1))
    for i in range(1, n+1):
        if in_or_not[i] == 1:
            print(i, end=' ')


if __name__ == "__main__":
    main()


Measured memory_bytes: 8336
from collections import deque
n = int(input())
lis = list(input().split())
ans = deque([])
x = n % 2
for i in lis:
    
    if x % 2 == 0:
        ans.append(i)
    else:
        ans.appendleft(i)
    x += 1
print(" ".join(ans))

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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	long long k;
	cin >> n >> k;
	vector<int> a(n), vis(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	int cur = 0, last;
	for (int i = 1; i <= n + 1; i++) {
		if (!vis[cur])
			vis[cur] = i;
		else {
			int size = (vis[last] - vis[cur]) + 1;
			int find = vis[cur] + (k) % size;
			for (int j = 0; j < n; j++) {
				if (vis[j] == find) {
					cout << j + 1 << '\n';
					return 0;
				}
			}
		}
		last = cur;
		cur = a[cur];
		k--;
		if (!k)
			break;
	}
	cout << cur + 1 << '\n';
}


Measured memory_bytes: 4768
num_problems = input()
a = input()
total = 0
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)


  

Measured memory_bytes: 8908
// 2011/04/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int p[10001];
	p[0] = 0;
	p[1] = 2;
	for(int i=2; i<=10000; i++){
		for(p[i]=p[i-1]+1; true; p[i]++){
			bool prm = true;
			for(int j=1; j<=i-1; j++){
				if(p[i]%p[j]==0){
					prm = false;
					break;
				}
			}
			if(prm)
				break;
			else
				continue;
		}
	}

	int s[10001];
	s[0] = p[0];
	for(int i=1; i<=10000; i++)
		s[i] = s[i-1]+p[i];

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

		cout << s[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 880
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    r,g,b,n = map(int, input().split())
    res = 0
    for i in range(3001):
        temp = n - r*i
        for j in range(3001):
            temp2 = temp - g*j
            if temp2>=0 and temp2%b==0:
                res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
int N, M, ans[100001], bit[100001], tmp[100001];
long long K, a[100001], s[100001];
void MUL(int *a, int *b, int *c)
{
	for (int i = 0; i <= N; i++)
		tmp[i] = a[b[i]];
	std::copy(tmp, tmp + N + 1, c);
}
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%lld", a + i);
	for (int i = 0; i <= N; i++)
	{
		bit[i] = i;
		ans[i] = i;
	}
	scanf("%d%lld", &M, &K);
	for (int i = 1, u; i <= M; i++)
	{
		scanf("%d", &u);
		std::swap(bit[u - 1], bit[u]);
	}
	for (; K; K >>= 1)
	{
		if (K & 1)
			MUL(ans, bit, ans);
		MUL(bit, bit, bit);
	}
	for (int i = 1; i < N; i++)
		a[i] -= a[i + 1];
	for (int i = 1; i <= N; i++)
		s[i] = a[ans[i]];
	for (int i = N - 1; i; i--)
		s[i] += s[i + 1];
	for (int i = 1; i <= N; i++)
		printf("%lld.0\n", s[i]);
	return 0;
}


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

int main(){
    int x;
    cin>>x;
    int h=x/100;

    if(x>h*100+h*5) cout<<0<<"\n";
    else cout<<1<<"\n";
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
ll H[305];
ll dp[305][305][305];

ll go(int pos, int idx, int k) {
	if (k < 0) return LINF;
	if (pos > N) return 0ll;
	ll& ret = dp[pos][idx][k];
	if (ret != -1ll) return ret;
	ret = LINF;
	ret = min(go(pos + 1, idx, k - 1), go(pos + 1, pos, k) + MAX(H[pos] - H[idx], 0ll));
	return ret;
}

int main()
{
	int i, j;
	scanf("%d%d", &N, &K);
	for (i = 1; i <= N; ++i) scanf("%lld", &H[i]);
	memset(dp, -1, sizeof(dp));
	ll ans = go(1, 0, K);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 221952