akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long
#define all(c) (c.begin(),c.end())
#define sz(s) (int)(s).size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const lli INF = 1e18;


void solve() {
    int n;
    cin >> n;
    vector<lli> arr(n + 1);

    FOR(i, 1, n + 1)
    {   arr[i]++;
        lli j = (lli)i * 2;
        while (j <= n)
        {
            arr[j]++;
            j += i;
        }
    }
    lli ans = 0;

    FOR(i, 1, n + 1) {
        ans += (lli)(i * arr[i]);
    }

    cout << ans << endl;
}

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

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    solve();




    return 0;
}


Measured memory_bytes: 81328
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 18 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])


Measured memory_bytes: 13924
#include <iostream>

using namespace std;

int main(){
	int a,b,k,x,j=0;
	cin >> a >> b >> k;

	if(a<b){
		x=a;
	}else{
		x=b;
	}

	for(int i=x;i>0;i--){
		if(a%i==0 && b%i==0){
			j++;
		}
		if(j == k){
			cout << i << endl;
			break; 
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a[11];
	double s, t, v1, v2;
	
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%lf,%lf",
				&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&a[10],&v1,&v2)!=EOF){
		s = 0;
		for(int i = 1; i <= 10; i++){
			s += a[i];
		}
		t = s/(v1+v2);
		s = 0;
		for(int i = 1; i <= 10; i++){
			s += a[i];
			if(s >= v1*t){
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a <<" " << b << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3592
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque

def main():
    h, w = map(int,input().split())
    h += 4
    w += 4
    C_h, C_w = map(int,input().split())
    C_h += 1
    C_w += 1
    D_h, D_w = map(int,input().split())
    D_h += 1
    D_w += 1
    S = ["#"*w for hh in range(h)]
    for hh in range(2, h-2):
        S[hh] = "##" + input() + "##"
    queue = deque([C_h*w + C_w])
    ans = [-1]*(h*w)
    ans[C_h*w + C_w] = 0
    visited = [False]*(h*w)
    visited[C_h*w + C_w] = True

    queue_0 = deque([C_h*w + C_w])
    while queue_0:
        node = queue_0.popleft()
        for xnode in (node - 1, node + 1, node - w, node + w):
            if S[xnode//w][xnode%w] == "." and not visited[xnode]:
                visited[xnode] = True
                ans[xnode] = 0
                queue_0.append(xnode)
                queue.append(xnode)
    while queue:
        node = queue.popleft()
        node_h = node//w
        node_w = node%w
        for xnode_h in (node_h - 2, node_h - 1, node_h, node_h + 1, node_h + 2):
            for xnode_w in (node_w - 2, node_w - 1, node_w, node_w + 1, node_w + 2):
                xnode = xnode_h*w + xnode_w
                if S[xnode_h][xnode_w] == "." and not visited[xnode]:
                    next_ans = ans[node] + 1
                    ans[xnode] = next_ans
                    queue.append(xnode)
                    visited[xnode] = True

                    queue_0 = deque([xnode])
                    while queue_0:
                        node2 = queue_0.popleft()
                        for xnode2 in (node2 - 1, node2 + 1, node2 - w, node2 + w):
                            if S[xnode2//w][xnode2%w] == "." and not visited[xnode2]:
                                visited[xnode2] = True
                                ans[xnode2] = next_ans
                                queue_0.append(xnode2)
                                queue.append(xnode2)

#    for i in range(h):
#        print(ans[w*i:w*(i+1)])
#    gnode = D_h*w + D_w
    print(ans[D_h*w + D_w])
        
if __name__=='__main__':
    main()

Measured memory_bytes: 96844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class DGatheringChildren {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;
        vector<int> r_ans(s.size(), 0);
        char now = 'R';
        int cnt_odd = 0;
        int cnt_even = 0;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == now) {
                if (i % 2 == 0)cnt_even++;
                else cnt_odd++;
            } else {
                if (i % 2 == 0) {
                    r_ans[i] += cnt_even;
                    r_ans[i - 1] += cnt_odd;
                } else {
                    r_ans[i] += cnt_odd;
                    r_ans[i - 1] += cnt_even;
                }
                cnt_odd = 0;
                cnt_even = 0;
            }
        }
        vector<int> l_ans(s.size(), 0);
        now = 'L';
        reverse(s.begin(), s.end());
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == now) {
                if (i % 2 == 0)cnt_even++;
                else cnt_odd++;
            } else {
                if (i % 2 == 0) {
                    l_ans[i] += cnt_even;
                    l_ans[i - 1] += cnt_odd;
                } else {
                    l_ans[i] += cnt_odd;
                    l_ans[i - 1] += cnt_even;
                }
                cnt_odd = 0;
                cnt_even = 0;
            }
        }
        vector<int> ans(s.size(), 0);
        for (int j = 0; j < s.size(); ++j) {
            ans[j] += r_ans[j];
            ans[j] += l_ans[s.size() - 1 - j];
            cout << ans[j] << " ";
        }
        cout << endl;
    }
};


int main() {
    DGatheringChildren solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int k, x;
  cin >> k >> x;

  string ans;
  if (k * 500 >= x) ans = "Yes";
  else ans = "No";

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    ll n, k;
    cin >> n >> k;
    ll ans;
    //else if (n == k) ans = 0;
    ll r = n % k;
    ans = min(r, k-r);
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3652
/*
 * Copyright (c) 2019 ... All rights reserved.
 * ...
 */
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;


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

bool inspectYYMM(char S[]) {
    if (S[2] == '0' and S[3] != '0') return true;
    if (S[2] == '1' and (S[3] == '0' or S[3] == '1' or S[3] == '2')) return true;
    return false;
}

bool inspectMMYY(char S[]){
    if (S[0] == '0' and S[1] != '0') return true;
    if (S[0] == '1' and (S[1] == '0' or S[1] == '1' or S[1] == '2')) return true;
    return false;
}

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

    // source code
    char S[4];
    for (int i = 0; i < 4; i++) cin >> S[i];

    if (inspectMMYY(S)){
        if(inspectYYMM(S)){
            cout << "AMBIGUOUS" << endl;
            return 0;
        }else{
            cout << "MMYY" << endl;
            return 0;
        }
    }else if(inspectYYMM(S)){
        cout << "YYMM" << endl;
        return 0;
    }
    cout << "NA" << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N;
	cin >> N;
	ce(0)
	flush(cout);
	string s;
	cin >> s;
	string Seat[100000];
	int left = 0, right = N;
	Seat[0] = s;
	while (s!="Vacant") {
		int mid = (left + right) / 2;
		ce(mid);
		flush(cout);
		cin >> s;
		Seat[mid] = s;
		if ((mid-left)%2==0) {
			if (Seat[left]!=Seat[mid]) {
				right = mid;
			}
			else {
				left = mid;
			}
		}
		else {
			if (Seat[left] != Seat[mid]) {
				left = mid;
			}
			else {
				right = mid; 
			}
		}
	}

    return 0;
}



Measured memory_bytes: 1620
n = int(input())
R = [list(input().split()) for i in range(n)]
for i in range(n):
  R[i][1] = int(R[i][1])
sR = sorted(R, key=lambda x: x[1], reverse=True)
sR = sorted(sR, key=lambda x: x[0])
A = []
for i in range(n):
  print((R.index(sR[i]) + 1))

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2005;
int n,k,Ans=MAXN;
int son[MAXN],vis[MAXN];
vector<int>T[MAXN];
void Dfs(int u,int fa,int dep,int gra){
	if(dep>k/2){
		if(k%2)son[gra]++;
		return ;
	}	
	vis[u]=1;
	int size=T[u].size();
	for(int i=0;i<size;i++){
		int v=T[u][i];
		if(v==fa)continue;
		Dfs(v,u,dep+1,gra);
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		T[x].push_back(y);
		T[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof(vis));
		memset(son,0,sizeof(son));
		int size=T[i].size(),ret=0;
		vis[i]=1;
		for(int j=0;j<size;j++){
			int v=T[i][j];
			Dfs(v,i,1,v);
			ret=min(ret,-son[v]);
		}
		for(int j=1;j<=n;j++)
			if(!vis[j])ret++;
		if(ret<Ans)Ans=ret;
	}
	printf("%d\n",Ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <list>
#include <stack>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod1 = 998244353, mod2 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
map<string, ll> mp;

int main()
{
    //freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    fast_io;
    ll n, i, mx = 0;
    vector<string> vc;
    string str;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> str;
        if (mp.find(str) == mp.end()) mp.insert({str, 0});
        mp[str]++;
    }
    for (auto f: mp) mx = max(mx, f.second);
    for (auto f: mp)
        if (f.second == mx) vc.pb(f.first);
    sort(all(vc));
    for (auto f: vc) cout << f << '\n';
    return 0;
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main() {
  int n, k; cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++)  {
    int cnt = 0;
    int a = i;
    while(a < k) {
      a *= 2;
      cnt++;
    }
    ans += pow(0.5, cnt);
  }
  ans /= n;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  int n,k,q;
  cin >> n >> k >> q;
  vi a(n);
  vecin(n,a);

  int ans = 1e9;
  for (int x : a)
  {
    vi store;
    multiset<int> m;
    for (int i = 0; i <= n; i++)
    {
        if (i == n || a[i] < x)
        {
          sort(full(store));
          for (int j = 0; j <= (int)store.size()-k; j++)
            m.insert(store[j]);
          store.clear();
        }
        else
          store.pb(a[i]);
    }
    if ((int)m.size() < q)
      continue;
    auto it = m.begin();
    for (int i = 0; i < q-1; i++)
      it++;
    ans = min(ans,*it-x);
  }

  cout << ans << endl;
}

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

  ll t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }
}



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

int main(void) {
    int N;cin>>N;
    int h = N / 100;
    N = N % 100;
    int j = N / 10;
    N = N % 10;
    int i = N;
    if (h == i) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long K = long.Parse(Console.ReadLine());
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long A = inputLongArray[0];
            long B = inputLongArray[1];
            for (long C = A; C <= B; C++)
            {
                if (C % K == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }
            Console.WriteLine("NG");
            return;

        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


Measured memory_bytes: 28176
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n,k;
    ll d[10];
    rep(i,10) d[i]=0;
    cin>>n>>k;
    rep(i,k){
        ll a;
        cin>>a;
        d[a]++;
    }
    ll s=0,m=10,ms=0,ti=0,dl=0;
    for(ll i=99999;i>=n;i--){
        s=0;
        ti=i;
        dl=1+log10(i);
        rep(j,dl){
            rep(k,10){
                if((ti%10==k)&&d[k]==1){
                    s++;
                    break;
                }
            }
            ti /= 10;
        }
        if(m >= s){
            m = s;
            ms = i;
        }
    }
    cout<<ms<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int INF =1e9+5;
int main()
{
    int n;
    cin>>n;
    int a[n],sum=0;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for (int i=0;i<n;i++)
    {
        for(int j:{i+1,i+2})
        {
            if(j<n){
            dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));}
            //cout<<dp[j]<<endl;
        }
    }

    cout<<dp[n-1];
}


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

#define ll long long
#define MAXN (19)

ll d;
ll mi10[MAXN], wjj[MAXN], tz[MAXN];
ll orz[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
ll otz[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
ll ans;

void dfs(int j, ll now, ll tmp, bool mmm = false){
	if(j == 0){
		if(now == d) ans += tmp;
		return;
	}
	
	if(now + 9 * tz[j] < d) return;
	if(now - 9 * tz[j] > d) return;
	
	for(int i = -9; i <= 9; ++ i){
		if(mmm){
		    dfs(j - 1, now + i * wjj[j], tmp * (i < 0 ? orz[-i] : otz[i]));
		}
		else{
			dfs(j - 1, now + i * wjj[j], tmp * orz[std::abs(i)]);
		}
	}
}

int main(){
	mi10[0] = 1;
	for(int i = 1; i < MAXN; ++ i) mi10[i] = mi10[i - 1] * 10ll;
	scanf("%lld", &d);
	for(int i = 2; i <= 18; ++ i){
		for(int j = i / 2, t = 1; j; -- j, ++ t){
			wjj[j] = mi10[i - t] - mi10[t - 1];
		}
		tz[0] = wjj[0];
		for(int j = 1; j <= i / 2; ++ j) tz[j] = tz[j - 1] + wjj[j];
		if(i & 1){
			dfs(i / 2, 0, 10, 1);
		}
		else{
			dfs(i / 2, 0, 1, 1);
		}
		//printf("%d complete\n", i);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

ll x,y;

int main()
{
    scanf("%lld%lld",&x,&y);
    if(x>y)std::swap(x,y);
    
    if(y-x<2||((y-x)%3==2&&y<5))puts("Brown");
    else puts("Alice");
    
    return 0;
}


Measured memory_bytes: 256
<?php
# 入力
fscanf(STDIN, '%d', $n);
$a = array_merge([0], array_map('intval', explode(" ", trim(fgets(STDIN)))));
$b = [];
$result = [];
for ($i = $n; $i > 0; $i--) {
    $sum = 0;
    for ($j = 2; $i * $j <= $n; $j++) {
        if (isset($b[$i * $j])) {
            $sum++;
        }
    }
    if ($sum % 2 != $a[$i]) {
        $b[$i] = true;
        $result[] = $i;
    }
}
$cnt = count($b);
echo $cnt.PHP_EOL;
if ($cnt > 0) {
    echo implode(" ", $result).PHP_EOL;
}
?>

Measured memory_bytes: 28272
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード

ll n, m, q, ans, a[55], b[55], c[55], d[55], A[10];


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






int main() {
	cin >> n >> m >> q;
	rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vector<ll>(1, 1));
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3644
str = gets

left = str.slice(0,2).to_i
right = str.slice(2,4).to_i

if left <= 12 && left > 0
  if right <= 12 && right > 0
    puts 'AMBIGUOUS'
  else
    puts 'MMYY'
  end
else
  if right <= 12 && right > 0
    puts 'YYMM'
  else
    puts 'NA'
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	// que[R] = {L, index_of_query};
	// um is map such that um[element] = last index the element was seen
	// s - a set that contains the last index as mentioned above
	// code assumes 0 indexed
	// complexity - O(n*log(n))
	unordered_map<int, int>um;
	pbds s;
	int n,q; cin >> n>>q;
	vector<int>a(n+1);
	for (int i=1;i<=n;i++)
		cin >> a[i];
	// q; //cin >> q;
	vector<int>ans(q+1);
	vector<vector<pair<int, int>>>que(n+1);
	for (int i = 1; i <= q; i++)
	{
		int L, R; cin >> L >> R;
		que[R].push_back({L, i});
	}
	for (int i = 1; i <= n; i++)
	{
		if (um.count(a[i]))
			s.erase(um[a[i]]);
		um[a[i]] = i;
		s.insert(i);
		for (auto it : que[i])
			ans[it.second] = s.size() - s.order_of_key(it.first);
	}
	for (int i = 1; i <= q; i++)
		cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 72528
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

long long sum(int x) {
    return 1LL * x * (x + 1) / 2;
}

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    forn (i, k, n + 2) {
        long long mn = sum(i - 1), mx = sum(n) - sum(n - i);
        ans = (ans + (mx - mn + 1) % MOD) % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    Rep(i, N) {
        cin >> p[i];
    }
    Sort(p);
    int ans = 0;
    Rep(i, K) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
n, a, b = map(int, input().split())
mod = 10**9 + 7


def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


def cmb(n, r, MOD):
    if n < r:
        return 0
    if n-r < r:
        r = n-r
    comb = 1
    for x in range(n-r+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, r+1):
        d = (d * x) % MOD
    comb *= powmod(d, MOD-2, MOD)
    return comb % MOD


a = cmb(n, a, mod)
b = cmb(n, b, mod)
ans = powmod(2, n, mod) - a - b - 1
print(ans % mod)


Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k)
        cout<<s<<"\n";
    else
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"...\n";
    }
    return 0;
}



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

long lcd(long a, long b) {
  long c = a * b / __gcd(a,b);
  return c;
}

int main() {
  long A,B,C,D; cin >> A >> B >> C >> D;
  long a = B / C;
  long b = B / D;
  long c = B / lcd(C,D);
  long d = (A - 1) / C;
  long e = (A - 1) / D;
  long f = (A - 1) / lcd(C,D);
  long divB = B - a - b + c; 
  long divA = A - 1 - d - e + f;
  long ans = divB - divA;
  cout << ans << endl;
}

Measured memory_bytes: 3632
dataset=gets.to_i()
dataset.times do
  a=gets.to_i()
  b=gets.to_i()
  c=a+b
  flag=0
  t=1
  while(c/(10**(t-1))>0)
    if(t>80)
      puts "overflow"
      flag=1
      break
    end
    t+=1
  end
  if(flag==0)
    puts c
  end
end

Measured memory_bytes: 6132
package main

import (
	"fmt"
	"sort"
)

type as []int

func (f as) Len() int {
	return len(f)
}

func (f as) Less(i, j int) bool {
	return f[i] > f[j]
}

func (f as) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

func main() {
	var (
		n int
		a []int
	)
	fmt.Scan(&n)

	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	sort.Sort(as(a))
	var al, bb int
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			al += a[i]
		} else {
			bb += a[i]
		}
	}

	fmt.Println(al - bb)
}

Measured memory_bytes: 512
#![allow(non_snake_case)]

use std::io;

fn print_check(h: u32, w: u32){
    for y in 0..h {
        for x in 0..w {
            if (x + y) % 2 == 0{
                print!("#");
            } else {
                print!(".");
            }
        }
        println!("");
    } 
}

fn main() {
    let sin = io::stdin();
    loop {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        let mut ws = buf.split_whitespace();
        let h: u32 = ws.next().unwrap().parse().unwrap();
        let w: u32 = ws.next().unwrap().parse().unwrap();
        if h == 0 && w == 0 {
            break;
        } else {
            print_check(h, w);
            println!("");
        }
    }
}



Measured memory_bytes: 5016
N,K=map(int,input().split())
pr=10**9+7
a=0
l=[None]*(K+1)
for i in range(K,0,-1):
    t=pow(K//i,N,pr)
    c=i*2
    while c<=K:
        t-=l[c]
        c+=i
    l[i]=t
    a=(a+t*i)%pr
print(a)

Measured memory_bytes: 68800
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = map(int,raw_input().split())
	ans[0] = (H-2)*(W-2)
	for i in xrange(N):
		a,b = map(int,raw_input().split())
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in xrange(xlb,xub):
			for y in xrange(ylb,yub):
				k = x+(y<<34)
				bef_c = count[k]
				ans[bef_c] -= 1
				ans[bef_c+1] += 1
				count[k] += 1
	for c in ans:
		print c
solve()

Measured memory_bytes: 98084
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int p[100001];
int par[100001];

int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}

bool same(int x, int y){
	return root(x)==root(y);
}

void unite(int x, int y){
	x = root(x);
	y = root(y);
	if(x == y) return;
	par[x] = y;
}

int main(int argc, const char * argv[]) {
	int N ,M ;
	cin >> N >> M;

	FOR(i,1,N){
		cin >> p[i];
		par[i] = i;
	}

	FOR(i,1,M){
		int x,y;
		cin >> x >> y;
		unite(x,y);
	}
	int ret = 0;
	FOR(i,1,N){
		if(same(i,p[i])) ret++;
	}
	println(ret);

	return 0;
}


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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


const int N = 1e5+10;
int arr[N];
int dp[N];
int pre[N];   
int n, m;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("jjj.txt", "w", stdout);
	#endif
}

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}



void solve()
{
	cin >> n;
	rep(i, 0, n){
		cin >> arr[i];
	}

	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	dp[2] = min(dp[1] + abs(arr[2]-arr[1]), abs(arr[2]-arr[0]));

	for(int i=3; i<n; i++){
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]));
	}

	cout << dp[n-1] << endl;
}		


int32_t main(){
	//fast();
    int t = 1;
    // cin>> t;
    while(t--)
    solve();
	//starboy1299();
}

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

/*
int calc(int x){
    int count = 0;
    for(int i=1; i<=sqrt(x); i++){
        if(i*i == x){
            count++;
        }
        else if(x % i == 0){
            count += 2;
        }
    }
    return count;
}
*/

int main(){
    int N;
    cin >> N;
    int64_t ans=0;
    for(int i=1; i<=N; i++){
        int64_t m;
        m = (N/i) * i;
        ans += (i+m)*m/(2*i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll sum1 = 0;
	for (int i = 0; i < n; ++i) {
		sum1 += a[i];
	}
	ll ans = 1000000000000000000ll;
	
	ll res = 0;
	for (int i = 0; i < n - 1; ++i) {
		res += a[i];
		ans = min(ans, abs(sum1 - 2 * res));
	}

	dunk(ans);

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct P {
  int n;
  vector<vector<pii>> d;
  P() {}
  P(int n) : n(n) { d.resize(4, vector<pii>(n)); }
};

int n, m;
int px, py, x, y;
vector<P> v;

bool check(vector<pii>& s, vector<pii>& t, int f) {
  bool res = true;
  int sz = s.size(), sgn = f ? -1 : 1;
  for (int i = 0; i < sz; i++) {
    res &= (s[i].first == sgn * t[i].first && s[i].second == sgn * t[i].second);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  while (cin >> n, n) {
    n++;
    v.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> m;
      v[i] = P(m - 1);
      cin >> px >> py;
      for (int j = 0; j < m - 1; j++) {
        cin >> x >> y;
        v[i].d[0][j] = {x - px, y - py};
        v[i].d[1][j] = {y - py, px - x};
        px = x, py = y;
      }
      for (int j = 0; j < m - 1; j++) {
        pii p0 = v[i].d[0][m - j - 2], p1 = v[i].d[1][m - j - 2];
        v[i].d[2][j] = {-p0.first, -p0.second};
        v[i].d[3][j] = {-p1.first, -p1.second};        
      }
    }

    for (int i = 1; i < n; i++) {
      bool same = false;
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 2; k++) {
          same |= check(v[0].d[0], v[i].d[j], k);
        }
      }
      if (same) cout << i << endl;
    }
    cout << "+++++" << endl;
  }  

  return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

int onaji(int n){
    int a;
    int b;
    int c;
    int d = 0;
    a = n % 10;
    b = (n / 10) % 10;
    c = ((n / 10) / 10) % 10;
    if(a == b && b == c)d = 1;
    return d;

}

int main(){
    int N ;
    cin >> N ;
    while(1){
    int owari = onaji(N);
    if(owari == 1)break;
    N++;
    }
    cout << N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
int power(int a,int n){
	int res=1;
	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}	
	return res;
}
int func(int i,int j,string &s,string &t ,vvi &dp){
    if(i==-1 || j==-1)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    else if(s[i]==t[j]){
        dp[i][j]=func(i-1,j-1,s,t,dp)+1;
        return dp[i][j];
    }
    else{
        dp[i][j] = max(func(i,j-1,s,t,dp),func(i-1,j,s,t,dp));
        return dp[i][j];
    }
}
void reverse(string str) 
{ 
   for (int i=str.length()-1; i>=0; i--) 
      cout << str[i];  
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    vvi dp(s.size(),vi(t.size(),-1));
    int n=s.size(),m=t.size();
    func(n-1,m-1,s,t,dp);
    int i=n-1,j=m-1;
    string s1="";
    while(i>=0 && j>=0){
        if(s[i]==t[j]){
            s1+=s[i];
            if(i==0 && j==0)break;
            i--;
            j--;
        }
        
        else{
            if(i==0 && j==0)break;
            if(i>0 && dp[i][j] == dp[i-1][j]){
                i--;
            }
            else if(j>0 && dp[i][j] == dp[i][j-1]){
                j--;
            }
        }
        
    }
    reverse(s1);
    return 0;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H;
    int W;
    int h, w;
    int nh, nw;
    pair<int, int> S;
    pair<int, int> G;

    cin >> H >> W;
    cin >> S.first >> S.second;
    cin >> G.first >> G.second;
    S.first -= 1;
    S.second -= 1;
    G.first -= 1;
    G.second -= 1;
    
    vector<string> c(H);
    for(int i=0; i<H; i++){
        cin >> c[i];
    }
    vector<vector<int>> dist(H, vector<int>(W));
    for(int i=0; i<H; i++){
        for(int g=0; g<W; g++){
            if (c[i][g] == '#'){
                dist[i][g] = -2;
            } else {
                dist[i][g] = -1;
            }
        }
    }

    set<pair<int, int>> checkList;
    queue<pair<int, int>> que;
    que.push(S);

    vector<vector<int>> directions {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

    int cost = 0;

    while (true) {
        if (que.empty()){
            cost += 1;
            for (auto x : checkList) {
                for(int i=-2; i<3; i++){
                    for(int g=-2; g<3; g++){
                        nh = x.first+i;
                        nw = x.second+g;
                        if (nw < 0 || nw > W-1 || nh < 0 || nh > H-1){
                            continue;
                        } else {
                            if (dist[nh][nw] == -1){
                                que.push({nh, nw});
                            }
                        }
                    }
                }
            }
            checkList.clear();
            if (que.empty()){
                cout << -1 << endl;
                return 0;
            }
        } else {
            h = que.front().first;
            w = que.front().second;
            dist[h][w] = cost;
            que.pop();
            if (h == G.first && w == G.second){
                cout << cost << endl;
                return 0;
            }
            for(int i=0; i<4; i++){
                nh = h+directions[i][0];
                nw = w+directions[i][1];
                if (nw < 0 || nw > W-1 || nh < 0 || nh > H-1){
                    continue;
                }
                if (dist[nh][nw] == -1){
                    que.push({nh, nw});
                    dist[nh][nw] = cost;
                }else if (dist[nh][nw] == -2){
                    checkList.insert({h, w});
                }
            }
        }
    }
}


Measured memory_bytes: 9952
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <functional>
using namespace std;

const int MAX_N = 100005;

vector<int> loser[MAX_N], dep[MAX_N];

int N;

int work(int x) {
  if (!loser[x].size()) return 0;
  
  for (int a : loser[x]) {
    int d = work(a);
    dep[x].push_back(d);
  }
  
  sort(dep[x].begin(), dep[x].end(), greater<int>());
  int mx = 0;
  for (int i = 0; i < dep[x].size(); ++i) 
    mx = max(mx, dep[x][i] + i);
  return mx + 1;
}

int main() {
  scanf("%d", &N);
  for (int i = 2, x; i <= N; ++i) {
    scanf("%d", &x);
    loser[x].push_back(i);
  }

  printf("%d\n", work(1));
  
  return 0;
}


Measured memory_bytes: 17408
package main

import "fmt"

func main() {
  var x int
  fmt.Scan(&x)
  
  fmt.Println(answerABC160B(x))
}


func answerABC160B(x int) int {
	var utilities = map[int]int{
		500: 1000,
		5:   5,
	}

	count500yen, rem := x/500, x%500
	count5yen := rem / 5

	return count500yen*utilities[500] + count5yen*utilities[5]
}



Measured memory_bytes: 1832
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	int left, right;
	
	std::cin >> N;
	int x;
	std::cin >> x;
	left = x;
	right = x;
	for (int i = 1; i < N; ++i) {
		std::cin >> x;
		left = std::min(x, left);
		right = std::max(x, right);
	}
	std::cout << (right - left) << "\n";
}


Measured memory_bytes: 256
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

A, B, K = map(int, input().split())

x = gcd(A, B)
y = []

for i in range(x):
    if x % (i + 1) == 0:
        y.insert(0, i + 1)

print(y[K - 1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Mon Apr 20 00:37:53 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> c(n);
    REP(i, n) std::cin >> c[i], c[i]--;
    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        std::cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    std::vector<Int> sz(n, 1);
    std::vector<std::map<Int, Int>> mps(n);
    std::vector<std::vector<Int>> nums(n);
    auto dfs = [&](auto f, int v, int prv) -> void {
        for (int s : g[v]) {
            if (s == prv) continue;
            f(f, s, v);
            sz[v] += sz[s];
            nums[c[v]].push_back(sz[s] - mps[s][c[v]]);
            if (mps[s].size() > mps[v].size()) std::swap(mps[s], mps[v]);
            for (auto& p : mps[s]) {
                mps[v][p.first] += p.second;
            }
        }
        mps[v][c[v]] = sz[v];
    };
    dfs(dfs, 0, -1);
    REP(i, n) {
        nums[i].push_back(n - mps[0][i]);
    }
    REP(i, n) {
        Int ans = n * (n + 1) / 2;
        for (Int x : nums[i]) ans -= x * (x + 1) / 2;
        std::cout << ans << "\n";
    }
}


Measured memory_bytes: 100236
/*input
5
3 3 3 3 3
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;	

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	ll ans = 0;
	int mx = a[0];
	repl(i, 1, n) {
		if(mx>a[i]) ans += mx-a[i];
		mx = max(mx, a[i]);
	}
	cout << ans;
	return 0;	
}

Measured memory_bytes: 4348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N-1];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N-1;i++) {
			C[i] = sc.nextInt();
		}
		
		int satisfact = 0;
		int preNum = 0;
		
		for(int i=0;i<N;i++) {
			int num = A[i];
			satisfact += B[num - 1];
			if(preNum + 1 == num && preNum != 0) {
				satisfact += C[preNum - 1];
			}
			preNum = num;
		}
		
		System.out.println(satisfact);
		
		sc.close();	
	}
}

Measured memory_bytes: 23508
#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)

typedef long long ll;

int main() {
    ll n,m;cin>>n>>m;
    
    ll a[n];
    ll b[n];
    ll tmp;
    ll Num = 1;
    rep(i,n) {
        cin>>a[i];
        
        int cc = 0;
        tmp = a[i];
        while(tmp%2==0){
            ++cc;
            tmp/=2;
        }
        b[i]=cc;
        
        Num = Num/__gcd(Num,a[i])*a[i];
        if(Num > 2*m){
          cout<<0<<endl;
          return 0;
        }
    }
    
    sort(b,b+n);
    rep(i,n-1){
        if(b[i]!=b[n-1]){
          cout<<0<<endl;
          return 0;
        }
    }
    
    ll Num2 = Num/2;
    
    ll ans = m / Num2 - (m / Num);
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
def resolve():
    N, P = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    odd = 0
    for a in A:
        if a % 2 == 1:
            odd += 1
    even = N - odd
    if P == 1:
        if odd > 0:
            ans = (2**even) * (2**(odd - 1))
        else:
            ans = 0
    else:
        if odd == 0:
            ans = (2**even)
        else:
            ans = (2**even) * (2**(odd - 1))
    print(ans)


resolve()


Measured memory_bytes: 9212