akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var x = new long[N];
            var y = new long[N];
            var s = new long[N];
            var t = new long[N];

            // マンハッタン距離の45度変換
            // (x, y) -> (x + y, x - y) = (s, t)
            // max(|x_i - x_j| + |y_i - y_j|)
            //     = max{max(s_i - s_j), max(t_i - t_j)}
            //     = max{max(s_i) - min(s_i), max(t_i) - min(t_i)}

            for (int i = 0; i < N; i++)
            {
                (x[i], y[i]) = Read2Longs();
                s[i] = x[i] + y[i];
                t[i] = x[i] - y[i];
            }

            return Math.Max(s.Max() - s.Min(), t.Max() - t.Min());
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 53304
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int N;
  int H;
  cin >> N >> H;
  int a[100010], b[100010];
  for (auto i = 0; i < N; ++i) {
    cin >> a[i] >> b[i];
  }
  int maxi = 0;
  for (auto i = 0; i < N; ++i) {
    maxi = max(maxi, a[i]);
  }
  sort(b, b+N);
  reverse(b, b+N);
  int cnt = 0;
  for (auto i = 0; i < N; ++i) {
    if (b[i] > maxi) {
      H -= b[i];
      cnt++;      
    } else {
      break;
    }
    if (H <= 0) {
      cout << cnt << endl;
      return 0;
    }
  }
  cnt += (H + maxi - 1) / maxi;
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> // only for GCC
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();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((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);

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

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

int main() {
  int n;

  while(cin >> n) {
    int ans = n%39;
    if(ans == 0) ans = 39;
    string str = "3C";

    str += (ans/10) + '0';
    str += (ans%10) + '0';
    cout << str << endl;  
  }
}

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

int A[10000000], n;

int binarySearch (int key) {
    int left  = 0;
    int right = n;
    int mid;

    while ( left < right ) {
        mid = ( left + right ) / 2;
        if ( key == A[mid] ) return 1;
        if ( key > A[mid] ) left = mid + 1;
        else if ( key < A[mid] ) right = mid;
    }
    return 0;
}

int main () {
    int i, q, k, sum = 0;
    scanf ("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    scanf ("%d", &q);
    for (i = 0; i < q; i++) {
        scanf ("%d", &k);
        if (binarySearch (k)) sum++;
    }
    printf ("%d\n", sum);
    return 0;
}


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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int M = nextInt();

		int[] a = new int[N];
		int[] b = new int[N];
		for(int i=0;i<N;i++){
			a[i]=nextInt();
			b[i]=nextInt();
		}

		int[] c = new int[M];
		int[] d = new int[M];
		for(int i=0;i<M;i++){
			c[i]=nextInt();
			d[i]=nextInt();
		}

		for(int i=0;i<N;i++){
			long dist =	Long.MAX_VALUE;
			int idx=-1;
			for(int k=0;k<M;k++){
				int tmp = Math.abs(a[i]-c[k])+Math.abs(b[i]-d[k]);
				if(tmp < dist){
					idx=k;
					dist=tmp;
				}
			}
			System.out.println(idx+1);
		}

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22740
def main():
    n = int(input())
    abc = []
    for i in range(n):
        abc.append(tuple(map(int, input().split())))

    am, bm, cm = abc[0]
    for ai, bi, ci in abc[1:]:
        am, bm, cm = max(bm, cm) + ai, max(am, cm) + bi, max(am, bm) + ci
    print(max(am, bm, cm))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21312
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll N,M;
ll A[200010], B[200010];
vector<ll> tree[100010];
vector<ll> tree_inv[100010];
ll d[100010] = {};
ll ans[100010] = {};
ll checked[100010] = {};
ll h[100010] = {};
// void dfs(ll cur, ll par, ll depth){
//     if(d[cur] > depth) return;
//     if(checked[cur]) return;
//     d[cur] = max(d[cur], depth);
//     // if(depth > N) return;
//     for(auto &e: tree[cur]){
//         if(e == par) continue;
//         dfs(e, cur, depth+1);
//     }
// }
// ll cnt = 0;

// void dfs2(ll cur, ll par){
//     // if(cnt == N-1) return;
//     for(auto &e: tree[cur]){
//         if(e == par) continue;
//         if(d[cur] == d[e]-1){
//             dfs2(e, cur);
//             ans[e] = cur+1;
//             cnt++;
//         }
//     }
// }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,0,N-1+M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        tree[A[i]].push_back(B[i]);
        h[B[i]]++;
        tree_inv[B[i]].push_back(A[i]);
    }
    stack<ll> st;
    rep(i,0,N){
        if(h[i] == 0){
            st.push(i);
        }
    }
    vector<ll> ans;
    while(st.size()){
        ll k = st.top();
        st.pop();
        ans.push_back(k);
        for(auto &e: tree[k]){
            h[e]--;
            if(h[e] == 0) st.push(e);
        }
    }

    map<ll,ll> mp;
    rep(i,0,N){
        mp[ans[i]] = i;
    }
    ll v[100010] = {};
    // printa(ans,N);
    rep(i,0,N){
        if(mp[i] == 0){
            // print(i);
            v[i] = -1;
        }else{
            ll val = -1;
            ll tt = -1;
            for(auto &e: tree_inv[i]){
                // print2(i,e);
                // print(ans[e]);
                if(val < mp[e]){
                    val = mp[e];
                    tt = e;
                }
            }
            v[i] = tt;
            // print2(i,tt);
        }
    }
    rep(i,0,N){
        print(v[i]+1);
    }

    // rep(i,0,M){
    //     cin >> x[i] >> y[i];
    //     x[i]--; y[i]--;
    //     tree[x[i]].push_back(y[i]);
    //     h[y[i]]++;
    // }
    // rep(i,0,N){
    //     d[i] = 0;
    // }
    // ll v = -1;
    // rep(i,0,N){
    //     if(tree_inv[i].size() == 0){
    //         v = i;
    //         break;
    //     }
    // }
    // dfs(v, -1, 0);
    // dfs2(v, -1);
    // // printa(d, N);
    // // printa(ans,N);
    // rep(i,0,N){
    //     print(ans[i]);
    // }

}


Measured memory_bytes: 23928
#include "stdio.h"

int N;
int K;
int num[10];
int fig[5040] = {};
int box;
int work;
int now;
int ans;

int main() {
	scanf("%d %d", &N, &K);
	while (N != 0) {
		ans = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &num[i]);
		}
		switch (K) {
		case 2:
			box = 0;
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					if (i != j) {
						fig[box] = num[i];
						if (num[j] >= 10)fig[box] = fig[box++] * 100 + num[j];
						else fig[box] = fig[box++]*10 + num[j];
					}
				}
			}
			break;
		case 3:
			box = 0;
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					for (int k = 0; k < N; k++) {
						if (i != j&&i != k&&j != k) {
							fig[box] = num[i];
							if (num[j] >= 10)fig[box] = fig[box] * 100 + num[j];
							else fig[box] = fig[box] * 10 + num[j];
							if (num[k] >= 10)fig[box] = fig[box++] * 100 + num[k];
							else fig[box] = fig[box++] * 10 + num[k];
						}
					}
				}
			}
			break;
		case 4:
			box = 0;
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					for (int k = 0; k < N; k++) {
						for (int l = 0; l < N; l++) {
							if (i != j&&i != k&&i != l&&j != k&&j != l&&k != l) {
								fig[box] = num[i];
								if (num[j] >= 10)fig[box] = fig[box] * 100 + num[j];
								else fig[box] = fig[box] * 10 + num[j];
								if (num[k] >= 10)fig[box] = fig[box] * 100 + num[k];
								else fig[box] = fig[box] * 10 + num[k];
								if (num[l] >= 10)fig[box] = fig[box++] * 100 + num[l];
								else fig[box] = fig[box++] * 10 + num[l];
							}
						}
					}
				}
			}
			break;
		}
		for (int i = 0; i < box-1; i++) {
			for (int j = i + 1; j < box; j++) {
				if (fig[i] > fig[j]) {
					work = fig[i];
					fig[i] = fig[j];
					fig[j] = work;
				}
			}
		}
		now = fig[0];
		ans++;
		for (int i = 1; i < box; i++) {
			if (fig[i] != now) {
				ans++;
				now = fig[i];
			}
		}
		printf("%d\n", ans);
		scanf("%d %d", &N, &K);
	}
	return 0;
}

Measured memory_bytes: 1048
import sys

input = sys.stdin.readline
N = int(input())
ans = N * (N + 1) * (N + 2) // 6
for _ in range(N - 1):
    u, v = map(int, input().split())
    if u > v:
        u, v = v, u
    ans -= u * (N + 1 - v)
print(ans)


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

#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()

const int N = 1e5;
int n;
vector <pair <int, int>> G[N + 7];

int xorDrzewa[N + 7];
int war[N + 7];

void dfs0(int v, int p) {
  war[v] = xorDrzewa[v];
  
  for (auto u : G[v]) {
    if (u.first != p) {
      xorDrzewa[u.first] = u.second;
      war[v] ^= u.second;
      dfs0(u.first, v);
    }
  }
}

int ile[16];
bool pusty[(1 << 15)];
int dp[(1 << 15)];

int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a + 1].push_back({b + 1, c});
    G[b + 1].push_back({a + 1, c});
  } 
    
  dfs0(1, 0);
  for (int i = 1; i <= n; ++i) ile[war[i]]++;
  
  int kraw = 0;
  ile[0] = 0;
  
  for (int i = 1; i < 16; ++i) {
    kraw += ile[i] / 2;
    ile[i] %= 2;
  }
  
  vector <int> roz;
  for (int i = 1; i < 16; ++i) if (ile[i]) roz.push_back(i);
  
  int m = SZ(roz);
  for (int x = 0; x < (1 << m); ++x) {
    int xr = 0;
    for (int i = 0; i < m; ++i) {
      if (x & (1 << i)) xr ^= roz[i]; 
    }
    if (xr == 0) pusty[x] = 1;
  } 
  
  for (int x = 1; x < (1 << m); ++x) {
    int res = -1e9;
    if (pusty[x]) res = 1;
    
    int y = (x - 1) & x;
    while (y > 0) {
      res = max(res, dp[y] + dp[x ^ y]);
      y = (y - 1) & x;
    } 
    
    dp[x] = res;
  }
  
  /*
  for (int x = 1; x < (1 << m); ++x) {
    for (int i = 0; i < m; ++i) if (x & (1 << i)) cout << roz[i] << ' ';
    cout << "- ";
    cout << pusty[x] << endl;
  }*/
  
  kraw += m - dp[(1 << m) - 1];
  cout << kraw << endl;
  return 0;
}

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

int main(){
  int n;
  int renga = 1;
  cin >> n;
  int ans = 0;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int buf;
    cin >> buf;
    if(buf == renga){
      renga++;
    }else{
      ans++;
    }
  }
  if(ans == n)ans = -1;
  cout << ans << endl;

}

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

if X > Y:
    max_pizzas = X
else :
    max_pizzas = Y
    
costs = []
for i in range(max_pizzas+1):
    A_left = X - i
    B_left = Y - i
    if A_left > 0:
        A_cost = A * A_left
    else :
        A_cost = 0

    if B_left > 0:
        B_cost = B * B_left
    else :
        B_cost = 0
    
    costs.append(A_cost + B_cost + (C * 2 * i))
    
print(min(costs))

Measured memory_bytes: 7016
import System.IO
import Control.Applicative ((<$>))

main = do
  s <- getLine
  let (a:b:c:_) = (\x -> read x :: Int) <$> words s
  putStrLn $ if isLegal a b c then "Yes" else "No"


isLegal :: Int -> Int -> Int -> Bool
isLegal a b c | a == b + c = True
              | a + b == c = True
              | a + c == b = True
              | otherwise  = False

Measured memory_bytes: 508
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
c1 = Counter(V[::2])
c2 = Counter(V[1::2])

l1 = sorted(c1.items(),key=lambda x:x[1], reverse=True)
l2 = sorted(c2.items(),key=lambda x:x[1], reverse=True)
l1.append((-1,-1))
l2.append((-1,-1))

if l1[0][0] == l2[0][0]:
    if l1[0][1] == l2[0][1] == n // 2: ans = n // 2
    else: ans = n - max(l1[0][1]+l2[1][1],l1[1][1]+l2[0][1])
else:
    ans = n - l1[0][1] - l2[0][1]
print(ans)

Measured memory_bytes: 21184
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	
	int ans=0;
	ans+=min(k,a);
	k-=min(k,a);
	k-=min(k,b);
	ans+=min(k,c)*-1;
	
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168

"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline

dp = 0
def solve(n):
    global dp
    dp = [[0] * (n+1) for _ in range(n+1)]
    dp[0][0] = 1

    for i in range(1, n+1):
        for j in range(i, n+1):
            t = 0
            for k in range(1, min(j+1, 3+1)):
                t += dp[i-1][j-k]
            dp[i][j] = t

    total = 0
    for d in dp:
        total += d[-1]
    return total


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        result = solve(n)
        print(ceil(result / 365 / 10))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7768
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n,0);
    int sm=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sm+=a[i];
    }

    int ctr=0;
    for(int i=0;i<n;i++){
        if(sm<=4*m*a[i]){
            ctr++;
        }
    }

    if(ctr>=m){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

inline ll f(ll x){return x*(x-1ll)/2;}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int k,s;
  cin>>k>>s; ++k;
  ll re=f(s+2);
  if(k<=s) re-=3*f(s-k+2);
  if(2*k<=s) re+=3*f(s-2*k+2);
  cout<<(re%MOD+MOD)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    int a[m];
    for(int i=0; i<m; i++){
        cin >> a[i];
    }
    int index = 0;
    int floors[n];
    for(int i=0; i<n; i++){
        if(index < m && a[index] == i){
            floors[i] = 0;
            index++;
        }else{
            floors[i] = 1;
        }
        //cout << floors[i] << ",";
    }
    //cout << endl;
    
    long long int ans[n+1];
    ans[0] = 1;
    ans[1] = 1;
    //cout << "1,1,";
    for(int i=2; i<=n; i++){
        long long int tmp = 0;
        if(floors[i-2] == 1) tmp += ans[i-2];
        if(floors[i-1] == 1) tmp += ans[i-1];
        ans[i] = tmp%1000000007LL;
        //cout << ans[i] << ",";
        //ans[i] = ans[i-2] + ans[i-1];
    }
    //cout << endl;
    cout << ans[n] << endl; 
    //cout << ans[n] << endl; 
    return 0;
}

Measured memory_bytes: 1792
//--- pE ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int N = ni();
		String str = ns();

		List<BIT> list_st = new ArrayList<>();
		for (int i=0; i<26; i++) list_st.add(new BIT(N+1));
		// SegmentTreeRSQ st = new SegmentTreeRSQ(1, N);
		for (int i=0; i<str.length(); i++) {
			int idx = str.charAt(i) - 'a';
			// int t = (int)list_st.get(idx).query(i + 1, i + 1);
			list_st.get(idx).addVal(i, 1);
		}

		int Q = ni();
		StringBuilder str_sb = new StringBuilder(str);
		for (;Q-->0;) {
			// int[] arr = strToIntArray(scanner.nextLine());
			// String[] vals = scanner.nextLine().split("\\s+");

			int q = ni();

			if (q == 1) {
				int i = ni();
				char c = ns().charAt(0);
				int n = str_sb.charAt(i-1) - 'a';
				int m = c - 'a';

				// int t = (int)list_st.get(n).query(i, i);
				list_st.get(n).addVal(i-1, -1);

				str_sb.setCharAt(i-1, c);

				// t = (int)list_st.get(m).query(i, i);
				list_st.get(m).addVal(i-1, 1);
			} else {
				int l = ni()-1;
				int r = ni()-1;
				int cnt = 0;
				for (int i=0; i<26; i++) {
					if (list_st.get(i).getSum(l, r) > 0) cnt ++;
				}
				System.out.println(cnt);
			}
		}
		return;
	}
	private int ni() {return Integer.parseInt(reader.next());}
	private String ns() {return reader.next();}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}

class BIT {
	public long[] arr;
	public BIT(int n) {
		arr = new long[n];
	}
	public long getSum(int i) {
		long sum = 0;
		for(i++;i > 0;i -= i&-i)sum += arr[i];
		return sum;
	}
	public long getSum(int l, int r) {
		return getSum(r) - getSum(l-1);
	}
	public void addVal(int i, long v) {
		if(v == 0)return;
		int n = arr.length;
		for(i++;i < n;i += i&-i)arr[i] += v;
	}
}


Measured memory_bytes: 160828
class Dice:
	# Label: 1=Up, 2=South, 3=East, 4=West, 5=North, 6=Down
	def __init__(self, nums):
		self.nums = nums
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
	def toU(self, num):
		if self.cD == num:
			for _ in range(2): self.goN()
		elif self.cN == num: self.goS()
		elif self.cE == num: self.goW()
		elif self.cW == num: self.goE()
		elif self.cS == num: self.goN()
	def right(self, num):
		if self.cN == num: return self.cW
		elif self.cE == num: return self.cN
		elif self.cW == num: return self.cS
		elif self.cS == num: return self.cE
		else: raise # ????????????
di1 = Dice([int(i) for i in input().split(' ')])
di2 = Dice([int(i) for i in input().split(' ')])
for i in di1.nums:
	if di2.nums.count(i) == 1:
		di1.toU(i)
		di2.toU(i)
		break
if di1.cU == di2.cU and di1.cD == di2.cD:
	nesw1 = ''.join(list(map(str, [di1.cN,di1.cE,di1.cS,di1.cW])))
	nesw1 += nesw1
	nesw2 = ''.join(list(map(str, [di2.cN,di2.cE,di2.cS,di2.cW])))
	if nesw1.count(nesw2) > 0: print('Yes')
	else: print('No')
else: print('No')


Measured memory_bytes: 7896
fn main() {
    const MOD: u64 = 1_000_000_007;
    let nk = read_vec::<u64>();
    let n = nk[0];
    let k = nk[1];
    if n + 1 == k {
        println!("1");
        return;
    }

    let mut sum = 0;
    for i in k..(n+1)+1 {
        let mi = i * (i - 1) / 2;
        let ma = i * (2 * (n+1) - i - 1) / 2;
        sum += ma - mi + 1;
        sum %= MOD;
    }
    println!("{}", sum);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		vector<pair<int,int>> v(n);
		int a = -inf , b = -inf , c=inf , d= inf;
		for(int i=0;i<n;++i)
		{
			cin>>v[i].first>>v[i].second;
			a = max(a,v[i].first+v[i].second);
			b = max(b,v[i].first-v[i].second);
			c = min(c,v[i].first+v[i].second);
			d  = min(d,v[i].first-v[i].second);
		}
		cout<<max(a-c,b-d);
			
    }
    return 0;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
int main() 
{ 
    char c[3];
    c[0]='A';
    c[1]='C';
    c[2]='L';
    int i;
    int n;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	printf("%c%c%c",c[0],c[1],c[2]);
	}
}

Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static Scanner cin = new Scanner();

    static void Main(string[] args) {
        var S = Console.ReadLine();
        bool flag = false;
        for (int i = 1; i <= S.Length; i++) {
            for (int j = i; j < S.Length; j++) {
                string tmp = "";
                if (i < S.Length) tmp = S.Substring(0, i) + S.Substring(j);
                else tmp = S;
                if (tmp == "keyence") flag = true;
            }
        }
        Console.WriteLine(flag ? "YES" : "NO");
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
def fizz_buzz(n):
    total = 0
    for i in range(1,n+1):
        if i % 15 == 0:
            continue
        elif i % 3 == 0:
            continue
        elif i % 5 == 0:
            continue
        else:
            total += i
    return total


if __name__ == "__main__":
    n = int(input())
    print(fizz_buzz(n))
    


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

#define ll long long 
using namespace std;



main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	map<ll,ll> mp;
	multimap<ll,ll>mp1;
	ll test,n,i,j,area,flag=0,a1[100000],d=0,m=INT_MAX,amt,r,a2[100000],x,y,k,K,I,m1,m2,m3,o,o1,o2,o3,dp1[100000],dp2[100000],a3[100000],dp3[100000];
	
	cin>>n;
	for(i=1;i<=n;++i){
		cin>>a1[i];
		cin>>a2[i];
		cin>>a3[i];}
	
	dp1[0]=dp2[0]=dp3[0]=0;
	for(i=1;i<=n;++i){
		dp1[i]=max(a1[i]+dp2[i-1],a1[i]+dp3[i-1]);
		dp2[i]=max(a2[i]+dp1[i-1],a2[i]+dp3[i-1]);
		dp3[i]=max(a3[i]+dp2[i-1],a3[i]+dp1[i-1]);
		}
		
	cout<<max(dp1[n],max(dp2[n],dp3[n]))<<endl;
	
	}
		
	





Measured memory_bytes: 4992
while True:
    a, op, b = input().split()
    if op == "?":
        break
    a, b = int(a), int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    else:
        print(a // b)

Measured memory_bytes: 7664
import math
a, b, x = [int(i) for i in input().split()]
c = (2 * x / a**2 ) - b
if c <= 0:
    c = (2 * x) / (a * b)
    print(math.degrees(math.atan2(b, c)))
else:
    print(math.degrees(math.atan2(b - c, a)))


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

const int MAX = 1E5 + 5;

int sum[MAX], q, l, r;
bool com[MAX];

void init()
{
    for (int i = 2; i < MAX; i++)
        if (!com[MAX])
            for (int j = i; 1LL * i * j < MAX; j++)
                com[i * j] = true;
    for (int i = 2; i < MAX; i++)
        sum[i] = sum[i - 1] + ((i & 1) && (!com[i] && !com[(i + 1) / 2]));

}

int main()
{
    init();
    scanf("%d", &q);
    while (q--)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", sum[r] - sum[l - 1]);
    }
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int D[107][7],i,j,N;
int G[55][6]={
	{1,2,3},{1,3,5},{1,5,4},{1,4,2},
	{2,1,4},{2,4,6},{2,6,3},{2,3,1},
	{3,1,2},{3,2,6},{3,6,5},{3,5,1},
	{4,1,5},{4,2,1},{4,6,2},{4,5,6},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,4,5},{6,5,3},{6,3,2}};

int ch(int a,int b)
{
	int i;
	for(i=0;i<24;i++)
	{
		if(D[a][1]==D[b][G[i][0]]&&
		   D[a][2]==D[b][G[i][1]]&&
		   D[a][3]==D[b][G[i][2]]&&
		   D[a][6]==D[b][7-G[i][0]]&&
		   D[a][5]==D[b][7-G[i][1]]&&
		   D[a][4]==D[b][7-G[i][2]])
		return 1;
	}
	return 0;
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		for(j=1;j<=6;j++)
			scanf("%d",&D[i][j]);
	for(i=0;i<N;i++)
		for(j=i+1;j<N;j++)
		{
			if(ch(i,j))
			{
				puts("No");
				return 0;
			}
		}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)



int main(void){
	//come[i] := i???(?????????????????????)??§??????????????¨?????????????????????????????????????????°
	int come[100010];

	rep(i, 100010) come[i] = 0;//0??§?????????

	int n; scanf("%d", &n);
	rep(i, n){
		int a, b;
		scanf("%d %d", &a, &b);
		reps(j, a, b + 1){
			come[j]++;
		}
	}

	
	int ans = 0;
	reps(i, 2, 100010){
		//???????????????????????????????????????i?????§????????°??\????????????????????????
		//come[i]????????????????????§???come[i] + 1??????i???????¶????????????????????¢??????????
		if(come[i] + 1 >= i){
			//??????????????????i?????§????????°??\??????????????¨???????????¶?????????????????§???
			//???????????\???????????????????????°???i-1???
			ans = max(ans, i - 1);
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}

bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

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

vl v[100005];
vector <bool> vis(100005);
ll ma=0;
void dfs(ll u,ll d){
	//vis[u]=1;
	ma=max(ma,d);
	for(int ch:v[u]){
			dfs(ch,d+1);
	}
}
ll dp[3004][3004];
ll a[3004];
ll solve(ll l,ll r,ll &n){
	if(l>n || r<0){
		return 0;
	}
	if(dp[l][r]>0){
		return dp[l][r];
	}
	//dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
	return dp[l][r]=max(a[l]-solve(l+1,r,n),a[r]-solve(l,r-1,n));
}

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   	ll n;
   	cin>>n;
   	for(ll i=0;i<n;i++){
   		cin>>a[i];
   	}
   	for(ll i=0;i<n;i++){
   		dp[i][i]=a[i];
   	}
   	cout<<solve(0,n-1,n)<<endl;
    return 0; 
}

Measured memory_bytes: 52344
import Foundation

func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func ok(k: Int, a: [Int], v: Int) -> Bool {
    let m = a.lazy.map { 
        Int((Double($0) / Double(v)).rounded(.up)) - 1
    }.reduce(0, +)

    return m <= k
}

func main() {
    let (n, k) = *readInts()
    let a = readInts()

    let ma = a.max()!

    var l = 1
    var r = ma
    while l < r {
        let mid = (l + r) / 2

        if ok(k: k, a: a, v: mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    print(r)
}

main()

Measured memory_bytes: 25048
#include <iostream>
using namespace std;
 
int main()
{
  	int x[5], n=5;
  	cin>>x[1]>>x[2]>>x[3]>>x[4]>>x[5];
  	if(x[1]==0)
      	cout<<1;
  	if(x[2]==0)
      	cout<<2;
  	if(x[3]==0)
      	cout<<3;
  	if(x[4]==0)
      	cout<<4;
  	if(x[5]==0)
      	cout<<5;
  	return 0;
}

Measured memory_bytes: 3600
c = [500,100,50,10,5,1]
while True:
    e = int(raw_input())
    if e == 0: break
    e = 1000-e
    i,m = 0,0
    while e > 0:
        if e >= c[i]:
            e -= c[i]
            m += 1
        else:
            i += 1
    print m

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

int main(){
	double at,bt;
	while(cin >> at >> bt){
		if(at < 35.50 && bt < 71.00) cout << "AAA" << endl;
		else if(at < 37.50 && bt < 77.00) cout << "AA" << endl;
		else if(at < 40.00 && bt < 83.00) cout << "A" << endl;
		else if(at < 43.00 && bt < 89.00) cout << "B" << endl;
		else if(at < 50.00 && bt < 105.00) cout << "C" << endl;
		else if(at < 55.00 && bt < 116.00) cout << "D" << endl;
		else if(at < 70.00 && bt < 148.00) cout << "E" << endl;
		else cout << "NA" << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	double n, a[100], max = 0, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= max) {
			max = a[i];
		}
	}
	for (int j = 0; j < n; j++) {
		ans += max / a[j];
	}
	cout << fixed;
	cout << setprecision(5) << max / ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int min(int x, int y)
{
	if (x < y)
	{
		return x;
	}
	return y;
}

int main()
{
	int x, n;
	scanf("%d %d", &x, &n);

	int p[102] = {0};
	for (int i = 0; i < n; i++)
	{
		int pp;
		scanf("%d", &pp);
		p[pp] = 1;
	}

	int ans = __INT32_MAX__;
	int diff = __INT32_MAX__;
	for (int i = 101; i >= 0; i--)
	{
		if (p[i] == 1)
		{
			continue;
		}

		if (abs(x - i) <= diff)
		{
			diff = abs(x - i);
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1736
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n, m;
    cin>>n>>m;

    priority_queue<int> pq;

    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        pq.push(x);
    }

    while(m--){
        int x = pq.top();
        pq.pop();
        x = x/2;
        pq.push(x);
    }

    int sum = 0;
    while(!pq.empty()){
        sum += pq.top();
        pq.pop();
    }

    cout<<sum;
} 

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

ull nxt_sbset(ull s){
	ull tem = s + (s & -s);
	ull btm = (~tem & s) / (s & -s) >> 1;
	return btm | tem;
}

int n,a[305][305];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll s = 0;
  bool f;
	cin>>n;
	rep(i,n)rep(j,n){ cin>>a[i][j],s += a[i][j]; }
	s /= 2;
	rep(i,n)repU(j,i + 1,n - 1){
		f = 0;
		rep(k,n){
			if(a[i][j] > a[i][k] + a[k][j]){ cout<<-1<<'\n'; return 0; }
			if(!f && k != i && k != j && a[i][j] == a[i][k] + a[k][j]) s -= a[i][j],f = 1;
		}
	}
	cout<<s<<'\n';
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define h 250

int main(){
  int H,i;
  int A[h];

  scanf("%d",&H);
  for(i=1 ; i<H+1 ; i++){
    scanf("%d",&A[i]);
  }

  for(i=1 ; i<H+1 ; i++){
    if(i==1){
      printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],A[i*2],A[i*2+1]);
    }
    if(i*2<H && i!=1){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[i/2],A[i*2],A[i*2+1]);
    }
    if(i*2==H){
      printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[i/2],A[i*2]);
    }
    if(i*2>H){
    printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[i/2]);
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+1;
long long n,a[N],b[N],A,B,s,v[N];
pair<int,int>p[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		p[i].first=a[i],p[i+n].first=b[i];
		p[i].second=i,p[i+n].second=i+n;
		A+=a[i],B+=b[i];
	}
	sort(p+1,p+2*n+1);
	for(int i=1;i<=n-2;i++)
		s+=p[i].first,v[p[i].second]=1;
	A=min(A,B);
	for(int i=1;i<=n;i++)
		if(v[i]+v[i+n]==2)
			A=min(A,s+p[n-1].first+p[n].first);
		else if(v[i]+v[i+n]==1)
			if(p[n-1].second==i||p[n-1].second==i+n)
				A=min(A,s+p[n].first+a[i]*(1-v[i])+b[i]*(1-v[i+n]));
			else
				A=min(A,s+p[n-1].first+a[i]*(1-v[i])+b[i]*(1-v[i+n]));
		else
			A=min(A,s+a[i]+b[i]);
	cout<<A;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> res(M, 1);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;

    int idx;
    vector<int> A(M, 0);
    for (int j = 0; j < K; j++) {
      cin >> idx;
      A[idx-1] = 1;
    }

    for (int j = 0; j < M; j++) {
      res[j] *= A[j];
    }
  }

  int counter = 0;
  for (int i = 0; i < M; i++) {
    if(res[i]) counter++;
  }


  cout << counter << '\n';
  return 0;
}

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

typedef long long ll;

void solve() {
	int n;
	cin >> n;
	int ans = 0, val;
	for (int i = 1; i <= n; ++i) {
		int cnt = 0;
		int x = i;
		while (x % 2 == 0) {
			cnt++;
			x /= 2;
		}
		// cout << cnt << '\n';
		if (cnt >= ans) {
			ans = cnt;
			val = i;
		}
	}
	cout << val;
}


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

	int tt = 1;
	// cin >> tt;
	for (int i = 1; i <= tt; ++i) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fl(i,a,b) for(int i=a;i<b;i++)
#define rfl(i,a,b) for(int i=a;i>b;i--)
#define cases() ll t;cin>>t;while(t--)
int main()
{
    ll a,b;
    cin>>a>>b;
    ll x=__gcd(a,b);
    cout<<(a*b)/x;
    return 0;
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int N;
    cin >> N;
    int p[N];
    REP(i, N) cin >> p[i];
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(i == N-1){
            if(p[i] == N) ans++;
            break;
        }
        if(p[i] == i+1){
            ans++;
            if(p[i+1] == i+2) i++;
        }
    }
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!
N = int(input())
A = list(map(int,input().split()))

mod = 1000000007
sm = 0

for i in range(N):
    sm += A[i]
    sm %= mod
    
ans = 0

for i in range(N):
    sm -= A[i]
    if sm < 0:
        sm += mod
        
    ans += A[i]*sm
    ans %=mod
        
print(ans)

Measured memory_bytes: 31560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b){
    cout << c << endl;
  }else if(a == c){
    cout << b << endl;
  }else{
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

ll abs(ll a){
	return (a > 0 ? a : -a);
}

int main(){
	ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	if(a > b){
		a ^= b ^= a ^= b;
	}
	ll dec = b - a;
	if(dec > d * (n - 1)){
		cout << "NO\n";
		return 0;
	}
	if(c == d){
		if(n & 1){
			if(!(n % c) && !((n / c) & 1)){
				cout << "YES\n";
				return 0;
			}
		}else{
			if(!(n % c) && ((n / c) & 1)){
				cout << "YES\n";
				return 0;
			}
		}
	}
	if(c * (n - 1) <= dec && dec <= d * (n - 1)){
		cout << "YES\n";
		return 0;
	}else{
		for(ll i = 0; i < n - 1; ++i){
			if((c * (n - i - 1) <= dec + c * i && dec + c * i <= d * (n - i - 1)) || (c * (n - i - 1) <= dec + d * i && dec + d * i <= d * (n - i - 1)) || (dec + c * i <= c * (n - i - 1) && dec + d * i >= d * (n - i - 1))){
				cout << "YES\n";
				return 0;
			}
		}
	}
	cout << "NO\n";
	return 0;
}

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

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

using namespace std;
 
int decode_mcxi(string x) {
  int t = 1;
  int ret = 0;
  rep(i, x.length()) {
    switch (x[i]) {
      case 'm':
        ret += t * 1000;
        t = 1;
        break;
      case 'c':
        ret += t * 100;
        t = 1;
        break;
      case 'x':
        ret += t * 10;
        t = 1;
        break;
      case 'i':
        ret += t;
        t = 1;
        break;
      default:
        t = x[i]-'0';
    }
  }
  return ret;
}

string encode_mcxi(int a) {
  string ret = "";

  int m = 0, c = 0, x = 0, i = 0;
  int cnt = 0;

  while (a != 0) {
    if (cnt == 0) { i = a%10; } 
    if (cnt == 1) { x = a%10; }
    if (cnt == 2) { c = a%10; }
    if (cnt == 3) { m = a%10; }
    a /= 10;
    cnt++;
  }
  if ( 2 <= m && m <= 9 ) { ret += char(m+'0'); }
  if ( m != 0 ) { ret += "m"; }
  if ( 2 <= c && c <= 9 ) { ret += char(c+'0'); }
  if ( c != 0 ) { ret += "c"; }
  if ( 2 <= x && x <= 9 ) { ret += char(x+'0'); }
  if ( x != 0 ) { ret += "x"; }
  if ( 2 <= i && i <= 9 ) { ret += char(i+'0'); }
  if ( i != 0 ) { ret += "i"; }

  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  
  int n; cin >> n;

  while (n--) {
    string a, b;
    cin >> a >> b;
    
    int sum = decode_mcxi(a) + decode_mcxi(b);

    cout << encode_mcxi(sum) << endl;
  }
  return 0;
}


Measured memory_bytes: 3004