akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
    // a: 丼 b: カレー c: パスタ d: ラーメン e: ハンバーグ
    vector<int> menu(5);
    vector<int> rem(5);
    for(int i = 0; i < 5; i++){
        cin >> menu[i];
        rem[i] = menu[i]%10;
    }

    vector<pair<int, int>> menuList(5);
    for(int i = 0; i < 5; i++){
        menuList[i] = make_pair(rem[i], menu[i]);
    }

    sort(menuList.begin(), menuList.end());

    int elaps = 0;
    for(int i = 4; i >= 1; i--){
        if(menuList[i-1].first != 0){
            elaps += menuList[i].second + 10 - menuList[i].first;
        }else{
            elaps += menuList[i].second;
        }
    }
    elaps +=  menuList[0].second;

    cout << elaps << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, ans = 0;
string s;
map<string, bool> m;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> s;
		if (!m[s])ans++;
		m[s] = true;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n, i, ave = 0, sum = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
        ave += a[i];
    }
    ave = round((float)ave/n);
    for(i=0; i<n; i++){
        sum += (ave - a[i])*(ave -a[i]);
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
t = A[0]
ans = 0
for i in range(1, N):
    if A[i] > t:
        t = A[i]
    elif A[i] == t:
        pass
    else:
        ans += t - A[i]
print(ans)

Measured memory_bytes: 32172
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
bc = []
d = {}
suma = sum(a)
for nr in a:
    if nr not in d:
        d[nr] = 1
    else:
        d[nr] += 1

for i in range(q):
    bc = [int(i) for i in input().split()]
    b = bc[0]
    c = bc[1]
    if b not in d:
        print(suma)
        continue
    suma = suma + (c - b) * d[b]
    if c not in d:
        d[c] = d[b]
    else:
        d[c] += d[b]
    d[b] = 0
    print(suma)




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

int main(){
  int A,B,C,X,Y;  cin >> A >> B >> C >> X >> Y;
  long long min = 1LL << 60;
  for(int c=0;;c = c + 2){
    int a = X - c/2;
    int b = Y - c/2;
    if(a < 0 && b < 0)  break;
    if(a < 0) a = 0;
    if(b < 0) b = 0;
    if(min > a*A + b*B + c*C){
      min = a*A + b*B + c*C;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    size_t t;
    vector<size_t> v;
    
    for(int i = 0;i < 4;i++){
    	cin >> t;
    	v.push_back(t);
    }sort(v.begin(),v.end());
    
    if(v.at(0) == v.at(1) && v.at(2) == v.at(3)){
    	cout << "yes\n";
    }else{
    	cout << "no\n";
    }
    
	return 0;
}

Measured memory_bytes: 3116
def main():
    from collections import deque, defaultdict
    n, *uvw = map(int, open(0).read().split())
    l = defaultdict(dict)
    g = [[] for _ in range(n + 1)]

    for u, v, w in zip(uvw[::3], uvw[1::3], uvw[2::3]):
        g[u].append(v)
        g[v].append(u)
        l[u].update({v: w % 2})

    l[0].update({1: 0})

    vis = [False] * (n + 1)
    col = [0] * (n + 1)

    q = deque()
    q.append([0, 1, 0])

    while q:
        i, j, k = q.popleft()
        if vis[j]:
            continue
        vis[j] = True
        c = k if l[min(i, j)][max(i, j)] == 0 else 1 - k
        col[j] = c

        for x in g[j]:
            q.appendleft([j, x, c])

    ans = '\n'.join(map(str, col[1:]))
    print(ans)


if __name__ == '__main__':
    main()


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

ll distSq(ll x, ll y) {
	return x*x + y*y;
}

int main() {

	IOS

	ll n, d;
	cin >> n >> d;

	ll c = 0, x, y;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;

		if (distSq(x, y) <= d*d)
			c++;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
    
/*
    Author: Koushik Sahu
    Created: 18 Sep 2020 10:17:02
*/

ll s;
array<ll, 2001> dp;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>s;
    dp.fill(0);
    dp.at(0) = dp.at(3) = 1;
    for(int i=4; i<=2000; i++){
        for(int j=3; j<=i; j++){
            dp[i] += (dp[i-j]%MOD);
            dp[i] %= MOD;
        }
    }
    cout<<dp[s]<<"\n";
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	string a;
	cin>>a;
	int n=(int)a.size();
	vector<vector<int>> dp(n+1,vector<int>(2));
	for(int i=0;i<n;++i){
		dp[i][0]=dp[i][1]=INF;
	}
	dp[0][0]=a[0]-'0';
	dp[0][1]=10-(a[0]-'0')+1;
	for(int i=1;i<n;++i){
		for(int carry=0;carry<2;++carry){
			if(!carry){
				dp[i][0]=min(dp[i-1][0]+(a[i]-'0'),dp[i-1][1]+(a[i]-'0'));
			}
			else{
				dp[i][1]=min(dp[i-1][0]+10-(a[i]-'0')+1,dp[i-1][1]+(10-(a[i]-'0')-1));
			}
			//~ cout<<i<<" "<<carry<<endl;
		}
	}
	cout<<min(dp[n-1][0],dp[n-1][1]);
	return 0;	
}


Measured memory_bytes: 55964
#include <iostream>
//#include "bits/stdc++.h"
#include <vector>
#include <stdlib.h>
#include <string>
#include <cctype>

using namespace std;

int main() {
	string t;
	int alphabet[26] = { 0 };

	for (; cin >> t;) {
		for (int i = 0;i < t.size(); ++i) {
			int temp;
			temp = tolower(t[i]) - tolower('a');
			alphabet[temp] += 1;
		}
	}

	for (int j = 0;j < 26; ++j) {
		string t;
		t = tolower('a') + j;
		cout << t << " : " << alphabet[j] << endl;
	}

	return 0;
}


Measured memory_bytes: 3136
# 縦 H ピクセル、横 W ピクセルの画像があります。
# 各ピクセルは英小文字で表されます。
# 上から i 番目、左から j 番目のピクセルは aij です。
# この画像の周囲 1 ピクセルを # で囲んだものを出力してください。

input_line = gets.chomp.split
h = input_line[0].to_i
w = input_line[1].to_i

pixels = Array.new
h.times do
  pixel = gets.chomp
  pixels << pixel
end

top_and_bottom_count = w + 2

# 一番上の行
top_and_bottom_count.times do
  print "#"
end

# 改行
print "\n"

h.times do |i|
  print "#"
  print pixels[i]
  print "#\n"
end

top_and_bottom_count.times do
  print "#"
end

print "\n"


Measured memory_bytes: 1788
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as B

query :: [(Int,Int,Int)] -> [(Int,Int,Int)]
query cs =
  foldl' (flip $ \(x,y,h) ->
             filter $ if h > 0
                      then (\(cx,cy,ch) -> ch == h + abs (x-cx) + abs (y-cy))
                      else (\(cx,cy,ch) -> ch <= abs (x-cx) + abs (y-cy)))
  [(cx,cy,h0 + abs (x0-cx) + abs (y0-cy)) | cx <- [0..100], cy <- [0..100]]
  cs'
  where
    ((x0,y0,h0):cs0,cs1) = partition (\(_,_,h) -> h > 0) cs
    cs' = cs0 ++ cs1
    
main :: IO ()
main = do
  n <- getLine
  cs <- map ((\(a:b:c:_)->(a,b,c))
              . unfoldr (B.readInt . B.dropWhile (== ' '))) 
         . B.lines <$> B.getContents
  let (cx,cy,ch):_ = query cs
  putStrLn $ show cx ++ ' ' : show cy ++ ' ' : show ch

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

int main() {
	long n,k=0,l=0,j=0;
	cin>>n;
	int s[n];
	vector<long>d(114,110);
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<n;i++){
		k+=s[i];
	}
	if(k%10!=0)cout<<k<<endl;
	else{
		for(int i=0;i<n;i++){
			if(s[i]%10!=0){
				l++;
				d.at(j)=s[i];
				j++;
			}
		}
		if(l==0)cout<<0<<endl;
		else{
			sort(d.begin(),d.end());
			cout<<k-d.at(0)<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
n=int(input());minn=100
def digit_sum(x):
  a,b=0,str(x)
  for i in range(len(b)):a+=int(b[i])
  return a
for i in range(1,n//2+1):a=digit_sum(i)+digit_sum(n-i);minn=min(minn,a)
print(minn)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(Math.max(a - b, Math.max(a * b, a + b)));
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 35592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int main()
{
	int w, h;
	while (cin >> h >> w, h)
	{
		int tai = h*h + w*w;
		int ansh, answ;
		for (int i = h + 1; i < 151; i++)
		{
			for (int j = i + 1; j < 151; j++)
			{
				if (i*i + j*j == tai)
				{
					ansh = i;
					answ = j;
					goto end;
				}
			}
		}

		for (int t = tai+1;; t++)
		{
			for (int i = 1; i < 151; i++)
			{
				for (int j = i + 1; j < 151; j++)
				{
					if (i*i + j*j == t)
					{
						ansh = i;
						answ = j;
						goto end;
					}
				}
			}
		}
	end:;
		cout << ansh << " " << answ << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;


int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ll f = x / 500;
    ans += f * 1000;
    x %= 500;
    ans += x - x % 5;
    cout << ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b;
	cin >> a >> b;

	println(max({a + b, a - b, a * b}));
}

Measured memory_bytes: 256
'use strict'
function main(input) {
  const tmp = input.split('\n');
  const N = parseInt(tmp[0], 10);
  const h = tmp[1].split(' ').map((elem) => parseInt(elem, 10));

  let dp = new Array(N);
  dp.fill(Infinity);
  dp[0] = 0;
  for (let i = 1; i < N; i++) {
    dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
    if (i > 1) {
      dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
    }
  }

  console.log(dp[N - 1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 27556
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N;
    void Solve()
    {
        N = cin.Nextint;
        int P = cin.Nextint;
        var A = cin.Scanint;
        int odd = 0;
        int even = 0;
       
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 == 0) even++;
            else odd++;
        }
        //WriteLine(odd + " " + even);
        var B = new BigInteger[51];
        B[0] = 1;
        for (int i = 1; i < 51; i++)
        {
            B[i] = B[i - 1] * i;
        }
        var C = new BigInteger[51];
        C[0] = 1;
        for (int i = 1; i < 51; i++)
        {
            C[i] = C[i - 1] * 2;
        }


        BigInteger evencnt = 0;
        for (int j = 0; j <= odd; j += 2)
        {
            evencnt += B[odd] / B[j] / B[odd - j] * C[even];
        }

        //WriteLine(evencnt);
        if (P == 0)
        {
            WriteLine(evencnt);
        }

        else
        {
            WriteLine(C[N] - evencnt);
        }
        
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 13648
#include <bits/stdc++.h>
using namespace std;
#define MAX 1010
#define MOD 1000000007
#define f first
#define s second
typedef pair<int,int> pi;
typedef long long int ll;
int h,w;
char g[MAX][MAX];
bool vis[MAX][MAX];
ll r[MAX][MAX];
bool ok(pi x){
    return x.f >= 0 && x.f < h && x.s >= 0 && x.s < w && g[x.f][x.s] == '.'; 
}
int main(){
    memset(r,0,sizeof(r));
    cin >> h >> w;
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            cin >> g[i][j];
        }
    }
    queue<pi> q;
    r[h-1][w-1] = 1;
    q.push({h-1,w-1});
    cout << '\n';
    memset(vis,false,sizeof(vis));
    while(!q.empty()){
        pi x = q.front();
        q.pop();
        if(ok({x.f,x.s-1})){
            r[x.f][x.s-1] += r[x.f][x.s];
            r[x.f][x.s-1] %= MOD;
            if(!vis[x.f][x.s-1]){
                q.push({x.f,x.s-1});
                vis[x.f][x.s-1] = true;
            }
        }
        if(ok({x.f-1,x.s})){
            r[x.f-1][x.s] += r[x.f][x.s];
            r[x.f-1][x.s] %= MOD;
            if(!vis[x.f-1][x.s]){
                q.push({x.f-1,x.s});
                vis[x.f-1][x.s] = true;
            }
        }
    }
    cout << r[0][0] << '\n';
    return 0;
}

Measured memory_bytes: 10240
N=int(input())
S=list(str(input()))
east=S[1:].count('E')
ans_min = east
ans = east
for l in range(1,N):
  if S[l-1]=='W':
    ans+=1
  if S[l]=='E':
    ans-=1
  if ans<=0:
    ans_min = 0
    break
  if ans < ans_min:
    ans_min = ans
print(ans_min)


Measured memory_bytes: 13508
def main():
    N = int(input())
    A = [input().split() for i in range(N)]
    S = input()
    flag = False
    ans = 0
    for i, a in enumerate(A):
        if a[0] == S:
            flag = True
        elif flag:
            ans += int(a[1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38480
#include<iostream>
using namespace std;
void solve()
{
    int n;
    cin>>n;
    for(int i=1000; i<=10000; i+=1000)
    {
        if(i>=n)
        {
            cout<<i-n<<endl;
            return;
        }
    }
}
int main()
{
    solve();
    return 0;
}


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

#define     Boost               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define     all(cont)           cont.begin(),cont.end()
#define     rall(cont)          cont.rbegin(),cont.rend()
#define     foreach(cont)       for(auto &val: cont)
#define     dbg(args...)        do {   cerr << #args << "-> " ;  show(args); } while(0); cerr<< endl ;
#define     TS                  template < typename T >
#define     TP                  template < typename F, typename S >
#define     TM                  template<typename T1, typename... T2>
#define     flush               cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define     Case                cout<< "Case "<< ++cs <<": "
#define     PI                  3.1415926535897932384
#define     eps                 1e-9
#define     inf                 LLONG_MIN
#define     INF                 LLONG_MAX
#define     mp                  make_pair
#define     pb                  push_back
#define     ff                  first
#define     ss                  second

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

/** Debugging Tool **/
TS void show(const T& v) {    cerr << v << ' ' ;}
TM void show(const T1& first,const T2&... rest){show(first);show(rest...);}
TP ostream& operator<<(ostream& os,const pair<F,S>& p){return os<<"("<<p.ff<<", "<<p.ss<<")";}
TS ostream& operator<<(ostream& os,const vector<T>& v){os << "{"; typename vector< T >::const_iterator it;
    for(it=v.begin();it!=v.end();it++){if( it != v.begin() )os<<", ";os<<*it;}return os<<"}";}
TS ostream& operator<<(ostream& os,const set<T>& v){os<<"[";typename set<T>::const_iterator it;
    for(it=v.begin();it!=v.end();it++){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
TP ostream& operator<<(ostream& os,const map<F,S>& v){os<<"[";typename map<F,S>::const_iterator it;
    for(it=v.begin();it!=v.end();it++){if(it!=v.begin())os<<", ";os<<it->ff<<" = "<<it->ss;}return os<<"]";}
/** Ends **/

const ll lim = 1e7+5 ;

ll nod[lim] ;

void func(){
    for(ll i=1; i<lim; i++) nod[i] = 1 ;
    for(ll i=2; i<lim; i++){
        for(ll j=i; j<lim; j+=i)
            nod[j]++ ;
    }
}


void solve(){
    ll n ;
    cin>> n ;

    ll ans = 0 ;
    for(ll i=1; i<=n; i++){
        ll temp = i * nod[i] ;
        ans += temp ;
    }

    cout<< ans << endl ;

}


int main()
{
    Boost;

    #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("input.txt","r",stdin);    // Read
    freopen("output.txt","w",stdout);  // Write
    #endif

    int t = 1,cs = 0 ;
    //cin>> t ;
    func() ;
    while(t--){
        //Case ;
        solve() ;
    }

    #ifndef ONLINE_JUDGE
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}



Measured memory_bytes: 81764
#include <bits/stdc++.h>
using namespace std;
long long n,k,a,s,t;
int main(){
    cin>>n>>k;
    a=n/k;
    s=n-(k*a);
    t=n-(k*(a+1));
    t-=t*2;
    if(s<t)t=s;
    cout<<t<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
//#include<iostream>
using namespace std;

char s[111];
int main()
{
	scanf("%s",s);int len=strlen(s);
	s[len-8]='\0';
	puts(s);
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut balls = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        balls.push((v[0], v[1]));
    }
    let mut diffs = HashMap::new();
    for i in 0..n {
        for j in i + 1..n {
            *diffs
                .entry((balls[i].0 - balls[j].0, balls[i].1 - balls[j].1))
                .or_insert(0) += 1usize;
            *diffs
                .entry((balls[j].0 - balls[i].0, balls[j].1 - balls[i].1))
                .or_insert(0) += 1usize;
        }
    }
    let mut max_v = 0;
    for value in diffs.values() {
        max_v = max(max_v, *value);
    }
    println!("{:?}", n - max_v);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
mod = 10 ** 9 + 7

n, k = map(int, input().split())
a = tuple(int(x) for x in input().split())

d = tuple([0] * (k + k + 1) for _ in range(n + 1))
d[0][0] = 1

# もらう
for pind, lim in enumerate(a, 1):
    csum = [0]
    t = 0
    for cnt in range(k + 1):
        t += d[pind - 1][cnt]
        csum.append(t)
    for distributed in range(k + 1):
        d[pind][distributed] = (csum[distributed + 1] - csum[max(0, distributed - lim)]) % mod

print(d[n][k])

Measured memory_bytes: 236160
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
	cin>>n>>m;
	bool zero=1;
	if(n>1) zero=0;
	int s[10], c[10];
	for(int i=0; i<m; i++){
		cin>>s[i]>>c[i];
		if(c[i]!=0) zero=0;
	}
	if(zero){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1; i<1000; i++){
		int d=0;
		int x=i;
		int t[10];
		while(x){
			t[n-d]=x%10;
			x/=10; d++;
		}
		if(d!=n) continue;
		bool dame=0;
		for(int j=0; j<m; j++){
			if(t[s[j]]!=c[j]){
				dame=1;
			}
		}
		if(!dame){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>

#define MAX	1500

using namespace std;

//ABCDEFGHIJKLMNOPQRSTUVWXYZ

int main()
{
	char str[MAX];

	cin >> str;

	int i = 0;
	while (str[i] != '\0')
	{
		str[i] -= 3;
		if (str[i] < 'A')
		{
			str[i] += 26;
		}

		i++;
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <chrono>

using namespace std;
using ll = long long;

vector<long long> divisor(long long n) {
	vector<long long> d;
	for (ll i(1); i * i <= n; ++i) {
		if (n % i == 0) {
			d.push_back(i);
			if (i * i != n) d.push_back(n / i);
		}
	}
	return d;
}


int main() {
	ll N, M;
	cin >> N >> M;
	vector<long long> d(divisor(M));
	sort(begin(d), end(d));
	ll g = M / N;
	ll i(0);
	while (i < d.size() && d[i] <= g) {
		++i;
	}
	cout << d[i - 1] << endl;
}


Measured memory_bytes: 256
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

typedef vector<int> vi;		typedef vector<ll> vl;
typedef pair<int, int> ii; 	typedef vector<ii> vii;

// code start here //

bool dp[2005][100005];
int a[2005];

signed main() {
	fastio;
	int n; cin >> n;
	int sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	dp[0][a[0]] = 1;
	rep(i, 1, n) {
		rep(j, 0, 100005) {
			if(dp[i - 1][j]) {
				if(j > a[i]) {
					dp[i][j - a[i]] = 1;
				}
				else {
					dp[i][a[i] - j] = 1;
				}
				if(a[i] + j < 100005) {
					dp[i][a[i] + j] = 1;
				}
			}
		}
	}
	rep(i, 0, 100005) {
		if(dp[n - 1][i]) return cout << (sum + i) / 2 << endl, 0;
	}
}



Measured memory_bytes: 196656
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=1e9;
const int magic=348;

int n,k;
int a[100048];

int gcd(int x,int y)
{
	return y==0?x:gcd(y,x%y);
}

int main ()
{
	int i;
	scanf("%d%d",&n,&k);
	int maxn=-1;
	for (i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		maxn=max(maxn,a[i]);
	}
	if (k>maxn)
	{
		printf("IMPOSSIBLE\n");
		return 0;
	}
	int g=a[1];
	for (i=2;i<=n;i++) g=gcd(g,a[i]);
	if (k%g==0) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
typedef long long ll;


int main(void){
    ll h,w;
    cin>>h>>w;
    cout<<abs((h-2)*(w-2));
}
/*
*/


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

int main() {
  long long N,Q,u,p,sum,A,B,C;
  cin>>N;
  sum=0;
  vector<long long>x(100001);
  for(int i=0;i<100001;i++){
    x[i]=0;
  }
  for(int i=0;i<N;i++){
    cin>>A;
    x[A]++;
    sum+=A;
  }
  cin>>Q;
  for(int i=0;i<Q;i++){
    cin>>B>>C;
    x[C]+=x[B];
    sum-=x[B]*B;
    sum+=x[B]*C;
    cout<<sum<<endl;
    x[B]=0;
  }
}

Measured memory_bytes: 4056
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let cs: Vec<u8> = s.chars().map(|c| c as u8 - b'0').rev().collect();
    let mut v = vec![0; cs.len()+1];

    let mut sum: usize = 0;
    let mut ten: usize = 1;
    for i in 0..cs.len() {
        sum += cs[i] as usize * ten % 2019;
        v[i+1] = sum % 2019;
        ten *= 10;
        ten %= 2019;
    }

    let mut cnt: Vec<usize> = vec![0; 2019];
    let mut ans: usize = 0;
    
    for i in (0..cs.len()+1).rev() {
        ans += cnt[v[i]];
        cnt[v[i]] += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 3952
s = input()
t = input()
if s==t:
    print("Yes")
    exit()
else:
    for i in range(1,len(s)):
        u = s[len(s)-i:len(s)]+s[:len(s)-i]
        if t==u:
            print("Yes")
            exit()
    else:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main () {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx;
  int dy = ty - sy;

  cout << string(dx, 'R') << string(dy, 'U')
       << string(dx, 'L') << string(dy, 'D')
       << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D'
       << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U'
       << "\n";
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;


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

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	sort(ASC(a));

	int j = 0;
	int ans = 0;

	for (int i = 0; i < n;)
	{
		j = i;
		int now = a[i];

		while (j < n && now == a[j]) j++;
		//cout << abs(i - j) << endl;

		if (abs(i - j) < a[i]) ans += abs(i - j);
		else if (abs(i - j) > a[i]) ans += abs(abs(i - j) - a[i]);

		i += abs(i - j);
		j = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll sum = 0, n = min(a, k);
    sum += n; k -= n;
    sum += 0; k -= min(k, b);
    sum -= k;
    cout << sum << "\n"; 
    return 0;
}

Measured memory_bytes: 3652
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long 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<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#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
#define TC(t) while(t--)

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 GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,k,g,x,m;

int main()
{
  scanf("%d %d",&n,&k);
  g = 0;
  m = 0;
  TC(n)
  {
    scanf("%d",&x);
    MAX(m,x);
    g = __gcd(g,x);
  }
  puts(k <= m && k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE");
  return 0;
}










Measured memory_bytes: 256
"use strict";//const 使用のため宣言
// inputに入力データ全体が入る
function Main(input) {

    const arg = input.split('\n');
    const A = parseInt(arg[0]);
    const B = parseInt(arg[1]);
    const C = parseInt(arg[2]);
    const X = parseInt(arg[3]);

    let count = 0;

    for (let a = 0; a <= A; a = (a + 1) | 0) {
        for (let b = 0; b <= B; b = (b + 1) | 0) {
            for (let c = 0; c <= C; c = (c + 1) | 0) {

                let sum = (500 * a) + (100 * b) + (50 * c);
                if (sum === X) count += 1;
                //console.log(sum);
                //console.log(count);



            }

        }

    }
    console.log(count);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//Main(require("fs").readFileSync("./a.txt", "utf8"));

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

bool judge;
string s,tar;

void rec(int ind,int t_ind,int dis,int prev){
    if(ind == s.size()){judge = true; return;}
    if(t_ind == tar.size()) return;;
    if(s[ind] == tar[t_ind] && ind == 0) rec(ind+1,t_ind+1,dis,t_ind);
    if(s[ind] == tar[t_ind] && (ind == 1 || t_ind - prev == dis)){
        rec(ind+1,t_ind+1,t_ind - prev,t_ind);
    }
    rec(ind,t_ind+1,dis,prev);
}

int main(){
    int n,ans = 0;
    cin >> n >> s;
    for(int i=0;i<n;i++){
        cin >> tar;
        rec(0,0,0,0);
        if(judge) ans++;
        judge = false;
    }
    cout << ans << endl;
}

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

using namespace std;

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


int main()
{
  int a, b;
  cin >> a >>b;
  if (b < a) {
    cout << a-1 << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int memo[2222][10];
vector<int> v[10];
int dfs(int b,int c){
  //cout<<b<<" "<<c<<endl;
  if(c==10) return 0;
  if(~memo[b][c]) return memo[b][c];
  int res=dfs(b,c+1),tmp=0;
  for(int i=0;i<(int)v[c].size();i++){
    if(b-(i+1)<0) break;
    tmp+=v[c][i];
    res=max(res,(tmp+i*(i+1))+dfs(b-(i+1),c+1));
  }
  //cout<<b<<" "<<c<<" "<<res<<endl;
  return memo[b][c]=res;
}
signed main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int c,g;
    cin>>c>>g;
    v[g-1].push_back(c);
  }
  for(int i=0;i<10;i++) sort(v[i].rbegin(),v[i].rend());
  /*
  for(int i=0;i<10;i++){
    cout<<i<<":";
    for(int j=0;j<(int)v[i].size();j++) cout<<v[i][j]<<" ";
    cout<<endl;
  }
  */
  memset(memo,-1,sizeof(memo));
  cout<<dfs(k,0)<<endl;
  return 0;
}

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

string rev(string s){
    reverse(s.begin(),s.end());
    return s;
}

int main() {

    string str2="dream";
    string str3="dreamer";
    string str4="erase";
    string str5="eraser";
    string str;
    cin>>str;
    str2=rev(str2);
    str3=rev(str3);
    str4=rev(str4);
    str5=rev(str5);
    string tmp="";
    bool f=1;
    for(int i=str.size()-1;i>=0;i--){
        tmp+=str[i];
        if(tmp==str2)tmp="";
        if(tmp==str3)tmp="";
        if(tmp==str4)tmp="";
        if(tmp==str5)tmp="";
        if(tmp.length()>7){
            f=0;
            break;
        }
    }
    cout<<(((f)?"YES":"NO"))<<endl;

    return 0;
}


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

using namespace std;

string t, ans;
vector< string > words, latte[21];

bool rec(int idx, vector< char > &add)
{
  if(idx == words.size()) {
    if(!ans.empty()) return (false);
    ans = t;
    for(auto &c : ans) if(isalpha(c)) c = add[c - 'A'];
    return (true);
  }

  const string &beet = words[idx];
  for(auto &str : latte[beet.size()]) {
    auto temp(add);
    bool flag = true;
    for(int i = 0; i < beet.size() && flag; i++) {
      if(temp[beet[i] - 'A'] != str[i] &&
         (temp[beet[i] - 'A'] != -1 ||
          temp[str[i] - 'A'] != -1))
        flag = false;
      else {
        temp[beet[i] - 'A'] = str[i];
        temp[str[i] - 'A'] = beet[i];
      }
    }
    if(!flag) continue;
    if(!rec(idx + 1, temp)) return (false);
  }
  return (true);
}

int main()
{
  int N;
  while(cin >> N, N) {
    for(int i = 0; i < N; i++) {
      string s;
      cin >> s;
      latte[s.size()].emplace_back(s);
    }
    cin.ignore();
    getline(cin, t);

    istringstream sss(t);
    string q;
    while(sss >> q) {
      if(q.back() == '.') q.pop_back();
      words.emplace_back(q);
    }
    sort(begin(words), end(words), [&](const string &a, const string &b)
    {
      return (set< char >(begin(a), end(a)).size() > set< char >(begin(b), end(b)).size());
    });
    vector< char > add(26, -1);
    if(rec(0, add)) cout << ans << endl;
    else cout << "-.\n";
    for(int i = 0; i < 21; i++) latte[i].clear();
    words.clear();
    ans.clear();
  }
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
int main()
{
    int n;
    std::cin >> n;
    std::vector<cpp_int> a(n);
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        if (a[i] == 0)
        {
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    cpp_int product = 1;
    cpp_int lim(1e18);
    for (int i = 0; i < n; ++i)
    {
        product *= a[i];
        if (product > lim)
        {
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << product << std::endl;
    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
	int h,w,k;
	cin >> h >> w >> k;
	VVL dp(h+1,VL(w,0));
	dp[0][0] = 1;
	VL memo = {1,2,3,5,8,13,21,34};
	for (int i = 1; i <= h; i++) {
		for (int j = 0; j < w; j++) {
			//	左から降りてくる
			if (j != 0) {
				dp[i][j] += memo[max(j-2,0)] * memo[max(w-j-2,0)] * dp[i-1][j-1];
			}
			// そのまま降りてくる
			dp [i][j] += memo[max(j-1,0)] * memo[max(w-j-2,0)] * dp[i-1][j];
			// 右から降りてくる
			if (j != w-1) {
				dp[i][j] += memo[max(j-1,0)] * memo[max(w-j-3,0)] * dp[i-1][j+1];
			}
			dp [i][j] %= MOD;
		}
	}
	cout << dp[h][k-1] << endl;
	return 0;
}


Measured memory_bytes: 256
import heapq

N, M = list(map(int, input().split()))
path = [[] for _ in range(N + 1)]
for _ in range(M):
  A, B = list(map(int, input().split()))
  path[A].append(B)
  path[B].append(A)

#print(N, M, path)

hq = [(0, 0, 1)]

mark = [None] * (N + 1)

while hq:
  cost, prev, node = heapq.heappop(hq)
  #print(cost, prev, node)
  if not mark[node]:
    mark[node] = prev
    for nxt in path[node]:
      heapq.heappush(hq, (cost + 1, node, nxt))

if all(mark[2:]):
  print('Yes')
  for m in mark[2:]:
    print(m)
else:
  print('No')

Measured memory_bytes: 59360
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;
  
int main(){
  int h, w;
  cin >> h >> w;
  int a[h][w];
  vector<p> odd;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }
  int n = 0, idx = 0;
  vector<p> v, vv;
  for(int i = 0; i < h; i++){
    if(i % 2){
      for(int j = w - 1; j >= 0; j--){
        if(a[i][j] % 2){
          a[i][j]--;
          if(j - 1 != -1){
            a[i][j-1]++;
            v.push_back(p(i, j));
            vv.push_back(p(i, j-1));
          }else{
            if(i + 1 < h){
              a[i+1][j]++;
              v.push_back(p(i, j));
              vv.push_back(p(i+1, j));
            }
          }
        }
      }
    }else{
      for(int j = 0; j < w; j++){
        if(a[i][j] % 2){
          a[i][j]--;
          if(j + 1 != w){
            a[i][j+1]++;
            v.push_back(p(i, j));
            vv.push_back(p(i, j+1));
          }else{
            if(i + 1 < h){
              a[i+1][j]++;
              v.push_back(p(i, j));
              vv.push_back(p(i+1, j));
            }
          }
        }
      }
    }
  }
  cout << v.size() << endl;
  for(int i = 0; i < v.size(); i++){
    cout << v[i].first + 1 << " " << v[i].second + 1 << " ";
    cout << vv[i].first + 1 << " " << vv[i].second + 1 << endl;
  }
  return 0;
}

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

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

int main(){
    int k;
    cin >> k;
    int i, j, l;
    int z = 0;
    int ans = 0;
    for(i = 1; i < k+1; i++){
        for(j = 1; j < k+1; j++){
            for(l = 1; l < k+1; l++){
                z = gcd(i, j);
                ans += gcd(z, l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n;
	string s;
	cin >> n;
	cin >> s;

	int ans=n;
	int temp=0;
	repd(i,1,n){
		if(s[i]=='E'){
			temp++;
		}
	}
	ans=min(ans,temp);

	temp=ans;
	repd(i,1,n){
		if(s[i-1]=='W'){
			temp++;
		}
		if(s[i]=='E'){
			temp--;
		}

		ans=min(temp,ans);
	}

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

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

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


Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	int a, b;
	cin >> a >> b;
	cout << (b - a) + b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e5+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld i,j,ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M],level[M];
lld parent[M],visit[M];
lld dfs(lld node,lld cnt)
{ 
  visit[node]=1;
  level[cnt].pb(node);
  for(auto ll:v[node])
  {
    if(visit[ll]==0)
    {
      parent[ll]=node;
      dfs(ll,cnt+1);
    }
  }
  mymax=max(mymax,cnt);
}
int main()
{
    is(n);
    parent[n]=n;
    up(0,n-1,i)
    {
      ds(x,y);
      parent[i+1]=i+1;
      v[x].pb(y);
      v[y].pb(x);
    }
    dfs(1,1);
    lld max_level=mymax;
    up(0,n+1,i)visit[i]=0;
    while(max_level>=2)
    {
      for(auto kk:level[max_level])
      {
        if(visit[kk]!=1)
        { 
       //   dg3(kk,parent[kk],visit[parent[kk]]);
          if(visit[parent[kk]]!=1)
          {
            visit[parent[kk]]=1;
          }
          else
          {
            cout<<"First\n";
            return 0;
          }
          visit[kk]=1;
        }
      }
      max_level--;
    }
    up(1,n+1,i)
    {
      if(visit[i]!=1)
      {
        cout<<"First\n";
        return 0;
      }
    }  
    cout<<"Second\n";
    return 0;
}

Measured memory_bytes: 11392
import java.util.*;

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

		int N = sc.nextInt();	
		
		int money = sc.nextInt();
		int min = 0;
		
		for(int i=0;i<N;i++){
			int t = sc.nextInt();
			if(min==0||t<min)
				min = t;
			money-=t;
		}
		
		int ans = N;
		ans += money/min;
		
		System.out.println(ans);
		

	}

}


Measured memory_bytes: 21716