akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define a first
#define b second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
int n,v[N];Pii s[N];
struct Frac{
	ll a,b;// a/b
	Frac(ll A=0,ll B=1){a=A;b=B;}
}ans;
ll gcd(ll a, ll b){return !b?a:gcd(b,a%b);}
inline Frac Norm(Frac y){
	ll g=gcd(y.a,y.b);y.a/=g;y.b/=g;return y;
}
inline void upd(Frac &x, Frac y){
	y=Norm(y);if(1.0*x.a/x.b>1.0*y.a/y.b)x=y;
}
bool cmp(Pii x, Pii y){return x.a+max(x.b-x.a,0)<y.a+max(y.b-y.a,0);}
bool ck(int k){
	ll tot=0;rep(i,1,n)tot+=max(s[i].b-s[i].a,0);
	rep(i,1,k)tot-=v[i];return tot>=0;
}
int main() {
	read(n);rep(i,1,n)read(s[i].a),read(s[i].b);
	sort(s+1,s+n+1,cmp);
	rep(i,1,n)v[i]=s[i].a+max(s[i].b-s[i].a,0);
	/*int L=0,R=n;
	while(L<R){
		int mid=(L+R+1)>>1;
		if(ck(mid))L=mid;else R=mid-1;
	}
	int k=L;*/
	int k=0;ll tot=0;rep(i,1,n)tot+=max(s[i].b-s[i].a,0);
	while(tot-v[k+1]>=0)k++,tot-=v[k];
	assert(k<n);
	ll ori=0;rep(i,1,n)ori+=max(s[i].b-s[i].a,0);
	rep(i,1,k)ori-=v[i];
	ans.a=1;ans.b=1;
	rep(i,1,n){
		ll tot=ori;
		if(i<=k)tot=tot+s[i].a-v[k+1];else tot-=max(s[i].b-s[i].a,0);
		upd(ans,(Frac){s[i].a-tot,s[i].b});
	//	printf("%d %lld %lld\n",i,s[i].a-tot,s[i].b);
	}
	ll x=ans.a,y=ans.b;
//	printf("%d %lld %lld\n",k,x,y);
	ans=(Frac){y-x+y*k,n*y};ans=Norm(ans);
	printf("%lld %lld\n",ans.a,ans.b);
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(){
    int a,b,plus,minus,into;
scanf("%d %d",&a,&b);
plus=a+b;
minus=a-b;
into=a*b;
if(plus>minus&&plus>into){printf("%d",plus);}

else if(minus>plus&&minus>into){printf("%d",minus);}

else if(into>plus&&into>minus){printf("%d",into);}
else printf("%d",minus);

return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Rain Flows into Dams
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

bool check(int n, int x0) {
  int x = x0;
  for (int i = 0; i + 1 < n; i++)
    x = as[i] - x;
  return (x0 + x >= as[n - 1]);
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  int x0 = -1, x1 = as[0];
  while (x0 + 1 < x1) {
    int x = (x0 + x1) / 2;
    if (check(n, x)) x1 = x;
    else x0 = x;
  }
  //printf("x1=%d\n", x1);

  printf("%d", x1 * 2);
  for (int i = 0, x = x1; i + 1 < n; i++) {
    x = as[i] - x;
    printf(" %d", x * 2);
  }
  putchar('\n');
  return 0;
}


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

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

  vector<int> a(N+2);
  for (int i = 1; i < N+1; i++) {
      cin >> a.at(i);
  }

  vector<int> data1(N+2);
  vector<int> data2(N+2);

  data1.at(0) = 0;
  data2.at(N+1) = 0;
  
  for (int i = 1; i < N+1; i++) {
      data1.at(i) = __gcd(a.at(i),data1.at(i-1));
  }

  for (int i = N; i >= 1; i--) {
      data2.at(i) = __gcd(a.at(i),data2.at(i+1));
  }

  int ans = 0;

  for (int i = 1; i <= N; i++) {
      int g = __gcd(data1.at(i-1),data2.at(i+1));
      ans = max(ans,g);
  }

  cout << ans << endl;

}


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

int main() {
	int N, X, m, min = 1000, count = 0;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> m;
		count += m;
		if (min > m) min = m;
	}
	cout << N + (X - count) / min << endl;
}

Measured memory_bytes: 764
R, G, B, N = map(int, input().split())
MAX_R = N // R + 1
MAX_G = N // G + 1
ans = 0
for i in range(MAX_R):
    for j in range(MAX_G):
        b_cnt = N - R * i - G * j
        if b_cnt >= 0 and b_cnt % B == 0:
            ans += 1

print(ans)


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for(int i = 0; i < M; i++) {
    cin >> p.at(i);
    cin >> S.at(i);
  }
  int W = 0;
  int A = 0;
  vector<int> w(N, 0), a(N, 0);
  for(int i = 0; i < M; i++) {
    if(S.at(i) == "WA" && a.at(p.at(i) - 1) == 0) {
      w.at(p.at(i) - 1)++;
    }
    else if(S.at(i) == "AC") {
      a.at(p.at(i) - 1)++;
    }
  }
  for(int i = 0; i < N; i++) {
    if(a.at(i) == 0) w.at(i) = 0;
    else if(a.at(i) != 0) A++;
    W += w.at(i);
  }
  cout << A << " " << W << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 100005, M = 100005, mod = 1000000007, mxLog = 20;
vector<int> adj[N];
int memo[N][2];

int solve(int u, int par, int par_color) {
    if (adj[u].size() == 0 || adj[u].size() == 1 && par != -1) {
        return 1 + par_color;
    }
    int &ret = memo[u][par_color];
    if (~ret)
        return ret;
    ret = 0;
    if (par_color) {
        long long x = 1;
        for (int v : adj[u]) {
            if (v == par)
                continue;
            x *= 1LL * solve(v, u, 1);
            x %= mod;
        }
        ret += x;
        x = 1;
        for (int v : adj[u]) {
            if (v == par)
                continue;
            x *= 1LL * solve(v, u, 0);
            x %= mod;
        }
        ret += x;
        ret %= mod;
    } else {
        long long x = 1;
        for (int v : adj[u]) {
            if (v == par)
                continue;
            x *= 1LL * solve(v, u, 1);
            x %= mod;
        }
        ret += x;
    }
    return ret;
}



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    int u, v;
    for (int i = 1; i < n; ++i) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset(memo, -1, sizeof memo);
    cout << solve(1, -1, 1) << '\n';


    return 0;
}

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

int main(){
	long long int x;
	long long int k,d;
	cin >> x>>k>>d;
	if(x<0)x=-1*x;
	long long int a = x/d;
	if(a<k && -1*a<k){
	x = x - a*d;
	k = k-a;
	}
	else{
		if(x>0)cout << x-k*d<< endl; 
		else cout << x+k*d <<endl;
		return 0;
	}
	if(k%2==0)cout << x<<endl;
	else cout << abs(x-d)<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//127 B
int main(void) {
	int r, d, x;
	cin >> r >> d >> x;
	rep(0, 10) {
		x = r * x - d;
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  //using namespace std;
  cpp_int x, k, d;
  cin>>x>>k>>d;
  cpp_int r = (x % d + d) % d;
  cpp_int ans = (long long)INF;
  cpp_int q;
  q = (x - r) / d;
  cpp_int cnt;
  cnt = k - abs(q);
  if(cnt >= 0 && cnt % 2 == 0) ans = min(ans, r);
  q = (x - (r - d)) / d;
  cnt = k - abs(q);
  if(cnt >= 0 && cnt % 2 == 0) ans = min(ans, d - r);
  cpp_int temp = abs(x + k * d);
  ans = min(ans, temp);
  temp = abs(x - k * d);
  ans = min(ans, temp);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3796
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

int k;

int num(State& begin) {
	int geko = 0;
	while (*begin >= '0' && *begin <= '9') {
		geko *= 10;
		geko += *begin - '0';
		begin++;
	}
	if (geko == 0) geko = 1;
	return geko;
}

string solve(State& begin) {
	string ans;
	while (*begin != ')') {
		int now = num(begin);
		if (*begin == '(') {
			begin++;
			string b = solve(begin);
			REP(q, now) {
				ans += b;
				if (ans.length() >= k) break;
			}
		}
		else {
			REP(q, now) {
				ans.push_back(*begin);
			}
			begin++;
		}
		while (ans.length() > k) {
			ans.pop_back();
		}
	}
	begin++;
	return ans;
}

void solve(){
	while(true){
		string s;
		cin >> s;
		if (s == "0") return;
		s.push_back(')');
		cin >> k;
		k++;
		State begin = s.begin();
		string ans = "0" + solve(begin);
		if (ans.size() - 1 >= k) {
			cout << ans[k] << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 8632
input_list = list(map(int, input().split(' ')))
a, b, c, x, y = input_list

total = 0
if a + b > 2 * c:
    total += 2 * c * min(x, y)
else:
    total += (a + b) * min(x, y)

if x == y:
    pass
elif x > y:
    if a > 2 * c:
        total += 2 * c * (x - y)
    else:
        total += a * (x - y)
else:
    if b > 2 * c:
        total += 2 * c * (y - x)
    else:
        total += b * (y - x)

print(total)


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

    bool ans = true;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % 2 != 0) { continue; }
        if (a % 3 != 0 && a % 5 != 0) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    A.sort()
    acc = list(accumulate(A))
    
    ans = N
    for i in range(N - 2, -1, -1):
        if 2 * acc[i] < A[i + 1]:
            ans -= i + 1
            break
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 59632
#include <bits/stdc++.h>
         
using namespace std;
 
#define ll  long long
#define mod 1000000007
#define pb push_back
#define pie 3.141592653589
#define inf 1e9

ll dt;


ll dfs(vector< vector<ll> > &g,ll i,vector<ll> &dp)
{
   if(dp[i]>-1)
   return dp[i];

   if(g[i].size()==0)
   {
    return 0;
   }
   for(auto j : g[i])
   {
        if(dp[j]==-1)
        dp[j]=dfs(g,j,dp)+1;
    
   }
   ll mx=0;
   for(auto j : g[i])
   {
     mx=max(mx,dp[j]);
   }
   return mx;
}

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



    ll i,n,n2,m,t,j,l,r,pos,mpos,f=0,k,p,n1,z,q,x,y,x1,y1,x2,y2,x3,y3,x4,y4,w;

    cin>>n>>m;
    vector< vector<ll> >g(n);
    set<ll> st;
    vector<ll> dp(n,-1);
    for(i=0;i<n;i++)
    {
        st.insert(i);
    }
    while(m--)
    {
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
        if(st.find(y)!=st.end())
        {
            st.erase(y);
        }
    }
    ll mx=0;
    for(auto i : st)
    {
        
        dp[i]=dfs(g,i,dp);
        mx=max(dp[i],mx);
    }
    
    cout<<mx;
   
  return 0;
}

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

#define ABS(X) (((X)>=0)?(X):(-(X)))

typedef long long ll;

int main () {
	int X, N;
	vector <pair <int,int> > v;
	cin >> X >> N;
	if (N==0) {
		cout << X << endl;
		return 0;
	}
	for (int i=0; i<N; i++) {
		int tmp;
		cin >> tmp;
		v.push_back (make_pair (ABS(X-tmp), tmp-X));
	}
	sort (v.begin(), v.end());
	if (v[0].first != 0) {
		cout << X << endl;
		return 0;
	}
	for (int i=1; i<N/2.0; i++) {
		if (v[2*i-1].second != -i) {
			cout << X-i << endl;
			return 0;
		}
		if (v[2*i].second != i) {
			cout << X+i << endl;
			return 0;
		}
	}
	if (N%2==0) {
		if (v[N-1].second != -N/2) {
			cout << X - N/2 << endl;
		} else {
			cout << X + N/2 << endl;
		}
	} else {
		cout << X - N/2 - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
nums = []
total = 0
for num in a:
    total += num
    nums.append(total)
minVal = 10 ** 9 * 2 + 1
for i in range(n - 1):
    sub = total - nums[i]
    minVal = min(abs(sub - nums[i]), minVal)
print(minVal)

Measured memory_bytes: 30592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string s;
  for(int i=0 ; i<n ; i++){
    cin >> s;
    if (s == "Y"){
      cout << "Four" << endl;
      break;
    }
  }
  if (s != "Y"){
    cout << "Three" << endl;
  }
}

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

int		main(void)
{
	string	a;	cin >> a;//1100
	int		cnt = 0;
	char	tmp = a.at(0);
	for (auto &i : a)
	{
		if (tmp == i || cnt >= 3)
			cnt++;
		else
			cnt = 1;
		tmp = i;
	}
	cout << (cnt >= 3 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
 int b;
char a[10];
//1000≦N≦9999
 b= scanf("%s",a);
 if (b<0){
  printf("Error");
  return 0;
}

if (( a[1]==a[0] || a[2]==a[3])  && a[1]==a[2]  ){
  printf("Yes");
 }
else{
printf("No");
}
 return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;

const int maxn=105;
int n, a[maxn], ans;

int main(){
    scanf("%d", &n);
    for (int i=0; i<n; ++i) scanf("%d", &a[i]);
    for (int i=1; i<n; ++i)
        if (a[i]==a[i-1]) a[i]=0, ++ans;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
const int MAXN = 205;
const int NOPE = -1;
int A[MAXN][MAXN];
int C[MAXN];
char S[MAXN];
int N;

bool dfs(int cur) {
    for (int nxt = 1; nxt <= N; ++nxt) {
        if (cur == nxt) continue;
        if (A[cur][nxt] == MAXN) continue;
        if (C[nxt] == C[cur]) return false;
        if (C[nxt] != NOPE) continue;

        C[nxt] = C[cur] ^ 1;
        if (!dfs(nxt)) return false;
    }
    return true;
}

void floyd_warshall() {
    for (int k = 1; k <= N; ++k) {
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N; ++j) {
                A[i][j] = std::min(A[i][k] + A[k][j], A[i][j]);
            }
        }
    }
}

int solve(int src) {
    C[src] = 0;
    if (!dfs(src)) {
        return NOPE;
    }
    floyd_warshall();
    int ret = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            ret = std::max(A[i][j], ret);
        }
    }
    return ret + 1;
}

void init() {
    for (int i = 1; i <= N; ++i) C[i] = NOPE;
}

int main() {
    scanf("%d", &N);
    init();
    for (int i = 1; i <= N; ++i) {
        scanf("%s", S+1);
        for (int j = 1; j <= N; ++j) {
            if (i == j) {
                A[i][j] = 0;
            } else if (S[j] - '0') {
                A[i][j] = 1;
            } else {
                A[i][j] = MAXN;
            }
        }
    }
    printf("%d\n", solve(1));
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){

    int i, x, y, z;

    i = 1;

    while (1) {
    	scanf("%d %d", &x, &y);
    	if ((x == 0) && (y == 0)) {
    		break;
    	} else {
    		if (x > y) {
    			z = x;
    			x = y;
    			y = z;
    		}
    		printf("%d %d\n", x, y);
    	}
    	i = i + 1;
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll H,W,ans=INF;
  cin >> H >> W;
  if((H*W)%3==0){
    cout << 0 << endl;
    return 0;
  }
  rep(i,H){
    ll A,B,C;
    A=W*(i+1);
    if(W%2==0){
      B=(W/2)*(H-i-1);
      C=(W/2)*(H-i-1);
    }else{
      B=(W/2)*(H-i-1);
      C=(W/2+1)*(H-i-1);
    }
    ans=min(ans,max(abs(A-B),max(abs(B-C),abs(C-A))));
  }
  rep(i,W){
    ll A,B,C;
    A=H*(i+1);
    if(H%2==0){
      B=(H/2)*(W-i-1);
      C=(H/2)*(W-i-1);
    }else{
      B=(H/2)*(W-i-1);
      C=(H/2+1)*(W-i-1);
    }
    ans=min(ans,max(abs(A-B),max(abs(B-C),abs(C-A))));
  }
  ans=min(ans,min(H,W));
  cout << ans << endl;
  
}

Measured memory_bytes: 3620
import Control.Monad

main = do
  [n, d] <- map read . words <$> getLine :: IO [Int]
  xys <- replicateM n $ map read . words <$> getLine :: IO [[Double]]
  print . length . filter (d >=) $ [(ceiling . sqrt) (x ^ 2 + y ^ 2) | (x : y : []) <- xys]


Measured memory_bytes: 165564
import math

n, k = map(int, input().split(" "))

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

abL = sorted(abL, key=lambda x: x[0])

cnt = 0
for a, b in abL:
    cnt += b
    if cnt >= k:
        print(a)
        exit()


Measured memory_bytes: 29360
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

string arc071a()
{
  size_t n;
  cin >> n;
  vector<string> a(n);
  cin >> a;

  const size_t inf = numeric_limits<size_t>::max();
  array<size_t, 26> val;
  val.fill(inf);

  for(const auto & w: a)
  {
    array<size_t, 26> cnt;
    cnt.fill(0);
    for(const auto i: w)
      ++ cnt[i - 'a'];

    for(size_t i = 0; i < 26; ++i)
      val[i] = min(val[i], cnt[i]);
  }

  string out;
  for(size_t i = 0; i < 26; ++i)
    out += string(val[i], 'a' + i);

  return out;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << arc071a();

  return EXIT_SUCCESS;
}



Measured memory_bytes: 256
N, K = raw_input().split()
D = raw_input().split()
candi = [str(i) for i in xrange(10)]
for d in D:
    candi.remove(d)

def decide(i):
    if i >= len(N):
        return ''
    for c in candi:
        if N[i] == c:
            return c + decide(i+1)
        elif N[i] < c:
            return c + candi[0] * (len(N) - i - 1)

if candi[-1] * len(N) >= N:
    print decide(0)
else:
    print (candi[0] if candi[0] != '0' else candi[1]) + candi[0] * len(N)

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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
  int a=in(),b=in(),c=in();
  if ((a-c)*(b-c)<0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e18;
 
typedef long long ll;
typedef long double ld;  
using u128 = __uint128_t;

void test_case()
{
    ll n,i,j;
    cin >> n;
    if(n == 1)
    {
        cout << 0 <<'\n';
        return ;
    }
    set<pair<ll,ll>> s;
    ll zz = n;
    ll res = 0;
    if(n%2 == 0)
    {
        s.insert({2,2});
        while(n%2==0)
            n/=2;
    }
    for(i = 3; i*i <= n; i+=2)
    {
        if(n%i == 0)
        {
            s.insert({i,i});
            while(n%i==0)
                n/=i;
        }
    }
    if(n > 1)
    {
        s.insert({n,n});
    }
    n = zz;
    while(n >= (*s.begin()).F)
    {
        auto it = s.begin();
        ll x = (*it).F, y = (*it).S;
        if(n % x == 0)
        {
            res ++;
            n /= x;
        }
        ll z = x * y;
        s.insert({z, y}); 
        s.erase(it); 
    }
    cout << res << '\n';
    
}

int32_t main()
{
    IOS(); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

class Main {
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a >= 0 && a <= 100){
if (b >= 0 && b <= 100){
if (c >= 0 && c <= 100){
if (a < b && b < c){
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
}
}
}


Measured memory_bytes: 26008
def check(numbers, count):
  if all([num % 2 == 0 for num in numbers]):
    numbers = [num / 2 for num in numbers]
    count += 1
    count = check(numbers, count)
  return count

length = input('')
numbers = [int(num) for num in (input('')).split()]
count = check(numbers, 0)
print(count)

Measured memory_bytes: 3188
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, A, B] = string_to_int(inputs[0])

    total_sum = 0
    for i in range(1, N+1):
        sum_num = reduce(lambda acc, x: acc + int(x), str(i), 0)
        if sum_num >= A and sum_num <= B:
            total_sum += i
    return total_sum


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3812
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n, k;
	cin >> n >> k;
	int x[50], y[50];
	long long int sortedx[50], sortedy[50];
	long long int ans = (long long int)4 * MOD * MOD;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		sortedx[i] = x[i];
		sortedy[i] = y[i];
	}
	sort(sortedx, sortedx + n);
	sort(sortedy, sortedy + n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int p = 0; p < n; p++) {
				for (int q = p + 1; q < n; q++) {
					int cnt = 0;
					for (int r = 0; r < n; r++) {
						if (sortedx[i] <= x[r] && x[r] <= sortedx[j] &&
						    sortedy[p] <= y[r] && y[r] <= sortedy[q])
							cnt++;
					}
					if (cnt >= k) {
						ans = min(ans, (sortedx[j] - sortedx[i]) *
						                   (sortedy[q] - sortedy[p]));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC103 C - Modulo Summation
// 2020.06.12

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  ll ans = 0;
  REPLL(i, N){
    ll a; cin >> a; a--;
    ans += a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	string s,t;
	cin >> s >> t;
	int ans = 0;
	REP(i,s.size()){
		if(s[i] != t[i])++ans;
	}
	out(ans);
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int a[85][85];
int b[85][85];




int main(){

int h,w;
cin>>h>>w;

rep2(i,h){
    rep2(k,w){
        cin>>a[i][k];
    }
}

rep2(i,h){
    rep2(k,w){
        cin>>b[i][k];
    }
}
long long size=2*80*160+1;
bool dp[size][h+1][w+1];

rep(i,size)rep2(y,h)rep2(x,w)dp[i][y][x]=false;

dp[abs(a[1][1]-b[1][1])][1][1]=true;
rep2(y,h){
    rep2(x,w){
        
        for(int i=0;i<size;i++){
                if(!dp[i][y][x])continue;
                
               if(x+1<=w){
                   int   p=abs(a[y][x+1]-b[y][x+1]);
                   dp[abs(i-p)][y][x+1]=true;
                   dp[i+p][y][x+1]=true;
                   
               }
               if(y+1<=h){
                   int  p=abs(a[y+1][x]-b[y+1][x]);
                   dp[abs(i-p)][y+1][x]=true;
                   dp[i+p][y+1][x]=true;
               }        
        }
    }
}
    


for(int i=0;i<size;i++){
    if(dp[i][h][w]){
        cout<<i<<endl;
        break;
    }
}

 return 0;
}
/*

*/


Measured memory_bytes: 164352
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	l := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
	for i := n; i > 0; i-- {
		seed := make([]string, i)
		for j := 0; j < i; j++ {
			seed[j] = "a"
		}
		a(1, n, seed, l, false)
	}
}
func a(mx int, n int, seed []string, l []string, f bool) {
	if len(seed) == n {
		fmt.Println(strings.Join(seed, ""))
	} else {
		if f {
			for i := 0; i < mx; i++ {
				a(larger(i+1, mx), n, append(seed, l[i]), l, true)
			}
			a(mx+1, n, append(seed, l[mx]), l, true)
		} else {
			for i := 1; i < mx; i++ {
				a(larger(i+1, mx), n, append(seed, l[i]), l, true)
			}
			a(mx+1, n, append(seed, l[mx]), l, true)
		}

	}
}
func larger(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}


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

int main(){
	int n,l;
    cin>>n>>l;
    
    vector<string> s(n);
    for (int i=0;i<n;i++){
    	cin>>s.at(i);
    }
    
    sort(s.begin(),s.end());
    
    for (int i=0;i<n;i++){
    	cout<<s.at(i);
    }
  cout<<endl;
}
     

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

using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX];
    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
        std::cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    std::cout << maxv << std::endl;

    return 0;
}


Measured memory_bytes: 3884
#include <iostream>
using namespace std;
int main() 
{
	long r,d,x[15],i;
  	cin >> r >> d >> x[0];
 
	for(i=0;i<11;i++){
		x[i+1]=r*x[i]-d;
	}

	for(i=1;i<11;i++){
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string a,b;
int main()
{
	cin>>a>>b;
	for(register int i=0;i<min(a.size(),b.size());++i) cout<<a[i]<<b[i];
	if(a.size()>b.size()) putchar(a[a.size()-1]);
	if(a.size()<b.size()) putchar(b[b.size()-1]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1;
    while(t--){
        int x; cin>>x;
        int val=x/200;
        cout<<10-val<<endl;
    }

}


Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a[101010], b[101010], d[101010];

int main(){
	cin >> n;
	for(int i = 0; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		cnt += min(b[i], a[i]+a[i+1]);
		a[i+1] -= max((i64)0, b[i] - a[i]);
		if(a[i+1] < 0) a[i+1] = 0;
	}
	cout << cnt << endl;
	
	return 0;
}

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

int main()
{
    int n,k,x,y;
    int result;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(n>k){
        int i=n-k;
        result=i*y+k*x;
        printf("%d",result);
    }else{
        result=n*x;
        printf("%d",result);
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int N,L;

  scanf("%d",&N); scanf("%d",&L);

 if(L>=0)
  printf("%d",(N-1)*(2*L+N)/2);
else if(L+N>=2)
  printf("%d",N*(2*L+N-1)/2);
else
  printf("%d",(N-1)*(2*L+N-2)/2);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  
  int n;
  cin >> n;
  
  vector<int> a(n,0);
  rep(i,n-1) {
  int x;
  cin >> x;
  a[x-1]++;
  }
  
  rep(i,n) {
  cout << a[i] << endl;
  }
  
}


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

int main () {
    int N; cin >> N;
    bool will_approve = true;
    for (int i = 0; i < N; i++) {
        int A; cin >> A;
        if (A % 2 == 0) {
            if (A % 3 == 0 || A % 5 == 0) {
                continue;
            } else {
                will_approve = false;
                break;
            }
        }
    }
    if (will_approve) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#include <functional>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vi a(Q), b(Q), c(Q), d(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i]; --b[i];
    }

    vector<vector<vector<int>>> comb(N + 1, vvi());
    for (int i = 1; i <= 1; i++) {
        comb[1].push_back({ i });
    }
    for (int i = 1; i < N; i++) {
        for (auto& v : comb[i]) {
            // 単調増加なので、末尾の値以上であるものを全て試す
            int b = v.back();
            for (int a = b; a <= M; a++) {
                auto v2 = v;
                v2.push_back(a);
                comb[i + 1].push_back(v2);
            }
        }
    }
    
        int ans = 0;
        for (auto& v : comb[N]) {
            int res = 0;
            for (int i = 0; i < Q; i++) if (v[b[i]] - v[a[i]] == c[i]) res += d[i];
            ans = max(ans, res);
        }

        cout << ans << endl;
}



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

int main() {
	int a, b;
	cin >> a >> b;
	if ((a == 2 && b == 1)|| (a==13&&b==1)) {
		cout << "Bob";
	}
	else if ((b == 2 && a == 1)||(b == 13 && a == 1)) {
		cout << "Alice";
	}
	else if (a > b) {
		cout << "Alice";
	}
	else if (b > a) {
		cout << "Bob";
	}
	else {
		cout << "Draw";
	}
}

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

using namespace std;

int main() {
	int banyak, angka, ganjil[100010], genap[100010];
	scanf("%d", &banyak);
	memset(ganjil, 0, sizeof ganjil);
	memset(genap, 0, sizeof genap);
	vector<pair<int, int> > daftar;
	pair<int, int> pganjil1, pganjil2, pgenap1, pgenap2;
	for (int i = 0; i < banyak; i++) {
		scanf("%d", &angka);
		if (i % 2 == 0)
			genap[angka]++;
		else
			ganjil[angka]++;
	}
	for (int i = 1; i < 100001; i++)
		daftar.push_back(make_pair(ganjil[i], i));
	sort(daftar.rbegin(), daftar.rend());
	pganjil1 = daftar[0];
	pganjil2 = daftar[1];
	daftar.clear();
	for (int i = 1; i < 100001; i++)
		daftar.push_back(make_pair(genap[i], i));
	sort(daftar.rbegin(), daftar.rend());
	pgenap1 = daftar[0];
	pgenap2 = daftar[1];
	angka = pganjil1.first + pgenap1.first;
	if (pganjil1.second == pgenap1.second)
		angka = max(pganjil1.first + pgenap2.first, pganjil2.first + pgenap1.first);
	banyak -= angka;
	printf("%d\n", banyak);
	return 0;
}

Measured memory_bytes: 2296
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <functional>
#include <climits>
 
using namespace std;

int main() {
    int a,b,m;
    cin>>a>>b>>m;
    vector<int> as, bs;
    int mina=INT_MAX, minb=INT_MAX;
    for (int i=0;i<a;++i){
        int x;
        cin>>x;
        as.push_back(x);
        mina=min(mina,x);
    }
    for (int i=0;i<b;++i){
        int x;
        cin>>x;
        bs.push_back(x);
        minb=min(minb,x);
    }
    int mprice = mina+minb;
    for (int i=0;i<m;++i){
        int x,y,c;
        cin>>x>>y>>c;
        --x;
        --y;
        int price=as[x]+bs[y]-c;
        if (price>=0){
            mprice=min(mprice,price);
        }
    }
    cout<<mprice;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a) cout<<k;
  else if(k<=a+b) cout<<a;
  else
  {
    cout<<2*a-k+b;
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include<cmath>
int main() {
    long long int  x;
    std::cin>>x;
    long long int m=100;
    long long int i=0;
    while(x>m){
        m=floor(m*1.01);
        i++;
    }
    std::cout<<i<<'\n';

    return 0;
}


Measured memory_bytes: 3744
import sys
from math import floor, sqrt

def prime_nums(n):
    sieve = set(range(2, n + 1))
    non_prime = set(range(2 * 2, n + 1, 2))
    sieve -= non_prime
    for i in range(3, floor(sqrt(n)) + 1, 2):
        if i in sieve:
            non_prime = set(range(i * 2, n + 1, i))
            sieve -= non_prime
    return sieve

p = prime_nums(10**5)

cnt = [None] * (10**5+1)
cnt[0] = 0
for i in range(1, 10**5+1, 2):
    if i in p and (i + 1) // 2 in p:
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
    cnt[i+1] = cnt[i]

q = int(sys.stdin.readline().rstrip())
lr = zip(*[map(int, sys.stdin.read().split())] * 2)

def main():
    for l, r in lr:
        yield cnt[r] - cnt[l-1]
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 26388
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;

struct Card { char suit[2]; int value; };

#define INFTY 2000000000

void merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  Card L[n1+1], R[n2+1];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1].value = INFTY;
  R[n2].value = INFTY;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].value <= R[j].value) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(Card A[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(Card A[], int p, int r) {
  int x = A[r].value;
  int i = p-1;
  for (int j = p; j < r; j++) {
    if (A[j].value <= x) {
      i = i+1;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i+1;
}

void quickSort(Card A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

int main() {
	int n;
  scanf("%d", &n);
  Card A[n], B[n];
  for ( int i = 0; i < n; i++ ) scanf("%s %d", &A[i].suit, &A[i].value);
  for ( int i = 0; i < n; i++ ) B[i] = A[i];

  quickSort(A, 0, n-1);
  mergeSort(B, 0, n);
  bool b = true;
  for ( int i = 0; i < n; i++ ) {
    if (strcmp(A[i].suit, B[i].suit) != 0) b = false;
  }
  if (b) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }
  for ( int i = 0; i < n; i++ ) printf("%s %d\n", A[i].suit, A[i].value);

  return 0;
}



Measured memory_bytes: 4924
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  cout << fixed << setprecision(10);
  priority_queue<double, vector<double>, greater<double>> q;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    q.push(a * 1.0);
  }
  while (q.size() > 1) {
    double tp1 = q.top();
    q.pop();
    double tp2 = q.top();
    q.pop();
    double ans = tp1 + tp2;
    q.push(ans/2);
  }
  cout << q.top() << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 3736
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt();
        System.out.println(Math.min(a%3, Math.min(b%3, (a+b)%3))==0?"Possible":"Impossible");
    }

}

Measured memory_bytes: 21716
n = int(input())
a = [int(input()) for _ in range(n)]
x = {0}
now = 0
cnt = 0
while True:
    now = a[now] - 1
    cnt += 1
    if now == 1:
        print(cnt)
        break
    if now in x:
        print(-1)
        break
    x.add(now)


Measured memory_bytes: 16008
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N, M, L;
vector<VPII> g;
vector<VPII> d;


signed main(){
    cin >> N >> M >> L;
    g.resize(N);
    d.resize(N);
    for_each(ALL(d), [](auto& di){ di.resize(N); });
    rep(i, 0, M){
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        g[A].eb(B, C);
        g[B].eb(A, C);
    }

    for_each(ALL(d), [](auto& di){ fill(ALL(di), make_pair(INF, INF)); });

    rep(i, 0, N){
        PQ<TIII, greater> pq;
        pq.emplace(0, 0, i);
        d[i][i] = { 0, 0 };
        while(!pq.empty()){
            int c, l, v;
            tie(c, l, v) = pq.top();
            pq.pop();
            if(make_pair(c, l) > d[i][v]) continue;
            for(auto& e : g[v]){
                if(v == e.first) continue;
                if(e.second > L) continue;
                PII p;
                if(l+e.second > L) p = { c+1, e.second };
                else p = { c, l+e.second };
                if(chmin(d[i][e.first], p)) pq.emplace(p.first, p.second, e.first);
            }
        }
    }

    int Q;
    cin >> Q;
    rep(i, 0, Q){
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if(d[s][t].first == INF) cout << -1 << endl;
        else cout << d[s][t].first << endl;
    }

    return 0;
}

Measured memory_bytes: 5672