akhauriyash/Code-Regression huggingface dataset:
import heapq

n = int(input())
hp = []
d = 1 << (n - 1)
for v in (d * int(s) for s in input().split()):
    heapq.heappush(hp, v)
for i in range(n - 1):
    x = heapq.heappop(hp)
    y = heapq.heappop(hp)
    #print(x, y)
    heapq.heappush(hp, (x + y) / 2)
print('%.6f' % (hp[0] / d))


Measured memory_bytes: 3060
#!/usr/bin/env python3
# ITP2_9_D: Set Operation - Set Symmetric Difference


def symdiff(n, m, a, b):
    i, j = 0, 0
    while i < n and j < m:
        if a[i] < b[j]:
            yield a[i]
            i += 1
        elif a[i] > b[j]:
            yield b[j]
            j += 1
        else:
            i += 1
            j += 1

    while i < n:
        yield a[i]
        i += 1
    while j < m:
        yield b[j]
        j += 1


def run():
    n = int(input())
    a = [int(i) for i in input().split()]
    m = int(input())
    b = [int(j) for j in input().split()]

    for v in symdiff(n, m, a, b):
        print(v)


if __name__ == '__main__':
    run()



Measured memory_bytes: 35912
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;

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

int main()
{
    int n, a[100005] = {}, b[100005] = {};
    ll sum = 0;
    cin >> n;
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n)
    {
        if (b[i] > a[i])
        {
            sum += a[i];
            if (b[i] - a[i] < a[i + 1])
            {
                sum += b[i] - a[i];
                a[i + 1] -= b[i] - a[i];
            }
            else
            {
                sum += a[i + 1];
                a[i + 1] = 0;
            }
        }
        else
        {
            sum += b[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    if((S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) || (S[0]==S[2] && S[1]==S[3]&& S[0]!=S[1]) || (S[0]==S[3] && S[1]==S[2]&& S[0]!=S[2])) cout <<"Yes"<<endl;
    else cout << "No"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      if(N%2==0){
        Console.WriteLine(Math.Pow(N/2,2));
      }else{
        Console.WriteLine((N/2)*(N/2+1));
      }
    }
    
  }

}


Measured memory_bytes: 27684
h, w = map(int, input().split())
if h ==1 or w == 1:
    print(1)
elif h % 2 == 0 and w % 2 == 0:
    print(h * w // 2)
elif h % 2 == 1 and w % 2 == 1:
    print(h * w // 2 + 1)
else:
    print(h * w // 2)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
   #define ll long long int
    using namespace std;
    ll mx=1000000000000000001;
    int main()
    {
            ll n;
            cin>>n;
            ll a[n];
            ll pre[n+1]={0};
            for(ll i=1;i<=n;i++){
                cin>>a[i-1];
                pre[i]=pre[i-1]+a[i-1];
            }
            ll dp[n+1][n+1];
            
            for(ll l=n-1;l>=0;l--)
            {
                for(ll r=l;r<n;r++)
                {
                    if(l==r)
                        dp[l][r]=0;
                    else
                    {
                         dp[l][r]=mx;
                        for(ll i=l;i<=r-1;i++)
                        {
                          
                            dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+(pre[r+1]-pre[l]));
                        }
                    }
                   
                }
                
            }
            cout<<dp[0][n-1];
        
        return 0;
    }

Measured memory_bytes: 1536
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,a;

  cin >> n;

  bool b = true;
  rep(i,n)
  {
    cin >> a;

    if(a % 2 == 0)
    {
      if(a % 3 == 0 || a % 5 == 0)
      {
        continue;
      }
      else
      {
        b = false;
        break;
      }
    }
  }

  cout << (b ? "APPROVED" : "DENIED ");


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> D(N);
  for ( int i = 0; i < N; i ++){
    cin >> D.at(i);
  }
  
  int sum = 0;
  
  for ( int i = 0; i < N; i ++){
    for ( int j = 0; j < N; j ++){
      if ( i == j ){
        continue;
      }else{
        sum += D.at(i) * D.at(j);
      }
    }
  }
  
  sum /= 2;
  
  cout << sum << endl;
  
}


Measured memory_bytes: 256
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))


import itertools
import math
A=[x for x in range(1,N+1)]
lis=itertools.permutations(A)

c=0
d=0
for s in lis:

  judge=True
  c+=1
  for i in range(N):
    if P[i] != s[i]:
      judge=False
  if judge:
    break
    
li=itertools.permutations(A)
  
for s in li:
  judge=True
  d+=1
  for i in range(N):
    if Q[i] != s[i]:
      judge=False
  if judge:
    break

print(abs(c-d))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
	char a[3];
	int i;
	for(i=0;i<=3;i++) cin>>a[i];
	if((a[0]=='Y')&&(a[1]=='A')&&(a[2]=='K')&&(a[3]=='I')) cout<<'Y'<<'e'<<'s'<<endl;
	else cout<<'N'<<'o'<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef unsigned long long ul;typedef queue<int> qii;typedef queue<pii> qpi;
//ll n;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*a-b;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = N * 800;
		int y = (N / 15) * 200;
		int sum = x-y;
		System.out.print(sum);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
vec adj[100005]; ll dp[100005]; bool vis[100005];
ll dfs(ll x)
{
	if(vis[x]==true)
	return dp[x];
	vis[x]=true;
	ll y=0;
	rep(i,0,adj[x].size())
	{
		if(!vis[adj[x][i]])
		y=max(y,1+dfs(adj[x][i]));
		else
		y=max(y,1+dp[adj[x][i]]);
	}
	return dp[x]=y;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n,w;
    	cin>>n>>m;
    	rep(i,0,m)
    	{
    		cin>>j>>l;
    		adj[j].pb(l);
		}
		l=0;
		repi(i,1,n)
		{
			dp[i]=0;
			vis[i]=false;
		}
    	repi(i,1,n)
    	{
    		if(!vis[i])
    		l=max(l,dfs(i));
		}
    	cout<<l;
    } 
	return 0;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n, m;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

	cin >> n >> m;
	vi a(n);
	forn(i, n) cin >> a[i];
	int sum = accumulate(all(a), 0);
	int cnt= 0 ;
	forn(i, n) {
		if (4*a[i]*m >= sum) ++cnt;
	}
	cout << (cnt >= m ? "Yes" : "No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;

const int MAX_V = 100010;
using Capacity = int;
using Cost = int;
const auto inf = numeric_limits<Capacity>::max() / 8;

struct Edge {
	int dst;
	Capacity cap, cap_orig;
	Cost cost;
	int revEdge; bool isRev;
	Edge(int dst, Capacity cap, Cost cost, int revEdge, bool isRev)
		:dst(dst), cap(cap), cap_orig(cap), cost(cost), revEdge(revEdge), isRev(isRev) {
	}
};

struct PrimalDual {
	int n;
	vector<vector<Edge> > g;
	PrimalDual(int n_) : n(n_), g(vector<vector<Edge> >(n_)) {}
	void add_edge(int src, int dst, Capacity cap, Cost cost) { // ?????????
		g[src].emplace_back(dst, cap, cost, g[dst].size(), false);
		g[dst].emplace_back(src, 0, -cost, g[src].size() - 1, true);
	}
	Cost solve(int s, int t, int f) {
		Cost res = 0;
		static Cost h[MAX_V], dist[MAX_V];
		static int prevv[MAX_V], preve[MAX_V];
		for(int i = 0; i < n; i++) {
			h[i] = 0;
		}
		while(f > 0) {
			typedef pair<Cost, int> pcv;
			priority_queue<pcv, vector<pcv>, greater<pcv> > q;
			for(int i = 0; i < n; i++) {
				dist[i] = inf;
			}
			dist[s] = 0;
			q.emplace(pcv(0, s));
			while(q.size()) {
				pcv p = q.top(); q.pop();
				int v = p.second;
				if(dist[v] < p.first) continue;
				for(int i = 0; i < g[v].size(); i++) {
					Edge &e = g[v][i];
					if(e.cap > 0 && dist[e.dst] > dist[v] + e.cost + h[v] - h[e.dst]) {
						dist[e.dst] = dist[v] + e.cost + h[v] - h[e.dst];
						prevv[e.dst] = v;
						preve[e.dst] = i;
						q.emplace(pcv(dist[e.dst], e.dst));
					}
				}
			}
			if(dist[t] == inf) {
				return -1;
			}
			for(int v = 0; v < n; v++) {
				h[v] += dist[v];
			}
			// s-t ????????????????????£??????????????????
			int d = f;
			for(int v = t; v != s; v = prevv[v]) {
				d = min(d, g[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d * h[t];
			for(int v = t; v != s; v = prevv[v]) {
				Edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.revEdge].cap += d;
			}
		}
		return res;
	}
	// ??????????????????=???????????????-?????¨??????????????¨???
	void view() {
		for(int i = 0; i < g.size(); i++) {
			for(int j = 0; j < g[i].size(); j++) {
				if(!g[i][j].isRev) {
					Edge& e = g[i][j];
					printf("%3d->%3d (flow:%d)\n", i, e.dst, e.cap_orig - e.cap);
				}
			}
		}
	}
};


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

	int V, E, F;
	cin >> V >> E >> F;

	PrimalDual pd(V);

	for(int i = 0; i < E; i++) {
		int u, v, c, d;
		cin >> u >> v >> c >> d;
		pd.add_edge(u, v, c, d);
	}

	int res = pd.solve(0, V - 1, F);
	if(res == inf) res = -1;
	cout << res << endl;
}

Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    char c[n];
    int r=0;
    for(int i=0;i<n;i++){
        cin >> c[i];
        if(c[i]=='R')r++;
    }
    int ans=0;
    for(int i=0;i<r;i++)if(c[i]=='W')ans++;
    cout << ans;
}

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

int main()
{
  int n=0;
  int a, b, c = 0;
  cin >> n;

  if(n < 10){
    if(n == 3){
      cout << "bon" << endl;
    }else if(n ==0 || n== 1 || n==6 || n==8){
      cout << "pon" << endl;
    }else{
      cout << "hon" << endl;
    }
  }

  if(n >= 10 && n < 100){
    n %= 10;
    if (n == 3)
    {
      cout << "bon" << endl;
    }
    else if (n == 0 || n == 1 || n == 6 || n == 8)
    {
      cout << "pon" << endl;
    }
    else
    {
      cout << "hon" << endl;
    }
  }

  if(n >= 100){
    n %= 10;
    n %= 10;
    if (n == 3)
    {
      cout << "bon" << endl;
    }
    else if (n == 0 || n == 1 || n == 6 || n == 8)
    {
      cout << "pon" << endl;
    }
    else
    {
      cout << "hon" << endl;
    }
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int n,k;
	cin>>n>>k;
	int now=1;
	while(n--)
	{
		int a=now*2;
		int b=now+k;
		if(a>b)
			now+=k;
		else 
			now*=2;
	}
	cout<<now<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	//ライバル社
	void color(int xy[][],int n,int m){
		int num = 1;
		while(true){
			int cnt = 0;
			for(int i = 1;i < m+1;i++){
				for(int j = 1;j < n+1;j++){
					if(xy[i][j] == num){
						if(xy[i+1][j] == 0){
							xy[i+1][j] = num + 1;
							cnt++;
						}
						if(xy[i-1][j] == 0){
							xy[i-1][j] = num + 1;
							cnt++;
						}
						if(xy[i][j+1] == 0){
							xy[i][j+1] = num + 1;
							cnt++;
						}
						if(xy[i][j-1] == 0){
							xy[i][j-1] = num + 1;
							cnt++;
						}
						if(i % 2 == 0){
							if(xy[i+1][j+1] == 0){
								xy[i+1][j+1] = num + 1;
								cnt++;
							}
							if(xy[i-1][j+1] == 0){
								xy[i-1][j+1] = num + 1;
								cnt++;
							}
						}else if(i % 2 == 1){
							if(xy[i+1][j-1] == 0){
								xy[i+1][j-1] = num + 1;
								cnt++;
							}
							if(xy[i-1][j-1] == 0){
								xy[i-1][j-1] = num + 1;
								cnt++;
							}
						}
					}
				}
			}
			if(cnt == 0)break;
			num++;
		}
	}
	//自社
	int Map(int xy[][],int n,int m){
		int num = 1;
		int result = 0;
		while(true){
			int cnt = 0;
			for(int i = 1;i < m+1;i++){
				for(int j = 1;j < n+1;j++){
					if(xy[i][j] == num*(-1)){
						if(xy[i+1][j] > num+1){
							xy[i+1][j] = num*(-1) - 1;
							cnt++;
						}
						if(xy[i-1][j] > num+1){
							xy[i-1][j] = num*(-1) - 1;
							cnt++;
						}
						if(xy[i][j+1] > num+1){
							xy[i][j+1] = num*(-1) - 1;
							cnt++;
						}
						if(xy[i][j-1] > num+1){
							xy[i][j-1] = num*(-1) - 1;
							cnt++;
						}
						if(i % 2 == 0){
							if(xy[i+1][j+1] > num+1){
								xy[i+1][j+1] = num*(-1) - 1;
								cnt++;
							}
							if(xy[i-1][j+1] > num+1){
								xy[i-1][j+1] = num*(-1) - 1;
								cnt++;
							}
						}else if(i % 2 == 1){
							if(xy[i+1][j-1] > num+1){
								xy[i+1][j-1] = num*(-1) - 1;
								cnt++;
							}
							if(xy[i-1][j-1] > num+1){
								xy[i-1][j-1] = num*(-1) - 1;
								cnt++;
							}
						}
					}
				}
			}
			if(cnt == 0)break;
			num++;
		}
		for(int i = 1;i < m+1;i++){
			for(int j = 1;j < n+1;j++){
				if(xy[i][j] < 0)result++;
			}
		}
		return result;
	}
	void doIt() { 
		while(true){
			int ans = 0;
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n+m == 0)break;
			int xy[][] = new int [m+2][n+2];
			int num = sc.nextInt();
			for(int i = 0;i < num;i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				xy[y][x] = 1;
			}
			color(xy,n,m);
			int map[][] = new int [m+2][n+2];
			int s = sc.nextInt();
			for(int k = 0;k < s;k++){
				for(int i = 1;i < m+1;i++){
					for(int j = 1;j < n+1;j++){
						map[i][j] = xy[i][j];
					}
				}
				int xm = sc.nextInt();
				int ym = sc.nextInt();
				map[ym][xm] = -1;
				if(k == 0){
					ans = Map(map,n,m);
				}else{
					if(ans < Map(map,n,m)){
						ans = Map(map,n,m); 
					}
				}
			}
			System.out.println(ans);
		}
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 22984
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    if (a == 1) a += 13;
    if (b == 1) b += 13;

    if (a > b) {
        cout << "Alice" << endl;
    } else if (a == b) {
        cout << "Draw" << endl;
    } else {
        cout << "Bob" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

#define rep(i,j) for(int i=0; i<j; i++ )
#define INF 10000000

int main(){
    int n;
    while( scanf("%d",&n), n ){
        int m;
        int map[100][100];
        scanf("%d", &m);
        rep(i,100) rep(j,100) map[i][j] = INF;
        rep(i,m){
            int a, b, d;
            scanf("%d,%d,%d", &a, &b, &d);
            map[a][b] = map[b][a] = d;
        }
        int count=0, memo[100], minIndex = 0;
		bool used[100];
        rep(i,n){
			memo[i] = map[0][i];
			used[i] = false;
		}
		memo[0] = INF;
		used[0] = true;
        rep(i,n-1){
            rep(j,n){
                if( memo[j] < memo[minIndex] ){
                    minIndex = j;
                }
            }
			count += memo[minIndex]/100-1;
			used[minIndex] = true;
			memo[minIndex] = INF;
			rep(j,n)
				if( !used[j] )
					memo[j] = min( memo[j], map[minIndex][j] );
        }
		printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 1064
import math
A,B=map(int,input().split())

#SA=(math.floor(math.floor(float(A)/0.08))*0.08,math.floor(math.ceil(float(A)/0.08))*0.08)
#SB=(math.floor(math.floor(float(B)/0.08))*0.08,math.floor(math.ceil(float(B)/0.08))*0.08)
SA=(math.floor(float(A)/0.08),math.ceil(float(A)/0.08))
SB=(math.floor(float(B)/0.08),math.ceil(float(B)/0.08))
ans=[]
for i in range(1,10003):
    SSA=math.floor(i*0.08)
    SSB = math.floor(i * 0.1)
    if SSA==A and SSB==B:
        print(i)
        exit()
print(-1)


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

public class Main {

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

		long N = nextLong();
		long P = nextLong();

		TreeMap<Long,Long> map = prime_factorize(P);

		long ans =1;
		for(long n:map.keySet()){
			long num = map.get(n);
			ans*=Math.pow(n,(num/N));
		}
		System.out.println(ans);
	}

	public static TreeMap<Long,Long>  prime_factorize(long N){
		TreeMap<Long,Long> map = new TreeMap<>();
		for(long i=2;i*i<=N;i++){
			long k=0;
			while(N%i==0){
				k++;
				N/=i;
			}
			map.put(i, k);
		}
		map.put(N, 1L);
		return map;
	}

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

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

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

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

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

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

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

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


}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a == 1 && b == 2) {
    cout << 3 << endl;
  } else if (a == 1 && b == 3) {
    cout << 2 << endl;
  } else if (a == 2 && b == 1) {
    cout << 3 << endl;
  } else if (a == 2 && b == 3) {
    cout << 1 << endl;
  } else if (a == 3 && b == 1) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    static int[][] l;
    static int[] d;
    static int[] f;
    static int time = 1;
    
    static void dfs(int v){
        d[v] = time;
        time++;
        int j = 0;
        while(l[v][j] != 0){
            if(d[l[v][j]]== 0){
                dfs(l[v][j]);
            }
            j++;
        }
        f[v] = time;
        time++;
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        l = new int[n + 1][100];
        d = new int[n + 1];
        f = new int[n + 1];
        
        for(int i = 1; i <= n; i++){
            int u = sc.nextInt();
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                int v = sc.nextInt();
                l[u][j] = v;
            }
        }
        for(int i = 1; i <= n; i++){
            if(d[i] == 0){
                dfs(i);
            }
        }
        for(int i = 1; i <= n; i++){
            System.out.println(i + " " + d[i] + " " + f[i]);
        }
    }
}



Measured memory_bytes: 28324
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    long long h; cin >> h;
    long long atNum = 0;
    long long monsters = 1;
    while (h > 0) {

        atNum += monsters;
        h = h /2;
        monsters = 2 * monsters;
    }
    cout << atNum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long S;
int main() {
	scanf("%lld", &S);
	long long A = 1e9;
	long long D = S / A;
	if (D == A) {
		printf("%lld %lld %lld %lld %lld %lld", 0LL, 0LL, A, A, A, 0LL);
		return 0;
	}
	long long T = S % A;
	long long C = 1;
	long long B = S % A;
	printf("%lld %lld %lld %lld %lld %lld\n", 0LL, A, C, 0LL, C + D, B);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>

int main(void){
  int a,b;
  char s[10],t[10];
  char z[10];
  
  scanf("%s %s",s,t);
  scanf("%d %d",&a,&b);
  
  scanf("%s",z);
  
  if(strcmp(s,z) == 0)
    a--;
  else
    b--;
  
  printf("%d %d",a,b);
}
  

Measured memory_bytes: 128
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,r,j;
    string s,t;
    cin>>r;
    if (r < 1200)
        cout << "ABC";
    else if (r >= 1200 && r < 2800)
        cout << "ARC";
    else
        cout << "AGC";
    return 0;
}





Measured memory_bytes: 3652
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    a_sum = sum(a_list)
    x_list = [0] * n
    x_list[0] = a_sum // 2 - sum(a_list[1::2])
    for i in range(1, n):
        x_list[i] = a_list[i - 1] - x_list[i - 1]
    print(" ".join(list(map(lambda x: str(x * 2), x_list))))

# それぞれの山に降った雨を2x1 2x2 ... 2xnとする
# a1 = x1+x2, a2 = x2+x3, ..., an = xn+x1
# aの総和は 2(x1+x2+...+xn)なので
# それを2で割って、a2, a4, ..., an-1を引くとx1となる
# あとは順番にx2以降を求める
# xi = ai-1 - xi-1


Measured memory_bytes: 75236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<ll> sosu;
void Sosu(ll x){
    bool s[x+1];
    fill(s,s+x+1,true);
    ll i;
    for(i=2;i*i<=x;i=i+2){
        if(s[i]){
            sosu.pb(i);
            for(ll j=2;j*i<=x;j++){
                s[j*i]=false;
            }
        }
        if(i==2)i--;
    }
    for(i=i;i<=x;i=i+2){
        if(s[i]){
            sosu.pb(i);
        }
    }
}

int main(){
    ll n;cin>>n;
    Sosu(1010);
    ll m;m=sosu.size();
    ll x;
    ll a[m];rep(i,0,m-1)a[i]=0;
    rep(i,1,n){
        x=i;
        rep(j,0,m-1){
            while(x%sosu[j]==0){
                a[j]++;
                x/=sosu[j];
            }
        }
    }
    ll ans=1;
    rep(i,0,m-1){
        ans=(ans*(a[i]+1))%i_7;
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1 && b==1){
    cout << "Draw" << endl;
  }
  else if(a==1 && b!=1){
    cout << "Alice" << endl;
  }
  else if(a!=1 && b==1){
    cout << "Bob" << endl;
  }
  else if(a==b){
    cout << "Draw" << endl;
  }
  else if(a>b){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int cnt = 0;
  for (int i = A; i < B + 1; i++) {
    int num_on = i % 10;
    int num_te = i / 10 % 10;
    int num_th = i / 1000 % 10;
    int num_ot = i / 10000 % 10;
    if ((num_on == num_ot) && (num_te == num_th)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
# coding=utf-8


class Dice(object):

    def __init__(self, label):
        self.label = label

    def _rotateS(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s5, s1, s3, s4, s6, s2]

    def _rotateN(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s2, s6, s3, s4, s1, s5]

    def _rotateE(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s4, s2, s1, s6, s5, s3]

    def _rotateW(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s3, s2, s6, s1, s5, s4]

    def rotate(self, r):
        if r == 'S':
            self._rotateS()
        elif r == 'N':
            self._rotateN()
        elif r == 'E':
            self._rotateE()
        elif r == 'W':
            self._rotateW()
        else:
            print 'Cannot rotate into ' + r + 'direction.'

    def _spinPos(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s1, s4, s2, s5, s3, s6]

    def _spinNeg(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s1, s3, s5, s2, s4, s6]

    def getTopLabel(self):
        return self.label[0]

    def match(self, top, front):
        iTop = self.label.index(top) + 1
        if iTop == 1:
            pass
        elif iTop == 2:
            self._rotateN()
        elif iTop == 3:
            self._rotateW()
        elif iTop == 4:
            self._rotateE()
        elif iTop == 5:
            self._rotateS()
        else:
            self._rotateS()
            self._rotateS()

        iFront = self.label.index(front) + 1
        if iFront == 2:
            pass
        elif iFront == 3:
            self._spinNeg()
        elif iFront == 4:
            self._spinPos()
        elif iFront == 5:
            self._spinPos()
            self._spinPos()


if __name__ == '__main__':
    d = Dice(map(int, raw_input().split()))
    n = input()
    for _ in xrange(n):
        top, front = map(int, raw_input().split())
        d.match(top, front)
        print d.label[2]

Measured memory_bytes: 4368
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  int king = 0;
  vector<int> cnt(8);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a < 400) cnt[0]++;
    else if (a < 800) cnt[1]++;
    else if (a < 1200) cnt[2]++;
    else if (a < 1600) cnt[3]++;
    else if (a < 2000) cnt[4]++;
    else if (a < 2400) cnt[5]++;
    else if (a < 2800) cnt[6]++;
    else if (a < 3200) cnt[7]++;
    else king++;
  }
  int c = 0;
  for (int i = 0; i < 8; i++) {
    if (cnt[i] > 0) c++;
  }
  cout << max(1, c) << " " << c + king << endl;
  return 0;
}

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

vector<long long>v;
vector<long long>::iterator low,up,it;
map<int,int>mp;
set<int>s;

int main(void){

    int n,k,d,a;

        cin>>n>>k;

    while(k--){

        cin>>d;

        for(int i=0; i<d; i++){
            cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size();
}


Measured memory_bytes: 3572
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S;
  while (cin >> S) {
    bool res = S.size() % 2 == 0;
    for (int i = 0; i < S.size(); i++) res &= S[i] == "hi"[i % 2];
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
A,B,C = map(int,input().split())

def divide2(x):
    r = 0
    while x%2 == 0:
        r += 1
        x = x/2
    return r

if A == B == C:
    if A%2 == 0:
        print(-1)
    else:
        print(0)
else:
    print(min(divide2(A+B),divide2(B+C),divide2(C+A)))

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;

int main(){
    int n;
    double dis[4] = {0};
    cin >> n;
    int x[n], y[n];
    
    for(int i = 0; i < n * 2; i++){
        if(i < n) cin >> x[i];
        else cin >> y[i - n];
    }
    
    for(int i = 0; i < n; i++){
        dis[0] += abs(x[i] - y[i]);
        dis[1] += (x[i] - y[i]) * (x[i] - y[i]);
        dis[2] += pow(abs(x[i] - y[i]), 3.0);
        dis[3] = (dis[3] > abs(x[i] - y[i])) ? dis[3] : abs(x[i] - y[i]);
    }
    
    dis[1] = sqrt(dis[1]);
    dis[2] = pow(dis[2], 1.0 / 3.0);
    cout << fixed << dis[0] << endl << dis[1] << endl << dis[2] << endl << dis[3] << endl;
}


Measured memory_bytes: 3432
#include<iostream>
#include<math.h>

using namespace std;


int main(){
    int k,n=0,cnt=0;

    cin>>n>>k;
    int a[n+1]={};
    for(int i=1;i<=k;i++){
        int d;
        cin>>d;
        for(int j=1;j<=d;j++){
            int tmp;
            cin>>tmp;
            a[tmp]++;
        }
    }
    
    for(int i=1;i<=n;i++){
        if(a[i]==0){
            cnt++;
        }
    }
    
    cout<<cnt<<"\n";

    return 0;
}            

Measured memory_bytes: 3624
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,k,a,b;

int main()
{
	scanf("%d%d%d%d",&n,&k,&a,&b);
	if(n<=k)
	{
		printf("%d\n",a*n);
	}
	else
	{
		printf("%d\n",a*k+b*(n-k));
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e4 + 5;

string s;

void solve()
{
    cin>>s;
    int sum=0;
    for(char c:s)
    {
        sum+=c-'0';
        sum%=9;
    }
    if(sum)
        cout<<"No";
    else
        cout<<"Yes";
}

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

Measured memory_bytes: 3740
#include <stdio.h>

int main(){
	int x,y;
	for(;; x=1,y=1){
		scanf("%d %d",&x,&y);
		if((x == 0)&&(y == 0)) break;
		if(x<y){
			printf("%d %d\n",x,y);
		}else if(y<x){
			printf("%d %d\n",y,x);
		}else{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char> >v(H,vector<char>(W,0));

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>v[i][j];
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(v[i][j]=='#'){
        bool check=false;
        if(i>0&&(v[i-1][j]=='#'))check=true;
        else if(i<(H-1)&&(v[i+1][j]=='#'))check=true;
        else if(j>0&&(v[i][j-1]=='#'))check=true;
        else if(j<(W-1)&&(v[i][j+1]=='#'))check=true;
        if(!check){cout<<"No"<<endl;return 0;}
      }
    }
  }

  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections
from heapq import *


def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    for _ in range(NI()):
        N,A,B,C,D = LI()

        q = []
        heapify(q)

        memo = {}

        def push(c,n):
            if memo.get(n,INF) > c :
                heappush(q,(c,n))
                memo[n] = c


        push(0,N)

        while q:
            c,n = heappop(q)
            m = [0] * 9
            if n == 1:
                print(c+D)
                break

            if n % 2 == 0:
                push(c+min(A,n//2*D),n//2)
            else:
                m[1] = m[-1] = 1
            if n % 3 == 0:
                push(c+min(B,n//3*2*D),n//3)
            else:
                m[3-(n%3)] = m[-(n%3)] = 1
            if n % 5 == 0:
                push(c+min(C,n//5*4*D),n//5)
            else:
                m[5-(n%5)] = m[-(n%5)] = 1
            for i in range(-4,5):
                if m[i] and n+i > 0: push(c+D*abs(i),n+i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 113916
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 50;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K;
    vec a(N), b(N);
    rep(i,N) cin>>a[i]>>b[i];
    ll ans = 0;
    rep(i,30){
        if((K>>i)&1){
            ll k = (K ^ (1LL<<i)) | ((1LL<<i) - 1), temp = 0;
            //cout<<k<<endl;
            rep(j,N) if((k | a[j]) == k) temp += b[j];
            ans = max(ans, temp);
        }
    }
    ll t = 0;
    rep(j,N) if((K | a[j]) == K) t += b[j];
    ans = max(ans, t);
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int n;
int v[20];
int c[20];
int main(){
    cin >> n;
    rep(i,n) cin>>v[i];
    rep(i,n) cin>>c[i];
    int ans = 0;
    rep(i, n){
        ans += max(0, v[i]-c[i]);
    }
    cout << ans << endl;
}



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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    string S;cin >> S;
    int a, z;

    REP(i, S.size())
    {
        if (S.at(i)=='A') {
            a = i;break;
        }
    }
    for(int i=S.size()-1; i>=0; i--)
    {
        if (S.at(i)=='Z') {
            z = i;break;
        }
    }
    cout << z - a +1 << endl;

    return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  double l;
  cin >> l;
  double ans = l*l*l/27;
  printf("%.7f\n", ans);
  return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 cin >> N;
 vector<int> as(N);
 for(int i = 0; i < N; i++){
   cin >> as.at(i);
   
 }
 int index = 1;
 int ans = 1;
 while(ans < N){
   index = as.at(index - 1);
   if(index == 2){
     cout <<ans << endl;
      return 0;
   }
   ans++;
 }
 cout << -1 << endl;
 
 return 0;
}


Measured memory_bytes: 640
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	ww := make([]int, n)
	sorted := make([]int, n)
	vv := make([]bool, n)
	min := 1 << 30
	for i := 0; i < n; i++ {
		ww[i] = getNextInt(scanner)
		if min > ww[i] {
			min = ww[i]
		}
		sorted[i] = ww[i]
		vv[i] = false
	}
	ttt := make(map[int]int, 0)
	sort.Sort(sort.IntSlice(sorted))
	for i := 0; i < n; i++ {
		ttt[sorted[i]] = i
	}
	ans := 0
	for i := 0; i < n; i++ {
		if vv[i] {
			continue
		}
		cur := i
		s := 0
		m := 1 << 30
		an := 0
		for {
			vv[cur] = true
			an++
			v := ww[cur]
			if m > v {
				m = v
			}
			s += v
			cur = ttt[v]
			if vv[cur] {
				break
			}
		}
		ans += minint(s+(an-2)*m, m+s+(an+1)*min)
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}
func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll gdc(ll a, ll b)
{
	if (a < b)
	{
		std::swap(a, b);
	}
	ll c = a%b;
	if (c == 0)return b;
	return gdc(b, c);
}

int main()
{
	ll N, M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;

	ll G = gdc(N, M);
	ll L = N*M / G;

	REP(i, N)
	{
		ll n = (L / N)*i + 1;
		ll m = (n - 1) *M / L;
		if (n != (L / M)*m + 1)
		{
			continue;
		}
		if (S[i] != T[m])
		{
			L = -1;
			break;
		}
	}

	cout << L << endl;

	return 0;
}

Measured memory_bytes: 512