akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  int Max = 24*3600+59*60+59;
  while(cin >> n,n){
    vector<int> v(Max+1,0);
    string s1,s2;
    rep(i,n){
     cin >> s1 >> s2;
     int sum1=0,sum2=0;
     for(int j=0; j<s1.size(); j+=3){
      if(j==0){
        sum1 += atoi(s1.substr(j,2).c_str())*3600;
        sum2 += atoi(s2.substr(j,2).c_str())*3600;
      }
      if(j==3){
        sum1 += atoi(s1.substr(j,2).c_str())*60;
        sum2 += atoi(s2.substr(j,2).c_str())*60;
      }
      if(j==6){
        sum1 += atoi(s1.substr(j,2).c_str());
        sum2 += atoi(s2.substr(j,2).c_str());
      }
     }
     v[sum1]++; v[sum2]--;
    }
    int ans = 0;
    rep(i,Max){
      v[i+1] += v[i];
      ans = max(ans,v[i+1]);
    }
    cout << ans << endl;
  }
  return 0;
}




Measured memory_bytes: 3416
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll INF = (ll)1e18;
const int S = (1 << 17) + 33;
const int N = 18;
ll a[S][3];
ll dp[S][N][N];
int n;
ll b[N];

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

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &b[i]);
/*
	n = 18;
	for (int i = 0; i < n; i++)
		b[i] = rng() % (int)1e9;
*/	
	a[1][0] = a[1][1] = 1;
	a[1][2] = n - 2;
	for (int i = 1; a[i][2] > 0; i++) {
		a[2 * i][0] = a[i][0];
		a[2 * i][1] = a[i][0] + a[i][1];
		a[2 * i][2] = a[i][2] - 1;
		a[2 * i + 1][0] = a[i][0] + a[i][1];
		a[2 * i + 1][1] = a[i][1];
		a[2 * i + 1][2] = a[i][2] - 1;
	}
	for (int id = (1 << (n - 1)) - 1; id > 0; id--)
		for (int l = 0; l < n; l++) {
			for (int r = l + 1; r < n && r <= l + 1 + a[id][2]; r++) {
				dp[id][l][r] = INF;
				if (r == l + 1) {
					dp[id][l][r] = 0;
					continue;
				}
				ll x = a[id][0] + a[id][1];
				for (int m = l + 1; m < r; m++) {
					ll w = b[m] * x + dp[2 * id][l][m] + dp[2 * id + 1][m][r];
					dp[id][l][r] = min(dp[id][l][r], w);
				}
			}
		}
	printf("%lld\n", dp[1][0][n - 1] + b[0] + b[n - 1]);

	return 0;
}


Measured memory_bytes: 335232
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,m;
  cin >> n >> m;
  vector<vector<LL>> vs(m);
  for(auto &s:vs) {
    LL k;
    cin >> k;
    s.resize(k);
    for(auto &x:s) {
      cin >> x;
      --x;
    }
  }
  vector<LL> p(m);
  for(auto &x:p) cin >> x;
  LL answer = 0;
  REP(i,(1<<n)) {
    bool flag = true;
    REP(j,m) {
      LL cnt = 0;
      for(auto x:vs[j]) if((1<<x) & i) ++cnt;
      if(cnt%2 != p[j]) flag = false;
    }
    if(flag) ++answer;
  }
  cout << answer << endl;
  return 0;
}


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

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


Measured memory_bytes: 640
#include<iostream>

using namespace std;
int main(){
    int a,b,c;
    while(cin>>a>>b>>c){
        double co=0;
        for(int i=1;i<11;i++){
            if(i==a||i==b||i==c)continue;
            if(i+a+b>20)break;
            co++;
        }
        if(co/7<0.5)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}

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

using namespace std;

int A[2000];
int n, q, m;
int t=0;

bool solve(int j){
	if (j==n) return false;
	t += A[j];
	if (t==m) return true;
	if (t<m){
		if (solve(j+1)) return true;
	}
	t -= A[j];
	return solve(j+1);
}

bool solve2(int m, int j)
{
	if (j==n) return false;
	if (m==A[j])return true;
	if (solve2(m-A[j], j+1))return true;
	return solve2(m,j+1);
}

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> A[i];
	sort(A, A+n, [](int a,int b){return a>b;});
	cin >> q;
	for (int i=0;i<q;i++) {
		t = 0;
		cin >> m;
		cout << (solve2(m,0) ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
const int maxn=205;
int a[maxn];
int main()
{
	int n,l,sum=0,min=1;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		a[i]=l+i-1;sum+=a[i];
	}
	//for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
	for(int i=1;i<=n;i++)
	{
		int x=abs(a[i]);
		if(x<abs(a[min])) min=i;
	}
	//cout<<"min is " <<min<<endl;
	cout<<sum-a[min];
	return 0;
}

Measured memory_bytes: 256
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define int long long
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;

int next(int u){
	if(u<10) return u+1;
	
	v32 rep;
	int s=u;
	while(u){
		rep.pb(u%10);
		u/=10;
	}

	//find the first number which can be increased
	int i=0;
	for(;i<rep.size();i++){
		if(i==0){
			if(rep[i]!=9 && rep[i+1]-rep[i]>=0)
				break;
		}
		else if(i==rep.size()-1){
			if(rep[i]!=9 && rep[i-1]-rep[i]>=0)
				break;
		}
		else{
			if(rep[i]!=9 && rep[i-1]-rep[i]>=0 && rep[i+1]-rep[i]>=0)
				break;
		}
	}
	if(i==rep.size()){
		return s+1;
	}
	else{
		//change at i
		int x=rep[i]+1;
		for(int j=i;j>=0;j--){
			rep[j]=x;
			x=max((ll)0,x-1);
		}
	}
	//calculate the value
	int x=1;
	int res=0;
	for(auto a : rep){
		res+=a*x;
		x*=10;
	}
	return res;
} 
 
int32_t main()
{
	IOS;
	cin>>k;
	int init=1;
	forn(i,k-1){
		init=next(init);
	}
	cout<<init<<ln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int  mod=1e9+7;
int main()
{
   int n;long long k;
   cin>>n>>k;long long ans=0;
   for(int i=k-1;i<=n;i++)
   {
   	 long long minnum=(long long)(i)*(i+1)/2;
   	 long long maxnum=(long long)(n-i+n)*(i+1)/2;
   	 //cout<<minnum<<" "<<maxnum<<endl;
   	 ans=(ans+(maxnum-minnum+1)%mod)%mod;
   }
  cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 3632
let N = stdin.ReadLine()
let A = stdin.ReadLine().Split() |> Array.map int64
let AA = Array.map abs A

if A
   |> Array.contains 0L
   || (A
       |> Array.filter (fun x -> x < 0L)
       |> Array.length) % 2 = 0
then Array.sum AA
else (Array.sum AA) - 2L * (Array.min AA)
|> stdout.WriteLine


Measured memory_bytes: 41076
Option Strict On

Module Module1
    Dim a, b, x, s As Long

    Sub Main()
        Dim arr() As Long = Array.ConvertAll(Of String, Long) _
            (Split(Console.ReadLine()), AddressOf Long.Parse)

        'let'
        a = arr(0) : b = arr(1)

        For Each x In arr
            s += x
        Next

        x = s \ 2 + (s Mod 2)

        Console.WriteLine(x)

    End Sub
End Module

Measured memory_bytes: 13536
def main():
    n=int(input())
    g=[{i for i in range(j+1,n)} for j in range(n)]
    matrix=[[0]*(n-i-1) for i in range(n-1)]
    def dfs(i,now):
        for j in g[i]:
            if visit[j]==False:
                visit[j]=True
                if now%2==0:
                    white.add(j)
                else:
                    black.add(j)
                dfs(j,now+1)
                break
    cnt=0
    cnt2=0
    while cnt<(n*(n-1))//2:
        cnt2+=1
        visit=[False]*n
        black=set()
        white=set()
        for i in range(n):
            if visit[i]==False:
                visit[i]=True
                black.add(i)
                dfs(i,0)
        for i in black:
            for j in white:
                ii,jj=min(i,j),max(i,j)
                if jj in g[ii]:
                    cnt+=1
                    g[ii].remove(jj)
                    matrix[ii][jj-ii-1]=cnt2
    for i in matrix:
        print(*i)
main()

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

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

    const auto ret = a + a*a + a*a*a;

    cout << ret << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    int minus_cnt = 0;
    rep(i, n) {
        ll tmp_a;
        cin >> tmp_a;
        if ( tmp_a < 0 ) {
            ++minus_cnt;
        }
        a[i] = abs(tmp_a);
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    if ( minus_cnt % 2 == 0 ) {
        ans = a[0];
    } 
    else {
        ans = -a[0];
    }
    for ( int i = 1; i < n; ++i ) {
        ans += a[i];
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<cstdio>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,m;
 cin>>n>>m;
 vector<ll>memo[n+10];
 ll p[m+10],y[m+10];
 rep(i,0,m){
  cin>>p[i]>>y[i];
  memo[p[i]].push_back(y[i]);
 }
 rep(i,1,n+1)sort(all(memo[i]));

 rep(i,0,m){
  printf("%012lld\n",p[i]*1000000+lower_bound(memo[p[i]].begin(),memo[p[i]].end(),y[i])-memo[p[i]].begin()+1);
 }
return 0;}


Measured memory_bytes: 10692
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n, m, k;
int a[N];
int ans, sum;

int main()
{
	//File("");
	cin >> k >> n;
	for (int i = 1; i <= n; i+=1)
	{
	    cin >> a[i];
	    if (i > 1)
	        ans = max(ans, a[i] - a[i - 1]);
	}
	ans = max(ans, k - a[n] + a[1]);
	cout << k - ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll a[200010],dp[200010][2],maxdp[200010];
int main(){
    ll i,j,k,n;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    ll s1=0,s2=0;
    maxdp[1]=max(a[0],a[1]);
    for(i=0;i<n;i++){
        if(i%2==0)s1+=a[i],dp[i][0]=s1;
        else s2+=a[i],dp[i][1]=s2;
        if((i&1)&&i>1)maxdp[i]=max(dp[i-3][0]+max(a[i],a[i-1]),maxdp[i-2]+a[i]);

    }
    if(n%2==0)cout<<maxdp[n-1];
    else{

        ll ma=maxdp[n-2];
       // cout<<ma<<endl;
        ll sum=a[n-1];
        for(i=n-3;i>=2;i-=2){
            ma=max(ma,sum+maxdp[i-1]);
            sum+=a[i];
        }
        cout<<max(ma,sum);
    }

}


Measured memory_bytes: 9872
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;

int main()
{
	char s[1001];
	int sum=0;
	while (1) {
		cin >> s;
		for (int i = 0; s[i] != '\0'; i++) sum += (int)s[i] - '0';
		if (sum == 0) break;
		cout << sum << endl;
		sum = 0;
	}
    return 0;
}

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

#define MAX_V 200
#define INF 2000000001
int d[MAX_V][MAX_V]; 
int V; 
int r[8];


void init(){
  for(int i=0;i<V;i++)
    for(int j=0;j<V;j++)
      if(i==j)d[i][j]=0;
      else d[i][j]=INF;
}

void warshall_floyd(){
  for(int k=0;k<V;k++)
    for(int i=0;i<V;i++)
      for(int j=0;j<V;j++)
	if(d[i][k]!=INF&&d[k][j]!=INF)
	  d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

int main(){
  int m,R;
  cin>>V>>m>>R;
  for(int i=0;i<R;i++){
    cin>>r[i];
    r[i]--;
  }
  init();
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    d[a][b]=c;
    d[b][a]=c;
  }
  warshall_floyd();
  vector<int> v;
  int ans=INF;
  for(int i=0;i<R;i++)v.push_back(i);
  do{
    int sum=0;
    for(int i=1;i<v.size();i++){
      sum+=d[r[v[i-1]]][r[v[i]]];
    }
    ans=min(ans,sum);
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans<<endl;
  return 0;
}


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

int f(int a, int b) {
  return max(a,b);
}

int e() {
  return (int)-1e9;
}

int target;

bool g(int v) {
  return v < target;
}

int main(){
  int n, q;
  cin >> n >> q;
  int a[n];
  segtree<int,f,e> seg(n); 
  rep(i,n) {
    cin >> a[i];
    seg.set(i,a[i]);
  }
  while(q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if(t == 1) seg.set(--x,y);
    else if(t == 2) cout << seg.prod(--x,y) << endl;
    else {
      target = y;
      cout << seg.max_right<g>(--x) + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6092
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX=200020;
const int INF=0x3f3f3f3f;
int r,c,n;
struct point{
    int x,y,idx,d;
    bool operator<(const point &a)const{
        return d<a.d;
    }
};
point geo[MAX];
int chk[MAX];
stack<int> cross;
int main(){
    scanf("%d%d%d",&r,&c,&n);
    for(int i=0;i<2*n;i++){
        int t1,t2,t=INF;
        scanf("%d%d",&t1,&t2);
        if(t1==0) t=t2;
        else if(t2==c) t=c+t1;
        else if(t1==r) t=c+r+(c-t2);
        else if(t2==0) t=c+r+c+(r-t1);
        geo[i]={t1,t2,i/2,t};
    }
    for(int i=0;i<n;i++){
        if(geo[i*2].d==INF||geo[i*2+1].d==INF) geo[i*2].d=INF,geo[i*2+1].d=INF;
    }
    sort(geo,geo+2*n);
    for(int i=0;i<2*n&&geo[i].d!=INF;i++){
        if(chk[geo[i].idx]==0) chk[geo[i].idx]=1,cross.push(geo[i].idx);
        else{
            if(cross.top()!=geo[i].idx){
                printf("NO\n");
                return 0;
            }
            cross.pop();
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 3968
s = list(input())

one = 0
zero = 0
for i in s[::2]:
    if i == '1':
        one += 1
    else:
        zero += 1

for i in s[1::2]:
    if i == '0':
        one += 1
    else:
        zero += 1

print(min(one, zero))

Measured memory_bytes: 9860
def get_primes(n: int) -> list:
    sieve=[1]*n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i] = [0] * ((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

X=int(input())
D=10**5+4
L=get_primes(D)
import bisect

print(L[bisect.bisect_left(L,X)])

Measured memory_bytes: 4172
import numpy as np

N = int(input())
A = list(map(int, input().split()))

Alice = []
Bob = []
for i in range(N):
  if i%2==0:
    Alice.append(max(A))
    A.remove(max(A))
  else:
    Bob.append(max(A))
    A.remove(max(A))

Alice = np.array(Alice)
Bob = np.array(Bob)

ans = np.abs(np.sum(Alice) -np.sum(Bob))

print(ans)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef long long ll;

ll n, ans, a[N], pre[N];
map < ll , int > h;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	h[0]++;
	for(int i = 1; i <= n; i++){
		scanf("%lld",a + i);
		pre[i] = pre[i - 1] + a[i];
		ans += h[pre[i]];
		h[pre[i]]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 18432
#include <stdio.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    char s[ ] = "123456";
    char c[ 8 ];
    int n;

    scanf ( " %d", &n );
    if ( !( n ) ) break ;

    while ( n-- )
    {
      const char t = s[ 0 ];

      scanf ( " %s", c );

      switch ( *c )
      {
        case 'n':
          s[ 0 ] = s[ 4 ];
          s[ 4 ] = s[ 5 ];
          s[ 5 ] = s[ 1 ];
          s[ 1 ] = t;
          break ;
        case 's':
          s[ 0 ] = s[ 1 ];
          s[ 1 ] = s[ 5 ];
          s[ 5 ] = s[ 4 ];
          s[ 4 ] = t;
          break ;
        case 'e':
          s[ 0 ] = s[ 2 ];
          s[ 2 ] = s[ 5 ];
          s[ 5 ] = s[ 3 ];
          s[ 3 ] = t;
          break ;
        case 'w':
          s[ 0 ] = s[ 3 ];
          s[ 3 ] = s[ 5 ];
          s[ 5 ] = s[ 2 ];
          s[ 2 ] = t;
          break ;
      }
    }

    putchar ( s[ 0 ] );
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int n,p,d1,d2,d,num,sum,i;
	scanf("%d",&n);
	while(n!=0){
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			d=d1+d2;
			if(d>sum){
				sum=d;
				num=p;
			}
		}
		printf("%d %d\n",num,sum);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
import java.math.*

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    // 整数として扱えるように1000倍する
    val (t, a) = readInputLine().split(" ").map{it.toInt() * 1000}
    
    val hs = readInputLine().split(" ").map{it.toInt()}
    
    var diff = Int.MAX_VALUE
    var ans = 0
    
    for ((i, h) in hs.withIndex()) {
        val hDiff = Math.abs(a - t + h * 6)
        
        if (hDiff < diff) {
            diff = hDiff
            ans = i + 1
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int X;
    cin >> X;
    vector<bool> dp(X + 1000, false);
    dp[0] = true;
    rep(i, X) {
        dp[i + 100] = dp[i + 100] || dp[i];
        dp[i + 101] = dp[i + 101] || dp[i];
        dp[i + 102] = dp[i + 102] || dp[i];
        dp[i + 103] = dp[i + 103] || dp[i];
        dp[i + 104] = dp[i + 104] || dp[i];
        dp[i + 105] = dp[i + 105] || dp[i];
    }
    if (dp[X]) {
        cout << 1 << '\n';
    } else {
        cout << 0 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
s = list(map(int,input().split()))
ans = 0

if s[0]%2 == 0:
    if s[1]%2 == 0:
        if s[2]%2 == 1:
            s[0] += 1
            s[1] += 1
            ans += 1
    else:
        if s[2]%2 == 0:
            s[0] += 1
            s[2] += 1
            ans += 1
        else:
            s[1] += 1
            s[2] += 1
            ans += 1
else:
    if s[1]%2 == 0:
        if s[2]%2 == 0:
            s[1] += 1
            s[2] += 1
            ans += 1
        else:
            s[0] += 1
            s[2] += 1
            ans += 1
    else:
        if s[2]%2 == 0:
            s[0] += 1
            s[1] += 1
            ans += 1

ms = max(s)
for i in range(3):
    ans += (ms-s[i])//2

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="ARC")
	{
		cout<<"ABC"<<endl;
	}
	else
	{
		cout<<"ARC"<<endl;
	}
	return 0;
}

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

int x;

int main() {
  cin >> x;
  int sum = 0;
  for (int i=1; i<=x; i++) {
    sum += i;
    if (sum >= x) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e6 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)1e6 + 7)
#define N ((int)2e5 + 7)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < pair < ll, pair < ll, ll > >,  null_type,  less < pair < ll, pair < ll, ll > > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

int cnt[505]  , brr[250005];

pair < int , int > arr[505];

int main()
{
    fastio;

    int n;

    cin>>n;

    for(int i = 1 ; i<=n ; i++){
        cin>>arr[i].first;
        arr[i].second = i;
    }

    sort(arr+1,arr+n+1);
    int cur = 1 , ext = 1 , fin = 1;
    arr[n+1].first = n*n+1;
    arr[n+1].second = n+1;
    for(int i = 1 ; i<=n*n ; i++){
        if(arr[cur].first < i){
            cout<<"No\n";
            return 0;
        }
        else if(arr[cur].first == i){
            if(cnt[arr[cur].second] != arr[cur].second - 1){
                cout<<"No\n";
                return 0;
            }
            brr[i] = arr[cur].second;
            cur++;
        }
        else{
            while(ext <= n && cnt[arr[ext].second] >= arr[ext].second-1) ext++;
            if(ext == n+1){
                while(cnt[arr[fin].second] == n) fin++;
                if(fin>=cur){
                    cout<<"No\n";
                    return 0;
                }
                brr[i] = arr[fin].second;
            }
            else{
                brr[i] = arr[ext].second;
            }
        }

        cnt[brr[i]]++;
    }

    cout<<"Yes\n";

    for(int i = 1 ; i <= n*n ; i++) cout<<brr[i]<<" ";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 2176
#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 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;
	
	int l;
	cin >> l;

	vector < int > ord;

	while (l) {
		if (l & 1) {
			ord.pb(1);
			l ^= 1;
		}
		if (l) {
			ord.pb(0);
			l >>= 1;
		}
	}

	ord.pop_back();
	rev(all(ord));

	int fn = 1, mx = 1;
	vector < pair < pii, int > > edges;

	for (auto i : ord) {
		if (i)
			edges.pb({{1, fn}, mx++});
		else {
			for (auto &j : edges)
				j.S <<= 1;
			mx <<= 1;
			fn++;
			edges.pb({{fn - 1, fn}, 0});
			edges.pb({{fn - 1, fn}, 1});
		}
	}

	cout << fn << " " << sz(edges) << "\n";
	for (auto i : edges)
		cout << i.F.F << " " << i.F.S << " " << i.S << "\n";
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void LCS(char *,char *);
int main(){
  int n,i,j,k[5],l,m;
  char a[1030][1030],b[1030][1030];
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%s",a[i]);
    scanf("%s",b[i]);
  }
    for(i=1;i<=n;i++){
      LCS(a[i],b[i]);
    }
    return 0;
}
void LCS(char *a,char *b){
  int m,l,n,i,j,c[1030][1030];
  m=strlen(a);
  l=strlen(b);
  for(i=1;i<=m;i++){
    for(j=1;j<=l;j++){
      c[i][j]=0;
    }
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=l;j++){
      if(a[i-1] == b[j-1]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else if(c[i-1][j] >=c [i][j-1]){
	c[i][j]=c[i-1][j];
      }
      else{
	c[i][j]=c[i][j-1];
      }
    }
  }
  printf("%d\n",c[m][l]);
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int a, b, c; cin>>a>>b>>c;
    int nmax=max({a, b, c}), sum=a+b+c;
    int ans=sum-nmax;
    int k; cin>>k;
    for(int i=0; i<k; i++){
        nmax*=2;
    }
    cout << ans+nmax << endl;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for(int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
    
  int count = 0;
   for (int i = 0; i < N; i++) {
     int sum = A.at(i).at(0) * B.at(0);
    for (int j = 0; j < M - 1; j++) {
      int X = A.at(i).at(j + 1) * B.at(j + 1);
      sum += X;
    }
     int S = sum + C;
     if(S > 0){
      count++;
    }
    
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
eva = []
count = 0

while True:
    m, f, r = map(int, input().split())
    sum = m + f
    if m == -1 and f == -1 and r == -1:
        break
    else:
        if m != -1 and f != -1:
            if sum >= 30:
                if 30 <= sum < 50:
                    if r < 50:
                        eva.append("D")
                    else:
                        eva.append("C")
                elif 50 <= sum < 65:
                    eva.append("C")
                elif 65 <= sum < 80:
                    eva.append("B")
                elif 80 <= sum:
                    eva.append("A")
            else:
                eva.append("F")
        else:
            eva.append("F")
    count += 1

for i in range(count):
    print(eva[i])


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

int main()
{
    ll a,b,c;
    cin>>a;
    b=sqrt(a);
    for(int i=b+1; i>=1; i--)
    {
        if(a%i==0)
        {
            c=i+(a/i);
            break;
        }
    }
    cout<<c-2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, c;
  cin >> a >> b >> c;

  if(a == b) cout << c;
  else if(b == c) cout << a;
  else cout << b;

  return 0;
}


Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

S = sys.stdin.readline().rstrip()
print(S[0] + str(len(S) - 2) + S[-1])


Measured memory_bytes: 13576
#include <bits/stdc++.h>
using namespace std;
#define maxn 55
#define maxm 125005
#define int long long
#define INF 1e9 + 10
int n, X, D, ans, cnt, dp[maxm];
int w[maxn], val[maxn], pos[maxn];
int tot, V[maxn * maxn], W[maxn * maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * k;
}

struct edge
{
    int cnp, to[maxn], last[maxn], head[maxn];
    edge() { cnp = 1; }
    void add(int u, int v)
    { to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++; }
}E1;

void dfs(int u)
{
    val[u] = 1;
    for(int i = E1.head[u]; i; i = E1.last[i])
    {
        int v = E1.to[i];
        dfs(v);
        w[u] += w[v]; val[u] += val[v];
    }
    cnt += val[u] * n; pos[u] = u;
}

bool cmp(int x, int y) { return val[x] * w[y] > val[y] * w[x]; }
void Get_min(int &x, int y) { x = x < y ? x : y; }

int num[60];

signed main()
{
    n = read(), X = read(), D = read();
    w[1] = read();
    for(int i = 2; i <= n; i ++)
    {
        w[i] = read(); int x = read();
        E1.add(x, i);
    }
    dfs(1);
    for(int i = 1; i <= cnt; i ++) dp[i] = INF;
    for(int i = 1; i <= n; i ++)
    {
        int len = 1, lim = X/w[i];
		if(i>1) lim=min(lim,D);

		if(lim>n) num[i]=lim-n,lim=n;

        while(lim >= len)
        {
            V[++ tot] = len * val[pos[i]];
            W[tot] = len * w[pos[i]];
            lim -= len, len <<= 1;
        }
        if(lim) V[++ tot] = lim * val[pos[i]], W[tot] = lim * w[pos[i]];
    }
    for(int i = 1; i <= tot; i ++)
        for(int j = cnt; ~j; j --)
                if(j >= V[i]) Get_min(dp[j], dp[j - V[i]] + W[i]); // k件物品

	sort(pos + 1, pos + n + 1, cmp);
    int ans = 0;
    for(int i = 0; i <= cnt; i ++)
       {
        if(dp[i] > X) continue;
        int ret = i, left = X - dp[i];
        for(int j = 1; j <= n; j ++)
        {
            int tem = pos[j];
			int used = min(num[tem], left / w[tem]);

            left -= w[tem] * used;
            ret += val[tem] * used;
        }
        ans = max(ans, ret);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 768
N, = map(int, input().split())
Ps = map(float, input().split())
dp = [0]*((N+1)**2)
dp[0] = 1
for i, p in enumerate(Ps):
    for j in range(N+1):
        dp[(i+1)*(N+1)+j] = p*dp[i*(N+1)+j-1] + (1-p)*dp[i*(N+1)+j]
r = 0
for i in range(N, N//2, -1):
    r += dp[N*(N+1)+i]
print(r)


Measured memory_bytes: 439560
#include <stdio.h>
#include <string.h>
#define LEN 100000

typedef struct pp{
  char name[100];
  int t;
}P;

void enqueue(P x);
P dequeue();

P Q[LEN];
int head=0, tail=0;

int main(){
  int elaps = 0;
  int i, q, n;
  P now_process;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail++;
  }

  while( head != tail ){
    now_process = dequeue();
    if( now_process.t <= q ){
      elaps += now_process.t;
      printf("%s %d\n",now_process.name, elaps);
    }
    else{
      elaps += q;
      now_process.t -= q;
      enqueue( now_process );
    }
  }
  
  return 0;
}

void enqueue(P x){
  int next = (tail+1)%LEN;
  
  strcpy( Q[tail].name, x.name );
  Q[tail].t = x.t;
  tail = next;
}

P dequeue(){
  P now_process;

  strcpy( now_process.name, Q[head].name);
  now_process.t = Q[head].t;
  head = (head+1)%LEN;
  return now_process;
}



Measured memory_bytes: 11840
def func1(x):
    if x == 'A':
        num = 1
    elif x == 'T':
        num = 1
    elif x == 'C':
        num = 1
    elif x == 'G':
        num = 1
    else:
        num = 0
    return num

x = list(input())

ans = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
j = 0
for i in range(len(x)):
    z = func1(x[i])
    if z == 1:
        ans[j] += 1
    else:
        j += 1
        continue

print(max(ans))


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
int main(){
	int a, b;
	while (cin >> a >> b) {
		int hoge = a + b;
		int iFigure;
		hoge = (int)log10(hoge) + 1;

		printf("%d\n", hoge);
	}
}


Measured memory_bytes: 1188
#include<stdio.h>
#include<cstdio>
using namespace std;

int main() {
  long long n, m, d;
  scanf("%lld%lld%lld", &n, &m, &d);
  long long num1, num2;
  if (d == 0) {
    num1 = m - 1;
    num2 = n;
  } else {
    num1 = 2 * (n - d) * (m - 1);
    num2 = n * n;
  }
  printf("%.10f\n", (double)num1/num2);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

string S;

bool dfs(int pos){
	if(pos == S.size()){
		return true;
	}
	bool ok = false;
	if(S.substr(pos, 7) == "dreamer"){
		if(dfs(pos + 7) == true){
			return true;
		}
	} 
	if(S.substr(pos, 5) == "dream"){
		if(dfs(pos + 5) == true){
			return true;
		}
	} 
	if(S.substr(pos, 6) == "eraser"){
		if(dfs(pos + 6) == true){
			return true;
		}
	}
	if(S.substr(pos, 5) == "erase"){
		if(dfs(pos + 5) == true){
			return true;
		}
	}
	return false;
}


int main(){
	cin >> S;
	if(dfs(0) == true){
		cout << "YES" << endl;
		return 0;
	}else{
		cout << "NO" << endl;
		return 0;
	}
}


Measured memory_bytes: 1792
# Contest: AtCoder Beginner Contest 145 (https://atcoder.jp/contests/abc145)
# Problem: D: Knight (https://atcoder.jp/contests/abc145/tasks/abc145_d)

def rint():
    return int(input())


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


x, y = rints()
if y > x:
    x, y = y, x
d = x - y
if d > y:
    print(0)
    exit(0)
x -= 2 * d
y -= d
if x % 3 != 0:
    print(0)
    exit(0)
rj = d + x // 3
lj = x // 3
M = 10**9 + 7
f = [1]
for i in range(1, rj + lj + 1):
    f.append(f[-1] * i % M)
print(f[rj + lj] * pow(f[lj], M - 2, M) * pow(f[rj], M - 2, M) % M)


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

int main(){
    string s;
    cin >> s;
    bool ans = false;
    for(int i=0; i<s.size()-1; i++){
        if(s.at(i) == s.at(i+1)) ans = true;
    }

    if(ans) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    long long int a, b, c;
    cin >> a >> b >> c;
    long long int ans = 0;
    
    if(a+b >= c){
        ans = b + c;
    }else{
        ans = a + b + 1 + b;
    }
    
    cout << ans << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool ans = false;
  for (int a = 1; a <= 9; a++) {
    for (int b = 1; b <= 9; b++) {
      if (a * b == n) {
        ans = true;
        break;
      }
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
   int a,b,c,k,i,ans;
   scanf("%d %d %d %d",&a,&b,&c,&k);
   if(k<=a)ans=k;
   else if(k<=a+b)ans=a;
   else ans=2*a+b-k;
   printf("%d\n",ans);
}

Measured memory_bytes: 3808
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli graph[301][301] = {};
lli graph2[301][301] = {};

int main(void) {

	lli N, M, L, Q;
	cin >> N >> M >> L;

	for (int i = 0; i < 301; i++) {
		for (int j = 0; j < 301; j++) {
			graph[i][j] = INF;
			graph2[i][j] = INF;
		}
		graph[i][i] = 0;
		graph2[i][i] = 0;
	}

	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;

		A--; B--;
		graph[A][B] = C;
		graph[B][A] = C;
	}

	//最短経路列挙O(N^3)
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}

	//ガス補給で置きなおす。O(N^2)
	//距離１して、あとで-1にする。
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			if (graph[i][k] <= L)
				graph2[i][k] = 1;
		}
	}

	//最短経路列挙O(N^3)
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				graph2[i][j] = min(graph2[i][j], graph2[i][k] + graph2[k][j]);
			}
		}
	}

	lli arr[100000];

	cin >> Q;

	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		if (graph2[s][t] == INF)
			arr[i] = -1;
		else
			arr[i] = graph2[s][t] - 1;
	}

	for (int i = 0; i < Q; i++) {
		COUT(arr[i]);
	}

	return 0;
}

Measured memory_bytes: 2688
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    r,g,b,n = f()
    ans = 0
    for i in range(n//r + 1):
        for j in range((n-r*i)//g +1 ):
            if (n-r*i - g*j)%b == 0:
                ans += 1

    
    print(ans)

solve()


Measured memory_bytes: 3060
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.reverse()
counter = 0
ans = 0
B = []
for i in range(M):
    BN,CN = map(int,input().split())
    B.append([CN,BN])
B.sort()
for i in A:
    for j in range(len(B)):
        if B[-1][0] > i:
            if counter <= N - B[-1][1]:
                ans += B[-1][0] * B[-1][1]
                counter += B[-1][1]
                B.pop(-1)
            else:
                ans += B[-1][0] * (N - counter)
                counter = N
        else:
            break
    if counter == N:
        break
    else:
        counter += 1
        ans += i
print(ans)

Measured memory_bytes: 24124
//g++ E.cpp -I /usr/local/include/ac-library
#include<cmath>
#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define mod 1000000007

#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
const ll MOD = 998244353;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

using mint=modint998244353;
const mint inv9=mint(1)/9;

struct S {
    mint x,w;
    S(mint x=0,mint w=1):x(x),w(w){}
};

struct F {
    S d;
};

S op(S a, S b) { return S{a.x*b.w+b.x, a.w*b.w}; }

S e() { return S{0, 1}; }

S mapping(int f, S a) { 
    if(f==0) return a;
    return S((a.w-1)*inv9*f,a.w);
}

int composition(int f,int g) { 
    if(f==0)return g;
    else return f;
}

int id() { return 0; }

int main(){
    int n,q;
    cin >> n>> q;
    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = S{1, 1};
    }
    lazy_segtree<S, op, e, int, mapping, composition, id> t(n);
    rep(i,n){
        t.set(i,{1,10});
    }
    rep(i,q){
        int l,r,d;
        cin >> l>>r>>d;
        --l;
        t.apply(l,r,d);
        S ans=t.prod(0,n);
        cout<<ans.x.val()<<endl;
    }
    return 0;
}

Measured memory_bytes: 11436
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=2;i<n;i++)
using namespace std;

int main() {
    int X;
    cin>>X;
    REP(i,1000){
        REP2(I,X){
        if((X+i)%I==0){
            break;
        }
        if(I==X-1){
            cout<<X+i; return 0;
        }
        }
    }
    if(X==2){cout<<2;}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,ans=0;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			ans+=(ar[i]*ar[j]);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
double PI=acos(-1.0);
signed main(){
    ll n;cin>>n;
    vector<ll>a(n+1);
    ll sum=0;
    rep(i,n+1){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=0;
    ll now=1;
    rep(i,n+1){
        ans+=now;
        sum-=a[i];
        if(now<a[i]){
            ans=-1;
            break;
        }else{
            now-=a[i];
        }
        if(now*2<=sum)now*=2;
        else{
            now=sum;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int nums[] = CPUtils.readIntArray(N, in);
            long cnt = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    for (int z = j + 1; z < N; z++)
                    {
                        if (nums[i] != nums[j] && nums[i] != nums[z] && nums[j] != nums[z])
                        {
                            if (isOK(nums[i], nums[j], nums[z]))
                            {
                                cnt++;
                            }
                        }
                    }
                }
            }
            out.println(cnt);
        }

        private boolean isOK(int a, int b, int c)
        {
            return ((a + b) > c) && ((a + c) > b) && ((b + c) > a);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 27828