akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int N, X, Y;

int main(void)
{
	cin >> N >> X >> Y;

	Graph G(N + 1); // 頂点 N 個 のグラフ

	for (int n = 1; n <= N - 1; n++)
	{
		G[n].push_back(n + 1);
		G[n + 1].push_back(n);
	}
	G[X].push_back(Y);
	G[Y].push_back(X);

	vector<int> Ans(N + 1, 0);
	vector<int> Dist(N + 1, -1);
	queue<int> que;

	for (int n = 1; n <= N; n++)
	{
		Dist.assign(N + 1, -1);
		Dist[n] = 0;
		que.push(n);

		while (!que.empty())
		{
			int now = que.front();
			que.pop();

			for (int next : G[now])
			{
				if (Dist[next] == -1)
				{
					Dist[next] = Dist[now] + 1;
					que.push(next);
					Ans[Dist[next]]++;
				}
			}
		}
	}

	for (int n = 1; n <= N - 1; n++)
	{
		cout << Ans[n] / 2 << endl;
	}
}

Measured memory_bytes: 384
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
    [k,s] <- (map strToInt . words) <$> getLine
    let sn = [(x,y,s-x-y) | x <- [0..k] , y <- [0..k] , s-x-y >= 0 , s-x-y <= k]
    print (length sn)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   vector<ll>t(n);
    for (int i = 0; i < n; ++i) {
        cin >>t[i];
    }
    ll ans=t[0];
    ll g=0;
    for (int i = 0; i < n; ++i) {
        g=__gcd(ans,t[i]);
        ans=t[i]*(ans/g);
//        cout <<ans <<endl;
    }
    cout<<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

// #define int long long

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    ll x, y;
    scanf("%lld%lld", &x, &y);
    ll i = 0LL;
    ll ret = 0;
    while (1) {
        if ((1LL << i) * x > y) {
            ret = i;
            break;
        }
        i++;
    }
    printf("%lld", ret);
    /* --------------------------------- */
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
import bisect
a,b,q = map(int,input().split())
s = []
t = []
for i in range(a):
    s.append(int(input()))
for i in range(b):
    t.append(int(input()))
X  =[int(input()) for i in range(q)]
#入力


for x in X:
    s_index= bisect.bisect_left(s,x)
    #print(s_index)
    t_index= bisect.bisect_left(t,x)
    #print(t_index)
    if s_index == 0 and t_index == 0:
        print(max(t[0]-x,s[0]-x))
    elif s_index == 0:
        if t_index != b:
            if t[t_index] < s[0]:
                print(s[0]-x)
            else:
                ans  =min(2*s[0]-x - t[t_index-1],t[t_index]-x,x+s[0]-2*t[t_index-1])
                print(ans)
        else:
            print(min(2*s[s_index]-x-t[t_index-1],s[s_index]+x-2*t[t_index-1]))
    elif t_index == 0:
        if s_index != a:
            if s[s_index] < t[0]:
                print(t[0]-x)
            else:
                ans  =min(2*t[0]- x- s[s_index-1],s[s_index]-x,x+t[0]-2*s[s_index-1])
                print(ans)
        else:
            print(min(2*t[t_index]-x-s[s_index-1],t[t_index]+x-2*s[s_index-1]))
    elif s_index == a and t_index == b:
        print(max(x-s[a-1],x-t[b-1]))
    elif s_index == a:
        if s[a-1] < t[t_index-1]:
            print(x-s[a-1])
        else:
            ans = min(x-t[t_index-1],t[t_index]+x-2*s[a-1],2*t[t_index]-x-s[a-1])
            print(ans)
    elif t_index == b:
        if t[b-1] < s[s_index-1]:
            print(x-t[b-1])
        else:
            ans = min(x - s[s_index - 1], s[s_index] + x - 2 * t[b - 1],2*s[s_index]-x-t[b-1])
            print(ans)

    else:
        if s[s_index-1] < t[t_index-1] and s[s_index] < t[t_index]:
            ans = min(x-s[s_index-1],x+s[s_index]-2*t[t_index-1],2*s[s_index]-x-t[t_index-1],t[t_index]-x)
            print(ans)
        if t[t_index - 1] < s[s_index - 1] and t[t_index] < s[s_index]:
            ans = min(x - t[t_index - 1], x + t[t_index] - 2 * s[s_index - 1], 2 * t[t_index] - x - s[s_index - 1],
                      s[s_index] - x)
            print(ans)
        if s[s_index-1] < t[t_index-1] and t[t_index] < s[s_index]:
            ans = min(x-s[s_index-1],s[s_index]-x)
            print(ans)
        if t[t_index - 1] < s[s_index - 1] and s[s_index] < t[t_index]:
            ans = min(x - t[t_index - 1], t[t_index] - x)
            print(ans)


Measured memory_bytes: 16196
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
vector<ll> G[300];
signed main(){
  init_io();
  ll n,m;
  cin >> n >> m;
  ll a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<n;i++){
    cout << G[i].size()<<endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// get longest common subsequence, O(s.length() * t.length())
struct LCS {
    vvi dp;
    string s, t;
    LCS(string s, string t) : s(s), t(t) {
        dp.assign(s.size() + 1, vi(t.size() + 1, 0));
        for (int i = 1; i <= s.size(); ++i) {
            for (int j = 1; j <= t.size(); ++j) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                chmax(dp[i][j], dp[i][j - 1]);
                chmax(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    int length() { return dp[s.size()][t.size()]; }
    string restore() {
        string ret(length(), 'a');
        int sidx = s.size();
        int tidx = t.size();
        int retidx = length() - 1;
        while (sidx > 0 && tidx > 0) {
            if (s[sidx - 1] == t[tidx - 1]) {
                ret[retidx] = s[sidx - 1];
                --retidx;
                --sidx;
                --tidx;
            } else if (dp[sidx][tidx] == dp[sidx - 1][tidx])
                --sidx;
            else
                --tidx;
        }
        return ret;
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    LCS lcs(s, t);
    cout << lcs.restore() << "\n";
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    
    queue<char> a,b,c;
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    for(int i=0;i<s1.size();i++)
      a.push(s1[i]);
        for(int i=0;i<s2.size();i++)
      b.push(s2[i]);
        for(int i=0;i<s3.size();i++)
      c.push(s3[i]);
      char x='a';
	//while(!a.empty()){
		//cout<<a.front()<<" ";
		//a.pop();
	//}
	
	//cout<<x<<" "<<a.size()<<" "<<b.size()<<" "<<c.size();
	ll l=0;
    while(1){
        if(x=='a')
        {  if(a.size()==0)
		{cout<<"A";return 0;}
            x=a.front();
		//	cout<<x<<endl;
            a.pop();
        }
        if(x=='b')
        {    if(b.size()==0)
		{cout<<"B";return 0;}
            x=b.front();
            b.pop();
        }
        if(x=='c')
        {  if(c.size()==0)
		{cout<<"C";return 0;}
            x=c.front();
            c.pop();
        }
		/*l++;
		if(l==5)
			break;
        cout<<a.size()<<" "<<b.size()<<" "<<c.size()<<endl;
        */
    } 

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set1 	tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define linf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a,mod-2);
}

void solve()
{
	string s;
	
	int n;
	
	cin>>s;
	
	n = s.size();
	
	map<int,int> rem;
	
	int remm = 0;
	
	rem[0] = 1;
	
	ll res = 0;
	
	int ten = 1;
	
	for(int i=n-1;i>=0;i--)
	{
		remm = (remm + (s[i]-'0')*ten)%2019;
		
		res += rem[remm];
		
		rem[remm]++;
		
		ten *= 10;
		
		ten %= 2019;
	}
	
	cout<<res;
}

signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3788
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        s = str(i)
        if s[-1] == '0':
            continue
        if s[0] == s[-1]:
            ans += 1
        if i < 10:
            continue
        if s[0] == s[-1]:
            ans += 2
        l = len(s)
        for i in range(2, l):
            ans += 10 ** (i - 2) * 2
        if s[0] < s[-1]:
            continue
        if s[0] > s[-1]:
            ans += 10 ** (l - 2) * 2
        elif l > 2:
            dp = int(s[1])
            for i in range(2, l - 1):
                dp *= 10
                dp += int(s[i])
            ans += dp * 2
    print(ans)

main()

Measured memory_bytes: 9172
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int ans = N;
    int cntW = 0, cntB = 0;
    rep(i, N) if(S[i] == '.') cntW++; else cntB++;
    int cntWR = 0, cntBR = 0;
    rep(i, N + 1) {
        ans = min(ans, cntBR + cntW);
        if(i < N) {
            if(S[i] == '.') {
                cntWR++; 
                cntW--;
            } else {
                cntBR++;
                cntB--;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

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

using namespace std;

class D {
	friend class UnionFind;

	int n_islands, n_bridges{ 0 }, m;
	vector<vector<int>> banned;
	vector<int> lands;

public:
	D()
	{
		cin >> n_islands >> m;
		banned.resize(n_islands + 1);
		lands.resize(n_islands + 1, -1);

		int a, b;
		REP(i, m)
		{
			cin >> a >> b;
			banned[a].PB(b);
			banned[b].PB(a);
		}
	}

	int root(int a)
	{
		if (lands[a] < 0)
			return a;

		lands[a] = root(lands[a]);
		return lands[a];
	}

	void add(int a, int b)
	{
		bool canAdd{ true };
		int union_adjacent{ root(a) };

		for (int c : banned[b])
		{
			if (root(c) == union_adjacent)
			{
				canAdd = false;
				break;
			}
		}

		if (canAdd)
		{
			++n_bridges;
			lands[b] = union_adjacent;
		}

	}

	void solve()
	{

		for (int a{ 1 }; a < n_islands; a++)
			add(a, a + 1);

		cout << n_islands - 1 - n_bridges;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 6400
def examA():
    H1, M1, H2, M2, K = LI()
    T = (H2-H1)*60 + (M2-M1)
    ans = T-K
    print(ans)
    return

def examB():
    T = SI()
    ans = ""
    for t in T:
        if t=="?":
            ans += "D"
        else:
            ans += t
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10416
(defun solve (v c)
  (let ((ans 0))
    (loop :for v-item :in v
          :for c-item :in c
          :if (> v-item c-item)
            :do (setf ans (+ ans (- v-item c-item))))
    ans))

(defun main ()
  (let* ((n (read))
         (v (loop :repeat n :collect (read)))
         (c (loop :repeat n :collect (read))))
    (format t "~A~%" (solve v c))))

(main)


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();

            Console.WriteLine(input[0] * input[1] / 2);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11348
R, G, B, N = map(int, input().split())

total = 0

for r in range(N // R + 1):
    for g in range((N - r * R) // G + 1):
        #print([r, g, N - r * R - g * G, (N - r * R - g * G) % B])

        if (N - r * R - g * G) >= 0 and (N - r * R - g * G) % B == 0:
            #print('count!')
            total += 1

print(total)


Measured memory_bytes: 40428
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll k; cin >> k;
	constexpr int n = 50;
	vector<ll> a(n);
	iota(a.begin(), a.end(), 0);
	for (int i = 0; i < n; i++) {
		a[i] += k / n + (n - i <= k%n);
	}
	cout << n << endl;
	for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
	return 0;
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int x;
	cin >> x;
	int count = 0;
	int init = 100;
	while (init < x) {
		init = init + init / 100;
		count ++;
	}
	cout << count << endl;
	return 0;
}

//!

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	cout<<n%k<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rem(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;



int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << '\n';
	return 0;

}

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

using namespace std;

const int N = 1e5+5,M = 10;

int d[N];
void bfs(int k){

    int i,j;

    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
    pq.push(make_pair(0,0));

    int first=0;
    while(!pq.empty()){
        pair<int,int> temp = pq.top();pq.pop();

        int root= temp.second;

        if(temp.first!= d[root])continue;

        if(first && root==0){
            cout<<d[root]<<endl;return;
        }
        int st= 0;
        if(!first)st=1;

        for(i=st;i<10;++i){
            int Next= (root*10+i)%k;

            if(d[Next]>d[root]+i || d[Next]==0){
                d[Next]= d[root]+i;
                pq.push(make_pair(d[Next],Next));
            }
        }
        first= 1;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    int k;
    cin>>k;
    bfs(k);
}

Measured memory_bytes: 2804
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
mint dp[100005][4];
int main(){
  string s;
  cin>>s;
  dp[0][0]=1;
  int n=s.size();
  for(int i=0;i<n;i++){
          for(int j=0;j<4;j++){
             if(s[i]=='?')dp[i+1][j]+=dp[i][j]*3;
             else dp[i+1][j]+=dp[i][j];
          }
          if(s[i]=='A'||s[i]=='?')dp[i+1][1]+=dp[i][0];
          if(s[i]=='B'||s[i]=='?')dp[i+1][2]+=dp[i][1];
          if(s[i]=='C'||s[i]=='?')dp[i+1][3]+=dp[i][2];
      }
 cout<<dp[n][3]<<endl;
}


Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var in string

	fmt.Scan(&in)
	for len(in) > 0 {
		in = in[:len(in)-1]
		if len(in)%2 != 0 {
			continue
		}
		if isGuu(in) {
			fmt.Println(len(in))
			return
		}
	}
}

func isGuu(in string) bool {
	n := len(in) / 2
	for i := 0; i < n; i++ {
		if in[i] != in[n+i] {
			return false
		}
	}
	return true
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const string target="AKIHABARA";

string Waf(string s){
	string t;
	for(auto c:s)if(c!='A')
		t+=c;
	return t;
}

bool Deg(string s){
	int j=0;
	REP(i,s.size()){
		while(j<int(target.size())&&target[j]!=s[i])
			j++;
		if(j==int(target.size()))return false;
		j++;
	}
	return true;
}

void No(){
	cout<<"NO"<<endl;
	exit(0);
}
void Yes(){
	cout<<"YES"<<endl;
	exit(0);
}

signed main(){
	string s=readString();
	if(Deg(s)&&Waf(s)==Waf(target))
		Yes();
	else
		No();
}

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

int main()
{
    int N;
    int M;
    cin >> N >> M;
    int i;
    float a[N];
    float total=0;
    for(i=0;i<N;i++){
        cin >> a[i];
        total+=a[i];
    }
    int count=0;
    for(i=0;i<N;i++){
        if(a[i]>=(total/4)/M){
            count++;
        }
    }
    if(count < M){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 384
<?php

fscanf(STDIN, "%d %d", $n, $k);
$V = array_map('intval', explode(' ', trim(fgets(STDIN))));

$max = 0;
for ($l = 0; $l <= $k; ++$l) {
    for ($r = 0; $r <= $k - $l; ++$r) {
        if ($r + $l > $n) continue;

        // 取り出した奴を入れる
        $s = [];
        $value = 0;


        for ($i = 1; $i <= $l; ++$i) {
            /* echo "  [l] i: $i, i-1: " . ($i - 1), PHP_EOL; */
            $value += $V[$i - 1];
            $s[] = $V[$i - 1];
        }

        for ($i = 1; $i <= $r; ++$i) {
            /* echo "  [r] i: $i, n-i: " . ($n - $i) . ", V: " . $V[$n - $i], PHP_EOL; */
            $value += $V[$n - $i];
            $s[] = $V[$n - $i];
        }

        $bval = $value;

        // 取り出す数
        $d = $k - $r - $l;
        sort($s);
        for ($i = 0; $i < $d; ++$i) {
            if ($i >= count($s)) break;
            if ($s[$i] > 0) break;

            $value -= $s[$i];
        }

        $max = max($max, $value);
        /* echo "l: $l, r: $r, d: $d, before_v: $bval, after_v: $value, max: $max", PHP_EOL; */
    }
}
echo $max;


Measured memory_bytes: 4604
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 1001
#define most_prime_number 2000010
#define prime_MAX_arr 2000010/2
ll PRIME[2000010];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/

#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 2000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;
string s;
bool palin(ll a, ll b)
{
    a--;
    b--;
    while(a<=b)
    {
        if(s[a++]!=s[b--]) return 0;
    }
    return 1;
}
int main()
{
      double a;
      cin >> a;
      a/= 3.00;
       cout << fixed << setprecision(12) << a*a*a;
}



Measured memory_bytes: 256
X = 0
Y = 1
H = 2

N = gets.to_i
POINTS = N.times.map { gets.split.map(&:to_i) }
POSITIVE_POINTS = POINTS.select { |point| point[H] > 0 }
ZERO_POINTS = POINTS.select { |point| point[H].zero? }

0.upto(100) do |y|
  0.upto(100) do |x|
    heights = POSITIVE_POINTS.map do |point|
      (point[X] - x).abs + (point[Y] - y).abs + point[H]
    end
    heights.uniq!
    if heights.size == 1
      height = heights[0]
      if ZERO_POINTS.all? { |point| height - (point[X] - x).abs - (point[Y] - y).abs <= 0 }
        puts "#{x} #{y} #{height}"
        exit
      end
    end
  end
end

Measured memory_bytes: 3836
i = list(map(int, input().split()))
n = i[0]
m = i[1]

ans_n = 0
ans_m = 0
if(n == 0):
    ans_n = 0
else:
    ans_n = n*(n-1)//2
if(m == 0):
    ans_m = 0
else:
    ans_m = m*(m-1)//2

print(ans_n + ans_m)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		double r;
		cin >> r;
		cout << fixed << setprecision(15);
		cout << 2*PI*r <<endl;
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>
int main()
{
	int a,b,x;
	scanf("%d %d %d",&x,&a,&b);
	int n=a/x,m=b/x;
	int p=0;
	for(int i=n;i<=m;i++)
	{
		if(i*x>=a&&i*x<=b)
		{
			p=1;
			break;
		}
	}
	if(p==1)printf("OK");
	else printf("NG");
	return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

using ll = long long;

int main()
{
	int N;
	cin >> N;
	
	vector<int> B(N - 1);
	rep(i, N - 1)
	{
		cin >> B[i];
	}

	ll ans = 0;
	ans += B[0] + B[B.size() - 1];
	rep(i, N - 2)
	{
		ans += min(B[i], B[i + 1]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define RAPIDA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int main(){
    RAPIDA
    int n;cin>>n;
    int r=n%10;
    if(r==2 || r==4 || r==5 || r==7 || r==9)
        cout<<"hon\n";
    else if(r==0 || r==1 || r==6 || r==8)
        cout<<"pon\n";
    else if(r==3)
        cout<<"bon\n";
    return 0;
}

Measured memory_bytes: 3616
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e5 + 100;



signed main() {
	speed;
	vector<int> a(3);
	for (int i = 0; i < 3; ++i) {
		cin >> a[i];
	}
	sort(all(a));
	cout << ((a[0] == a[1] && a[1] != a[2]) || (a[0] != a[1] && a[1] == a[2]) ? "Yes" : "No");
	return 0;
}

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


int main() {
  string S;
  cin >> S;
  bool flg = true;
  for (int i = 0; i < S.size(); ++i) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        flg = false;
        break;
      }
    } else {
      if (S[i] == 'R') {
        flg = false;
        break;
      }
    }
  }
  
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

bool flug[1000001];//false???????´???°

int main() {
	int a, b, n;
	for (int i = 2;i*i <= 1000000;i++) {
		if (!flug[i]) {
			for (int j = i * 2;j <= 1000000;j += i) {
				flug[j] = true;
			}
		}
	}
	while (cin >> a >> b >> n, a + b + n) {
		queue<int> que;
		flug[1] = true;
		for (int i = 1;i <= 1000000;i ++) {
			if (!flug[i]) {
				if (i - a >= 0) {
					if ((i - a) % b == 0) {
						que.push(i);
					}
				}
			}
		}
		for (int i = 0;i < n - 1;i++) {
			que.pop();
		}
		cout << que.front() << endl;
	}
	return 0;
}

Measured memory_bytes: 2516
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var N int
	N = nextInt()
	CH := N % 10
	if CH == 3 {
		fmt.Println("bon")
	} else if CH == 0 || CH == 1 || CH == 6 || CH == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	return i
}


Measured memory_bytes: 1756
//
//  main.cpp
//  ajo
//
//  Created by Hashimoto Ryo on 2015/06/20.
//  Copyright (c) 2015??´ Hashimoto Ryo. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;
//
//int bubbleSort(int A[], int N){
//    int sw = 0;
//    bool flag = 1;
//    for(int i = 0;flag;i++){
//        flag = 0;
//        for(int j = N - 1;j >= i + 1;j--){
//            if(A[j] < A[j-1]){
//                swap(A[j], A[j-1]) ;
//                flag = 1;
//                sw++;
//            }
//        }
//    }
//    return sw;
//
//}
//
//int main(){
//
//    int A[100],N,sw;
//    cin >> N;
//    for (int i = 0; i < N; i++) {
//        cin >> A[i];
//    }
//    sw = bubbleSort(A, N);
//    
//    for(int i = 0;i < N;i++){
//        if(i) cout << " ";
//        cout << A[i];
//    }
//    cout << endl;
//    cout << sw << endl;
//    return 0;
//}
//
//


int main(){

    int n;
    int a[MAX];
    int count = 0;
    
    //?????¬????????\???
    cin >> n;
    for(int i = 0;i < n ; i++){
        cin >> a[i];
    }
    
    //?????¬???????????????
    for(int i = 0;i < n - 1;i++){
        
        int j = n - 1;//?????????????????????????????????
        while(j > i){
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                count++;
            }
            j--;
        }
    }
    
    for(int i = 0;i < n;i++){
        if(i)cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    string days[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s; cin >> s;
    fo(i, 7) {
        if (days[i] == s) {
            cout << 7-i;
            return;
        }
    }

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
  int K, X;
  cin >> K >> X;

  for (int i = 0; i < (2 * K -1); i++){
    cout << X - K + 1 + i;
    if (i < 2 * K -2){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
n = int(input())
ans = [0]*(10001)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      key = x**2+y**2+z**2+x*y+y*z+z*x
      if key <= 10000:
        ans[key] += 1
for i in range(1, n+1):
  print(ans[i])

Measured memory_bytes: 9188
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
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> inline void in(T &a) { cin >> a; }
template <class T, class U> inline void in(T &a, U &b) { cin >> a >> b; }
template <class T, class U, class V> inline void in(T &a, U &b, V &c) {
  cin >> a >> b >> c;
}
template <class T> inline void out(T a) { std::cout << a << endl; }
template <class T, class U> inline void out(T a, U b) {
  cout << a << ' ' << b << endl;
}
template <class T, class U, class V> inline void out(T a, U b, V c) {
  cout << a << ' ' << b << ' ' << c << endl;
}
#define inf 1e9
using ll = int64_t;

void Main() {
  int n;
  in(n);
  std::vector<ll> a(n + 1), b(n);
  for (auto &x : a) {
    in(x);
  }
  for (auto &x : b) {
    in(x);
  }

  ll count = 0;
  rep(i, n) {
    if (a[i] - b[i] < 0) {
      count += a[i] + (a[i + 1] - (b[i] - a[i]) > 0 ? (b[i] - a[i]) : a[i +
      1]); a[i + 1] = a[i + 1] - (b[i] - a[i]) > 0 ? a[i + 1] - (b[i] - a[i])
      : 0;
    } else {
      count += b[i];
    }
  }

  // repr(i, n) {
  //   if (a[i + 1] > b[i]) {
  //     count += a[i + 1] - b[i];
  //   } else {
  //     count += a[i + 1] + (b[i] - a[i + 1] < a[i] ? b[i] - a[i + 1] : a[i]);
  //     a[i] -= b[i] - a[i + 1] < a[i] ? b[i] - a[i + 1] : a[i];
  //   }
  // }
  // 
  // rep(i, n) {
  //   int tmp = (a[i] + a[i + 1]) - b[i];
  //   if (tmp < 0) {
  //     tmp = a[i] + a[i + 1];
  //     a[i + 1] = 0;
  //   } else {
  //     tmp = b[i];
  //   }
  //   count += tmp;
  // }

  out(count);

  return;
}

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


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	int cnt=0;
	while(cin>>n,n){
		cnt++;
		cout<<"Case #"<<cnt<<": ";
		vi in(n);
		rep(i,n)cin>>in[i];
		if(in[0]!=1){
			cout<<"Cannot pay some amount"<<endl;
			continue;
		}
		int r=(n==1?in[n-1]:in[n-1]+in[n-2])+10;
		vi dp(r+10,inf);
		dp[0]=0;
		rep(i,n)rep(j,dp.size())if(dp[j]!=inf){
			if(j+in[i]<dp.size())dp[j+in[i]]=min(dp[j+in[i]],dp[j]+1);
		}
		bool h=true;
		rep(i,dp.size()){
			int t=i;
			int co=0;
			for(int j=n-1;j>=0;j--){
				while(t>=in[j]){
					co++;
					t-=in[j];
				}
			}
			if(co!=dp[i])h=false;
		}
		if(h)cout<<"OK"<<endl;
		else cout<<"Cannot use greedy algorithm"<<endl;
	}
}

Measured memory_bytes: 1212
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


void solve(){
    ll m,n;
    cin>>m>>n;
    cout<<mod_pow<ll>(m,n,mod)<<"\n";
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(3);
    solve();
    return 0;
}



Measured memory_bytes: 3232
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 = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
    };

    let (n, k) = {
        let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
        let n: i32 = ws.next().unwrap().parse().unwrap();
        let k: i32 = ws.next().unwrap().parse().unwrap();
        (n, k)
    };

    let mut hs: Vec<i32> = Vec::new();
    for _ in 0..n {
        hs.push(read());
    }

    hs.sort();

    let mut min_h = 1000000000;
    for i in 0..n - k + 1 {
        let min = hs[i as usize];
        let max = hs[(k + i - 1) as usize];
        if min_h > max - min {
            min_h = max - min;
        }
    }

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

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,ans=1;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		ans += min(ans,k);
	}
	printf("%d",ans);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger

/**
 * Created by m00nlight on 7/27/15.
 */
object Main {
  def main(args: Array[String]) {
    val xs = io.Source.stdin.getLines.toList.map(_.toInt).drop(1)
    println(xs.filter {x => {
      val xx = new BigInt(BigInteger.valueOf(x))
      xx.isProbablePrime(29)
    }}.size)
  }
}

Measured memory_bytes: 69200
#C-rally
N = int(input())
A = list(map(int, input().split()))
ans_min = 10**8
 
for i in range(min(A), max(A)+1):
    ans = 0
    for j in range(N):
        ans += (A[j] - i) ** 2
    
    if ans < ans_min:
        ans_min = ans
 
print(ans_min)


Measured memory_bytes: 9104
//ΔAGC024C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,a[N];
int main()
{
	int i,x;
	LL s=0;
	scanf("%d",&n);
	for(i=0;i<n;i=i+1){
		scanf("%d",a+i);
		if(a[i]>i||(i&&a[i]-a[i-1]>1)){
			cout<<-1;
			return 0;
		}
	}
	x=0;
	for(i=n-1;i>=0;i=i-1){
		if(x!=a[i])
			s+=a[i],x=a[i];
		if(x)
			x--;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

		int N =sc.nextInt();

		if(N==25){
			System.out.println("Christmas");
		}else if (N==24){
			System.out.println("Christmas Eve");
		}else if(N==23){
			System.out.println("Christmas Eve Eve");
		}else{
			System.out.println("Christmas Eve Eve Eve");
		}

	}
}


Measured memory_bytes: 20692