akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int A, B;
   cin >> A >> B;
   int ans = 0;
   if (A >= 13) ans = B;
   else if (A >= 6) ans = B / 2;
   else ans = 0;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#define LL long long
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
   // freopen("data.txt","r",stdin);
    LL a;LL b;
    cin>>a>>b;
    LL i=0;
    while(a<=b)
    {
        ++i;
        a<<=1;
    }
    cout<<i;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 3e3 + 10;
char s[N], t[N];
int dp[N][N];

int main() {
  scanf("%s%s", s + 1, t + 1);
  int n = strlen(s + 1);
  int m = strlen(t + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i] == t[j]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  string ret;
  for (int i = n, j = m; i >= 1 && j >= 1; ) {
    if (s[i] == t[j]) {
      ret += s[i];
      --i;
      --j;
    } else {
      if (dp[i][j] == dp[i - 1][j]) {
        --i;
      } else {
        --j;
      }
    }
  }
  reverse(ret.begin(), ret.end());
  puts(ret.c_str());
  return 0;
}


Measured memory_bytes: 35584
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

n = int(input())
graph = [[] for _ in range(n)]  #[(v_to, edge_idx)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append((b, i))
    graph[b].append((a, i))


def dfs(v, v_p, target):
    if v == target:
        return True, 0

    for v_next, edge_idx in graph[v]:
        if v_next == v_p:
            continue
        is_target, path = dfs(v_next, v, target)
        if is_target:
            return is_target, path | (1 << edge_idx)
    return False, 0


m = int(input())
cond = []
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    _, path = dfs(u, -1, v)
    # print(u, v, bin(path))
    cond.append((u, v, path))

ans = 1 << (n - 1)
for bit in range(1, 1 << m):
    l = 0
    path = 0
    for i, (u, v, path_i) in enumerate(cond):
        if (bit >> i) & 1:
            l += 1
            path = path | path_i

    c = n - 1 - bin(path).count('1')
    ans += ((-1)**(l % 2)) * (1 << c)

print(ans)


Measured memory_bytes: 43180
#include<bits/stdc++.h>
using namespace std;
const int N = 710;
int n, m, fa[N], rl[N], g[N][2], mp[N][N], f[N];
inline int Ask(int x) {
	if (!fa[x]) return x;
	int tmp = Ask(fa[x]);
	rl[x] ^= rl[fa[x]];
	return fa[x] = tmp;
}
inline void Merge(int x, int y) {
	int u = Ask(x), v = Ask(y);
	if (u == v) {
		if (rl[x] == rl[y]) puts("-1"), exit(0);
		return;
	}
	fa[u] = v;
	rl[u] = rl[x] ^ rl[y] ^ 1;
}
inline void Append(int x, int y) {
	for (int i = n; ~i; --i) {
		int ans = 0;
		if (i >= x) ans |= f[i - x];
		if (i >= y) ans |= f[i - y];
		f[i] = ans;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, x, y; i <= m; ++i) {
		scanf("%d%d", &x, &y);
		if (x > y) swap(x, y);
		mp[x][y] = 1;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (!mp[i][j]) Merge(i, j);
	for (int i = 1; i <= n; ++i) {
		Ask(i);
		++g[Ask(i)][rl[i]];
	}
	f[0] = 1;
	for (int i = 1; i <= n; ++i) if (!fa[i]) Append(g[i][0], g[i][1]);
	int ans = n >> 1;
	while (!f[ans]) --ans;
	printf("%d\n", ans * (ans - 1) / 2 + (n - ans) * (n - ans - 1) / 2);
	return 0;
}

Measured memory_bytes: 2176
import fractions

n = int(input())
A = list(map(int, input().split()))
n = len(A)

L = [0]
R = [0]
ans_list = []

for i in range(n-1):
    L.append(fractions.gcd(L[i], A[i]))
    R.append(fractions.gcd(R[i], A[n-1-i]))

for j in range(n):
    ans_list.append(fractions.gcd(L[j], R[-j-1]))

print(max(ans_list))

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n, W;
  cin >> n >> W;
  ll dp[110][100010];
  rep(i, 0, 110){
    rep(j, 0, 100010){
      dp[i][j] = INF;
    }
  }
  vl w(n), v(n);
  rep(i, 0, n)
    cin >> w[i] >> v[i];
  
  dp[0][0] = 0;
  
  rep(i, 0, n){
    rep(j, 0, 100010){
      if(j >= v[i]){
        llchmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
      }
      llchmin(dp[i+1][j], dp[i][j]);
    }
  }
  
  ll ans = 0;
  rep(i, 0, 100010){
    if(dp[n][i] <= W)
      ans = i;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 89564
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll m,n,cnt,sum;
int Prime[200005],yy[2000005]; 
inline void getprime()
{
	for(int i=1;i<=2e6;++i) yy[i]=1;
	for(int i=2;i<=2e6;++i)
	{
		if(yy[i]) Prime[++cnt]=i;
		for(int j=1;j<=cnt&&i*Prime[j]<=2e6;++j)
		{
			yy[i*Prime[j]]=0;
			if(i%Prime[j]==0) break;
		}
	}
}
int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
    cin>>m>>n;
    ll k=__gcd(m,n);
    getprime();
    for(int i=1;i<=cnt&&Prime[i]<=k;++i)
    {
    	if(k%Prime[i]==0) sum++;
    	while(k%Prime[i]==0) k/=Prime[i];
	}
	if(k>1) sum++;
	cout<<sum+1;
	return 0;
}

Measured memory_bytes: 11992
#include <bits/stdc++.h>
using namespace std;
#define PRINT(x) std::cout << x << std::endl;
#define FOR(i, n) for(int i = 0; i < (n); ++i)
int result;
int n, m, q;
vector<int> a, b, c, d;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    FOR(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) 
        now += d[i];
    }
    result = max(now, result);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  FOR(i, q) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  dfs(vector<int>(1, 1));
  PRINT(result);
}

Measured memory_bytes: 3584
#include<stdio.h>

int right;

class Dice2{
  public:
    int D[6];
    
    Dice2(int a, int b, int c, int d, int e, int f){
        D[0] = a;
        D[1] = b;
        D[2] = c;
        D[3] = d;
        D[4] = e;
        D[5] = f;
    }
    
    void right_side(int u, int f){
        if (u == D[0] && f == D[1]) right = D[2];
        if (u == D[0] && f == D[2]) right = D[4];
        if (u == D[0] && f == D[3]) right = D[1];
        if (u == D[0] && f == D[4]) right = D[3];
        
        if (u == D[1] && f == D[0]) right = D[3];
        if (u == D[1] && f == D[2]) right = D[0];
        if (u == D[1] && f == D[3]) right = D[5];
        if (u == D[1] && f == D[5]) right = D[2];
        
        if (u == D[2] && f == D[0]) right = D[1];
        if (u == D[2] && f == D[1]) right = D[5];
        if (u == D[2] && f == D[4]) right = D[0];
        if (u == D[2] && f == D[5]) right = D[4];
        
        if (u == D[3] && f == D[0]) right = D[4];
        if (u == D[3] && f == D[1]) right = D[0];
        if (u == D[3] && f == D[4]) right = D[5];
        if (u == D[3] && f == D[5]) right = D[1];
        
        if (u == D[4] && f == D[0]) right = D[2];
        if (u == D[4] && f == D[2]) right = D[5];
        if (u == D[4] && f == D[3]) right = D[0];
        if (u == D[4] && f == D[5]) right = D[3];
        
        if (u == D[5] && f == D[1]) right = D[3];
        if (u == D[5] && f == D[2]) right = D[1];
        if (u == D[5] && f == D[3]) right = D[4];
        if (u == D[5] && f == D[4]) right = D[2];
        
    }
};

int main(){
    
    int list[6];
    scanf("%d %d %d %d %d %d", &list[0], &list[1], &list[2], &list[3], &list[4], &list[5]);
    
    int q;
    scanf("%d",&q);
    
    int u, f;
    for ( int i = 0; i < q; i++){
        scanf("%d %d", &u, &f);
    
        Dice2 saikoro(list[0], list[1], list[2], list[3], list[4], list[5]);
        saikoro.right_side(u, f);
    
        printf("%d\n",right);
    }
    
    return 0;
}


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

using namespace std;

int memo[200][200][200];

int solve(int a, int b, int c) {
    if (a > 199 || b > 199 || c > 199)
        return 1e7;
    if (a == b && a == c)
        return 0;

    int &r = memo[a][b][c];

    if (r == -1) {
        r = 1 + min(solve(a + 1, b + 1, c), solve(a + 1, b, c + 1));
        r = min(r, 1 + min(solve(a, b + 1, c + 1), solve(a + 2, b, c)));
        r = min(r, 1 + min(solve(a, b + 2, c), solve(a, b, c + 2)));
    }

    return r;
}

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

    memset(memo, -1, sizeof memo);
    int a, b, c;
    cin >> a >> b >> c;
    cout << solve(a, b, c) << '\n';

    return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, s, n) for (int i = (s); i <= (n); ++i)

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

template <class A, class B>
inline bool chmax(A &a, const B b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B b) { return b < a && (a = b, true); }

const int INF = 0x3f3f3f3f;
const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = int(1e9) + 7;

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	vector< vector<int> > vec(100010);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		if (a <= m) vec[a].push_back(b);
	}
	
	i64 res = 0;
	priority_queue<int> que;
	reps(i, 1, m) {
		for (int j = 0; j < vec[i].size(); ++j) {
			que.push(vec[i][j]);
		}
		if (!que.empty()) {
			res += que.top();
			que.pop();
		}
	}
	
	cout << res << "\n";
		
	return 0;
}


Measured memory_bytes: 5632
n = gets.chomp.to_i
x = y = t = 0
n.times do
    ti, xi, yi = gets.chomp.split(" ").map(&:to_i)
    x = (x - xi).abs
    y = (y - yi).abs
    isOk = ti - t - (x + y)
    if isOk != 0 && isOk % 2 != 0 || isOk < 0
        puts "No"
        exit
    end
    x, y, t = xi, yi, ti
end
puts "Yes"

Measured memory_bytes: 1788
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
s=list(input())
t=list(input())
for i in range(n):

    if s[i:]==t[:n-i]:
        print(n+i)
        exit()
print(2*n)

Measured memory_bytes: 10452
#include <stdio.h>

int main(void) {
    int k;

    scanf("%d", &k);
    if (k % 2 == 0)
        printf("%d\n", k * k / 4);
    else
        printf("%d\n", (k / 2) * (k / 2 + 1));

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> ans(n, -1);
    while (m--) {
        int s, c; cin >> s >> c;
        s--;
        if (ans[s] != -1 && ans[s] != c) {
            cout << -1 << '\n';
            exit(0);
        }
        ans[s] = c;
    }
    if (n == 1) {
        if (ans[0] == -1)
            ans[0] = 0;
        cout << ans[0] << '\n';
        exit(0);
    }
    if (ans[0] == 0) {
        cout << -1 << '\n';
        exit(0);
    }
    if (ans[0] == -1)
        ans[0] = 1;
    for (int i = 1 ; i < n; i++)
        if (ans[i] == -1)
            ans[i] = 0;
    for (auto &v : ans)
        cout << v;
    cout << '\n';
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    M = 1000
    kabu = 0
    for i in range(N-1):
        if A[i] <= A[i+1]:
            M += A[i] * kabu
            kabu = 0
            kabu += M // A[i]
            M = M % A[i]
        else:
            M += A[i] * kabu
            kabu = 0

    else:
        M += kabu * A[i+1]
    print(M)


if __name__ == '__main__':
    main()

Measured memory_bytes: 61792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5+100;
LL a[maxn];

int main()
{
    int n;
    cin >> n;
    for(int i = 1;i<=n;++i)
        cin >> a[i];
    LL ma = a[1];
    LL ans =1;
    for(int i = 2;i<=n;++i)
    {
        if(a[i]<=ma)
        {
            ans++;
        }
        ma = min(ma,a[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    L = int(input())
    print((L**3)/27)


if __name__ == "__main__":
  main()


Measured memory_bytes: 12404
#include <stdio.h>

int main(void){

  int n,Lt;
  scanf("%d %d", &n, &Lt);
  int c[n];
  int t[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &c[i], &t[i]);
  }
  int min = 1001;
  for (int i = 0; i < n; i++) {
    if (t[i] <= Lt && c[i] < min) {
      min = c[i];
    }
  }
  if (min > 1000) {
    printf("TLE\n");
  } else {
    printf("%d\n", min);
  }

  return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{

    static int[] kouka = {10,50,100,500};

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

	int money = sc.nextInt();

	boolean boo = false;
	while(money!=0){
	    if(boo)System.out.println();
	    boo = true;
	    int[] coin = new int[4];
	    for(int i=0; i<coin.length; i++){
		coin[i] = sc.nextInt();
	    }

	    String ans = solve(coin,money);
	    System.out.print(ans);

	    money = sc.nextInt();
	}
    }
    
    public static String solve(int[] coin, int money){
	int sum = 0;
	for(int i=0; i<coin.length; i++){
	    sum += kouka[i] * coin[i];
	}
	int[] oturiKouka = getOturi(sum,money);
	String ans = "";
	for(int i=0; i<coin.length; i++){
	    if(coin[i]-oturiKouka[i]>0)ans += kouka[i] + " " + (coin[i]-oturiKouka[i]) + "\n";
	}
	return ans;
    }

    public static int[] getOturi(int shiharai,int money){
	int oturi = shiharai - money;
	int[] oturiKouka = new int[4];
	while(oturi!=0){
	    for(int i=kouka.length-1; i>=0;){
		if(oturi-kouka[i]>=0){
		    oturi = oturi - kouka[i];
		    oturiKouka[i]++;
		}else i--;
	    }
	}
	return oturiKouka;
    }
}

Measured memory_bytes: 12000
h,w,k=map(int,input().split())

inputCake=[]

for _ in range(h):
  temp=input()
  temp2=[]
  for i in temp:
    temp2.append(i)
  inputCake.append(temp2)
  
#print(inputCake)

result=[[0] * w for i in range(h)]

row=0
rowA=[]

number=1
for i in range(h):
  #行にいちごがある場合
  if "#" in inputCake[i]:
    rowA.append(row)
    count=0
    for j in range(w):
      #いちごを見つけたら
      if inputCake[i][j]=="#":
        #一つ目なら
        if count==0:
          result[i][j]=str(number)
          count+=1
        else:#二つ目以降なら
          number+=1
          result[i][j]=str(number)
      else:
      #いちごじゃなかったら
        result[i][j]=str(number)
    number+=1
  row+=1
    

    
    
#print(result)
#print(rowA)

lastnum=rowA[len(rowA)-1]
for i in range(h):
  #print(rowA)
  if i in rowA:
    print(' '.join(result[i]))
    rowA.pop(0)
  else:
    if rowA!=[]:
      print(' '.join(result[rowA[0]]))
    else:
      print(' '.join(result[lastnum]))
    

Measured memory_bytes: 54384
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,k = myinput()
ab = mylistinput(n)

ab = mysort(ab,0,False)
# print(ab)

count = 0
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    count += b
    if count >= k:
        print(a)
        exit()
print("E")

Measured memory_bytes: 64728
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint a[364364],b[364364];
int n;
bool cal(lint mi){
	lint ret=0;
	rep(i,n) b[i]=a[i];
	for(int i=0;i<n-1;i+=2){
		if(mi>b[i] || b[i]>b[i+1]) b[i+2]+=b[i]-b[i+1];
	}
	return b[n-1]>=mi;
}
int main()
{
	cin>>n;rep(i,n) cin>>a[i];
	lint s=0,s2=0;
	rep(i,n){
		if(i%2==0) s+=a[i];else s2+=a[i];
	}
	if(n%2==0){
		cout<<max(s,s2)<<' '<<min(s,s2)<<endl;return 0;
	}
	lint lo=-123456789012345678LL,hi=123456789012345678LL;
	while(hi>lo){
		lint mi=(hi+lo+1)/2;
		//cout<<lo<<' '<<hi<<' '<<mi<<endl;
		if(cal(mi)) lo=mi;else hi=mi-1;
	}
	cout<<max(s,s2+lo)<<' '<<s+s2-max(s,s2+lo)<<endl;
}


Measured memory_bytes: 5376
c1 = [int(x) for x in input().split()]
c2 = [int(x) for x in input().split()]
c3 = [int(x) for x in input().split()]

a2 = None
a3 = None
for i in range(c1[0]+1):
    a1 = i
    b1 = c1[0]-a1
    b2 = c1[1]-a1
    b3 = c1[2]-a1
    if c2[0]-b1 == c2[1]-b2 == c2[2]-b3:
        a2 = c2[0]-b1
    else:
        pass
    if c3[0]-b1 == c3[1]-b2 == c3[2]-b3:
        a3 = c3[0]-b1
    else:
        pass

print("Yes" if a2 is not None and a3 is not None else "No")

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef long long LL;
#define REP(i,s,N) for (int i=s; i<N; i++)

string IntToString(int number) {
	stringstream ss;
	ss << number;
	return ss.str();
}

int main() {
	vector<string> s(3), ans(3);
	REP(i,0,3) {
		cin >> s[i];
		ans[i] = s[i][0] - 32;
	}
	cout << ans[0] << ans[1] << ans[2] << endl;
}

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

#define INF 2*1000000000

//var 
int N,h[100001], dp[100001];

int main(){
	cin >> N;
	for(int i = 1; i<=N; i++){
		cin >> h[i];
		dp[i] = INF;
	}
	dp[1] = 0;
	for(int i = 1; i<=N; i++){
		if(i+1<=N)dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		if(i+2<=N)dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}cout << dp[N] << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ARC077
{
    public class C
    {
        private void Run()
        {
            var n = int.Parse(Console.ReadLine().Trim());
            var A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();

            var b = new long[A.Length];
            bool f = true;
            int left = 0, right = A.Length - 1;
            foreach (var a in A.Reverse())
            {
                if (f)
                {
                    b[left] = a;
                    left++;
                }
                else
                {
                    b[right] = a;
                    right--;
                }
                f ^= true;
            }
            Console.WriteLine(string.Join(" ", b));
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 51840
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=10001

for i in range(0,102):
    if (i in p):
        continue
    else:
        tmp=(x-i)**2
        if tmp<ans:
            ans=tmp
            c=i
print(c) 

Measured memory_bytes: 9184
#include<stdio.h>

int main(){
		int m,d,i,j,ans=0;
		scanf("%d%d",&m,&d);
		for(i=1;i<=m;i++){
				for(j=1;j<=d;j++){
						int a=j/10;
						int b=j%10;
						if(a>=2&&b>=2){
								if(i==a*b)ans++;
						}
				}
		}
		printf("%d\n",ans);
				return 0;
}


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

using namespace std;
using ll = long long;

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

template <typename T>
struct fenwick_tree {
    int n;
    vector<T> d;
    fenwick_tree(int n = 0) : n(n), d(n + 1) {}

    void add(int i, T x = 1) {
        assert(0 <= i && i < n);
        i++;
        while (i <= n) {
            d[i - 1] += x;
            i += i & -i;
        }
    }
    T sum(int i) {
        T x = 0;
        while (i > 0) {
            x += d[i - 1];
            i -= i & -i;
        }
        return x;
    }
};

int main() {
    int N, Q, l, r, idx = 0;
    cin >> N >> Q;
    vector<int> c(N), good(N, -1), ans(Q);
    REP(i, N) cin >> c[i];
    vector<tuple<int, int, int>> query(Q);
    REP(i, Q) {
        cin >> l >> r;
        query[i] = {r - 1, l - 1, i};
    }

    sort(query.begin(), query.end());
    fenwick_tree<int> fw(N);

    REP(i, Q) {
        l = get<1>(query[i]);
        r = get<0>(query[i]);
        // goodを更新する
        // 合わせてBIT木も更新する
        while (idx <= r) {
            if (good[c[idx] - 1] >= 0) {
                fw.add(good[c[idx] - 1], -1);
            }
            good[c[idx] - 1] = idx;
            fw.add(idx, 1);
            idx++;
        }
        ans[get<2>(query[i])] = fw.sum(r + 1) - fw.sum(l);
    }

    REP(i, Q) cout << ans[i] << endl;
}


Measured memory_bytes: 17460
#include<bits/stdc++.h>
#define ll long long
#define F(i,a,b) for(ll i=a;i<b;i++)
#define RF(i,a,b) for(ll i=a;i>b;i--)
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb(x) push_back(x)
#define pob pop_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define w(t) int t; cin>>t;while(t--)
using namespace std;
const int inf=(int)1e9;
char flip_bits(char c){return (c == '0')? '1': '0';}

int smallestDivisor(int n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return 2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return i; 
    } 
  
    return n; 
} 
int main()
{
    
    ios::sync_with_stdio(0);   
    cin.tie(0);   
    ll a[100000];
    ll dp[100000];
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll i,j,prev; 
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])) ,(dp[i-2]+abs(a[i]-a[i-2])));

    }
    cout<<dp[n-1];

return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main() {
  int n = 0,kazu[10000],a,i;
  for(n = 0;n < 10000;n++){
    scanf("%d",&a);
    if(a == 0) break;
    kazu[n] = a;
  }
  for(i = 1;i <= n;i++){
    printf("Case %d: %d\n",i,kazu[i-1]);
}
return 0;
}

Measured memory_bytes: 632
s = input()
ans1, ans2 = 0, 0
for i, e in enumerate(s):
  if i%2:
    if e=="0":
      ans1 += 1
    if e=="1":
      ans2 += 1
  else:
    if e=="1":
      ans1 += 1
    if e=="0":
      ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;cin>>n;
    rep(i,1000){
        int res=i*(i-1)/2;
        if(res==n){
            cout<<"Yes"<<endl;
            cout<<i<<endl;
            vector<int>v[i];
            int cnt=1;
            rep(j,i)REP(k,j+1,i){
                v[j].push_back(cnt);
                v[k].push_back(cnt);
                cnt++;
            }
            rep(j,i){
                cout<<v[j].size()<<" ";
                for(auto e:v[j])cout<<e<<" ";
                cout<<endl;
            }
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 2304
def f(a, b):
    if a % 2 == 0:
        pass
    else:
        a -= 1
    a //= 2
    b += a
    return a, b

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

cnt = 1
for i in range(inp[2]):
    if cnt % 2 == 0:
        inp[0], inp[1] = f(inp[1], inp[0])
    else:
        inp[1], inp[0] = f(inp[0], inp[1])


if inp[2] % 2 == 0:
    print(inp[0], inp[1], sep=" ")
else:
    print(inp[1], inp[0], sep=" ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b;
    string s;
    cin>>a>>b>>s;
    bool d = true;
    rep(i,a+b+1){
        if(i==a){
            if(s[i]!='-')d = false;
        }
        else{
            if(s[i]=='-')d = false;
        }
    }
    if(d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,q,a,t,x;
	cin >> n >> q;
	vector< priority_queue<int> > st(n+1);
	for(int i=0;i<q;i++){
		cin >> a;
		if(a==0){
			cin >> t >> x;
			st[t].push(x);
		}else if(a==1){
			cin >> t;
			if(!st[t].empty()){
				cout << st[t].top() << endl;
			}
		}else{
			cin >> t;
			if(!st[t].empty()){
				st[t].pop();
			}
		}
	}
}


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

#define rep(i,n) for(int i = 0; i < n; ++i)

using namespace std;

int main(void){
int x,y;
cin >> x >> y;

if(x == y){
cout << x + x  << endl;

}else if(x > y){
cout << x + x -1 << endl;
}else{
cout<< y+y-1 << endl;
}
return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    int mn = INF;
    REP(i, n - k + 1) {
        chmin(mn, a[i + k - 1] - a[i]);
    }
    cout << mn << EOL;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 100010;
const int maxK = 19;
const int MOD = 1000000007; 
ll a[maxN];
ll c[maxN];
int s[maxN];
ll power(ll b,ll k,ll p)
{
	if(k==0)
		return 1;
	ll t = power(b,k/2,p);
	t =  (t*t)%p;
	if(k%2 == 1)
		t = (t*b)%p;
	return t;
}
ll combine(int n,int m,int p)
{
	if(n<m)
		return 0;
	ll ret = (a[m]*a[n-m])%p;
	ret = (a[n] * power(ret,p-2,p))%p;
	return ret;
}
int main()
{
	int n; 
	scanf("%d",&n); 
	n++;
	a[0] = 1;
	a[1] = 1;
	int p = MOD;
	for(int i=2;i<=n;i++)
		a[i] = (a[i-1]*i)%p;
	int q;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(s[x] == 0)
		{
			s[x] = i;
		}
		else
		{
			q = n - (i - s[x] +1);
			break;
		}
	}
	for(int i=1;i<=n;i++)
	{
		ll ans = ((combine(n,i,p) - combine(q,i-1,p))+MOD)%MOD;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll x , k , d;

int main() {
	scanf("%lld %lld %lld" , &x , &k , &d);
	if (x < 0) {
		ll cnt = abs(x)/d;
		if (k < cnt) {
			printf("%lld" , abs(x+d*k));
			return 0;
		}
		x += cnt*d;
		k -= cnt;
		ll tmp = x+d;
		ll tmp2 = x-d;
		if (k%2 == 1) printf("%lld" , min(abs(tmp) , abs(tmp2)));
		else printf("%lld" , abs(x));
	}
	else {
		ll cnt = x/d;
		if (k < cnt) {
			printf("%lld" , abs(x-d*k));
			return 0;
		}
		x -= cnt*d;
		k -= cnt;
		ll tmp = x-d;
		ll tmp2 = x+d;
		if (k%2 == 1) printf("%lld" , min(abs(tmp) , abs(tmp2)));
		else printf("%lld" , abs(x));
	}
	
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
vector<int> dist;
const int INF = 1e9;
struct  edge{int to, cost;};
vector<edge> G[100010];

void dij(int start){
  priority_queue<P, vector<P>, greater<P> > que;
  for(int i = 0; i < dist.size(); i++){
    dist[i] = INF;
  }
  dist[start] = 0;
  que.push(P(0, start));
  
  while(!que.empty()){
    P p = que.top(); que.pop();
    int next = p.second;
    if(dist[next] < p.first) continue;
    for(int i = 0; i < G[next].size(); i++){
      edge e = G[next][i];
      if(dist[next] + e.cost < dist[e.to]){
        dist[e.to] = dist[next] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
}

signed main(){
  int V, E, r; cin >> V >> E >> r;
  for(int i = 0; i < E; i++){
    int s, t, d; cin >> s >> t >> d;
    edge e = {t, d}; G[s].push_back(e);
  }
  dist.resize(V, INF);
  dij(r);
  for(int i = 0; i < V; i++){
    if(dist[i] == INF) cout << "INF" << endl;
    else cout << dist[i] << endl;
  }
}



Measured memory_bytes: 19552
#include<iostream>
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<time.h>
#include<random>
#include<string>
#include<cmath>
#include <ctime>
#include<bitset>
#include <cctype>
#define debug cout<<"*********degug**********";
#define index index_
#define int long long
#define RE register
#define yn yn_
using namespace std;
mt19937 rnd(233);
const long long max_ = 1e7 + 7;
const double alpha = 0.75;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
int c[50000000 + 500], yuan[50000000 + 500], n, d,A;
int low_bit(int x) {
	return (x&(-x));
}

void change(int x, int value) {
	while (x <= n) {
		c[x] += value;
		x = x + low_bit(x);
	}
}

int sum_(int x) {
	//算1到x的总和
	int ans = 0;
	while (x != 0) {
		ans += c[x];
		x = x - low_bit(x);
	}
	return ans;
}
struct kk{
	int xi, health;
}node[max_];
bool cmp(const kk & t1, const kk & t2) {
	return t1.xi < t2.xi;
}
int  yn = 0;
signed main() {
	n = read(), d = read(), A = read();
	for (int i = 1; i <= n; i++) {
		node[i].xi = read(); node[i].health = read();
		yuan[++yn] = node[i].xi;
	}
	sort(yuan + 1, yuan + 1 + yn);
	yn = unique(yuan + 1, yuan + 1 + yn) - yuan - 1;
	sort(node + 1, node + 1 + n,cmp);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int weizhi = lower_bound(yuan + 1, yuan + 1 + yn, node[i].xi) - yuan;
		int t = sum_(weizhi) + node[i].health;
		if (t <= 0) {
			continue;
		}
		else {
			int cishu = (int)ceil( (t*1.0) / A);
			ans += cishu;
			int R = lower_bound(yuan + 1, yuan + 1 + yn, node[i].xi + d + d) - yuan;
			if (yuan[R] > node[i].xi + d + d)R--;
			change(weizhi, -cishu * A);
			change(R + 1, cishu * A);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;
 
struct Line {
	LL a, b;

	LL operator()(LL x) {
		return a * x + b;
	}
	Line(LL p = 0, LL q = 0) : a(p), b(q) {}
};

struct LiChaoTree {
	int size = 1;
	vector<Line> tree;

	LiChaoTree(int n) {
		while(size < n)
			size *= 2;
		tree.resize(size << 1);
	}

	LL get_min(int x) {
		int v = x + size;
		LL ans = LL(1e18);
		while(v) {
			ans = min(ans, tree[v](x));
			v >>= 1;
		}
		return ans;
	}

	void add_func(Line new_func, int v, int l, int r) {
		int m = (l + r) / 2;
		bool domin_l = tree[v](l) > new_func(l),
			 domin_m = tree[v](m) > new_func(m);
		if(domin_m)
			swap(tree[v], new_func);

		if(l == r)
			return;
		else if(domin_l == domin_m)
			add_func(new_func, v << 1 | 1, m + 1, r);
		else
			add_func(new_func, v << 1, l, m);
	}

	void add_func(Line new_func) {
		add_func(new_func, 1, 0, size - 1);
	}
};

LL square(int x) {
	return x * LL(x);
}

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

	int n;
	LL C;
	cin >> n >> C;
	vector<int> h(n);
	for(int &hi : h)
		cin >> hi;

	vector<LL> dp(n);
	LiChaoTree lines(h[n - 1] + 1);
	lines.add_func({-2 * h[0], square(h[0])});

	for(int j = 1; j < n; ++j) {
		dp[j] = lines.get_min(h[j]) + square(h[j]) + C;
		lines.add_func({-2 * h[j], square(h[j]) + dp[j]});
	}
	cout << dp[n - 1] << '\n';
}



Measured memory_bytes: 35328
#include<stdio.h>
    
int main(void){
    
int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
if(r<=x&&(x+r)<=W&&r<=y&&(y+r)<=H){
printf("Yes\n");
}
else{
printf("No\n");
}
return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (max(a, c) - min(a, c) <= d){
    cout << "Yes" << endl;
  }
  else {
    if (max(a, b) - min(a, b) <= d){
      if (max(b, c) - min(b, c) <= d){
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}



int main(void){
    ll n;
    cin>>n;
    ll ans=n*(n-1)/2;
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
//ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


struct item
{
	int value, weight;
};


int main() {
	int c[105][10005];
	item item[105];
	int n, w;
	cin >> n >> w;
	REP(i, n) c[i][0] = 0;
	REP(i, w) c[0][i] = 0;
	FOR(i, 1, n + 1) {
		int a, b;
		cin >> a >> b;

		item[i].value = a;
		item[i].weight = b;
		//cout << item[i].value << item[i].weight << endl;
	}
	FOR(i, 1, n + 1) {
		FOR(j, 1, w + 1) {
			c[i][j] = c[i - 1][j];
			if (item[i].weight > j) continue;
			c[i][j] = max(c[i - 1][j], c[i - 1][j - item[i].weight] + item[i].value);
		}
	}
	cout << c[n][w] << endl;
}

Measured memory_bytes: 7096
#include <iostream>
#include <vector>
#include <algorithm> //sort,二分探査など
#include <cassert>
#include <tuple>
//#include<bitset>
//#include<cmath>//pow,logなど
//#include<deque>
//#include<functional>
//#include<iterator>
//#include<map>
//#include<numeric>//gcd,lcm
//#include<queue>
//#include<set>
//#include<stack>
//#include<string>
//#include<utility>//pair

//QCFium法
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//浮動小数点処理高速化
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using i64 = int64_t;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;

#define _overload3(_1, _2, _3, name, ...) name
#define repi(i, start, end) for (int i = (int)(start); i < (int)(end); ++i)
#define _rep(i, n) repi(i, 0, n)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, start, end) for (int i = (int)(start); i > (int)(end); --i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
  rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
  for (T &in : v)
    is >> in;
  return is;
}

i64 pow_mod(i64 a, i64 b, i64 m)
{
  i64 ret = 1;
  while (b > 0)
  {
    if (b & 1)
    {
      ret = ret * a % m;
    }
    a = a * a % m;
    b >>= 1;
  }
  return ret;
}

//sort(rng(P),[](const vi &a, const vi &b){return a[1]<b[1];});

void Main()
{
  i64 N;
  cin >> N;
  i64 ans = pow_mod(10, N, MOD);
  ans = (ans + MOD - pow_mod(9, N, MOD)) % MOD;
  ans = (ans + MOD - pow_mod(9, N, MOD)) % MOD;
  ans += pow_mod(8, N, MOD);
  ans %= MOD;
  cout << ans << "\n";
}

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define endl '\n'
#define time clock_t tStart = clock();
#define show printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define ll                    long long int
#define loop(a,b)             for(int i=a;i<=b;++i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);

using namespace std;
void FAST_IO();
int main()
{
    //_time_
   //FAST_IO() ;
    ll a[7];
    for(ll i=0;i<6;i++)
        cin>>a[i];
    bool check=true;
    for(ll i=0;i<5;i++)
    {
        for(ll j=i;j<5;j++)
        {
            if(a[j]-a[i]>a[5])
            {
                check=false;
                break;
            }
        }
    }
    if(check)
        cout<<"Yay!\n";
    else
        cout<<":(\n";
   // show
    return 0;
}
void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
#ifndef _offline
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}



Measured memory_bytes: 256
#include <iostream>

constexpr int MAX_N = 100000;

using ll = long long int;

int n, q;

ll seg[MAX_N * 4], lazy[MAX_N * 4];

void init(int size) {

	n = 1;

	while (n < size)
		n *= 2;
}

void eval(int k, int l,int r ) {

	seg[k] += lazy[k];

	if (r - l > 1) {
		lazy[k * 2 + 1] += lazy[k] / 2;
		lazy[k * 2 + 2] += lazy[k] / 2;
	}

	lazy[k] = 0;
}

void add(int a, int b, int v, int k, int l, int r) {

	eval(k, l, r);

	if (r <= a || b <= l)
		return;

	if (a <= l&&r <= b) {

		lazy[k] = v*(r - l);

		eval(k, l, r);

		return;
	}

	add(a, b, v, k * 2 + 1, l, (l + r) / 2);
	add(a, b, v, k * 2 + 2, (l + r) / 2, r);

	seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
}

ll getSum(int a, int b, int k, int l, int r) {

	eval(k, l, r);

	if (r <= a || b <= l)
		return 0;

	if (a <= l&&r <= b)
		return seg[k];

	return getSum(a, b, k * 2 + 1, l, (l + r) / 2) + getSum(a, b, k * 2 + 2, (l + r) / 2, r);
}

int main() {

	std::cin >> n >> q;

	init(n);

	int com, s, t, x;

	for (int i = 0; i < q; ++i) {

		std::cin >> com >> s >> t;

		if (com == 0) {

			std::cin >> x;

			add(s - 1, t, x, 0, 0, n);
		}

		else
			std::cout << getSum(s - 1, t, 0, 0, n) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 6252
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);		
		int n=in.nextInt();
		int m=in.nextInt();
		int ans=0;
		if(n-2*m>0)
		{
			ans=n-2*m;
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 21844
A, B, C, X, Y = [int(i) for i in input().split(' ') ]


BB = B if B < 2*C else 2 * C
AA = A if A < 2 * C else 2 * C



if X < Y:
    R1 = BB * (Y - X)
elif X > Y:
    R1 = AA * (X -Y)
else:
    R1 = 0

if A + B > 2 * C:
    R2 = min(X,Y) * 2 * C
else:
    R2 = min(X,Y) * (A+B)

print(R1 + R2)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<string>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int count_first = 1;
    int count_end = n;
    int count = 0;
    while(1){
        if(n==k){
            count++;
            break;
        }else if(count_end-count_first<k-1){
            count++;
            break;
        }
        count+=2;
        count_first+=k-1;
        count_end-=k-1;
        if(count_first>=count_end)   break;
    }
    /*
    int count =0;
    if(k!=2)
    count =n/(k-1);
    else if(k==2 && n==2)
    count = 1;
    else
    count = n/k-1;
    */
    cout << count << endl; 
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt();
		if(a + b > 24){
			System.out.println((a + b) % 24);
		}else if(a + b == 24){
			System.out.println(0);
		}else{
			System.out.println(a + b);
		}
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

int main()
{
	LL n;
	cin >> n;
	cout << ((n-1)*(n))/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int c=0,f=0;
	while(n--)
	{
	    int a,b;
	    cin>>a>>b;
	    if(a==b)
	    {
	        c++;
	        if(c>=3)
	        {
	            f=1;
	        }
	    }
	    else
	    {
	     c=0;   
	    }
	}
	if(f==1)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    ll x;
    cin >> x;
    int a,b;
    a=x/500;
    b=x%500/5;
    cout << 1000*a+5*b << endl;
}

Measured memory_bytes: 256
n, a = map(int, input().split())
b = list(map(int, input().split()))
b.sort()
c = 0
for i in range(n):
  if a < b[i] or (i == n - 1 and b[i] != a):
    break
  a -= b[i]
  c += 1
print(c)

Measured memory_bytes: 9116
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] l = new int[n];
		
		for(int i = 0; i < n; i++) {
			l[i] = stdIn.nextInt();
		}
		int cnt = 0;
		
		for(int i = 0; i < n; i++) {
			for(int j = i+1; j < n; j++) {
				for(int k = j + 1; k < n; k++) {
					if(l[i] != l[j] && l[j] != l[k]&& l[k] != l[i] && l[i] < l[j]+l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j] ) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 36684