akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge>>G;

int ans, mon;
int main() {
	string h;
	cin >> h;
	for (int i = 0; i < h.length(); ++i) {
		if (h[i] == 'A' || h[i] == 'G' || h[i] == 'C' || h[i] == 'T') { ++mon; }
		else {
			ans = max(ans, mon);
			mon = 0;
		}
	}
	cout << max(ans, mon) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
char s[2005][2005];
int a[2005][2005]= {0};
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
    {
        scanf("%s",s[i]);
    }
    int j;
    for(int i=0; i<n; ++i)
    {
        int sum=0;
        for(j=1; j<m; ++j)
        {
            if(s[i][j-1]!='#'&&s[i][j]=='.')
            {
                sum++;
                a[i][j]+=sum;
            }
            else
                sum=0;
        }
        sum=0;
        for(j=m-2; j>=0; --j)
        {
            if(s[i][j+1]!='#'&&s[i][j]=='.')
            {
                sum++;
                a[i][j]+=sum;
            }
            else
                sum=0;
        }
    }
    int cott=-1;
    for(int i=0; i<m; ++i)
    {
        int sum=0;
        for(j=1; j<n; ++j)
        {
            if(s[j-1][i]!='#'&&s[j][i]=='.')
            {
                sum++;
                a[j][i]+=sum;
            }
            else
                sum=0;
        }
        sum=0;
        for(j=n-2; j>=0; --j)
        {
            if(s[j+1][i]!='#'&&s[j][i]=='.')
            {
                sum++;
                a[j][i]+=sum;
            }
            else
                sum=0;
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
            if(s[i][j]=='.')
                cott=max(cott,a[i][j]+1);
    }
    printf("%d\n",cott);
    return 0;
}


Measured memory_bytes: 19840
//Range
import java.util.Scanner;

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

Measured memory_bytes: 17176
n = int(input())
check = []
ans = 0
for _ in range(n):
    n1, n2 = map(int, input().split())
    if n1 == n2:
        check.append(1)
    else:
        check.append(0)

for i in range(n-1):
    if sum(check[i:i+3])==3:
        ans = 1
        break
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9124
N, M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]
AB.sort(key=lambda a: (a[0], -a[1]))

ans = 1
right = 10**18
for l, r in AB:
    if l >= right:
        ans += 1
        right = 10**18
    right = min(right, r)
print(ans)

Measured memory_bytes: 27704
while 1:
    H,W = map(int,input().split())
    if (H,W) == (0,0):
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2 == 0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7012
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> Ls(N);
    REP(n, N) cin >> Ls[n];
    sort(ALL(Ls));
    ll ans = 0;
    REP(i, N - 2) {
        auto a = Ls[i];
        FOR(j, i + 1, N - 1) {
            auto b = Ls[j];
            FOR(k, j + 1, N) {
                auto c = Ls[k];
                if (a + b > c) ++ans;
                else break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b)
       {if(b<c)
       {
            cout<<"Yes"<<endl;
       }
       else
       cout<<"No"<<endl;
       }
    else
        cout<<"No"<<endl;
    
    return 0;
}


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

long long int solve(vector<long long int> H, long long int K){
	sort(H.begin(), H.end());
  	if(H.size()<=K) return 0;
  	long long int cost = 0;
  	for(long long int i=0; i<H.size()-K; ++i) cost += H[i];
  	return cost;
}

int main(){
	long long int N, K; cin>>N>>K;
  	vector<long long int> H(N);
  	for(int i=0; i<N; ++i) cin>>H[i];
  	cout<<solve(H, K)<<endl;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
  int N,P = 0,G = 0,W = 0,Y = 0, co = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    string c;
    cin >> c;

    if(c == "P"){
         P = 1;
    }else if(c == "W"){
         W = 1;
    }else if(c == "G"){
         G = 1;
    }else if(c == "Y"){
         Y = 1;
    }
  }
  co = P+W+G+Y;
  if(co == 3){
      cout << "Three" << endl;
    }else{
      cout << "Four" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI               \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double
#define endl "\n"

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
   AB_BHI_NI_DEGI
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
   //cout.precision(20);
   //cout << fixed;
   int T = 1;
   //cin >> T;
   int cnt = 1;
   while (T--)
   {
      int d, t, s;
      cin >> d >> t >> s;
      int c = t * s;
      if (c >= d)
         cout << "Yes\n";
      else
         cout << "No\n";
   }
   return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
const int MOD=1e9+7;
const int N=1e6+10;
int add(int a,int b){
        int ans=(int)(((long long int)a+(long long int)b)%MOD);
        if(ans<0)ans+=MOD;
        return ans;
}
int mul(int a,int b){return (int)(((long long int)a*(long long int)b)%MOD);}
int main(){
        int n,h,d,f[N],ans,s[N],tot=0;
        scanf("%d%d%d",&n,&h,&d);
        s[0]=0;
        f[0]=1;
        for(int i=1;i<=n;i++){
                f[i]=mul(f[i-1],i);
                tot=add(tot,f[i]);
        }
        for(int i=1;i<=d;i++)s[i]=add(f[n],mul(s[i-1],tot+1));
        for(int i=d+1;i<=h;i++)s[i]=add(s[i-1],mul(add(s[i-1],-s[i-d-1]),tot));
        ans=add(s[h],-s[h-1]);
        printf("%d\n",ans);
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

int mod=1e9+7;
struct Mint {
    int val;
    Mint inv() const{
        int tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x){if((val=x%mod)<0)val+=mod;}
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this*=x.inv();}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    int cnt[3]={}; Mint ans=1;
    rep(i,0,n){
        int val=0;
        rep(j,0,3)if(a[i]==cnt[j])val++;
        if(val==0){printf("0\n"); return 0;}
        ans*=val;
        rep(j,0,3)if(a[i]==cnt[j]){cnt[j]++; break;}
    }
    printf("%d\n",ans.val);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll L(n); rep(i, n) cin >> L[i];
  sort(all(L));
  ll ans = 0;
  rep(i, n)
  {
    for(ll j = i + 1;j < n;j++)
    {
      for(ll k = j + 1;k < n;k++)
      {
        if(L[k] < L[j] + L[i]&&L[i] != L[j]&&L[j] != L[k]) ans++;
      }
    }
  }
  cout << ans << endl;
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(4); //高精度少数表示
  Main();
  return 0;
}


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

using i64 = long long int;

int dp[103][10005]={0};

int main(){
    int n, w;
    cin >> n >> w;
    vector<pair<int, int>> v;
    for(int i=0;i<n;++i){
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }

    for(int i=1;i<=n;++i){
        for(int j=0;j<=w;++j){
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if(j+v[i-1].second <= w)
                dp[i][j+v[i-1].second] = max(dp[i][j+v[i-1].second], dp[i][j]+v[i-1].first);
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}



Measured memory_bytes: 6988
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
bool comp(pair<int,int> p1,pair<int,int> p2){
  return (p1.first == p2.first && p1.second > p2.second) || p1.first < p2.first;
}
int main(){
  priority_queue<int> que;
  int i,n,m,a=0;
  pair<int,int> p[100010];
  scanf("%d %d\n",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d %d\n",&p[i].first,&p[i].second);
  }
  int ans=0;
  sort(p,p+n,comp);
  for(i=1;i<=m;i++){
    while(a<n){
      if(p[a].first==i){
        que.push(p[a].second);
        a++;
      }
      else{
        break;
      }
    }
    if(que.empty()){
      continue;
    }
    ans+=que.top();
    que.pop();
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans=LINF,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c;
    rrep(i,1,1001){
        if(a%i==0&&b%i==0){
            cnt=(a/i)*(b/i);
            cnt*=c;
            ans=min(ans,cnt);
        }
    }
    Cout(ans);
    return 0;
}



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


int main(void) {
    using namespace std;

    long n;
    cin >> n;

    vector<pair<long,long>> r;
    if(n % 2) {
        vector<vector<long>> a;

        a.push_back({n});

        for(int i=1; i<=(n-1)/2; i++)
            a.push_back({i, n-i});

        for(int i=0; i<a.size(); i++)
            for(int j=i+1; j<a.size(); j++)
                for(auto x: a[i])
                    for(auto y: a[j])
                        r.push_back({x, y});

    } else {
        vector<vector<long>> a;

        for(int i=1; i<=n/2; i++)
            a.push_back({i, n-i+1});

        for(int i=0; i<a.size(); i++)
            for(int j=i+1; j<a.size(); j++)
                for(auto x: a[i])
                    for(auto y: a[j])
                r.push_back({x, y});
    }

    cout << r.size() << endl;
    for(auto &t: r)
        cout << t.first << ' ' << t.second << endl;

    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int a;
    int sum = 0;
    for(int i=0; i<M; ++i){
        cin >> a;
        sum += a;
    }
    cout << ((N - sum < 0) ? -1 : N - sum) << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],b[MAX];
ll ans=0;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read(),b[i]=read();
	for(int i=n;i>=1;--i)
	{
		a[i]=(b[i]-(a[i]+ans)%b[i])%b[i];
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline

h,w,n=map(int,input().split())
sr,sc=map(int ,input().split())
s=input()
p=input()

t={"L":0,"R":0,"U":0,"D":0}
a={"L":0,"R":0,"U":0,"D":0}

for i in range(n):
    if s[i]=="L":
        t["L"]+=1
    elif s[i]=="R":
        t["R"]+=1
    elif s[i]=="U":
        t["U"]+=1
    elif s[i]=="D":
        t["D"]+=1
    if t["R"]-a["L"]==w-sc+1 or t["L"]-a["R"]==sc or t["D"]-a["U"]==h-sr+1 or t["U"]-a["D"]==sr:
        print("NO")
        break
    else:
        if p[i]=="L" and a["L"]-t["R"]<sc-1:
            a["L"]+=1
        elif p[i]=="R" and a["R"]-t["L"]<w-sc:
            a["R"]+=1
        elif p[i]=="U" and a["U"]-t["D"]<sr-1:
            a["U"]+=1
        elif p[i]=="D" and a["D"]-t["U"]<h-sr:
            a["D"]+=1
else:
  print("YES")

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

int main(void) {
	int i,j;
	int h, w;
	char **picture;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	h = atoi(ch);
	ch = strtok(NULL, " ");
	w = atoi(ch);

	picture = (char **)calloc(h + 2, sizeof(char *));
	for(i = 0; i < h + 2; i += 1) {
		picture[i] = (char *)calloc(w + 4, sizeof(char));
	}

	for(i = 0; i < h; i += 1) {
		fgets(&picture[i + 1][1], sizeof(buf), stdin);
	}
	for(i = 0; i < w; i += 1) {
		picture[0][i + 1] = '#';
		picture[h + 1][i + 1] = '#';
	}
	for(i = 0; i < h + 2; i += 1) {
		picture[i][0] = '#';
		picture[i][w + 1] = '#';
		picture[i][w + 2] = '\n';
		picture[i][w + 3] = '\0';
	}
	for(i = 0; i < h + 2; i += 1) {
		printf("%s",picture[i]);
	}


	for(i = 0; i < h + 2; i += 1) {
		free(picture[i]);
	}
	free(picture);
	return 0;
}


Measured memory_bytes: 2112
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 998244353
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll


signed main() {
	fast;

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

	while(t--) {
		
		int x;
		cin>>x;

		if(x>=1800) cout<<1;
		else if(x>=1600) cout<<2;
		else if(x>=1400) cout<<3;
		else if(x>=1200) cout<<4;
		else if(x>=1000) cout<<5;
		else if(x>=800) cout<<6;
		else if(x>=600) cout<<7;
		else cout<<8;
		cout<<endl;

	}
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int N,A[4],B[4],sum;
bool flag=true;

void go(int num){
  //cout<<num<<endl;
  if(num==0){
    B[num]=1;
    go(1);
  }else if(num<=3){
    B[num]=1;
    go(num+1);
    B[num]=0;
    go(num+1);
  }else{
    for(int i=0;i<4;i++){
      if(B[i]==1) sum+=A[i];
      else sum-=A[i];
      //cout<<sum<<endl;
    }
    if(sum==7 && flag==true){
      cout<<A[0];
      for(int i=1;i<4;i++){
        if(B[i]==1) cout<<"+";
        else cout<<"-";
        cout<<A[i];
      }
      cout<<"=7"<<endl;
      flag=false;
    }
    sum=0;
  }
}

int main(){
  cin>>N;

  for(int i=3;i>=0;i--){
    A[i]=N%10;
    N/=10;
    //cout<<A[i]<<endl;
  }
  
  go(0);
}


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

vector<int> G[100005];
int solve(int v,int p){
  int x = 0;
  for(int to : G[v]) {
    if (to != p)
      x ^= solve(to,v)+1;
  }
  return x;
}
int main(){
  int n; cin >> n;
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b;
    G[a].emplace_back( b );
    G[b].emplace_back( a );
  }
  if( solve( 1, 1 ) ) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 10368
c1, c2, c3, money = [int(input()) for i in range(4)]

counta = 0

for i in range(c1+1):
    for j in range(c2+1):
        if 0 <= (money - 500*i - 100*j)/50 <= c3:
            counta += 1

print(counta)

Measured memory_bytes: 2940
#include <iostream>

int main()
{
    int N, X, T;
    std::cin >> N >> X >> T;

    int ans;
    for( ans = 0; N > 0; ans += T)
    {
        N -= X;
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		Map<Integer, List<Integer>> ent = new HashMap<>();
		for (int i = 0; i < N; i++) {
			int day = scan.nextInt();
			int sal = scan.nextInt();
			ent.computeIfAbsent(day, o -> new ArrayList<>()).add(sal);
		}

		PriorityQueue<Integer> part = new PriorityQueue<>(Comparator.reverseOrder());
		int sal = 0;
		for (int i = 1; i <= M; i++) {
			// 後方から可能なバイトを取得し、選択可能なバイトとしてキューに追加
			List<Integer> aList = ent.get(i);
			if (aList != null) {
				part.addAll(aList);
			}
			// 選択可能なバイトのうち、一番給料の良いバイトを選択
			Integer aPart = part.poll();
			if (aPart != null) {
				sal += aPart;
			}
		}
		System.out.println(sal);
	}
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n, T;
  cin >> n >> T;

  int64_t ans = n * T;
  int64_t e;
  for (auto i : irange(0L, n)) {
    int64_t t;
    cin >> t;

    if (i > 0 && t < e) {
      ans -= (e - t);
    }
    e = t + T;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
open System

let rec isSubList xs ys =
    match xs, ys with
    | [], _ -> true
    | _, [] -> false
    | x::xs, y::ys when x = y -> isSubList xs ys
    | xs, y::ys -> isSubList xs ys

let n = stdin.ReadLine() |> int
let s = stdin.ReadLine() |> Seq.toList

let a = List.length [
    for i in ['0'..'9'] do
    for j in ['0'..'9'] do
    for k in ['0'..'9'] do
    if isSubList [i; j; k] s then yield () ]
 
printfn "%d" a

Measured memory_bytes: 22272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	while(b<0) b+=MOD;
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
	
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	vector<ll> a;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x;
		a.pb(x);
	}
	sort(a.begin(),a.end());
	int cntpos = 0; int zero=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>0)
		{
			cntpos++;
		}
		else if(a[i]==0)
		{
			zero++;
		}
	}
	if(k==n)
	{
		int ans=1;
		for(int i=0;i<n;i++)
		{
			ans=mult(ans,a[i]);
		}
		cout<<ans<<'\n';
		return 0;
	}
	//is negative
	if(cntpos==0&&zero==0&&k%2==1)
	{
		int ans = 1;
		reverse(a.begin(),a.end());
		for(int i=0;i<k;i++)
		{
			ans=mult(ans,MOD+a[i]);
		}
		cout<<ans<<'\n';
		return 0;
	}
	//ans>=0
	int cntneg = 0; 
	while(cntneg+2<=k&&k-cntneg>cntpos)
	{
		cntneg+=2; 
	}
	int l=cntneg;
	int r=n-(k-cntneg); //k-cntneg, chosen
	while(r+1<n&&(a[l]*a[l+1])>(a[r]*a[r+1]))
	{
		l+=2; r+=2;
	}
	int ans=1;
	for(int i=0;i<l;i++)
	{
		ans=mult(ans,a[i]);
	}
	for(int i=r;i<n;i++)
	{
		ans=mult(ans,a[i]);
	}
	cout<<ans<<'\n';
}


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

int use[1260 - 540 + 1][10001];
int login[1260 - 540 + 1][10001];

int main(void)
{
	int N, M;
	int r;
	int t, n, m, s;
	int q;
	int ts, te;
	int i, j;
	int queue;
	int cnt;
	
	while (1){
		scanf("%d%d", &N, &M);
//printf("[%d %d]\n", N, M);
		if (N == 0 && M == 0){
			break;
		}
		
		scanf("%d", &r);
		
		memset(use, 0, sizeof(use));
		memset(login, 0, sizeof(login));
		for (i = 0; i < r; i++){
			scanf("%d%d%d%d", &t, &n, &m, &s);
			
			if (s == 1){
				use[t - 540][m]++;
				login[t - 540][m] = 1;
			}
			else {
				use[t - 540 - 1][m]--;
			}
		}
#if 0
for (i = 540; i<= 1260; i++){
if (i%60==0)puts("");
if (use[i-540][1]==0){
printf("*");
}else{
printf("%d", use[i-540][1]);
}
}
puts("");
for (i = 540; i<= 1260; i++){
if (i%60==0)puts("");
if (login[i-540][1]==0){
printf("*");
}else{
printf("%d", login[i-540][1]);
}
}
#endif
		for (i = 1; i <= M; i++){
			queue = 0;
			for (j = 540; j <= 1260; j++){
				if (queue > 0){
					queue += use[j - 540][i];
					use[j - 540][i] = 1;
				}
				else {
					queue += use[j - 540][i];
				}
                if (login[j - 540][i] == 1){
					use[j - 540][i] = 1;
                }
			}
		}
#if 0
for (i = 540; i<= 1260; i++){
if (i%60==0)puts("");
printf("%d", use[i-540][1]);
}
puts("");
#endif
		
		scanf("%d", &q);
		for (i = 0; i < q; i++){
			scanf("%d%d%d", &ts, &te, &m);
			cnt = 0;
			for (j = ts; j < te; j++){
				if (use[j - 540][m] == 1){
					cnt++;
				}
			}
			printf("%d\n", cnt);
		}
	}
	return (0);
}

Measured memory_bytes: 56940
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int dp[100010][2];
string s;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> s;
    dp[0][0] = 1;
    int n = s.size();
    rep(i, 0, n){
        if(s[i] == '0'){
            (dp[i + 1][0] += dp[i][0]) %= mod;
            (dp[i + 1][1] += dp[i][1] * 3) %= mod;
        }else{
            (dp[i + 1][0] += dp[i][0] * 2) %= mod;
            (dp[i + 1][1] += dp[i][0] + dp[i][1] * 3) %= mod;
        }
    }
    int ans = dp[n][0] + dp[n][1];
    cout << ans % mod << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int N;
    cin >> N;
    int A[N], B[N];

    for (int i = 1; i <= N + 1; i++)
        cin >> A[i];
    for (int i = 1; i <= N; i++)
        cin >> B[i];

    long long int count = 0;

    for (int i = 1; i <= N; i++)
    {
        bool flag = 0;
        int disc1 = A[i] - B[i];
        if (disc1 >= 0)
        {
            count += B[i];
            flag = 1;
        }
        else
        {
            count += A[i];
            B[i] -= A[i];
        }

        int disc2 = A[i + 1] - B[i];
        if (flag == 0)
        {
            if (disc2 >= 0)
            {
                count += B[i];
                A[i + 1] -= B[i];
            }
            else
            {
                count += A[i + 1];
                A[i + 1] = 0;
            }
        }
    }

    OP(count)

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
string s;
ll r,g,b;
int main(){
    cin>>n>>s;
    REP(i,s.size()){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    ll ans=r*g*b;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(j+j-i>=n)continue;
            if(s[i]!=s[j]&&s[i]!=s[j+j-i]&&s[j]!=s[j+j-i])ans--;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll ans;
ll N;
string X;
ll t[55];
string s[55];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> s[i] >> t[i];
    cin >> X;
    bool flag = false;
    for(int i = 0; i < N; i++) {
        if(flag) ans += t[i];
        if(s[i] == X) flag = true;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	bool isValid = true;
	int t, x, y;
	t = x = y = 0;
	for (int i = 0; i < n; i++)
	{
		int ti, xi, yi;
		cin >> ti >> xi >> yi;
		int d = abs(xi - x) + abs(yi - y);
		if (d > ti || (ti - d) % 2 != 0)
			isValid = false;
	}
	cout << (isValid ? "Yes" : "No") << 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;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k, x, y;
  cin >> k >> x >> y;
  int s[2] = {1, 1};
  if (x < 0) {
    s[0] = -1;
    x *= -1;
  }
  if (y < 0) {
    s[1] = -1;
    y *= -1;
  }
  vector<vector<ll>> ans;
  ll nowx = 0, nowy = 0;
  auto add = [&](int i) {
    if (nowx+k <= x)
      nowx += k;
    else if (nowx < x) {
      nowy += k-(x-nowx);
      nowx = x;
    } else
      nowy += k;
  };
  if (k%2 == 0) {
    if ((x+y)%2) {
      cout << -1 << '\n';
      return 0;
    } else {
      while (nowx+nowy+k*2 < x+y) {
        add(k);
        ans.push_back({s[0]*nowx, s[1]*nowy});
      }
      if (nowx+nowy+k == x+y)
        ans.push_back({s[0]*x, s[1]*y});
      else if (nowx+nowy+k*2 == x+y) {
        add(k);
        ans.push_back({s[0]*nowx, s[1]*nowy});
        ans.push_back({s[0]*x, s[1]*y});
      } else {
        int dist = x+y-nowx-nowy;
        if (nowx+dist/2 <= x) {
          nowx += dist/2;
          nowy -= k-dist/2;
        } else {
          nowy = y-dist/2;
          nowx = x+k-dist/2;
        }
        ans.push_back({s[0]*nowx, s[1]*nowy});
        ans.push_back({s[0]*x, s[1]*y});
      }
    }
  } else {
    if ((x+y)%2) {
      if (k <= x)
        nowx += k;
      else {
        nowx = x;
        nowy = k-x;
      }
      ans.push_back({s[0]*nowx, s[1]*nowy});
    }
    while (nowx+nowy+k*2 < x+y) {
      rep(i, 2) {
        add(k);
        ans.push_back({s[0]*nowx, s[1]*nowy});
      }
    }
    if (nowx != x || nowy != y) {
      if (nowx+nowy+k == x+y)
        ans.push_back({s[0]*x, s[1]*y});
      else if (nowx+nowy+k*2 == x+y) {
        add(k);
        ans.push_back({s[0]*nowx, s[1]*nowy});
        ans.push_back({s[0]*x, s[1]*y});
      } else if (nowy <= y) {
        int dist = x+y-nowx-nowy;
        if (nowx+dist/2 <= x) {
          nowx += dist/2;
          nowy -= k-dist/2;
        } else {
          nowx = x+k-dist/2;
          nowy = y-dist/2;
        }
        ans.push_back({s[0]*nowx, s[1]*nowy});
        ans.push_back({s[0]*x, s[1]*y});
      } else {
        int dist = nowx+nowy-x-y;
        nowx = x+k-dist/2;
        nowy = y+dist/2;
        ans.push_back({s[0]*nowx, s[1]*nowy});
        ans.push_back({s[0]*x, s[1]*y});
      }
    }
  }
  cout << ans.size() << '\n';
  for (auto e : ans)
    cout << e[0] << ' ' << e[1] << '\n';
  return 0;
}

Measured memory_bytes: 14252
# ????????????????????£??????????????????????¨?????????°???????¨??????????
def rpn(data)
  stack = []
  data.each { |v|
    case v
    when /^[0-9]+$/; stack.push v.to_i
    when /^\+$/; stack.push(stack.pop + stack.pop)
    when /^-$/;
      v1 = stack.pop
      stack.push(stack.pop - v1)
    when /^*$/; stack.push(stack.pop * stack.pop)
    else puts "Error : not match"
    end
  }
  stack.pop
end

# main
data = gets.split(' ')
res = rpn(data)
puts res

Measured memory_bytes: 8620
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,M,X = MI()
L = LI2(N)
ans = INF
for l in product([0,1],repeat=N):
    know = [0]*M
    cost = 0
    for i in range(N):
        if l[i]==1:
            cost += L[i][0]
            for j in range(M):
                know[j] += L[i][j+1]
    if min(know)<X:
        continue
    ans = min(ans,cost)
if ans==INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 73400
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll N;
	cin >> N;

	vector<vector<ll>> dists(N, vector<ll>(N));
	vector<vector<ll>> walls(N, vector<ll>(N, 1));
	for (ll i = 0; i < N; ++i) {
		for (ll j = 0; j < N; ++j) {
			dists[i][j] = i + 1;
			dists[i][j] = min(dists[i][j], N - i);
			dists[i][j] = min(dists[i][j], j + 1);
			dists[i][j] = min(dists[i][j], N - j);
		}
	}

	ll res = 0;
	ll P;
	queue<pair<ll, ll>> check_queue;
	vector<vector<bool>> checked(N, vector<bool>(N, false));
	queue<pair<ll, ll>> for_rollback;
	for (ll i = 0; i < N * N; ++i) {
		cin >> P;
		--P;
		ll x, y;
		x = P / N;
		y = P % N;
		walls[x][y] = 0;
		res += --dists[x][y];

		check_queue.emplace(x, y);
		while (!check_queue.empty()) {
			tie(x, y) = check_queue.front();
			check_queue.pop();
			for_rollback.emplace(x, y);

			if (x + 1 < N) {
				if (!checked[x + 1][y] && dists[x + 1][y] > dists[x][y] + walls[x + 1][y]) {
					dists[x + 1][y] = dists[x][y] + walls[x + 1][y];
					check_queue.emplace(x + 1, y);
					checked[x + 1][y] = true;
				}
			}
			if (x - 1 >= 0) {
				if (!checked[x - 1][y] && dists[x - 1][y] > dists[x][y] + walls[x - 1][y]) {
					dists[x - 1][y] = dists[x][y] + walls[x - 1][y];
					check_queue.emplace(x - 1, y);
					checked[x - 1][y] = true;
				}
			}
			if (y + 1 < N) {
				if (!checked[x][y + 1] && dists[x][y + 1] > dists[x][y] + walls[x][y + 1]) {
					dists[x][y + 1] = dists[x][y] + walls[x][y + 1];
					check_queue.emplace(x, y + 1);
					checked[x][y + 1] = true;
				}
			}
			if (y - 1 >= 0) {
				if (!checked[x][y - 1] && dists[x][y - 1] > dists[x][y] + walls[x][y - 1]) {
					dists[x][y - 1] = dists[x][y] + walls[x][y - 1];
					check_queue.emplace(x, y - 1);
					checked[x][y - 1] = true;
				}
			}
		}

		while (!for_rollback.empty()) {
			tie(x, y) = for_rollback.front();
			for_rollback.pop();
			checked[x][y] = false;
		}
	}

	cout << res << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 11468
N = int(input())
A = list(map(int, input().split()))

pm = sum(A)
e = 1
te = 1
for i in A:
    pm -= i
    e = min((e-i) * 2,pm)
    if e < 0:
        break
    te += e
if e < 0:
    print(-1)
else:
    print(te)

Measured memory_bytes: 20124
#include <iostream>
#include <cstdlib> //絶対値abs
#include <algorithm> //minmax
using namespace std;
int N;
long long h[100010];
long long dp[100010];
const long long INF = 1LL << 62;
int main(){
	cin >> N;
	for (int i = 0; i < N; ++i){
		cin >> h[i];
	}
	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	dp[0] = 0;
	dp[1] = abs(h[1]-h[0])+dp[0];

	for (int i = 2; i < N; ++i){
		dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
	}

	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
ans = 1000
hoge = 0

s = input()
t = input()

sl = len(s)
tl = len(t)
for i in range(sl-tl+1):
    hoge = 0
    for j in range(tl):
        if s[i+j] != t[j]:
            hoge = hoge + 1
    if hoge == 0:
        ans = 0
        break
    if ans > hoge:
        ans = hoge
print(ans)

Measured memory_bytes: 67460
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll x;
    std::cin >> x;
    const ll maxv = 1e3;
    auto pow5 = [](ll x) {
        ll a = x * x;
        return a * a * x;
    };
    for (ll a = -maxv; a <= maxv; a++) {
        for (ll b = -maxv; b <= maxv; b++) {
            ll a5 = pow5(a);
            ll b5 = pow5(b);
            if (a5 - b5 == x) {
                std::cout << a << " " << b << "\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define N 100050
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
#define int long long
typedef pair<int, int> pii;

int n, m, q, k, v[N];

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

	cin>>n>>m>>k;

	cout<<min({n + m, m + k, n + k})<<'\n';
}

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

///idea: https://atcoder.jp/contests/abc174/submissions/15671761
/***
I changed the binary search to the standard BINARY search that I use ALWAYS 
and 100% OK
*/ 

int maxN=2e5+5;
int n,k;
vector<int>a(maxN);

bool isValid(int mid){
    int kk = 0; 
    if(mid==0)
        return false;
    for(int i=0;i<n;i++){
        if(a[i]<=mid)
            continue;
        int t=a[i]/mid;
        kk += t; ////t ta cut korsi ei log ke
    }
    return (kk<=k);///kk<=k hole EI MID or largest log value possibel
}
void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int lo=0,hi=1e9+5;
    while(lo<=hi){
        int mid=(lo+hi)/2; 
        if(isValid(mid)){
            hi=mid-1;
        }
        else{
            lo = mid+1; 
        }
            
    }
    cout<<lo<<"\n"; 
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve(); 
    return 0;
}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll r,D,x,x0;
    cin>>r>>D>>x;
    rep(0,i,10){
        x0=r*x-D;
        cout<<x0<<endl;
        x=x0;
    }
}


Measured memory_bytes: 256
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

A,B,C = MULT_INT_LIST()

ans = C-(A-B)
if ans<0:
  ans = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
const char char_max = (char)(((unsigned char) char(-1)) / 2);

int main() {
  fast
  ll n;
  cin>>n;
  map<ll,ll>m;
  rep(i,0,n) {
      ll a;
      cin>>a;
      m[a]++;
  }
  for(auto i=m.begin();i!=m.end();i++){
      if(i->sc!=1) {
          cout<<"NO";
          return 0;
      }
  }
  cout<<"YES";
}



Measured memory_bytes: 12800
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll n;
  std::cin>>n;

  std::vector<std::vector<P>> graph(n);

  rep(i,0,n){
    ll a;
    std::cin>>a;

    rep(j,0,a){
      ll x,y;
      std::cin>>x>>y;
      x--;
      graph[i].push_back({x,y});
    }
  }

  ll ans=0;

  for(ll i=(1<<n) - 1;i>=0;i--){
    bool isok=true;
    ll cnt=0;
    rep(bit,0,n){
      if((i>>bit)&1){
        cnt++;
        for(P e:graph[bit]){
          if(((i>>e.first)&1)!=e.second){
            isok=false;
          }
        }
      }
    }


    if(isok)chmax(ans,cnt);
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 256