akhauriyash/Code-Regression huggingface dataset:
/* be name khoda */

#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 100010;

ll n;
pii seg[maxn], lt[maxn], rt[maxn];
bool vis[maxn];

ll calc() {
    fori (i, n) lt[i] = {seg[i].S, i};
    fori (i, n) rt[i] = {seg[i].F, i};
    sort(lt, lt + n), sort(rt, rt + n, greater<pii>());
    ll pl = 0, pr = 0;
    ll x = 0, s = 0;
    memset(vis, 0, sizeof vis);
    fori (i, n) {
        if (i % 2) {
            while (vis[lt[pl].S]) ++pl;
            ll id = lt[pl].S;
            vis[lt[pl].S] = 1;
            if (lt[pl].F < x) {
                s += x - lt[pl].F;
                x = lt[pl].F;
            }
        } else {
            while (vis[rt[pr].S]) ++pr;
            ll id = rt[pr].S;
            vis[id] = 1;
            if (rt[pr].F > x) {
                s += (rt[pr].F - x);
                x = rt[pr].F;
            }
        }
    }
    return s + abs(x);
}

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

    cin >> n;
    fori (i, n) {
        cin >> seg[i].F >> seg[i].S;
    }
    ll ans = calc();
    fori (i, n) seg[i] = {-seg[i].S, -seg[i].F};
    smax(ans, calc());
    cout << ans << '\n';

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

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

  if(x == 0) cout << 1 << endl;
  else if(x == 1) cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std;
ll dp[3007][3007];
ll a[3007];
ll n;
ll solve(ll i,ll j)
{
    if(dp[i][j]!=-1)return dp[i][j];
    if(i==j)return dp[i][j]=a[i];
    dp[i][j]=max(a[i]-solve(i+1,j),a[j]-solve(i,j-1));
    return dp[i][j];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i];
    cout<<solve(0,n-1);
}

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

int main(void) {
  int h, w;
  cin >> h >> w;

  string board[50];

  for (int i = 0; i < h; ++i)
    cin >> board[i];

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

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (board[i][j] == '#')
        continue;

      int num = 0;
      for (int d = 0; d < 8; ++d) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if (ni < 0 or h <= ni)
          continue;
        if (nj < 0 or w <= nj)
          continue;
        if (board[ni][nj] == '#')
          num++;
      }

      board[i][j] = char(num + '0');
    }
  }

  for (int i = 0; i < h; ++i)
    cout << board[i] << endl;

  return 0;
}


Measured memory_bytes: 256
# 英大文字のみからなる長さ N の文字列 S があります。
# S の連続する部分列 (入出力例をご覧ください) として ABC がいくつ含まれるかを求めてください。
# 制約： 3≤N≤50, Sは英大文字のみからなる。
# 入力: N
#       S

# 文字列長を受け取る
N = input()

# 文字列を受け取る
S = input()

print(S.count('ABC'))

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,D,X; cin >> N >> D >> X;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    for(int i = 0; i < N;i++){
        ll now = 1;
        while(now <= D){
            X++;
            now += A[i];
        }
    }
    cout << X << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int A;
	cin >> A;
	cout << A * A * A + A * A + A << endl;
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N + 1);
  for (int i = 1; i < N + 1; i++)
  {
    cin >> a.at(i);
  }
  vector<int> b(N + 1);
  for (int i = N; i >= 1; i--)
  {
    int sum = 0;
    for (int j = i * 2; j <= N; j += i)
    {
      sum += b[j];
    }
    if (sum % 2 == a[i])
    {
      b[i] = 0;
    }
    else
      b[i] = 1;
  }
  int cnt = 0;
  for (int i = 1; i <= N; i++)
  {
    if (b[i])
      cnt++;
  }
  cout << cnt << endl;
  for (int i = 1; i <= N; i++)
  {
    if (b[i])
      cout << i << " ";
  }
}


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

typedef long long ll;
const int mod = (int)1e9+7;

int N;
double dp[303][303][303];

double solve(int a, int b, int c){
	if(a+b+c==0)
		return 0;
		
	if(dp[a][b][c] !=-1)
		return dp[a][b][c];
	double ans = 0;
	if(a){
		ans += (1 + solve(a-1,b,c))*a/N;
	}	
	if(b){
		ans += (1 + solve(a+1,b-1,c))*b/N;
	}
	if(c){
		ans += (1 + solve(a,b+1,c-1))*c/N;
	}
	ans = (ans + 1)*N/(a+b+c) -1;
	return dp[a][b][c] = ans;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	cin>>N;
	int st[4],x;
	for(int i=0;i<4;i++)
		st[i] = 0;
		
	for(int i=0;i<N;i++){
		cin>>x;
		st[x]++;
	}	
	for(int i=0;i<=N;i++)
		for(int j=0;j<=N;j++)
			for(int k=0;k<=N;k++) 
				dp[i][j][k] = -1;
	cout<<setprecision(15)<<solve(st[1],st[2],st[3]);
    return 0;
}









Measured memory_bytes: 217472
#include<iostream>
#include<string>
using namespace std;
int main(){
  int count=0;
  string w,t;
  cin >> w;
  for(int i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  cin >> t;
  while(t!="END_OF_TEXT"){
   
    for(int i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) count++;
    cin >> t;
  }
  cout << count << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	LL h,w,ans,s1,s2,s3,mx,mn;
	cin>>h>>w;
	if(w%3==0||h%3==0) {
		cout<<0<< endl;

	}
	else {
		ans=min(h,w);
		for(int i=1;i<w;++i) {
			s1=h*i;
			s2=h/2*(w-i);
			s3=h*w-s1-s2;
			mx=max(s1,max(s2,s3));
			mn=min(s1,min(s2,s3));
			ans=min(ans,mx-mn);
		}
		for(int i=1;i<h;++i) {
			s1=w*i;
			s2=w/2*(h-i);
			s3=h*w-s1-s2;
			mx=max(s1,max(s2,s3));
			mn=min(s1,min(s2,s3));
			ans=min(ans,mx-mn);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    int n;
    scanf("%d", &n);
    std::vector<int> a(n);
    rep(i, n) std::cin >> a[i];
    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
        ans += cnt;
    }
    std::cout << ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int nMax=1e5, MOD=1e9+7;
LL inv[nMax], Fact[nMax], invF[nMax];
LL Comb(int n, int r){ return (((Fact[n]*invF[r])%MOD)*invF[n-r])%MOD; }

int main(){
inv[1]=Fact[0]=Fact[1]=invF[0]=invF[1]=1;
for(int i=2; i<nMax; i++){ 
  inv[i]=((MOD-MOD/i)*inv[MOD%i])%MOD;
  Fact[i]=(Fact[i-1]*i)%MOD; invF[i]=(invF[i-1]*inv[i])%MOD;
}
int N, K; LL M=0, m=0; cin >> N >> K; vector<LL> A(N);
for(int i=0; i<N; i++){ cin >> A[i]; } sort(A.begin(), A.end());
  
for(int i=0; i<N; i++){
if(K<=i+1){ M=(M+(Comb(i, K-1)*((A[i]+MOD)%MOD))%MOD)%MOD; }
if(K<=N-i){ m=(m+(Comb(N-i-1, K-1)*((A[i]+MOD)%MOD))%MOD)%MOD; }
}
cout << ((M-m)+MOD)%MOD << "\n"; 
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  int K,S;
  cin >> K >> S;
  int x,y,z;
  int sum;
  int cnt = 0;
  rep(i,K+1){
    rep(j,K+1){
      sum = i + j;
      if(S - sum <= K && 0 <= S - sum ) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  int a,b;
  cin >> a >> b;
  string s="",t="";
  rep(i,b) s+=(char)('0'+a);
  rep(i,a) t+=(char)('0'+b);
  pr(min(s,t));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] sec = new long[5];
            long total = 0;
            for(int i= 0; i < 5; i++)
            {
                long time = long.Parse(Console.ReadLine());
                    total += time;
                long num = (time / 10 + 1) * 10 - time;
                //増やした時間
                if (time % 10 != 0)
                {
                    sec[i] = num;
                }
            }
            //5個目だけ追加しない
            Array.Sort(sec);
            for(int j = 0; j < 4; j++)
            {
                total += sec[j];
            }
            Console.WriteLine(total);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 27556
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define N 100000

int main(){
        int n, p[N+1][3];

        cin >> n;
        p[0][0] = 0; p[0][1] = 0; p[0][2] = 0;
        for (int i=1;i<=n;i++)
                for (int j=0;j<3;j++) cin >> p[i][j];

        for (int i=1;i<=n;i++) {
                int dt = p[i][0] - p[i-1][0];
                int d = (p[i][1] - p[i-1][1]) + (p[i][2] - p[i-1][2]);
                if (dt - d < 0 || (dt-d)%2 != 0) {
                        cout << "No" << endl;
                        return 0;
                }
        }
        cout << "Yes" << endl;

        return 0;
}


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

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

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 1e6 + 10;
char str[maxn];

void solve() {
  scanf("%s", str + 1);
  int n= strlen(str+1);
  int ans = 0;
  rep(i, 1, n) {
    if (str[i] == 'P') {
      putchar('P');
      ans += i < n && str[i + 1] != 'P';
    } else {
      putchar('D');
      ans++;
    }
  }
//  cout << ans<<endl;
}


int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define inf 1000000000 // 1e9
#define M 1000000007
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int32_t main(){
    fastio;
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];

    int dp[n];
    dp[0]=0;
    
    for(int i=1;i<n;i++){
        int melhor = dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=i-2;j>=0 && i-j<=k;j--){
            melhor = min(melhor,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=melhor;
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){
    speed();
    int n; cin >> n;
    int A[n];
    rep(i, 0, n) cin >> A[i];
    sort(A, A+n);
    cout << A[n/2] - A[(n/2)-1] << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
input=sys.stdin.readline
from collections import deque
from bisect import bisect_left

def main():
    n,m=map(int,input().split())
    X,Y=set(),set()
    H=[]
    V=[]
    for _ in range(n):
        a,b,c=map(int,input().split())
        X.add(a); X.add(b)
        Y.add(c)
        V.append((a,b,c))
    for _ in range(m):
        d,e,f=map(int,input().split())
        X.add(d)
        Y.add(e); Y.add(f)
        H.append((d,e,f))
    X=list(X); Y=list(Y)
    X.sort(); Y.sort()
    MapX={}; MapY={}
    for i,x in enumerate(X):
        MapX[x]=i
    for i,y in enumerate(Y):
        MapY[y]=i
    h=len(MapX)*2; w=len(MapY)*2
    Grid=[[0]*w for _ in range(h)]
    for a,b,c in V:
        a=MapX[a]*2; b=MapX[b]*2; c=MapY[c]*2
        for x in range(a,b+1):
            Grid[x][c]=1
    for d,e,f in H:
        d=MapX[d]*2; e=MapY[e]*2; f=MapY[f]*2
        for y in range(e,f+1):
            Grid[d][y]=1
    s_x=bisect_left(X,0)*2-1
    s_y=bisect_left(Y,0)*2-1
    if s_x<0 or s_y<0 or s_x>=h-1 or s_y>=w-1:
        return 'INF'
    Grid[s_x][s_y]=1
    D=[(1,0),(-1,0),(0,1),(0,-1)]
    ans=0
    q=deque([(s_x,s_y)])
    Grid[s_x][s_y]=1
    while q:
        x,y=q.popleft()
        ans+=(X[x//2+1]-X[x//2])*(Y[y//2+1]-Y[y//2])
        for dx,dy in D:
            half_x,half_y=x+dx,y+dy
            if Grid[half_x][half_y]!=0:
                continue
            to_x,to_y=half_x+dx,half_y+dy
            if to_x<0 or to_y<0 or to_x==h-1 or to_y==w-1:
                return 'INF'
            if Grid[to_x][to_y]!=0:
                continue
            Grid[to_x][to_y]=1
            q.append((to_x,to_y))
    return ans
    
if __name__=='__main__':
    print(main())

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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;
vector<int> adj[N], comp;
int res[N], n, m, k, visit[N];
map<int, int> bro;

int dfs(int node) {
    if(visit[node])
        return 0;
    visit[node] = 1;
    comp.pb(node);
    int ret = 1;
    for(int x: adj[node]) {
        ret += dfs(x);
    }
    res[node] -= adj[node].size();
    return ret;
}

bool same(int x, int y) {
  return bro[x] == bro[y];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    cin >> n >> m >> k;
    forn(i, m) {
        int x, y; cin >> x >> y;
        --x, --y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    forn(i, N) {
        if(!visit[i]) {
            comp.clear();
            int co = dfs(i)-1;
            for(int x: comp) {
                bro[x] = i+1;
                res[x] += co;
            }
        }
    }
    forn(i, k) {
        int x, y; cin >> x >> y;
        --x, --y;
        if(same(x, y))
            --res[x], --res[y];
    }
    forn(i, n)
        cout << res[i] << " ";
    cout << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

L = []
for i in range(M):
    bc = tuple(map(int,input().split()))
    L.append(bc)

L = sorted(L,key=lambda x:-x[1])
n = 0
for b,c in L:
    n += b
    A += [c] * b
    if n >= N:
        break
        
A.sort()
print(sum(A[-N:]))

Measured memory_bytes: 90008
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int a,b;
    cin>>a>>b;
    int ans=((b-1)+(a-1)-1)/(a-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a =  Integer.parseInt(sc.next());
        int b =  Integer.parseInt(sc.next());
        
        int ans = 0;
        
        for (int i=0; i<2; i++) {
            if (a>b) ans += a--;
            else ans += b--;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);

		for (; ;) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			
			if (x == 0 && y == 0) break;
			
			if (x > y) {
				int t = y;
				y = x;
				x = t;
			}
			
			System.out.println(x + " " + y);
		}
	}
}



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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    ll ans=1;
    rep(i,n){
        ans=min(2*ans,ans+k);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long  n,m,d;
  cin>>n>>m>>d;
  if(d!=0){
  long double M=2*(m-1)*(n-d);
  std::cout << std::fixed;
  std::cout << std::setprecision(10) << M/n/n<<endl;
}else{
  long double M=m-1;
  std::cout << std::fixed;
  std::cout << std::setprecision(10) << M/n<<endl;
}
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

enum eps = 1e-9;

void main() {
    double a, b, x;
    scan(a, b, x);

    bool check(double t) {
        t = cTp(t);

        double v;

        if (b / tan(t) <= a) {
            v = a * b * b / (2 * tan(t));
        }
        else {
            v = a * a * b - a^^3 * tan(t) / 2;
        }

        return v >= x;
    }

    double ng = 90, ok = 0;

    foreach (_ ; 0 .. 200) {
        auto mid = (ok + ng) / 2.0;
        (check(mid) ? ok : ng) = mid;
    }

    writefln("%.12f", ok);
}

double cTp(double t) {
    return t / 180.0 * PI;
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

int main() 
{
    long long int n;
    cin>>n;
    if(n%2==0)
    cout<<n/2<<endl;
    else
    cout<<n/2 +1<<endl;
    

   
   // cout<<a[i]<<" ";
    return 0;
}

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

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

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e5 + 10;
int n;
ll X, D;

struct node {
  ll l, r;
};

map <ll, vector <node> > mp;

int main() {
  scanf("%d %lld %lld", &n, &X, &D);
  if (!D) {
    return printf("%d", X ? n + 1 : 1), 0;
  }
  if (D < 0) {
    D = -D, X -= (n - 1) * D;
  }
  bool flg0 = 0;
  rep(i, 1, n) {
    __int128 L = X * i + __int128(D) * i * (i - 1) / 2;
    __int128 R = X * i + __int128(D) * i * (2 * n - i - 1) / 2;
    if (L <= 0 && R >= 0 && X * i % D == 0) flg0 = 1;
    ll val = X * i % D;
    L = (L - val) / D, R = (R - val) / D;
    mp[val].push_back({(ll) L, (ll) R});
  }
  ll ans = !flg0;
  for (auto tmp : mp) {
    vector <node> vec = tmp.second;
    sort(vec.begin(), vec.end(), [] (node P, node Q) {
      return P.l < Q.l;
    });
    ll mx = vec.begin() -> l - 1;
    for (node p : vec) {
      ll l = p.l, r = p.r;
      if (mx < r) ans += (r - max(l - 1, mx)), mx = r;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string s = to_string(n);
    int sz = s.size();

    bool IncNo9 = false;
    for (int i = 1; i < sz; i++) {
        if (s[i] != '9') IncNo9 = true;
    }

    cout << (s[0] - '0' + (sz - 1) * 9 - !!(IncNo9)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=409;
const ll MAXLG=__lg(MAXN)+2;
ll n,a[MAXN];
ll dp[MAXN][MAXN],sum[MAXN][MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        cin >> a[i];
    }

    MEM(dp,INF);
    REP (l,n) {
        dp[l][l] = 0;
        sum[l][l] = a[l];
    }

    REP1 (len,n-1) {
        for (ll l=0;l+len<n;l++) {
            for (ll t=l;t<l+len;t++) {
                sum[l][len+l] = sum[l][t] + sum[t+1][l+len];
                dp[l][len+l] = min(dp[l][len+l],dp[l][t]+dp[t+1][l+len]+sum[l][len+l]);
            }
        }
    }
    cout << dp[0][n-1] << endl;

    return 0;
}


Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;

  REP(i,s.length()){
    s[i] += n;
    if(s[i] > 'Z'){
      s[i] -= ('Z' - 'A') + 1;
    }
  }

  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void){
	
	double a,b,c,d,e,f,x,y,x1,x2,y1,y2;
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){;
	
	
	x=(c*e-b*f)/(a*e-b*d);
	y=(c*d-a*f)/(b*d-a*e);
	
	if(a*e-b*d<0 && c*e-b*f==0){
		x *= -1;
	}
	if(b*d-a*e<0 && c*d-a*f==0){
		y *= -1;
	}
	x1 = (int) x*10000;
	x2 = ((int) x*1000)*10;
	
	if(x1-x2>=5){
		x += 0.001;
	}
	
	y1 = (int) y*10000;
	y2 = ((int) y*1000)*10;
	
	if(y1-y2>=5){
		y += 0.001;
	}
	
	printf("%.3lf %.3lf\n",x,y);
	}
	
return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    ll X, m = 100;
    cin >> X;
    ll count = 0;
    while(m < X) {
        m = (ll)(m * 1.01);
        count++;
    }
    cout << count << endl;
    return 0;
}



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

int main(){
	int a, b;
	string s;

	cin >> a >> b;

	if (a > b)
		s = "a > b";
	else if (a < b)
		s = "a < b";
	else
		s = "a == b";

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1192
ARGF.each do |line|
  n, x = line.split.map(&:to_i)
  break if n == 0 && x == 0
  ary = [*1..n]
  i = 0
  ary.combination(3){ |a,b,c| i += 1 if (a+b+c) == x }
  puts i
end

Measured memory_bytes: 6100
[print(min(m[i])[0])for h in[__import__('heapq')]for a,d,r,n,x in[(h.heappush,h.heappop,range,lambda:map(int,input().split()),list.append)]for N,M,S in[n()]for g,q in[([[]for _ in r(N)],[(0,S,0)])]for L in[max(A for _ in r(M)for U,V,A,B in[n()]if not(x(g[U-1],(V-1,A,B))or x(g[V-1],(U-1,A,B))))*(N-1)]for m in[[[[2**64]for _ in r(L+1)]for _ in r(N)]]for _ in[[[x(g[i],(i,-C,D))for i in r(N)for C,D in[n()]],[[[_ for s,v,i in[d(q)]for _ in[[a(q,(s+c,j,t))for t,p,c in g[i]for j in[min(L,v-p)]for y in[m[t][j]]if v>=p and s+c<y[0] and not(y.clear()or x(y,s+c))]]if not(x(l,None)if q else l.clear())]]for l in[[None]]for _ in l]]]for i in r(1,N)]


Measured memory_bytes: 78172
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n){
        if((i+1) % 2 == 1){
            if(a[i] % 2 == 1){
                sum++;
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  long long m=0;
  cin >> n;
  int arr[n];
  for(int i=0; i<n; i++){
    cin >> arr[i];
    if(arr[i]>m)
        m=arr[i];
  }
  long long max=10000000;
  for(int i=1; i<=m; i++){
    long long tot=0;
    for(int j=0; j<n; j++){
        tot+=(arr[j]-i)*(arr[j]-i);
    }
    if(tot<max)
        max=tot;
  }
  cout << max;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
 {  fast();
	int t, n, k;
	string s;
 cin>>s;
 if(s=="ABC")cout<<"ARC"<<endl;
 else cout<<"ABC"<<endl;
 }

Measured memory_bytes: 3640
module Main where

import Data.List

main = do
  n <- fmap (read::String -> Int) getLine
  names <- fmap lines getContents
  let subgroup = map (count names) "MARCH"
  print $ combi 3 subgroup

count::[String] -> Char -> Int
count x a = length . filter (\(x:xs) -> x == a) $ x

combi::Int -> [Int] -> Int
combi 0 _ = 1
combi _ [] = 0
combi n (x:xs)
 | length xs < n - 1 = 0
 | otherwise =  x * combi (n - 1) xs + combi n xs




Measured memory_bytes: 39164
#include <bits/stdc++.h>
#define pb push_back
#define lli unsigned long long int
using namespace std;

int main() {
	// your code goes here
    int n;
    cin>>n;
    lli a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    
    lli last=a[0];
    lli ans=0;
    
    for(int i=1;i<n;i++)
    {
        if(a[i]<last)
        ans+=last-a[i];
        else
        last=a[i];
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5124
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    string s;
    cin >> s;
    REP(i,0,s.size()-1) if (s[i] == 'A' && s[i+1] == 'C') {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 764
#include<stdio.h>
#define N 2000
int o1;
int A1[N];
int han(int a2,int b){
  int a;
  if(a2==0) return 1;
    if(b>=o1)return 0;
    
   a =  han(a2-A1[b],b+1)||han(a2,b+1);
   return a;
}

int main(){
  int i,j;
  int A2;
  int o2;
  scanf("%d",&o1);
  for(i=0;i<o1;i++){
    scanf("%d",&A1[i]);
  }

   scanf("%d",&o2);
 
  for(j=0;j<o2;j++){
    scanf("%d",&A2);
    if(han(A2,0)==1)printf("yes\n");
    
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;

int main() 
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;i=i+2)
	{
		if(a[i]%2!=0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
  int number = 0, candy = 0;
  int tmp = 0;
  int j;
  vector<int> request;
  request.clear();
  cin >> number >> candy;
  for(int i = 0; i < number; ++i)
  {
    cin >> tmp;
    request.emplace_back(tmp);
  }
  sort(request.begin(), request.end());
  tmp = 0;
  for(j = 0; j < number; ++j)
  {
    tmp += request[j];
    if(tmp > candy)
    {
      break;
    }
    else if(tmp == candy)
    {
      ++j;
      break;
    }
    else if(tmp < candy && (j + 1) == number)
    {
      break;
    }
  }
  cout << j;
  return 0;
}

Measured memory_bytes: 256
S = input()
n = len(S) - 1
sumLine = 0
for i in range(2 ** n):
  op = [0] * (n)
  e = ''
  for j in range(n):
    if (i >> j) & 1  :
      e += S[j] + '+'
    else:
      e += S[j]

  sumLine += eval(e+S[-1])
print(sumLine)


Measured memory_bytes: 3060
import sys

n, m , x, y= map(int, input().split())

X = list(map(int, input().split()))

Y = list(map(int, input().split()))

xm = max(X)

ym = min(Y)


for z in range(x+1, y+1):
    if(z > xm and z <= ym):
        print("No War")
        sys.exit()


print("War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000
 
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main() {
    int n,k;
    cin>>n>>k;
 
    COMinit();
 
    reps(i,1,k+1){
        cout << COM(n-k+1,i)*COM(k-1,i-1)%MOD << endl;
    }
 
 
 
 
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    int n,t,l,b;
    while(scanf("%d%d%d%d", &n, &t, &l, &b) && n){
        char board[101];
        fill(board, board+101, ' ');
        int tmp;
        rep(l){
            scanf("%d", &tmp);
            board[tmp] = 'l';
        }
        rep(b){
            scanf("%d", &tmp);
            board[tmp] = 'b';
        }

        long double dp[t+2][n+1];
        fill(dp[0], dp[t+2], 0.0);
        dp[0][0] = 1.0;
        repp(tt, t){
            rep(n){
                long double inc = dp[tt][i] * 1.0 / 6.0;
                reppp(dice, 1, 7){
                    int next = min(i+dice, 2*n - (i+dice));
                    if(board[next] == 'l'){
                        if(next == n || tt+1 == t){
                            dp[tt+1][next] += inc;
                        }else{
                            dp[tt+2][next] += inc;
                        }
                    }else if(board[next] == 'b'){
                        dp[tt+1][0] += inc;
                    }else{
                        dp[tt+1][next] += inc;
                    }
                }
            }
        }

        long double ans = 0.0;
        repp(tt, t+1){
            ans += dp[tt][n];
        }
        printf("%.6Lf\n", ans);
    }
}



Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mem(dp, v) memset(dp, v, sizeof dp)
using namespace std;
const ll N = 6e5 + 7, inf = 1e17;
ll br[N];
//string s;
//ll foo(int i, int j)
//{//cout<<"dsa";
//    ll &ret = dp[i][j];
//    if(i == j) return 1;
//    if(i > j) return 0;
//    if(ret != -1) return ret;
//    ll ans = 0;
//    if(s[i] == s[j]) ans = (1 + foo(i + 1, j - 1)) + foo(i + 1, j) + foo(i, j - 1)- foo(i + 1, j - 1);
//    else ans = foo(i + 1, j) + foo(i, j - 1) - foo(i + 1, j - 1);
//    return ret = ans;
//}
double ar[N];
int main()
{
    string s, t, u;
    ll n, k;
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
    {
        cin>>ar[ i ];
        ar[ i ] = ( (ar[ i ] * ( ar[ i ] + 1) ) / 2.0) / ar[ i ];
    }
    queue<double>Q;
    double ans = 0.0, tot = 0.0;
    for(int i = 1; i <= n; i++)
    {
        Q.push(ar[ i ]);
        tot += ar[ i ];
        if(Q.size() > k){
            tot -= Q.front();
            Q.pop();
        }
        ans = max(ans , tot);
    }
    cout<<fixed<<setprecision(8)<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main() {
    
    int n,x;
    
    while(1) {
        
        cin >> n >> x;
        
        int count = 0;
        
        if ((n == 0) && (x == 0)) break;
        
        for (int i = 1; i <= n; i ++) {
            for (int j = i + 1; j <= n; j ++) {
                for (int k = j + 1; k <= n; k ++) {
                    
                    if (i + j + k == x) {
                        
                        count += 1;
                    
                        
                    }
                
                }
            }
        }
        
        cout << count << endl;
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long int n;
    cin>>n;
    long long int i=1,sum=0;
    while(i<=n)
    {
      if(i%3!=0&&i%5!=0)
            sum=sum+i;
            i++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
h,w,k = map(int,input().split())
C = [list(input().rstrip()) for i in range(h)]

for i in range(h):
    for j in range(w):
        C[i][j] = int(C[i][j])
# print(C)

A = [[0] * w for i in range(h)]
A = C
# for i in range(h):
#     A[i][0] = C[i][0]

# for i in range(h):
#     for j in range(1, w):
#         A[i][j] = A[i][j-1] + C[i][j]

# B = [[0] * w for i in range(2**h)]

# for i in range(2**h):
#     ib = format(i, "b").zfill(h)
#     for kk in range(w):
#         for j in range(h):
#             if ib[j] == "1":
#                 B[i][kk] += A[j][kk]


ans = 10**15

for i in range(2**(h-1)):
    owa=0
    ib = format(i, "b").zfill(h-1)
    H = [0] * h
    t = 0
    for j in range(h-1):
        if ib[j] == "1":
            t += 1
        H[j+1] = t
    # print(H)
    ans0 = ib.count("1")
    ans00 = ans0
    D = [0] * h
    for j in range(w):
        DD = [0] * h
        for kk in range(h):
            DD[H[kk]] += A[kk][j]
        f = 0
        # print(D)
        for kk in range(h):
            if DD[kk] > k:
                owa = 1
                break
            elif DD[kk]+D[kk] > k:
                f = 1
                
        if owa==1:
            break
        if f == 1:
            ans0 += 1
            D = DD[:]
        else:
            for kk in range(h):
                D[kk] += DD[kk]

    if owa==0:
        ans = min(ans, ans0)
        # print(ib, ans, ans00,ans0)
print(ans)

Measured memory_bytes: 47836
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  string ans = "";
  while (N != 0) {
    if (N % 2 != 0) {
      N--;
      ans = "1" + ans;
    }
    else {
      ans = "0" + ans;
    }
    N /= -2;
  }

  if (ans == "") {
    cout << '0' << endl;
  }
  else {
    cout << ans << endl;
  }
  return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string s;
    cin >> s;
    map<string, int> mp;
    mp["SUN"]=7;
    mp["MON"]=6;
    mp["TUE"]=5;
    mp["WED"]=4;
    mp["THU"]=3;
    mp["FRI"]=2;
    mp["SAT"]=1;
    P(mp[s]);

}

Measured memory_bytes: 256