akhauriyash/Code-Regression huggingface dataset:
/*
      Ashraful Islam Paran
      22-August-2020
      19:31:08
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i <= 0; i--)
#define w(t) int t; cin >> t; while (t--)



typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second


int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s;
    cin>>s;
    int sum=0;
    f(s.size())
    {
        sum+=s[i]-'0';
    }
    //cout<<sum<<endl;
    if(sum%9==0)
    {
        yes;
    }
    else
    {
        no;
    }
    
    
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

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

int main() {
  int N,j,k,l,m;
  cin >> N;
  j=k=l=m=0;
 
  for(int i;i < N;i++) {
    string S ;cin >> S;
      if(S=="P") {j++;}
    else if(S=="W") {k++;}
    else if(S=="G") {l++;}
    else if(S=="Y") {m++;}
  }
  if(j==0 || k==0 || l==0 || m==0) {
    cout << "Three" << endl;}
  else {cout << "Four" <<endl;}
}

Measured memory_bytes: 256
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int a, b;
  cin >> a >> b;
  if (b >= a) {
    cout << "unsafe\n";
  } else {
    cout << "safe\n";
  }
  return 0;
}


Measured memory_bytes: 3648
def main():
  h, w, k = map(int, input().split())
  C = [list(input()) for _ in range(h)]

  result = 0
  for i in range(1 << h):
    for j in range(1 << w):
      cnt = 0
      for n in range(h):
        if i >> n & 1:
          continue

        for m in range(w):
          if j >> m & 1:
            continue

          if C[n][m] == '#':
            cnt += 1

      if cnt == k:
        result += 1

  print(result)


if __name__ == "__main__":
  main()


Measured memory_bytes: 9124
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
permutations_lis = itertools.permutations(range(1,n+1))# 全ての場合のリストを生成
dis_list = []
for i,case in enumerate(permutations_lis):
    if list(case) == p :
        a = i 
    if list(case) == q :
        b = i
print(abs(a-b))

    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define l long int 
#define ll long long int 
vector<int>adj[1000001];
int vis[1000001];
int cnt=0;
int fact[1000001];
bool temp=false;
void f(int x)
{
    if(temp==true)
    return ;
    for(int i=1;i*i<=x;i++)
    {
        if(x%i==0)
        {
            int a=i;
            int b=x/i;
            if(a==b)
            {
                a=i;
                b=1;
            }
            if(a!=1)
            {
                if(fact[a])
                {
                    temp=true;
                    return;
                }
                fact[a]++;
            }
            if(b!=1)
            {
                if(fact[b])
                {
                    temp=true;
                    return;
                }
                fact[b]++;
            }
        }
    }
}
int main()
{
    int n;
    cin>>n;  
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        int ele;
        cin>>ele;
        v.push_back(ele);
    }
    int gcd=v[0];
    f(v[0]);
    for(int i=1;i<n;i++)
    {
        f(v[i]);
        gcd=__gcd(gcd,v[i]);
    }
    if(!temp)
    {
        cout<<"pairwise coprime"<<"\n";
    }
    else if (gcd==1)
    {
        cout<<"setwise coprime"<<"\n";
    }
    else
    {
        cout<<"not coprime"<<"\n";
    }
    
    
    return 0;
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;

int n, k, pos, x[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;
	
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		if (x[i] < 0)
			pos = i;
	}

	int ans = (int)1e9;

	for (int i = pos + 1; i <= min(n, pos + k - 1); i++) {
		int j = i - k + 1;
		if (j < 1)
			continue;
		int len1 = x[i];
		int len2 = -x[i - k + 1];
		ans = min(ans, len2 + len1 + min(len1, len2));
	}

	if (pos + k <= n)
		ans = min(ans, x[pos + k]);
	if (pos - k + 1 >= 1)
		ans = min(ans, -x[pos - k + 1]);

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


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

int main(void) {
    int N;

    cin >> N;
    map<char, unsigned long long> m;
    vector<int> mm;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        switch(s[0]) {
            case 'M': m[s[0]]++;break;
            case 'A': m[s[0]]++;break;
            case 'R': m[s[0]]++;break;
            case 'C': m[s[0]]++;break;
            case 'H': m[s[0]]++;break;
        }
    }

    for (auto it : m) {
        mm.push_back(it.first);
    }

    if (m.size() < 3) {
        cout << 0 << endl;
        return 0;
    }
    else if (m.size() == 3) {
        unsigned long long sum = 1;
        for (auto it : m) {
            sum *= it.second;
        }
        cout << sum << endl;
    }
    else {
        int size = m.size();
        unsigned long long sum = 0;
        for (int i = 0; i < size - 2; i++) {
            for (int j = i + 1; j < size - 1; j++) {
                for (int k = j + 1; k < size; k++) {
                    sum += m[mm[i]] * m[mm[j]] * m[mm[k]];
                }
            }
        }
        cout << sum << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll d; cin >> d;

    vector<ll> c(26);
    for (ll i = 0; i < 26; ++i) {
        cin >> c[i];
    }

    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; ++i) {
        for (ll j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    vector<ll> t(d);
    for (ll i = 0; i < d; ++i) {
        ll idx = 0;
        ll mx = 0;
        for (ll j = 0; j < 26; ++j) {
            if (mx < s[i][j]) {
                mx = s[i][j];
                idx = j;
            }
        }
        t[i] = idx;
    }

    vector<ll> score(d, 0);
    vector<vector<ll>> last(d, vector<ll>(26, 0));

    auto re_score = [&](ll start) {
        for (ll i = start; i < d; ++i) {
            score[i] = (i - 1 >= 0 ? score[i - 1] : 0) + s[i][t[i]];

            if (i - 1 >= 0) {
                last[i] = last[i - 1];
            } else {
                for (ll j = 0; j < 26; ++j) {
                    last[0][j] = 0;
                }
            }

            last[i][t[i]] = i + 1;

            ll j = i + 1;

            for (ll k = 0; k < 26; ++k) {
                score[i] -= c[k] * (j - last[i][k]);
            }
        }
    };

    re_score(0);

    ll mx_score = score[d - 1];
    for (int r = 0; r < 20; ++r) {
        for (ll i = 0; i < d; ++i) {
            for (ll j = 0; j < 26; ++j) {
                ll tmp = t[i];

                t[i] = j;
                re_score(i);

                if (mx_score >= score[d - 1]) {
                    t[i] = tmp;
                    re_score(i);
                } else {
                    mx_score = score[d - 1];
                }
            }
        }
    }

    for (ll i = 0; i < d; ++i) {
        cout << t[i] + 1 << endl;
    }
}

Measured memory_bytes: 3800
n = int(input())
if 9 >= n:
    print(0)
    exit()

dic = {}
dic[2] = 1
dic[3] = 1

for i in range(4,n+1):
    
    for j in dic.keys():
        
        if i % j == 0:
            while i % j == 0:
                dic[j] += 1
                i //= j
                
    if i != 1:
        dic[i] = 1


ans = {}
ans[2] = 0
ans[4] = 0
ans[14] = 0
ans[24] = 0
ans[74] = 0
for i,j in dic.items():
    for k in ans.keys():
        if j >= k:
            ans[k] +=1


count = 0
count += ans[24]*(ans[2]-1)
count += ans[74]
count += ans[14]*(ans[4]-1)
count += (ans[4]*(ans[4]-1)//2)*(ans[2]-2)
print(count)




Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int count = 0;
		
		for(int i=0;i<a.length();i++) {
			if(a.charAt(i)!=(b.charAt(i))) {
				//String s = a.replace(a.charAt(i), b.charAt(i));
				count++;
			}
		}
		System.out.println(count);
	}
}

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

using namespace std;

int main()
{
    long long int n, i, h[100000], s[100000];
    cin>>n;
    for(i=1; i<=n; i++) cin>>h[i];
    s[1]=0; s[2]=abs(h[2]-h[1]);
    for(i=3; i<=n; i++)
    {
        s[i]=min(s[i-1]+abs(h[i-1]-h[i]), s[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<s[n];

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int flag[60];

int main(void) {
	int a, b, c;
	int cur, t;

	scanf("%d %d %d", &a, &b, &c);

	cur = t = 0;
	flag[0] = 1;
	while (1) {
		if (cur <= c + t * 60 && c + t * 60 <= cur + a) {
			printf("%d\n", c + t * 60);
			return 0;
		}

		cur += a + b;
		if (flag[cur % 60]) {
			puts("-1");
			return 0;
		}
		flag[cur % 60] = 1;

		while (c + t * 60 < cur)
			t++;
	}

	return 0;
}

Measured memory_bytes: 596
N = str(input())
def main1(N):
    count = 0
    for i in range(1, len(N) + 1):
        if i % 2 != 0 :
            if i != len(N):
                count += 9 * 10**(i-1)
            else:
                if len(N) != 1:
                    count += ((int(N[0]) - 1) * 10**(i-1)
                        + int(N[1:len(N)]) + 1)
                else:
                    count += int(N[0])
    print(count)

main1(N)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[114];
    int K;

    Scs(s);
    int N = strlen(s);
    Scd(K);

    ll ans = 0;
    ll ans1 = 0;
    ll anss = 0;
    bool delfin = false;
    bool delfirst = false;

    char prev = 0;
    Rep(i,N){
        if( s[i] == prev ){
            ans++;
            prev = 0;
        }else{
            prev = s[i];
        }
    }
    Rep(i,N){
        if( s[i] == prev ){
            ans1++;
            prev = 0;
            if( i == 0 ) delfirst = true;
        }else{
            prev = s[i];
            if( i == N-1 ) delfin = true;
        }
    }
    // printf ("%lld\n", ans );
    // printf ("%lld\n", ans1 );
    // printf ("%d %d\n", delfin , delfirst );

    if( delfirst && delfin ){
        anss += ans;
        anss += ans1*K-ans1;
    }else{
        anss += ans * ((K+1)/2);
        anss += ans1*(K/2);
    }

    printf ("%lld\n", anss );

    return 0;
}





Measured memory_bytes: 256
#include<cstdio>
using namespace std;
long long N,K,zj,cnt;
int main()
{
	scanf("%lld %lld",&N,&K);
	if(K%2==0)
	{
		zj=N/K;
		cnt+=zj*(zj-1)*(zj-2);
		cnt+=zj*(zj-1)*3;
		cnt+=zj;
		if(N%K>=K/2)
		zj++;
		cnt+=zj*(zj-1)*(zj-2);
		cnt+=zj*(zj-1)*3;
		cnt+=zj;
	}
	else
	{
		zj=N/K;
		cnt+=zj*(zj-1)*(zj-2);
		cnt+=zj*(zj-1)*3;
		cnt+=zj;
	}
	printf("%lld",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;
 
int main()
{
	double n, x, t, j;

	int ans; 

	cin >> n >> x >> t;

	j = ceil(n/x);

	ans = j*t;

	cout << fixed << ans;

  	return 0;
}

Measured memory_bytes: 3720
#include<cstdio>
#include<algorithm>

using namespace std;

#define FOR(i, a, b) for(int i = a; i <= b; i++)

struct Card
{
	char color;
	int value;
	friend bool operator!= (Card a, Card b)
	{
		if(a.color != b.color || a.value != b.value)
			return true;
		else
			return false;
	}
};

const int MAX = 40;
int n;
Card s[MAX], org[MAX];

void BubbleSort(void)
{
	FOR(i, 0, n - 1)
	{
		for(int j = n - 1; j >= i + 1; j--)
		{
			if(s[j].value < s[j - 1].value)
				swap(s[j], s[j - 1]);
		}
	}
	FOR(i, 0, n - 1)
	{
		printf("%c%d", s[i].color, s[i].value);
		if(i != n - 1)
			printf(" ");
		else
			printf("\n");
	}
	printf("Stable\n");
	return;
}

void SelectionSort(void)
{
	FOR(i, 0, n - 1)
	{
		int minj = i;
		for(int j = i; j < n; j++)
			if(org[j].value < org[minj].value)
				minj = j;
		swap(org[i], org[minj]);
	}
	FOR(i, 0, n - 1)
	{
		printf("%c%d", org[i].color, org[i].value);
		if(i != n - 1)
			printf(" ");
		else
			printf("\n");
	}
	bool flag = true;
	FOR(i, 0, n - 1)
	{
		if(s[i] != org[i])
		{
			flag = false;
			break;
		}
	}
	if(flag)
		printf("Stable\n");
	else
		printf("Not stable\n");
	return;
}

int main()
{
	while(~scanf("%d", &n))
	{
		FOR(i, 0, n - 1)
		{
			getchar();
			scanf("%c%d", &s[i].color, &s[i].value);
			org[i].color = s[i].color, org[i].value = s[i].value;
		}

		BubbleSort();
		SelectionSort();
	}
	return 0;
}



Measured memory_bytes: 2748
function main(input) {
  input = input.trim();
  const [x1, y1, x2, y2] = input.split(" ").map(a => Number(a));
  const x3 = x2 - y2 + y1;
  const y3 = y2 + x2 - x1;
  const x4 = x3 - x2 + x1;
  const y4 = y3 - y2 + y1;
  console.log([x3, y3, x4, y4].join(" "));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){ 
    ll a,b,c,d; cin>>a>>b>>c>>d;
    lp(i,0,1000){
        if(i%2 == 0){
            c-=b;
            if(c <= 0) {
            cout<<"Yes";
            return 0;
        }
        } else {a-=d;
        if(a <= 0){
            cout<<"No";
            return 0;
        }}
    }
    return 0;
}   

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3596
#include<stdio.h>



int gcm_pow2( int ,int ) ;



int main()
{
	int w ,h ,cost ;
	scanf( "%d %d %d" ,&w ,&h ,&cost ) ;


	cost *= (  ( w * h ) / gcm_pow2( w ,h )  ) ;



	printf( "%d\n" ,cost ) ;


	return 0 ;
}



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

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

#define FOR(i,a,b)      for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b)     for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)        FOR(i,0,n)
#define RREP(i,n)       RFOR(i,n,0)
#define ALL(v)          (v).begin(),(v).end()
#define BIT(n)          (1LL<<(n))
#define IN(x,l,r)       ((l)<=(x)&&(x)<=(r))
#define INCLUDE(s,v)    (s.find(v)!=string::npos)
#define LEN(s)          (string(s)).length()
#define SHOW(x)         cout<<#x<<" = "<<x<<endl
#define SORT(v)         sort(ALL(v))
#define SZ(v)           (ll)(v).size()
#define UNIQ(v)         SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)         for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)           priority_queue<T,vector<T>,greater<T>>
#define REPLACE(s,f,t)  for(auto p=s.find(f);p!=string::npos;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);

template<class T>string join(const vector<T>& v,string d=" ") {stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}
template<class T>ostream& operator<<(ostream& o,const vector<T>& v) {o<<"{";if(SZ(v))o<<join(v,", ");o<<"}";return o;}
template<class T,class U>ostream& operator<<(ostream& o,const pair<T,U>& p) {o<<"(";o<<p.first<<", "<<p.second;o<<")";return o;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    string S; cin >> S;
    if (INCLUDE(S, "AC")) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations_with_replacement

N,M,X = map(int,input().split())
CA = []
for i in range(N):
  CA.append(list(map(int,input().split())))

OK = True
CA = np.array(CA)
sums = np.sum(CA,axis=0)
for i in range(1,M+1):
  if sums[i] < X:
    OK = False
    break

if OK == False:
  print(-1)
else:
  As = []
  for A in combinations_with_replacement(range(0, N),N):
    As.append(tuple(set(A)))
  As = list(map(list, set(As)))
  min_ = sums[0]
  for i in As:
    mini_CA = []
    for j in i:
      mini_CA.append(CA[j])
    mini_CA = np.array(mini_CA)
    OK2 = True
    sums = np.sum(mini_CA,axis=0)
    for k in range(1,M+1):
      if sums[k] < X:
        OK2 = False
        break
    if OK2 == True and sums[0] < min_:
      min_ = sums[0]
  print(min_)

Measured memory_bytes: 164792
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10001;
int ans[MAXN];
int main()
{
	int n;
	cin>>n;
	for(int i=n;i<=999;i++)
	{
		int tot=0;
		int m=i;
		while(m!=0)
		{
			ans[tot++]=m%10;
			m/=10;
		}
		int flag=1;
		for(int j=tot-1;j>=1;j--)
		{
			if(ans[j]!=ans[j-1])
			{
				flag=0;
				break;
			}
		}
		if(flag)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

ecum = [0] * n

for i, item in enumerate(s):
  if i == 0:
    if item == "E":
      ecum[i] = 1
  else:
    if item == "E":
      ecum[i] = ecum[i-1] + 1
    else:
      ecum[i] = ecum[i-1]

ans = n
for i, item in enumerate(s):
  if i == 0:
    cost = ecum[-1]
  else:
    cost = i - ecum[i-1] + ecum[-1] - ecum[i]
  ans = min(ans, cost)
  
print(ans)

Measured memory_bytes: 15180
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

vector<int> inputs;
map<int, int> counter;

long long hoge(int num){
    long long ret = num;
    ret *= (num - 1);
    ret /= 2;
    return ret;
}


int main(int argc, char* argv[]){
    int num;
    cin >> num;

    int a;
    inputs.resize(num);

    for(int i = 0; i < num; ++i){
        cin >> a;
        inputs[i] = a;

        if(counter.find(a) == counter.end()){
            counter[a] = 1;
        }
        else{
            counter[a] += 1;
        }
    }

    long long all_sum = 0;
    for(const auto& x : counter){
        long long sum = hoge(x.second);
        all_sum += sum;
    }

    for(int i = 0; i < num; ++i){
        int rem = inputs[i];
        long long ans = all_sum - counter[rem] + 1;
        cout << ans << endl;
    }

}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int n; cin>>n;
    vector<ll> a(3), dp(3), new_dp(3);
    for(int i = 0 ; i < 3; i++)
      cin>>a[i];
    for(int i = 0 ; i < 3; i++)
      dp[i] = a[i];
    for(int i = 1; i < n; i++){
      for(int j = 0; j < 3; j++)
        cin>>a[j];
        
      for(int j = 0; j <3; j++){
        for(int k = 0; k <3 ; k++){
          if(j==k) continue;
          new_dp[k] = max(new_dp[k], dp[j]+a[k]);
        }
      }
      dp = new_dp;
      new_dp = vector<ll> (3,0);
    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;
    return 0;
}

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

int main() {

    int n,m,x;
    cin>>n>>m>>x;
    int a[m];
    int left = 0;
    int right=0;

    for(int i=0;i<m;i++){
        cin>>a[i];
        if(x>a[i]){
            left++;
        }
        else{
            right++;
        }
    }
    if(left>=right){
        cout<<right<<endl;
    }
    else{
        cout<<left<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=400010;
int i,j,k,n,m,x,y,t,la,no,ans;
struct data{int l,r,sum,lazy;}T[2][N*4];
vector<int>c[N];
void build(int id,int i,int l,int r){
	T[id][i]={l,r,0,0};
	if (l==r)return;
	int mid=l+r>>1;
	build(id,i*2,l,mid);build(id,i*2+1,mid+1,r);
}
void pushup(int id,int i){T[id][i].sum=T[id][i*2].sum+T[id][i*2+1].sum;}
void pushdown(int id,int i){
	if (T[id][i].lazy){
		T[id][i*2].lazy=T[id][i*2+1].lazy=T[id][i].lazy;
		T[id][i*2].sum=(T[id][i*2].r-T[id][i*2].l+1)*(T[id][i].lazy-1);
		T[id][i*2+1].sum=(T[id][i*2+1].r-T[id][i*2+1].l+1)*(T[id][i].lazy-1);
		T[id][i].lazy=0;
	}
}
void change(int id,int i,int l,int r,int num){
	pushdown(id,i);
	if (T[id][i].l==l&&T[id][i].r==r){
		T[id][i].sum=num*(r-l+1);
		T[id][i].lazy=num+1;
		return;
	}
	int mid=T[id][i].l+T[id][i].r>>1;
	if (r<=mid)change(id,i*2,l,r,num);
	else if (l>mid)change(id,i*2+1,l,r,num);
	else{change(id,i*2,l,mid,num);change(id,i*2+1,mid+1,r,num);}
	pushup(id,i);
}
int query(int id,int i,int l,int r){
	pushdown(id,i);
	if (T[id][i].sum==0)return -1;
	if (T[id][i].l==T[id][i].r)return T[id][i].l;
	int mid=T[id][i].l+T[id][i].r>>1;
	if (r<=mid)return query(id,i*2,l,r);
	else if (l>mid)return query(id,i*2+1,l,r);
	else {
		int te=query(id,i*2,l,mid);
		if (te!=-1)return te;
		return query(id,i*2+1,mid+1,r);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&t);
	ans=1013687232;
	for (i=1;i<=t;i++){
		scanf("%d%d",&x,&y);
		if (x>1)c[y].push_back(x);
	}
	for (i=1;i<=m;i++)c[i].push_back(n+1);
	for (i=1;i<=m;i++)sort(c[i].begin(),c[i].end());
	no=0;la=1;
	build(0,1,1,n);build(1,1,1,n);
	change(no,1,1,c[1][0]-1,1);
	ans=c[1][0]-1;
	for (i=2;i<=m;i++){
		swap(no,la);change(no,1,1,n,0);
		int be=1;
		for (j=0;j<c[i].size();j++){
			if (be<=c[i][j]-2){
				int pos=query(la,1,be,c[i][j]-2);
				if (pos!=-1){change(no,1,pos+1,c[i][j]-1,1);/*printf("###%d %d\n",i,c[i][j]);*/ans=min(ans,c[i][j]-1);}
			}
			be=c[i][j];
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 51712
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", n*(n+1)/2+1);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int n = sz(s);
    rep(i, n) {
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
        char c = s.back();
        s.pop_back();
        s = c + s;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
cnt = 0

for i in range(1000):
	t = str(i).zfill(3)
	t_idx = 0
	for s_idx in range(n):
		if s[s_idx] == t[t_idx]:
			t_idx += 1
			if t_idx == 3:
				break
	if t_idx == 3:
		cnt += 1

print(cnt)

Measured memory_bytes: 41068
#include <bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=2e5+10 ;

int sr, sc, h, w, n, a[N], b[N];
char s[N] ,t[N];

bool win(int len, int star){
	int lo= 0, hi=len+1;
	for (int i=	n; i; --i){
		if ( b[i]==1) lo=max(0, lo-1); else
		if ( b[i]==-1) hi=min(len+1, hi+1); 
		
		if ( a[i]==1 ) --hi;	else
		if ( a[i]==-1 ) ++lo;
		#ifdef che
		debug("i=%d, lo=%d, hi=%d, a[]=%d, b[]=%d\n", i, lo, hi,a[i],b[i]);
		#endif
		if ( lo+1==hi) return true;
	}
	if ( star<=lo || star>=hi) return true;
	return false;
}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d%d%d", &h, &w, &n);
	scanf("%d%d",&sr, &sc);
	scanf("%s%s", s+1,t+1);
	for (int i=1; i<=n; ++i){
		if ( s[i]=='L') a[i]=-1;	else
		if ( s[i]=='R') a[i]=1;	else
			a[i]=0;
		if ( t[i]=='L') b[i]=-1;	else
		if ( t[i]=='R') b[i]=1;	else
			b[i]=0;	
	}
	bool ok= win(w, sc);
	
	for (int i=1; i<=n; ++i){
		if ( s[i]=='U') a[i]=-1;	else
		if ( s[i]=='D') a[i]=1;	else
			a[i]=0;
		if ( t[i]=='U') b[i]=-1;	else
		if ( t[i]=='D') b[i]=1;	else
			b[i]=0;	
	}
	ok |= win(h, sr);
	puts(ok ? "NO" : "YES");
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

	int N,K;
	cin>>N>>K;

	string S;
	cin>>S;

	int index = K - 1;

	S[index] = S[index] + 32;

	cout<<S<<endl;	

	return 0;
} 

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

int main(){

  int x=0,i;
  char T[1000],W[11];
  char end[]="END_OF_TEXT";

  scanf("%s",W);

  while(1){
    scanf("%s",T);
    if(strcmp(T,end)==0){
      break;
    }
    if(strcasecmp(T,W)==0){
      x++;
    }
  }
    printf("%d\n",x);
    return 0;
  }
  

Measured memory_bytes: 564
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

class union_find{
  int n_; 
  vector<int> par, rank, size;
public:
  union_find(int n): n_{n} {
    par.resize(n_);
    rank.resize(n_);
    size.resize(n_);

    REP(i, n_){
      par[i] = i;
      rank[i] = 1;
      size[i] = 1;
    }
  } 

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rank[x] > rank[y]){
      par[y] = x;
      size[x] += size[y];
    } else {
      par[x] = y;
      size[y] += size[x];
      if(rank[x] == rank[y]) rank[y]++;
    }
  }

  int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  vector<int> get_par(){ return par; }
};

int main() {
  int n, m; cin >> n >> m;
  vector<int> ip(n), x(m), y(m);
  union_find uf(n);

  REP(i, n){
    int p; cin >> p;
    p--;
    ip[p] = i;
  }

  REP(i, m){
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;

    uf.unite(x[i], y[i]);
  }

  int ans = 0;
  vector<int> par = uf.get_par();
  REP(i, n) {
    if(i == ip[i] || uf.same(i, ip[i])) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<int> ok(n, 1);
  while (m--) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ok[a] &= h[a] > h[b];
    ok[b] &= h[b] > h[a];
  }
  cout << accumulate(ok.begin(), ok.end(), 0);

  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> x(n);
    inc(i, 0, n) cin >> x[i];
    vector<int> xs = x;
    sort(xs.begin(), xs.end());
    int l = xs[n/2-1];
    int r = xs[n/2];
    inc(i, 0, n){
        if(x[i] <= l){
            cout << r << endl;
        }else{
            cout << l << endl;
        }
    }
    return 0;
}


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

for i in range(1, N):
    if H[-i] < H[-i-1]:
        H[-i-1] -= 1

res = 'Yes'
for i in range(N-1):
    if H[i] > H[i+1]:
        res = 'No'

print(res)


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

typedef pair<int,int> II;

const int mod = 1e9+7;

int Pow(int x, int k , int mod) {
	int res = 1;
	while (k) {
		if (k & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		k >>= 1;
	}
	return res;
}
int C(int k, int n) {
	int res = 1;
	for(int i=1;i<=n;i++) {
		res = 1ll * res * i % mod;
	}
	
	for(int i=1;i<=k;i++) {
		res = 1ll * res * Pow(i, mod-2, mod) % mod;
	}
	
	for(int i=1;i<=n-k;i++) {
		res = 1ll * res * Pow(i, mod-2, mod) % mod;
	}
	
	return res;
}

int main() {
	//freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	
	int n , m;
	cin >> n >> m;
	if ((n + m ) % 3) {
		cout << 0;
		return 0;
	}
	
	int total = ( n + m ) / 3;
	int diff = n - m;
	if ((total + diff) % 2) {
		cout << 0;
		return 0;
	}
	
	int b = (total + diff) / 2;
	int a = total - b;
	
	//cerr << a <<" " << b << endl;
	if ((a < 0) || (b < 0)) {
		cout << 0;
		return 0;
	}
	
	cout << C(a, total);
	
	return 0;
}


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

int main(){
	long long int a,b,c;
	cin>>a>>b>>c;
	
	long long int ta,tb,tc;
	
	long long int aa=a;
	long long int bb=b;
	long long int cc=c;
	
	int cnt=0;
	
	while(a%2==0&&b%2==0&&c%2==0){
		cnt++;
		ta=b/2+c/2;
		tb=a/2+c/2;
		tc=a/2+b/2;
		
		a=ta;
		b=tb;
		c=tc;
		
		//cout<<a<<" "<<b<<" "<<c<<endl;
		
		if(a==aa&&b==bb&&c==cc){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	long long int n,d;
	scanf("%lld %lld",&n,&d);
	d = d * d;
	
	long long int ans = 0;
	int i;
	for(i = 0;i < n;++i){
		
		long long int a,b;
		scanf("%lld %lld",&a,&b);
		
		if((a*a + b*b) <= d) ans++;
		
		
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 1704
INF = 10 ** 7
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush

fac = [1,1]
for i in range(2,51):
    fac.append(fac[-1] * i)

def nck(n,k):
    return fac[n]//fac[n - k]//fac[k]

def main():
    n,a,b = map(int,input().split())
    v = list(map(int,input().split()))

    v.sort(reverse=True)
    tot = sum(v[:a])
    cnt = a

    ok = 0
    change = 0
    for i in range(a,n):
        if v[i] * cnt == tot:
            ok += 1
        elif v[i] == v[a - 1]:
            change += 1
    
    same = 1
    for i in range(a - 2,-1,-1):
        if v[i] == v[a - 1]:
            same += 1
    
    ans = 0
    if ok > 0:
        for i in range(same,b - a + same + 1):
            ans += nck(same + ok,i)
    elif change > 0:
        ans += nck(same + change,same)
    else:
        ans += 1

    print(tot/cnt)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#define N 100
#define M 2000000
   
int main()
{
   
  int n,p[N],m[N][N];
  int i,j,k,l,q;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&j);
  }
 
  p[n] = j;;
  for(i=1;i<=n;i++)
    m[i][i] = 0;
   
  for(l=2;l<=n;l++) {
    for(i=1;i<=n-l+1;i++){
       
      j = i + l - 1;
      m[i][j] = M;
       
      for(k=i;k<=j-1;k++) {
        q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
         
        if(m[i][j] > q)
          m[i][j] = q;
      }
    }
  }
  printf("%d\n",m[1][n]);
   
  return 0;
}

Measured memory_bytes: 636
from collections import Counter
n, p = map(int, input().split())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


c = Counter(prime_factorize(p))
ans = 1
for num, cnt in c.items():
    if cnt >= n:
        ans *= num ** (cnt // n)
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>

using ll = long long;

constexpr int MAX_N = 100000;

int N, K;
ll csum_A[MAX_N];

int main(){

	while(true){

		std::cin >> N >> K;

		if(N == 0 && K == 0) break;

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

			ll input;

			std::cin >> input;

			if(i == 0) csum_A[i] = input;
			else csum_A[i] = csum_A[i - 1] + input;
		}

		ll ans = csum_A[K - 1];

		for(int i = 0; i < N - K; ++i){

			ans = std::max(ans, csum_A[i + K] - csum_A[i]);

		}

		std::cout << ans << std::endl;
	}

	return 0;
}



Measured memory_bytes: 3880
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var R = int.Parse(Console.ReadLine());

            if (R < 1200)
            {
                Console.WriteLine("ABC");
            }
            else if (R < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");

            }
        }
    }
}


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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m, k;
	static long mod = 998244353;
	static Boolean[][][] memo;
	static String s;
	static HashSet<Integer> nodes;
	static ArrayList<Integer>[] ad;
	static boolean[] vis, taken;
	static int[] occ, ans;
	static TreeSet<Long> al;
	static long[] val;
	static char[] b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
	  int l=(sc.nextInt()-1)/n;
	  int r=(sc.nextInt())/n;
	  if(r>l)
		  System.out.println("OK");
	  else
		  System.out.println("NG");
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int main() {
  int H, R;
  cin >> H >> R;

  if (H + R > 0) {
    cout << 1 << endl;
  } else if (H + R == 0) {
    cout << 0 << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


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

using namespace std;

int main(void) {
    int N, T;
    cin >> N >> T;
    vector<int> cost(N);
    vector<int> time(N);
    for(int i=0; i<N; i++) {
        cin >> cost.at(i) >> time.at(i);
    }

    int ans = INT32_MAX;
    for(int i=0; i<N; i++) {
        if(time.at(i) <= T) {
            ans = min(ans, cost.at(i));
        }
    }
    if(ans == INT32_MAX) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1e18;

const int N = 400;
ll dp[N][N];
ll sum[N][N];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> sum[i][i];
	for (int len = 2; len <= n; ++len) {
		for (int a = 0; a + len <= n; ++a) {
			int b = a+len-1;
			sum[a][b] = sum[a][a] + sum[a+1][b];
		}
	}
	for (int len = 2; len <= n; ++len) {
		for (int a = 0; a + len <= n; ++a) {
			int b = a + len - 1;
			dp[a][b] = INF;
			for (int i = a; i < b; ++i) {
				dp[a][b] = min(dp[a][b], dp[a][i] + dp[i+1][b]);
			}
			dp[a][b] += sum[a][b];
		}
	}
	cout << dp[0][n-1] << '\n';
}


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

using namespace std;

int main() {
	int n, m;
	while (cin >> n >> m, n + m) {
		vector<int> p(n + 1), tmp;
		for (int i = 0; i < n; ++i) cin >> p[i];
		p[n] = 0;
		for (int i = 0; i <= n; ++i)
			for (int j = i; j <= n; ++j)
				if (p[i] + p[j] <= m) tmp.push_back(p[i] + p[j]);
		sort(tmp.begin(), tmp.end());
		int ans = 0;
		for (int i = 0; i < tmp.size(); ++i)
			ans = max(ans, tmp[i] + *(upper_bound(tmp.begin(), tmp.end(), m - tmp[i]) - 1));
		cout << ans << endl;
	}
		
	return 0;
}


Measured memory_bytes: 6708
parseInt(x) = parse(Int, x);N_MAX = 2 * 10^5;fac = Array{Int}(N_MAX+1);inv = Array{Int}(N_MAX+1);MOD = 10^9 + 7;function COMINIT();fac[1] = 1;for i in 1:N_MAX-1;fac[i+1] = fac[i] * (i+1) % MOD;end;for i in 1:N_MAX;inv[i] = powermod(fac[i], MOD-2, MOD);end;end;function Comb(n, k);if n <= 0 || k < 0;return 0;end;if k > n;return 0;end;if k == 0 || n == k;return 1;end;return ((fac[n] * inv[k]) % MOD * inv[n-k])%MOD;end;function H(n, m);return Comb(n + m, m);end;function main();COMINIT();n,k = parseInt.(split(readline()));m = min(k, n-1);ans = 0;for i in 0:m;ans += (Comb(n,i) * H(n-1-i,i)) % MOD;ans %= MOD;end;println(ans);end;main();

Measured memory_bytes: 154868
l, r = map(int, input().split())
if r - l >= 2018:
    print(0)
else:
    mod_l = l % 2019
    mod_r = r % 2019
    if mod_r > mod_l:
        mod_list = [mod_l + i for i in range(mod_r - mod_l + 1)]
        mod = []
        for i in range(len(mod_list)):
            for j in range(len(mod_list)):
                if i < j:
                    mod.append(mod_list[i] * mod_list[j] % 2019)
        print(min(mod))
    else:
        print(0)

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

int main()
{
  int n, k;
  cin >> n >> k;
  ll ans = 1e18;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  for(int i = 0; i < n-k+1; i++){
    ll t;
    if(abs(v[i]) >= abs(v[i+k-1])){
      t = abs(v[i+k-1])+abs(v[i+k-1]-v[i]);
    }else{
      t = abs(v[i])+abs(v[i+k-1]-v[i]);
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 1272
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL N;
  cin >> N;
  vector<LL> a(N);

  LL sum = 0;

  REP(i,N){
    cin >> a[i];
    sum += a[i];
  }
  //bound
  sum = (sum - 1) / 2 + 1;

  vector<vector<LL>> v(a.size()+1, vector<LL>(100001, 0));
  v[0][0] = 1;

  REP(i,a.size()){
    REP(j,90001){
      v[i + 1][j] += v[i][j]*2;
      v[i + 1][j+a[i]] += v[i][j];
      v[i + 1][j] %= mod;
      v[i + 1][j + a[i]] %= mod;
    }
  }

  LL ans = 1;

  REP(i,a.size()){
    ans *= 3;
    ans %= mod;
  }

  FOR(i,sum,90001){
    ans -= v[a.size()][i] * 3;
    ans %= mod;
    ans += mod;
    ans %= mod;
  }

  vector<vector<LL>> vv(a.size()+1, vector<LL>(100001, 0));
  vv[0][0] = 1;

  REP(i,a.size()){
    REP(j,90001){
      vv[i + 1][j] += vv[i][j];
      vv[i + 1][j+a[i]] += vv[i][j];
      vv[i + 1][j] %= mod;
      vv[i + 1][j + a[i]] %= mod;
    }
  }

  FOR(i,sum,90001){
    ans += vv[a.size()][i] * 3 *2;
    ans %= mod;
    ans += mod;
    ans %= mod;
  }

  LL cnt = 3;

  REP(i,a.size()){
    cnt *= 2;
    cnt %= mod;
  }

  ans -= cnt;
  ans %= mod;
  ans += mod;
  ans %= mod;

  cout << ans << endl;
}


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

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

    sort(a.begin(), a.end(),greater<int>());
    int att = 0;
    rep(i, n) {
        att += a[i];
        if(h <= att) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
//#define scanf scanf_s
typedef long long int lli;

// ITP1_2_D
// 長方形の中に円が含まれるかどうかを判定
int main()
{
	int iInputW, iInputH, iInputX, iInputY, iInputR;

	scanf("%d %d %d %d %d", &iInputW, &iInputH, &iInputX, &iInputY, &iInputR);

	// 左、下、右、上の判定
	if (iInputX - iInputR < 0 || iInputY - iInputR < 0 || iInputX + iInputR >iInputW || iInputY + iInputR > iInputH)
	{
		printf("No\n");
		return 0;
	}

	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(void){
  int x, y;
  cin >> x >> y;

  if(x == 2) ;
  else if(x == 4 || x == 6 || x == 9 || x == 11) x = 1;
  else x = 0;
  if(y == 2) ;
  else if(y == 4 || y == 6 || y == 9 || y == 11) y = 1;
  else y = 0;

  if(x == y) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    ll X;
    cin>>X;
    ll sho = X / 100;
    ll amari = X % 100;
    ll maxx = sho * 5;
    if(amari <= maxx){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256