akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    i64 n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    i64 k = 1;
    double ans = v[0];
    for (int i = 1; i < n; ++i) {
        ans += (double)(v[i] * k);
        k *= 2;
    }
    cout << ans / (double)k << endl;
}


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

int main() {
    int n,m,l; cin >> n;
    m = n%100; l=n/100;
  	int a,b,c,d,e,f,g,h,i,cnt;
    a=m/5; b=m%5;
    cnt+=a;
    c=b/4; d=b%4;
    cnt+=c;
    e=d/3; f=d%3;
    cnt+=e;
    g=f/2; h=f%2;
    cnt+=g;
    i=h/1;
    cnt +=i;

    if(cnt<=l){
        cout << 1<<endl;
    }else{
        cout << 0<< endl;
    }
}

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



int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    bool tf = true;
    rep(i,n) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0)
                tf = false;
        }
    }
    
    if(tf)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    
    
    return 0;
}




Measured memory_bytes: 3632
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
for lis in s:
  idx_list = np.argsort(lis/c)[::-1]
  li += li_one
  max_idx = 0
  max_score = -10**10
  for i in idx_list:
    tmp = li
    li[i] = 0
    sum_c_li = np.sum(c*li)
    score = lis[i] - sum_c_li
    if score >= max_score:
      max_idx = i
      max_score = score
    li = tmp
  print(max_idx + 1)


  

Measured memory_bytes: 27508
#!/usr/bin/env python3

def main():
    N = int(input())
    S = input()
    if N%2!=0:
        print('No')
        return
    
    hanbun = N/2
    zenhan = ''
    kouhan = ''
    for i in range(N):
        if i >= hanbun:
            kouhan += S[i]
        else:
            zenhan += S[i]
    
    if zenhan == kouhan:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	ll a, b = 0;
	cin >> a;
	
	char c;
	cin >> c;
	b += (c - '0') * 100;
	cin >> c >> c;
	b += (c - '0') * 10;
	cin >> c;
	b += (c - '0') * 1;
	
	cout << (a * b) / 100ll << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3684
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100100
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define drp(x, a, b) for(int x=a; x>=b; x--)
int st[N<<1], deg[N], d[N], n, vis[N], a[N], tot, num[N], l[N], ans=1, fac[N], inv[N];
typedef long long LL;

int power(int x, int y){
	int an = 1;
	for(; y; y >>= 1, x = (LL)x * x % mod) if(y & 1) an = (LL)an * x % mod;
	return an;
}

int C(int x, int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return (LL)fac[x] * inv[y] % mod * inv[x - y] % mod;
}

void renew(int &x, const int y){
	x += y;
	if(x < 0) x += mod;
	if(x >= mod) x -= mod;
}

void init(){
	fac[0] = inv[0] = fac[1] = inv[1] = 1;
	rep(i, 2, n){
		fac[i] = (LL)fac[i - 1] * i % mod;
		inv[i] = power(fac[i], mod - 2);
	}
}

int getdp(){
	int fr = 0;
	rep(i, 1, tot) st[i + tot] = st[i];
	rep(i, 1, tot) if(l[st[i]]){
		fr = i;
		break;
	}
	reverse(st + fr + 1, st + fr + tot);
	int a = fr + l[st[fr]] - 1, b = a + 1, c = 1;
	rep(i, fr + 1, fr + tot - 1)if(l[st[i]]){
		int na = i + l[st[i]] - 1, nb = na + 1, cc = 0;
		if(a < i) renew(cc, c);
		if(b < i) renew(cc, c);
		a = na;
		b = nb;
		c = cc;
	}
	int ans = 0;
	if(a < fr + tot) renew(ans, c);
	if(b < fr + tot) renew(ans, c);
	return ans;
}

int que[N], h, t;
int main(){
	scanf("%d", &n);
	rep(i, 1, n)
	{
		scanf("%d", a+i); deg[a[i]]++;
	}
	rep(i, 1, n) if(deg[i]>2) return puts("0"), 0;
	rep(i, 1, n) d[i] = deg[i];
	rep(i, 1, n) if(!d[i]) que[++t] = i;
	rep(h, 1, t){
		int u = que[h];
		--d[a[u]];
		vis[u] = 1;
		if(!d[a[u]]) que[++t] = a[u];
	}
	rep(i, 1, n) if(vis[i] && deg[i] >= 2){
		puts("0");
		exit(0);
	}
	rep(i, 1, n) if(vis[i] && !deg[i]){
		int x = i, cnt = 0;
		for(x = i; vis[x]; x = a[x])cnt++;
		l[x] = cnt;
	}
	init();
	ans=1;
	rep(i, 1, n)if(!vis[i])
	{
		int u = i, cu = 1;
		tot = 0;
		int res = 0;
		do{
			st[++tot] = u;
			cu &= !l[u];
			vis[u] = 1;
			u = a[u];
		}while(u != i);
		if(cu){
			num[tot] ++;
			res = 1;
		}else{
			res = getdp();		
		}
		ans = (LL)ans * res % mod;
	}
	rep(i, 1, n) if(num[i])
	{
		int tot = num[i];
		int res = 0;
		for(int x = 0; x <= tot; x += 2){
			int cb = 1;
			cb = (LL)cb * power(i, (x >> 1)) % mod;
			cb = (LL)cb * C(tot, x) % mod;
			cb = (LL)cb * fac[x] % mod;
			cb = (LL)cb * inv[x >> 1] % mod;
			cb = (LL)cb * power((mod + 1) >> 1, x >> 1) % mod;
			if((i > 1) && (i & 1)){
				cb = (LL)cb * power(2, tot - x) % mod;
			}
			renew(res, cb);
		}
		ans = (LL)ans * res % mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}



int main(){
  int A,B;
  cin >> A >> B;
  if(B % A == 0) cout << A + B << endl;
  else cout << B - A << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = (cin.ReadInt * cin.ReadInt) % 2 == 0 ? "Even" : "Odd";
            WriteLine(a);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 27892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int n = 0;
            if(x>=1800)
            {
                n = 1;
            }
            else if(x>=1600)
            {
                n = 2;
            }
            else if(x>=1400)
            {
                n = 3;
            }
            else if(x>=1200)
            {
                n = 4;
            }
            else if(x>=1000)
            {
                n = 5;
            }
            else if(x>=800)
            {
                n = 6;
            }
            else if(x>=600)
            {
                n = 7;
            }
            else
            {
                n = 8;
            }
            Console.WriteLine(n);
        }
    }
}

Measured memory_bytes: 27468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    string s; cin >> s;
    cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}

Measured memory_bytes: 3612
from heapq import heappush, heappop
from math import sqrt
import sys
readline = sys.stdin.buffer.readline
write = sys.stdout.write
N, M = map(int, readline().split())
PS = [list(map(int, readline().split())) for i in range(N)]
QS = [list(map(int, readline().split())) for i in range(M)]

def dot3(O, A, B):
    ox, oy = O; ax, ay = A; bx, by = B
    return (ax - ox) * (bx - ox) + (ay - oy) * (by - oy)
def cross3(O, A, B):
    ox, oy = O; ax, ay = A; bx, by = B
    return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def dist2(A, B):
    ax, ay = A; bx, by = B
    return (ax - bx) ** 2 + (ay - by) ** 2
def is_intersection(P0, P1, Q0, Q1):
    C0 = cross3(P0, P1, Q0)
    C1 = cross3(P0, P1, Q1)
    D0 = cross3(Q0, Q1, P0)
    D1 = cross3(Q0, Q1, P1)
    if C0 == C1 == 0:
        E0 = dot3(P0, P1, Q0)
        E1 = dot3(P0, P1, Q1)
        if not E0 < E1:
            E0, E1 = E1, E0
        return E0 <= dist2(P0, P1) and 0 <= E1
    return C0 * C1 <= 0 and D0 * D1 <= 0

def solve(N, PS, q0, q1):
    yield 10**18
    p0 = PS[0]; p1 = PS[1]
    if not is_intersection(p0, p1, q0, q1):
        yield sqrt(dist2(p0, p1))
        return
    V0 = [i for i in range(2, N) if not is_intersection(p0, PS[i], q0, q1)]
    V1 = [i for i in range(2, N) if not is_intersection(p1, PS[i], q0, q1)]
    D0 = [sqrt(dist2(p0, p)) for p in PS]
    D1 = [sqrt(dist2(p1, p)) for p in PS]
    for v0 in V0:
        for v1 in V1:
            if v0 != v1:
                if is_intersection(PS[v0], PS[v1], q0, q1):
                    continue
                yield D0[v0] + D1[v1] + sqrt(dist2(PS[v0], PS[v1]))
            else:
                yield D0[v0] + D1[v1]

ans = min(
        sqrt(dist2(QS[0], QS[1])) + min(solve(N, PS, QS[0], QS[1])),
        sqrt(dist2(PS[0], PS[1])) + min(solve(M, QS, PS[0], PS[1]))
        )
if ans < 10**9:
    write("%.16f\n" % ans)
else:
    write("-1\n")


Measured memory_bytes: 6140
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n,k = readmi()
t = read()
ans = ""
for i in range(n):
    if i + 1 == k:
        ans += t[i].lower()
    else:
        ans += t[i]
print(ans)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b; cin >> a >> b;
    if(b%a == 0) cout << a+b << endl;
    else cout << b-a << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7652
n = int(input())
h = [int(i) for i in input().split()]
dp = [0,abs(h[0]-h[1])]
for i in range(2,n):
    dp.append(min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]))
print(dp[-1])


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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(long long n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(long long n, long long k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(void){
    ll r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
    combination C(r2+1+c2+1);
    mint ans(0);
    ans += C(r2+1+c2+1,r2+1) - C(r1+c2+1,r1) - C(r2+1+c1,r2+1) + C(r1+c1,r1);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;


int main() {
    llint N;
    cin >> N;
    vector<llint> a(N), b(N);
    llint suma = 0, sumb = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        suma += a[i];
    }
    llint rez = 0;
    for(int i = 0; i < N; i++) {
        cin >> b[i];
        sumb += b[i];
    }
    bool change = true; 
    while(suma < sumb && change) {
        change = false;
        for(int i = 0; i < N; i++) {
            if(b[i] > a[i] && b[i] >= b[(i - 1 + N) % N] && b[i] >= b[(i + 1) % N]) {
                llint diff = b[(i - 1 + N) % N] + b[(i + 1) % N];
                llint kolko = min((b[i] - a[i]) / diff, (b[i] - max(b[(i - 1 + N) % N], b[(i + 1) % N]) - 1) / diff + 1);
                if(kolko == 0) {
                    continue;
                }
                b[i] -= diff * kolko;
                sumb -= diff * kolko;
                rez += kolko;
                change = true;
            }
        }
    }
    if(a == b) {
        cout << rez;
    }
    else {
        cout << -1;
    }
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
#define int ll
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 

typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};


signed main(){
	int N;
	string s, t;
	cin >> N >> s >> t;

	// N文字一致するか？
	int r = 0;
	for (int i = N; i >= 0; i--){
		bool f = true;
		for (int j = 0; j < i; j++){
			if (s[N -i+j] != t[j]){ f = false; break; }
		}
		if (f){
			r = i; break;
		}
	}

	cout << 2 * N - r << endl;



	return 0;
}


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


using namespace std;
 
int main(){
int N;
cin >> N;
vector<string> s(N);
map<string,int> str;
for(int i = 0; i < N; i++){
     cin >> s[i];
     str[s[i]] += 1;

}
int max = 0;
for(int i = 0; i < N; i++){
    if(max < str[s[i]]) max = str[s[i]]; 
}
sort(s.begin(),s.end());
map<string,int> t;

for(int i = 0; i < N; i++){
    if(max == str[s[i]] &&  t[s[i]] == 0){ t[s[i]] = 1; cout << s[i] << endl;}

}




return 0;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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 under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main(){
	int n;
	cin >> n;
	ll sum = 0;
	rep1(i, n) {
		if (i % 3 && i % 5) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, l = 0, r = 0; string t;
	cin >> n;
	vector<string> v(n);
	for (auto &i : v)
		cin >> i;
	cin >> t;
	string t1 = t, t2 = t;
	replace(t1.begin(), t1.end(), '?', 'a');
	replace(t2.begin(), t2.end(), '?', 'z');
	for (auto i : v)
	{
		string a = i, b = i;
		replace(a.begin(), a.end(), '?', 'a');
		replace(b.begin(), b.end(), '?', 'z');
		if (b < t1)
			++l;
		if (t2 < a)
			++r;
	}
	for (int i = l + 1; i <= n - r + 1; ++i)
		cout << i << (i == n - r + 1 ? "\n" : " ");
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
        
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[]=new int[m];
		
		for(int i=0;i<m;i++) {
		 a[i]=sc.nextInt();
		}
		int s=0;
		for(int i=0;i<m;i++) {
			s+=a[i];
		}
		if(s>n){
		System.out.println(-1);
		}else{
		System.out.println(n-s);
		}
	}
}

Measured memory_bytes: 37884
#include <bits/stdc++.h>
/*
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
*/

#define INF 10e15
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
	long long int n, W;
    cin >> n >> W;

    long long int v, w;
    vector<pair<long long int, long long int> > a;

    long long int i, j;
    for(i = 0; i < n; i++){
        cin >> v >> w;
        pair<long long int, long long int> p = make_pair(w, v);
        a.push_back(p);
    }

    vector<pair<long long int, long long int> > x;
    for(i = 0; i < (1<<(n/2)); i++){
        long long int tmp_w = 0;
        long long int tmp_v = 0;
        for(j = 0; j < n/2; j++){
            if((i>>j)&1){
                tmp_w += a[j].first;
                tmp_v += a[j].second;
            }
        }
        pair<long long int, long long int> p = make_pair(tmp_w, tmp_v);
        x.push_back(p);
    }
    sort(x.begin(), x.end());

    for(i = 1; i < x.size(); i++){
        x[i].second = max(x[i].second, x[i-1].second);
    }


    long long int ans = 0;
    for(i = 0; i < (1<<(n - n/2)); i++){
        long long int tmp_w = 0;
        long long int tmp_v = 0;
        for(j = 0; j < n - n/2; j++){
            if((i>>j)&1){
                tmp_w += a[n/2+j].first;
                tmp_v += a[n/2+j].second;
            }
        }

        if(tmp_w <= W){
            long long int tmp;
            pair<long long int, long long int> p = make_pair(W-tmp_w, INF);
            tmp = (lower_bound(x.begin(), x.end(), p) - 1) -> second;
            ans = max(ans, tmp + tmp_v);
        }

    }

    cout << ans << endl;
}


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

int main(){
  int A,B;
  cin >> A >> B;


  if(A == B){
    cout << "Draw" << endl;
  }else if(A == 1){
    cout << "Alice" << endl;
  }else if(B == 1){
    cout << "Bob" << endl;
  }else if(A > B){
    cout << "Alice" << endl;
  }else if(B > A){
    cout << "Bob" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
 
int main() {
  int N, d1, d2, count = 0, ans = 0;
  cin >> N;
  for(int i= 0; i<N; i++){
    cin >> d1 >> d2;
    if(d1 == d2)count++;
    else count = 0;
    if(count==3)  ans = 1;
  }
  if (ans == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline void read(int &x)
{
	x=0;
	int p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
int n;
int sum;
int ans;
int ans1;
int main()
{
//	freopen("C.in","r",stdin);
//	freopen("C.out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++)
	{
		int x;
		read(x);
		if(x%4==0)sum++;
		if(x%2==1)ans++;
		else if(x%4!=0)ans1++;
	}
	if(ans1==n)return puts("Yes"),0;
	else ans++;
	if(sum>=n/2)return puts("Yes"),0;
	if(sum>=ans-1)return puts("Yes"),0;
	puts("No");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
m=list(map(int,input().split()))
a=[]
if m[0]<m[1]:
    a.append([0,-1])
for i in range(1,n-1):
    if m[i]>m[i-1] and m[i]>=m[i+1]:
        a.append([i,1])
    elif m[i]<=m[i-1] and m[i]<m[i+1]:
        a.append([i,-1])
    elif m[i]<m[i-1] and m[i]<=m[i+1]:
        a.append([i,-1])
    elif m[i]>=m[i-1] and m[i]>m[i+1]:
        a.append([i,1])
if m[n-1]>m[n-2]:
    a.append([n-1,1])
#print(a)
k=0
r=1000
t=0
for i in range(len(a)):
    if a[i][1]==-1 and t==0:
        k=r//m[a[i][0]]
        r-=k*m[a[i][0]]
        t=1
    elif a[i][1]==1 and t==1:
        
        
        r+=k*m[a[i][0]]
        k=0
        t=0
        
    #print(k,r)
print(r)
        
        

Measured memory_bytes: 62128
// 解説前
#include <iostream>

int solve_C() {
  int N;
  std::cin >> N;

  int result = 0;
  int count = 0;
  int curr;
  std::cin >> curr;
  for (int i = 1; i < N; ++i) {
    int next;
    std::cin >> next;
    if (next <= curr) {
      count++;
    } else {
      result = count > result ? count : result;
      count = 0;
    }
    curr = next;
  }
  result = count > result ? count : result;

  std::cout << result;
  return 0;
}

int main() { return solve_C(); }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define mod 1000000007

using namespace std;

int main(){
  int n;
  
  cin >> n;
  int b[n-1];
  
  rep(i,0,n-2)cin >> b[i];
  
  long long ans = b[0];
  
  rep(i,1,n-2){
    ans += min(b[i-1], b[i]);
  }
  
  ans += b[n-2];
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

#define NODE_NUM (100)

int n;
int current_time = 0;
int M[NODE_NUM][NODE_NUM] = { 0 };
int ans[NODE_NUM][2] = { 0 };
stack<int> S;

void DepthFirstSearch(int node)
{
	int current, next;

	current_time++;

	S.push(node);
	ans[node - 1][0] = current_time;

	while (!S.empty()) {
		current_time++;

		current = S.top();
		next = -1;

		rep(i, n) {
			if (M[current - 1][i] == 1 && ans[i][0] == 0) {
				next = i + 1;
				break;
			}
		}

		if (next == -1) {
			ans[current - 1][1] = current_time;
			S.pop();
		}
		else {
			ans[next - 1][0] = current_time;
			S.push(next);
		}
	}
}

int main()
{
	int u, k, v;
	bool NowSearching = true;

	cin >> n;
	rep(i, n) {
		cin >> u >> k;
		rep(j, k) {
			cin >> v;
			M[u - 1][v - 1] = 1;
		}
	}

	rep(i, n) {
		if (ans[i][0] == 0) DepthFirstSearch(i + 1);
	}

	rep(i, n) {
		cout << i + 1 << ' ' << ans[i][0] << ' ' << ans[i][1] << endl;
	}

	return 0;
}


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

int main()
{
  int h1, h2, m1, m2, studytime, diff,result;
  diff = 0;
  result = 0;
  cin >> h1 >> m1 >> h2 >> m2 >> studytime;

  if (m1 == m2)
  {
    diff = h2 - h1;
    diff = diff * 60 - studytime;
  }
  else if(m2 > m1)
  {
    diff = h2 - h1;
    diff = diff * 60 + (m2- m1)-studytime;
    //cout << diff << endl;
    //result = diff / studytime;
  }
  else
  {
    h2 = h2 - 1;
    m2 = m2 + 60;
    diff = h2 - h1;
    diff = diff * 60 + (m2- m1) - studytime;
    //result = diff / studytime;
  }
  cout << diff << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>

using namespace std;


int main() {

	string S;
	cin >> S;
	int a = stoi(S.substr(0, 2));
	int b = stoi(S.substr(2, 2));

	if (a < 13 && a > 0) {
		if (b < 13 && b > 0) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (b < 13 && b > 0) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int mod = 1e9+7;
  vector<vector<ll>>dp(s.size()+1,vector<ll>(13));
  dp[0][0] = 1;
  rep(i,0,s.size()){
    int c;
    if(s[i] == '?') c = -1;
    else c = s[i]-'0';
    rep(j,0,10){
      if(c != -1 && c != j) continue;
      rep(k,0,13) dp[i+1][(k*10+j)%13] += dp[i][k];
    }
    rep(j,0,13) dp[i+1][j] %= mod;
  }
  cout << dp[s.size()][5] << endl;
}

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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_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 int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    long int n,t,a,b;
    cin >> n;
    cin >> a;
    for(long int i = 0; i < n - 1; ++i){
        cin >> b;
        a = LCM(a,b);
    }

    cout << a << endl;


}

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

template<class T> int LIS(vector<T> a,  bool is_strong = true) {
    const T INF = 1<<30; // to be set appropriately
    int n = (int)a.size();
    vector<T> dp(n, INF);
    for (int i = 0; i < n; ++i) {
        if (is_strong) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
        else *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}


int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i], a[i] *= -1;
    cout << LIS(a, false) << endl;
}


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

int main() {
    int n, q, c = 0, T;
    int S[10001];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &T);
        for (int j = 0; j < n; j++) {
            if (T == S[j]) {
                c++;
                break;
            }
        }
    }
    printf("%d\n", c);
    return 0;
}


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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<ll> &v){
    for(ll x: v){
        cout<<x<<" ";
    }
    newline;
}

const ll MOD = 1e9+7;
const ll nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    ll n, m; cin>>n>>m;
	set<ll> a;

	for(int i=0; i<m; i++){
		ll x; cin>>x;
		a.insert(x);
	}

	ll dp[n+1];

	memset(dp, 0, sizeof(dp));

	dp[0] = 1;

	for(ll i=1; i<=n; i++){
		if(a.find(i)==a.end()){
			dp[i] += dp[i-1];
			dp[i]%=MOD;
			if(i>1){
				dp[i]+=dp[i-2];
				dp[i]%=MOD;
			}
		}
	}

	cout<<dp[n]<<endl;
    
    return 0;
}

Measured memory_bytes: 8924
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<ll> sum(n + 1, 0);
	rep(i, n)
	{
		ll a; cin >> a;
		sum[i + 1] = sum[i] + a;
	}
	ll res = 1e18;
	for (int i = 1; i < n; ++i)
	{
		ll snu = sum[i];
		ll ara = sum[n] - sum[i];
		res = min(res, abs(snu - ara));
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
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 main()
{
    int N;
    cin >> N;
    vector<int> a(N + 1);
    rep2(i,1,N+1){
        cin >> a[i];
    }

    vector<int> b;
    for(int i = N; i >= 1 ; i--){
        int k;
        k = N/i;
        int num = 0;
        rep2(j,1,k){
            num += a[i * (j + 1)];
        }
        if(a[i] != num%2){
            b.push_back(i);
            a[i] = 1;
        }
        else a[i] = 0;
    }

    cout << b.size() << endl;
    rep(i,b.size())  cout << b[i] << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 2424
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int A, B;
    string S;
    io.read(A, B, S);
    string ans = "Yes";
    for(int i = 0; i < S.size(); i++){
        if(i == A){
            if(S[i] != '-') ans = "No";
        }
        else{
            if(S[i] < '0' || S[i] > '9') ans = "No";
        }
    }
    cout << ans;
    return 0;
}

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

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

    int a[n];
    int tmp;
    int ans = 0;
    fill(a, a+n, 0);
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp > n) {
            ans++;
        } else {
            a[tmp-1]++;
        }
    }

    for (int i = 0; i < n; i++) {
        if (a[i] >= i+1) {
            ans += a[i] - i -1;
        } else {
            ans += a[i];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
 
int main(){
    int a,b,respuesta,k,hola;
     
    while((scanf("%d",&a))!=EOF){
        scanf("%d",&b);
        hola=a+b;
        for(respuesta=1;;){
            hola=(hola-hola%10)/10;
            if(hola>0)
            respuesta++;
            else{
                printf("%d\n",respuesta);
                break;
            }
        }
    }
         
     
    return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, M;
	long K;
	long[] A, B;
	int count = 0;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		K = Long.parseLong(tokens[2]);
		A = new long[N];
		B = new long[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			B[i] = Long.parseLong(tokens[i]);
		}

	}

	void calc() {
		long time = 0;
		Deque<Long> remainA = new ArrayDeque<>();
		for (int i = 0; i < N; ++i) {
			remainA.add(A[i]);
		}
		Deque<Long> remainB = new ArrayDeque<>();
		for (int i = 0; i < M; ++i) {
			remainB.add(B[i]);
		}
		Deque<Long> readA = new ArrayDeque<>();
		Deque<Long> readB = new ArrayDeque<>();

		// まずAを読めるだけ読む
		while (!remainA.isEmpty()) {
			if (time + remainA.peekFirst() <= K) {
				long t = remainA.pollFirst();
				readA.add(t);
				time += t;
			} else {
				break;
			}
		}
		// 余裕があればBも読めるだけ読む
		while (!remainB.isEmpty()) {
			if (time + remainB.peekFirst() <= K) {
				long t = remainB.pollFirst();
				readB.add(t);
				time += t;
			} else {
				break;
			}
		}

		int maxCount = readA.size() + readB.size();

		while (!readA.isEmpty()) {
			// Aから読むのを1つ減らす
			long t = readA.pollLast();
			time -= t;
			while (!remainB.isEmpty()) {
				if (time + remainB.peekFirst() <= K) {
					long t2 = remainB.pollFirst();
					readB.add(t2);
					time += t2;
				} else {
					break;
				}
			}
			maxCount = Math.max(maxCount, readA.size() + readB.size());
			if (remainB.isEmpty()) {
				break;
			}
		}
		System.out.println(maxCount);

	}

	void showResult() {
	}
}


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

int main() {
  int d;
  int sum;

  while(cin >> d) {
    sum = 0;
    for (int i=d; i<600; i+=d) {
      sum += i*i*d;
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t ;
	// cin >> t;
	// while (t--) {
	int n , k ;
	cin >> n >> k ;
	vector<int>p(n) ;
	for (int i = 0 ; i < n ; i++) {
		cin >> p[i] ;
	}
	sort(p.begin(), p.end()) ;
	cout << accumulate(p.begin() , p.begin() + k , 0) << "\n";



	// }

	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	
	string s; cin >> s;
	string t; cin >> t;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return  0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    //vector <string>s(2000);
    string s,t,u;
    cin>>s;
    int a;
    a=s.size();
    t='e';u='s';
    if(s.at(a-1)=='s'){cout<<s<<t<<u<<endl;}
    else{cout<<s<<u<<endl;}
    
}

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

int main() {

    int a,b;
    cin>>a>>b;
    int a2,b2,ab;
    a2=a*2-1;
    b2=b*2-1;
    ab=a+b;
    if(a2>=b2 && a2>=ab){
        cout<<a2<<endl;
    }else if(b2>=a2 && b2>=ab){
        cout<<b2<<endl;
    }else if(ab>=a2 && ab>=b2){
        cout<<ab<<endl;
    }
    
    return 0;
}


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

int main()
{
 int n,m,x,y;
  cin>>n>>m>>x>>y;
  if(x>=y)
  {
    cout<<"War\n";
    return 0;
  }
  vector<int> a(n),b(m);
  for(int &i:a) cin>>i;
  for(int &i:b) cin>>i;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  x = max(x,a[a.size()-1]);
  y = min(y,b[0]);
  if(x>=y)
  {
    cout<<"War\n";
    return 0;
  }
  else
    cout<<"No War\n";
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

string ans;

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

    
    if(n == 0){
        cout << 0 << endl;
    }else{
        while(n != 0){
            if(abs(n) % 2 == 1){
                ans+='1';
                n = (n-1)/(-2);
            }else{
                ans+='0';
                n /= -2;
            }
        }
        reverse(ans.begin(),ans.end());
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i];
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll cnt[114514];
signed main() {
	string s;
	ll k;
	cin >> s >> k;
	ll n = s.size();
	rep(i, n)cnt[i] = (26 - (s[i] - 'a')) % 26;
	rep(i, n) {
		if (cnt[i] <= k) {
			k -= cnt[i];
			s[i] = 'a';
		}
	}
	s[n - 1] = (char)(s[n - 1] + (k % 26));
	cout << s << endl;
	ggr
}





Measured memory_bytes: 1408