akhauriyash/Code-Regression huggingface dataset:
//2019.7.22 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 1e18+1e9
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=150+10;
namespace MAIN{
    int n,k,kcz;
    int dp[N][N][N];
    int f[N][N];
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    inline int solve(const res &n,const res &k){
        for(res i=0;i<=n;i++)
            for(res j=0;j<=k;j++)
                f[i][j]=0;
        f[0][0]=1;
        for(res i=0;i<n;i++)
            for(res j=0;j<=k;j++)
                if(f[i][j])add(f[i+1][0],f[i][j]),add(f[i+1][j+1],f[i][j]);
        res ret=0;
        for(res i=0;i<=k;i++)add(ret,f[n][i]);
        return ret;
    }
    inline void MAIN(){
        n=read(),k=read(),kcz=read();
        if(k%2==0){printf("%d\n",mul(solve(n>>1,k>>1),solve(n-(n>>1),k>>1)));return;}
        dp[0][0][0]=1;
        for(res i=0;i<=n;i++){
            res r=i<<1,l=r-k;
            for(res j=0;j<=n;j++)
                for(res p=0;p<=k;p++)
                    if(dp[i][j][p]){
                        add(dp[i+1][0][0],dp[i][j][p]);
                        if((1<=r&&r<=n)&&(1<=l&&l<=n))add(dp[i+1][j+1][max(p+1,j+1)],dp[i][j][p]);
                        if((1<=r&&r<=n))add(dp[i+1][j+1][0],dp[i][j][p]);
                        if((1<=l&&l<=n))add(dp[i+1][0][p?p+1:p],dp[i][j][p]);
                    }
        }
        printf("%d\n",dp[n+1][0][0]);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, e, t;
ll f[maxn], x[maxn];
ll s0[20][maxn];
ll s1[20][maxn];
inline ll min0(int l,int r) { const int lg = std::__lg(r - l + 1); return l <= r ? std::min(s0[lg][r], s0[lg][l + (1 << lg) - 1]) : 1e18; }
inline ll min1(int l,int r) { const int lg = std::__lg(r - l + 1); return l <= r ? std::min(s1[lg][r], s1[lg][l + (1 << lg) - 1]) : 1e18; }
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> e >> t;
	rep(i, 1, n) cin >> x[i];
	int j = 0;
	s0[0][0] = 0;
	s1[0][0] = - x[1] * 2;
	rep(i, 1, n) {
		for(;x[i] - x[j + 1] << 1 > t;) ++ j;
		f[i] = std::min(min0(j, i - 1) + t, x[i] * 2 + min1(0, j - 1));
		s0[0][i] = f[i];
		s1[0][i] = f[i] - x[i + 1] * 2;
		for(int j = 1;1 << j <= i + 1;++j) {
			s0[j][i] = std::min(s0[j - 1][i], s0[j - 1][i - (1 << j - 1)]);
			s1[j][i] = std::min(s1[j - 1][i], s1[j - 1][i - (1 << j - 1)]);
		}
	}
	std::cout << f[n] + e << '\n';
}


Measured memory_bytes: 56832
# include <bits/stdc++.h>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

ll N;

ll solve(vector<ll> a) {
    ll res = 1e18;
    for (ll i = a[0]; i <= a[N - 1]; i++) {
        ll rem = 0;
        rep(j, N) rem += pow(a[j] - i, 2);
        res = min(res, rem);
    }
    return res;
}

int main() {
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    
    cout << solve(A) << endl;
}

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

#define ll long long

int main()
{
  ll n;
  cin>>n;
  
  ll arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  
  ll ans = 1000;
  ll temp = ans;
  ll share = ans/arr[0];
  
  ans = ans - share*arr[0];
  
  for(int i=1;i<n;i++)
  {
     if(arr[i]>arr[i-1]){
        ans += share*arr[i];
        temp = ans;
        share = ans/arr[i];
        ans = ans - share*arr[i];
     }
     else if(arr[i]<arr[i-1]){
        ans = temp;
        share = ans/arr[i];
        ans = ans - share*arr[i];
     }
  }
        cout<<temp;
}


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S,T;
  cin >> S >> T;
  int N = S.size();
  bool answer = true;
  for(int i = 0 ; i < N ; i++){
    if(S.at(i) != T.at(i)){
      answer = false;
    }
    }
    if(answer){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define umii unordered_map<int,int>
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;cin>>t;
    cout<<1-t<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int a[100010];
int L, R;
ll ans = 0;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }  
  sort(a, a+N);
  L = a[0], R = a[N-1];
  ans += R - L;
  int l = 1, r = N-2;
  while (l <= r) {
    int LL = abs(L - a[l]);
    int LR = abs(L - a[r]);
    int RL = abs(R - a[l]);
    int RR = abs(R - a[r]);
    if (LL >= max({RL, LR, RR})) {
      ans += LL;
      L = a[l++];
    } else if (RL >= max({LL, LR, RR})) {
      ans += RL;
      R = a[l++];
    } else if (LR >= max({RR, LL, RL})) {
      ans += LR;
      L = a[r--];
    } else if (RR >= max({LR, LL, RL})) {
      ans += RR;
      R = a[r--];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M,L;
int P[301][301];
bool used[301][301];
pair<int,int>D[301][301];
vector<pair<int,int> >G[301];
main()
{
	cin>>N>>M>>L;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	for(int k=1;k<=N;k++)
	{
		for(int i=1;i<=N;i++)
		{
			P[k][i]=-1;
			D[k][i]=make_pair(1e9,0);
		}
		P[k][k]=k;
		D[k][k]=make_pair(0,-L);
		for(int _=0;_<N;_++)
		{
			int u=-1;
			for(int i=1;i<=N;i++)
			{
				if(used[k][i])continue;
				if(u<0)u=i;
				else if(D[k][u]>D[k][i])u=i;
			}
			used[k][u]=true;
			int cnt=D[k][u].first;
			int now=-D[k][u].second;
			for(pair<int,int>p:G[u])
			{
				int v=p.first;
				pair<int,int>nxt;
				nxt.first=cnt;
				if(now>=p.second)nxt.second=p.second-now;
				else if(L>=p.second)nxt.second=p.second-L,nxt.first++;
				else continue;
				if(D[k][v]>nxt)
				{
					D[k][v]=nxt;
				}
			}
		}
	}
	int Q;
	cin>>Q;
	for(;Q--;)
	{
		int s,t;cin>>s>>t;
		int ans=D[s][t].first;
		if(ans<1e9)cout<<ans<<endl;
		else cout<<-1<<endl;
	}
}

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static int res;
    static bool[] th;
    static P[] ps;
    static void Solve()
    {
        var nm = Input.ar;
        ps = P.Make(nm[0], nm[1], isWeighted: false);
        th = new bool[nm[0]];
        dfs(0);
        WriteLine(res);
    }
    static void dfs(int index)
    {
        th[index] = true;
        if (th.All(b => b))
        {
            res++;
            th[index] = false;
            return;
        }
        foreach (var ad in ps[index].adj)
            if (!th[ad])
                dfs(ad);
        th[index] = false;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class P : IComparable<P>
{
    public int index;
    public List<int> adj;
    public List<int> rev;
    public Dictionary<int, int> dist;
    public int parent;
    public long Weight { get; set; }
    public P(int index,long Weight=Input.Inf)
    {
        this.index = index;
        adj = new List<int>();
        rev = new List<int>();
        dist = new Dictionary<int, int>();
        this.Weight = Weight;
    }
    public static P[] Make(int num, int edge = 0, bool isNotDirected = true, bool isWeighted = true)
    {
        var ps = Enumerable.Range(0, num).Select(v => new P(v)).ToArray();
        for (var i = 0; i < edge; i++)
        {
            var inp = Input.ar;
            inp[0]--;
            inp[1]--;
            for (var j = 0; j <= ToInt32(isNotDirected); j++)
            {
                ps[inp[j]].adj.Add(inp[1 - j]);
                if (!isNotDirected)
                    ps[inp[1 - j]].rev.Add(inp[j]);
                if (isWeighted)
                    ps[inp[j]].dist[inp[1 - j]] = inp[2];
            }
        }
        return ps;
    }
    public override string ToString()
        => $"{index + 1} {Weight}";
    public override int GetHashCode()
        => index.GetHashCode();
    public int CompareTo(P p)
        => Weight.CompareTo(p.Weight);
}


Measured memory_bytes: 12116
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    H = readInts()
    mi_ = 0
    prv_ = H[0]
    cnt = 0
    for i in range(1,n):
        if prv_ >= H[i]:
            prv_ = H[i]
            cnt += 1
        else:
            mi_ = max(mi_,cnt)
            prv_ = H[i]
            cnt = 0
    mi_ = max(mi_, cnt)
    print(mi_)

if __name__ == '__main__':
  main()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
 
#define maxn 100010
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
int a[maxn], q[maxn];
long long f[maxn];
int main()
{
	int n,m,T;
        scanf("%d%d%d",&n,&m,&T);
	for (int i=1;i<=n;++i)scanf("%d",&a[i]);
	int p = 1, head = 0, tail = 0;
        long long fp = 1234567891234567ll;
	for (int i = 1; i <= n; ++i)
	{
		while ((a[i] - a[p]) * 2 > T) cmin(fp, f[p - 1] - 2 * a[p]), ++p;
		while (head < tail && (a[i] - a[q[head + 1]]) * 2 > T) ++head;
		f[i] = 1ll * i * T;
		cmin(f[i], fp + 2 * a[i]);
		head < tail ? cmin(f[i], f[q[head + 1] - 1] + T) : 0;
		cmin(f[i], f[i - 1] + T);
		while (head < tail && f[q[tail] - 1] > f[i]) --tail;
		q[++tail] = i;
	}
	printf("%lld\n", f[n] + m);
	return 0;
}

Measured memory_bytes: 1792
import sys
import math
from itertools import permutations
from itertools import combinations

#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(input())

pos = int(N//(1.08))
pos2 = (pos+1)
pos3 = (pos-1)

if int(pos*(1.08))==N:
    print(pos)
elif int(pos2*(1.08))==N:
    print(pos2)
elif int(pos3*(1.08))==N:
    print(pos3)
else:
    print(':(')






Measured memory_bytes: 3060
n = int( input() )
#print( n )

s = str( n )
#print( s[-1] )

if s[ -1 ] == "2" or s[ -1 ] == "4" or s[ -1 ] == "5" or s[ -1 ] == "7" or s[ -1 ] == "9":
    print( "hon" )
elif s[ -1 ] == "0" or s[ -1 ] == "1" or s[ -1 ] == "6" or s[ -1 ] == "8":
    print( "pon" )
elif s[ -1 ] == "3":
    print( "bon" )


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

int n,m,x,y,a[202000],s[202000],ans,las,t,f[202000];
vector<int>vec[202000];

namespace seg{
	int mn[808000];
	int A(int x,int l,int r,int p,int v){
		if (l==r) return mn[x]=min(mn[x],v);
		int mid=l+r>>1;
		if (p<=mid) A(x<<1,l,mid,p,v);
		else A(x<<1|1,mid+1,r,p,v);
		mn[x]=min(mn[x<<1],mn[x<<1|1]);
	}
	int Q(int x,int l,int r,int st,int en){
		if (st>en) return 1e8;
		if (l==st&&r==en) return mn[x];
		int mid=l+r>>1;
		return min( Q(x<<1,l,mid,max(st,l),min(en,mid)) , Q(x<<1|1,mid+1,r,max(st,mid+1),min(en,r)) );
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n; for (int i=1;i<=n;++i) cin>>a[i], ans+=a[i], s[i]=s[i-1]+(a[i]?-1:1);
	for (cin>>m;m--;) cin>>x>>y, vec[x].push_back(y);
	
	memset(seg::mn,33,sizeof seg::mn);
	for (int i=1;i<=n;++i){
		for (auto o:vec[i]){
			t=min(las+s[o]-s[i-1],seg::Q(1,1,n,i,o)+s[o]);
			f[o]=min(f[o],t);
			seg::A(1,1,n,o,t-s[o]);
		}
		las=min(las,f[i]);
	}
	cout<<ans+las;
}

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

ans = 0

r_max = N // R
for r in range(r_max + 1):
    g_max = (N - R * r) // G
    for g in range(g_max + 1):
        tmp = N - R * r - G * g
        if tmp % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void NO(){cout<<"NO"<<endl;exit(0);}
ll gcd(ll x,ll y){return y==0?1:gcd(y,x%y);}
ll lcm(ll x, ll y){return x/gcd(x,y)*y;}
int main(){
ll n;cin>>n;map<ll,ll>m;for(int i=0;i<n;++i){ll x;cin>>x;m[x]++;}ll a=0;for(auto&p:m)if(p.second%2)++a;cout<<a<<endl;
return 0;}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;

int c[26]={0};

int main()
{
	int h,w;
	si(h); si(w);
	rep(i,0,h)
	{
		string s;
		cin>>s;
		rep(i,0,s.length())
			c[s[i]-'a']++;
	}

	rep(i,0,26)
		c[i]%=4;

	int a[4];
	clr(a);

	rep(i,0,26)
		a[c[i]]++;

	if(h%2==0 && w%2==0)
	{
		if(a[1] || a[3] || a[2])
			printf("No");
		else
			printf("Yes");

	}
	else if((h%2==0 && w%2) || (w%2==0 && h%2) )
	{
		if(h%2==0) w=h;
		if(a[1] || a[3] || a[2]>w/2)
			printf("No");
		else
			printf("Yes");
	}
	else
	{
		if(!a[3] && !a[1])
			printf("No");
		else
		{
			if(a[1])	a[1]--;
			else
			{
				a[3]--;
				a[2]++;
			}
			if(a[1] || a[3] || a[2]> h/2 + w/2)
				printf("No");
			else
				printf("Yes");
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);

    int x = 0;
    int ma = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x += 1;
        } else {
            x -= 1;
        }

        if (x > ma) {
            ma = x;
        }
    }

    printf("%d\n", ma);

    return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

struct Primal_Dual
{
  const int INF = 1 << 30;
  typedef pair< int, int > Pi;

  struct edge
  {
    int to, cap, cost, rev;
  };
  vector< vector< edge > > graph;
  vector< int > potential, min_cost, prevv, preve;

  Primal_Dual(int V) : graph(V) {}

  void add_edge(int from, int to, int cap, int cost)
  {
    graph[from].push_back((edge) {to, cap, cost, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, -cost, (int) graph[from].size() - 1});
  }

  int min_cost_flow(int s, int t, int f)
  {
    int V = graph.size(), ret = 0;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    potential.assign(V, 0);
    preve.assign(V, -1);
    prevv.assign(V, -1);

    while(f > 0) {
      min_cost.assign(V, INF);
      que.push(Pi(0, s));
      min_cost[s] = 0;

      while(!que.empty()) {
        Pi p = que.top();
        que.pop();
        if(min_cost[p.second] < p.first) continue;
        for(int i = 0; i < graph[p.second].size(); i++) {
          edge &e = graph[p.second][i];
          int nextCost = min_cost[p.second] + e.cost + potential[p.second] - potential[e.to];
          if(e.cap > 0 && min_cost[e.to] > nextCost) {
            min_cost[e.to] = nextCost;
            prevv[e.to] = p.second, preve[e.to] = i;
            que.push(Pi(min_cost[e.to], e.to));
          }
        }
      }
      if(min_cost[t] == INF) return -1;
      for(int v = 0; v < V; v++) potential[v] += min_cost[v];
      int addflow = f;
      for(int v = t; v != s; v = prevv[v]) {
        addflow = min(addflow, graph[prevv[v]][preve[v]].cap);
      }
      f -= addflow;
      ret += addflow * potential[t];
      for(int v = t; v != s; v = prevv[v]) {
        edge &e = graph[prevv[v]][preve[v]];
        e.cap -= addflow;
        graph[v][e.rev].cap += addflow;
      }
    }
    return ret;
  }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int v,e,f;
    cin>>v>>e>>f;
    Primal_Dual pri(v);
    FOR(i,0,e){
      int from,to,cap,cost;
      cin>>from>>to>>cap>>cost;
      pri.add_edge(from,to,cap,cost);
    }
    cout<<pri.min_cost_flow(0,v-1,f)<<endl;

}



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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    if (n > m)
        swap(n, m);
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        cnt += m;
        if (cnt >= k)
            return cout << i + 1, 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> p={{0,1}};
long long s,n,m,a,b;
int main() {
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a;
		b+=a;
		s+=p[b%=m]++;
	}
	cout<<s;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, m, k[101], s[101][101];
bool b[101];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> k[i];
		for(int j = 0; j < k[i]; j++){
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	
	i64 ans = 0;
	for(int i = 0; i < (1 << n); i++){
		bool ok = 1;
		for(int j = 0; j < m; j++){
			int cnt = 0;
			for(int ii = 0; ii < k[j]; ii++){
				if((i >> s[j][ii] & 1)){
					cnt++;
				}
			}
			if(cnt % 2 != b[j]) ok = 0;
		}
		if(ok) ans++;
	}
	
	cout << ans << endl;
	
	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 a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if(a<=b&&b<=c){
        System.out.printf("%d %d %d\n",a,b,c);
    }else if(a<=c&&c<=b){
    System.out.printf("%d %d %d\n",a,c,b);
}else if(b<=a&&a<=c){
    System.out.printf("%d %d %d\n",b,a,c);
}else if(b<=c&&c<=a){
    System.out.printf("%d %d %d\n",b,c,a);
}else if(c<=a&&a<=b){
    System.out.printf("%d %d %d\n",c,a,b);
}else if(c<=b&&b<=a){
    System.out.printf("%d %d %d\n",c,b,a);
}


    sc.close();

}

}


Measured memory_bytes: 26392
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = max({ A + B,A - B,A*B });
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
shop_num, want_drink_num = STDIN.gets.split.map(&:to_i)

cost_index = Hash.new {|h, k| h[k] = []}
buyables = []
shop_num.times do |i|
  cost, buyable = STDIN.gets.split.map(&:to_i)
  cost_index[cost] << i
  buyables << buyable
end

payment = 0

def get_buy_num(buyable, surplus)
  return buyable if surplus > buyable
  surplus
end

cost_index.sort.each do |cost, idxs|
  idxs.each do |i|
    buy_num = get_buy_num(buyables[i], want_drink_num)
  	payment += cost * buy_num
    want_drink_num -= buy_num
    break if want_drink_num == 0
  end
end

STDOUT.puts payment

Measured memory_bytes: 23012
#include <stdio.h>
 
int main(void) {
long long int L,R,i,j,k,a;
scanf("%d %d\n",&L,&R);

if(R-L<=673){
  a=2020;
for(i=L;i<R;i++){
	for(j=i+1;j<=R;j++){
		if(i<j){
			k=(i*j)%2019;
			if(a>k){
				a=k;
			}
		}
	}
}
}
if(R-L>673){
	a=0;
}
printf("%d\n",a);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char A[] = new char[S.length()];
		for(int i = 0; i <= S.length()-1; i++) {
			A[i] = S.charAt(i);
		}
		int B[] = new int[S.length()];
		for(int i = 0; i <= S.length()-1; i++) {
			B[i] = (int)A[i];
			B[i] += N;
			if(B[i] > 90) {
				B[i] -= 26;
			}
		}
		for(int i = 0; i < S.length(); i++) {
			A[i] = (char)B[i];
		}
		for(int i = 0; i < S.length(); i++) {
			System.out.print(A[i]);
		}
		sc.close();
	}

}


Measured memory_bytes: 25040
#include<iostream>
#include <algorithm>
#include<vector>
#include<map>
#include <set>
#include<string>
#include <queue>
#include <stack>
#include <random>
#define INF 1000000001
#include<iostream>
#include<vector>
using ll = long long;



int main()
{    

    ll N, Y;
    std::cin >> N >> Y;
   
   Y /= 1000;

   if(Y < N) {
       std::cout << "-1 -1 -1" << std::endl;
       return 0;

   }
   const ll surplus = 10 * N - Y;
   if(surplus < 0){
        std::cout << "-1 -1 -1" << std::endl;
        return 0;
   }

   ll one, five;
   for(one = ll(surplus / 9); one >= 0; one--){
    if((surplus - one * 9) % 5 == 0){
        five = (surplus - one * 9) / 5;
        if(one + five > N) continue;
        std::cout << N - five - one << " " << five << " " << one << std::endl;
        return 0;
    }
   }
        std::cout << "-1 -1 -1" << std::endl;

   return 0;
    
}



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

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i =0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end(),greater<int>());
  
  int A=0;
  int B=0;
  
  for(int i =0;i<n;i++){
    if(i%2==0) A+=vec.at(i);
    else B+=vec.at(i);
  }
  cout<<A-B<<endl;
  return 0;
}
    
  
  
    
         
  
  

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val h = Seq.fill(n)(sc.nextInt())
    var sum = 0;
    for (i <- h) {
      if (i >= k) {
        sum += 1
      }
    }
    println(sum)
  }
}

Measured memory_bytes: 54324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    FOR(i, L, R+1) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define ll  long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<ll>

#define sz(x) ((int) (x).size())
#define pll pair<long long,long long>
#define mp make_pair
#define F first
#define S second
#define T int tt; cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);
 
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define display(x) for(auto i : x) cout << i << " "; cout << '\n';
#define input(x) for(int i = 0; i < n; i++) cin >> x[i];
#define make(x,y) fill(all(x), y)
#define FO(i,startLoop,n) for (int i = startLoop; i < n; i++)

#define mod 1000000007
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define ITFO(myiterator, mymap) for(auto myiterator = mymap.begin(); myiterator!=mymap.end(); ++myiterator)
using namespace std;  
 

int main()
{
    fastio
    cin.tie(NULL); cout.tie(0);
    
     
  
  int n; cin>>n; vi a(n, 0), dp(n, INT_MAX); input(a);
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);

  for(int i = 2; i<n; ++i)  dp[i] = min(abs(a[i] - a[i-1]) + dp[i - 1] , abs(a[i] - a[i -2]) + dp[i -2]);
  cout<<dp[n-1];
  cerr << "\nTime elapsed: "<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;

int main() {
    int x; cin >> x;
    string ans = "NO";
    if (x == 3 || x == 5 || x == 7) ans = "YES";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
#define fastIO ios::sync_with_stdio(false);	cin.tie(NULL); cout.tie(NULL);
#define asc(s) sort(s.begin(),s.end())
#define des(s) sort(s.rbegin(),s.rend())
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define rev(v) reverse(v.begin(), v.end())
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define precision(x,p) fixed<<setprecision(p)<<x
#define mod 1000000007
#define PI 3.14159265358979
typedef long long ll;
    
vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string>beg(buf), end;    
    vector<string>list(beg, end);
    return list;
}
    
    
bool isvowel(char c)
{
    string s = "aeiou";
    if(find(s.begin(),s.end(), c) != s.end()) return true;
    return false; 
}

bool cmp(pair <int,int> &a, pair <int,int> &b)
{
    return a.second > b.second || (a.second==b.second && a.first>b.first);
}

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

    if(n==1)
    cout<<"Hello World";

    else
    {
        int a,b;
        cin>>a>>b;

        cout<<a+b;
    }

}


int main()
{
    fastIO

    int t=1;
    // cin>>t;
    
    for(int test_case=1;test_case<=t;test_case++)
        solve();
    
        return 0;
}   

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

int main()
{
	int  n;

 	cin >> n;
	 	vector<int>a(n+1);
		 vector<int>b(n);
	for (int i = 0; i <= n ; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n ; i++)
	{
		cin >> b[i];
	}
	long long  ans = 0;

	for(int i = 0; i < n; i++){
		if(a[i] >= b[i]){
			ans += b[i];
		}else{
			b[i]-= a[i];
			ans += a[i];
			if(a[i+1] >= b[i]){
				a[i+1] -= b[i];
				ans += b[i];
			}else{
				ans += a[i+1];
				a[i+1] = 0;
			}

		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=[int(i) for i in input().split()]

def f(a,t):
  ans=0
  cur=0
  for i in a:
    cur+=i
    if t==True and cur<1:
      ans+=(1-cur)
      cur=1
    elif t==False and cur>-1:
      ans+=(1+cur)
      cur=-1
    t=not t
  return ans
print(min(f(a,True),f(a,False)))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define F first
#define S second
#define INF 1<<26
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>PP;
typedef struct{
  int to,cost;
}Edge;
int main(){
  int c,n,m,st,go;
  while(1){
    int d[11111][111];
    cin >> c >> n >> m >> st >> go;
    if(c==0 && n==0 && m==0 && st==0 && go==0)break;
    for(int i=0;i<=m;i++){
      for(int j=0;j<=c;j++){
	d[i][j]=INF;
      }
    }
    st--;go--;
    
    int a,b,f;
    vector<Edge> G[1111];
    for(int i=0;i<m;i++){
      cin >> a >> b >> f;
      a--;b--;
      G[a].push_back((Edge){b,f});
      G[b].push_back((Edge){a,f});
    }
    priority_queue<PP,vector<PP>,greater<PP> >pq;
    pq.push(PP(0,P(st,c)));
    d[st][c]=0;
    while(!pq.empty()){
      PP p=pq.top();//左から、コスト、今いる場所、残りのチケット
      pq.pop();
      int now=p.S.F;//今いる場所
      int ti=p.S.S;//チケット
      for(int i=0;i<G[now].size();i++){
	Edge e=G[now][i];
	if(ti){//チケットがあったら
	  if(d[e.to][ti-1] > d[now][ti]+(e.cost/2)){
	    d[e.to][ti-1]=d[now][ti]+(e.cost/2);
	    pq.push(PP(d[e.to][ti-1],P(e.to,ti-1)));
	  }
	}
	if(d[e.to][ti] > d[now][ti]+e.cost){
	  d[e.to][ti]=d[now][ti]+e.cost;
	  // cout << d[e.to][ti] << endl;
	  pq.push(PP(d[e.to][ti],P(e.to,ti)));
	}
      } 
    }
    
    int ans=INF;
    for(int i=0;i<=c;i++){
      ans=min(ans,d[go][i]);
    }
    cout << ans << endl;
  }
}

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

int dfs(int, bool[], int);
int n, m;
std::list<int> edges[8];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    bool visited[8]{};
    printf("%d\n", dfs(0, visited, 0));

    return 0;
}


int dfs(int pos, bool visited[], int visited_num)
{
    if (visited[pos]) return 0;
    if (visited_num == n - 1) return 1;
    visited[pos] = true;
    int count{};
    for (auto &e : edges[pos])
    {
        count += dfs(e, visited, visited_num + 1);
    }
    visited[pos] = false;
    return count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
    string N;
    int total=0;
    cin >> N;

    for(int i=0;i<N.length();i++){
       total += ctoi(N.at(i));
    }
    if(total%9==0)
        cout << "Yes"<<endl;
    else
    {
        cout << "No" << endl;
    }
    
        
}

Measured memory_bytes: 3764
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/




/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int main() {
	ll l, r; cin >> l >> r;

	if (r - l >= 2019) { cout << 0 << endl; return 0; }

	l %= 2019;
	r %= 2019;

	ll ans = INF;

	for (ll i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			ans = min(ans, (i * j) % 2019);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	string x;

	for (int i = 0; i < n; i++)
	{
		cin >> s[i] >> t[i];
	}
	cin >> x;

	bool flg = false;
	int cnt = 0;

	for (int i = 0; i < n; i++)
	{
		if (flg) cnt += t[i];
		if (x == s[i]) flg = true;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  string s;
  int cnt = 0;
  for(int i=a; i<=b; i++){
    s = to_string(i);
    if(s.at(0) == s.at(4) && s.at(1) == s.at(3)){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int a,b,c=0,e=0;;
    cin>>a>>b;
    int d[a];
    for(int i=0;i<a;i++)
    {
        cin>>d[i];
    }
    if(b>=a)
    {
      cout<<0<<endl;
    }
    else
    {
       sort(d,d+a);
       e=a-b;
       for(int i=0;i<e;i++)
       {
           c+=d[i];
       }
       cout<<c;

    }

}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define Ms(s, n) memset(s, n, sizeof(s))
#define Rp(i,l,m) for(int i=l; i<m; ++i)
#define Rpd(i,l,m) for(int i=l; i>=m; --i)
#define Rpp(i,l,m) for(int i=l; i<=m; i++)
#define RpAll(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define All(a) (a).begin(), (a).end()
#define Fi first
#define Se second
#define Pb push_back
#define Pf push_front
#define Is insert
#define Sz(a) int((a).size())
#define ooi INT_MAX
#define ool LLONG_MAX
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a,ll b) {ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
inline ll fpow(ll n,ll k){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%MOD;n=n*n%MOD;}return r;}
const int base = 311;
const int N = 2e5 + 5;

ll n, m, k, test, a[N], f[N];

void Solve(){
    cin >> n;
    string s;
    cin >> s;
    if(n<3200) cout << "red"; else cout << s;

}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    Solve();
    return 0;
}




















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

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

    int A, B;
    cin >> A >> B;

    int d = abs(A - B);
    if (d % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << min(A, B) + (d / 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

int par[100005];
int find(int x) {
  return par[x] == x ? x : (par[x] = find(par[x]));
}
bool merge(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return false;
  par[x] = y;
  return true;
}

bool xcmp(pipii a, pipii b) {
  return a.second.first < b.second.first;
}
bool ycmp(pipii a, pipii b) {
  return a.second.second < b.second.second;
}

pipii l[100000];
int n;

void solve() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    l[i].first = i;
    cin >> l[i].second.first >> l[i].second.second;
  }
  vector<pipii> candEdges;
  sort(l, l+n, xcmp);
  for(int i = 1; i < n; i++) {
    int nw = 1e9;
    nw = min(nw, abs(l[i].second.first - l[i-1].second.first));
    nw = min(nw, abs(l[i].second.second - l[i-1].second.second));
    candEdges.push_back({nw, {l[i].first, l[i-1].first}});
  }
  sort(l, l+n, ycmp);
  for(int i = 1; i < n; i++) {
    int nw = 1e9;
    nw = min(nw, abs(l[i].second.first - l[i-1].second.first));
    nw = min(nw, abs(l[i].second.second - l[i-1].second.second));
    candEdges.push_back({nw, {l[i].first, l[i-1].first}});
  }
  ll ret = 0;
  sort(candEdges.begin(), candEdges.end());
  for(int i = 0; i < n; i++) par[i] = i;
  for(pipii out: candEdges) {
    if(merge(out.second.first, out.second.second)) ret += out.first;
  }
  cout << ret << "\n";
}

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


Measured memory_bytes: 6132
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int a[200000];

int main(){
  int k,n;
  cin >> k >> n;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int maxdist = 0;
  for(int i = 0;i < n-1;i++){
    if(maxdist < a[i+1]-a[i]){
      maxdist = a[i+1]-a[i];
    }
  }
  if(maxdist < a[0]-a[n-1]+k){
    maxdist = a[0]-a[n-1]+k;
  }
  cout << k-maxdist << endl;
  return 0;
}

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

int main()
{
	//2.すごろく	
	/*
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> A;
		if (A == 1)
		{
			if (A == _A)
			{
				A_count[k]++;
			}
			else
			{
				k++;
				A_count[k] = 2;
			}
		}
		_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;
	*/

	//タイムカード
	int t[2][3];
	int x[3][3];
	for (int n=0; n < 3; n++)
	{
		for (int i=0; i < 2; i++)
			for (int k=0; k < 3; k++)
				cin >> t[i][k];
			
		for (int m = 2; m >= 0; m--)
		{
			x[n][m] = t[1][m] - t[0][m];
			if (t[0][m] > t[1][m])
			{
				x[n][m] += 60;
				t[1][m - 1]--;
			}
		}
	}
	for (int n= 0; n < 3; n++)
	{
		cout << x[n][0] << ' ' << x[n][1] <<' '<< x[n][2] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3092
import math
def resolve():
  found = False
  N = int(input())
  for x in range(int(N/1.08), int((N+1)/1.08+1)):
    if N == math.floor(x*1.08):
      print(x)
      found = True
      break
  
  if not found:
    print(":(")

resolve()

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

int main(void)
{
	char s[101];
	int count = 0;
	
	while(scanf("%s", s) != EOF) {
		int i;
		int l = strlen(s);
		
		if(l == 1) count++;
		else {
			for(i = 0; i < l / 2; i++) {
				if(i == l / 2 - 1) {
					if(s[i] == s[l - i - 1]) count++;
				}
				else {
					if(s[i] != s[l - i - 1]) break;
				}
			}
		}
	}
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 540
import sys
for e in sys.stdin:
 a=b=int(e)
 while 1:
  a-=1
  if 2 in[a,pow(2,a,a)]:break
 while 1:
  b+=1
  if 2 in[b,pow(2,b,b)]:break
 print(a,b)


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

int main(){
  int n;
  cin >> n;
  vector<char> A(n);
  vector<char> B(n);
  vector<char> C(200);
  rep(i,n) cin >> A[i];
  rep(i,n) cin >> B[i];
  rep(i,2*n){
    if(i%2 == 0) C[i] = A[i/2];
    else C[i] = B[i/2];
  }
  rep(i,2*n) cout << C[i];
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int h, w;
int gy, gx;

int dfs(vector<vector<int>> &field, int sy, int sx, int md){
	int res = INF;
	md--;
	
	if(md < 0) return INF;
	
	for(int i = 0; i < 4; i++){
		int dis, ny = sy, nx = sx;

		for(dis = 0; ; dis++){
			ny += (i - 1) % 2, nx += (2 - i) % 2;
			
			if(ny < 0 || ny >= h || nx < 0 || nx >= w) {
				dis = -1;
				break;
			}
			
			if(ny == gy && nx == gx) {
				return 1;
			}
			
			if(field[ny][nx] == 1) break;
		}
		
		if(dis <= 0) continue;
		
		field[ny][nx] = 0;
		
		res = min(res, dfs(field, ny - (i - 1) % 2, nx - (2 - i) % 2, md) + 1);
		
		md = min(res, md);
		
		field[ny][nx] = 1;
	}
	
	return res;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	
	while(true){
		int sy, sx;
		int ans;
		vector<vector<int>> field;
		
		cin>>w>>h;
		
		if(!h && !w) break;
		
		field.resize(h, vector<int>(w));
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
				
				if(field[i][j] == 2) {
					sy = i, sx = j;
					field[i][j] = 0;
				}
				
				if(field[i][j] == 3) {
					gy = i, gx = j;
					field[i][j] = 0;
				}
			}
		}
		
		ans = dfs(field, sy, sx, 10);
		
		cout<<(ans >= INF ? -1 : ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3232
import math

d,g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
ans = 10 ** 18
for i in range(2 ** d):
  solve = []
  tmp = 0
  score = 0
  for j in range(d):
    solve.append((i >> j) & 1)
  for j in range(d):
    if not solve[j]:
       continue
    p,c = pc[j]
    tmp += p
    score += p * (j+1) * 100 + c
  if score >= g:
    ans = min(ans, tmp)
    continue
  res = g - score
  for j in range(d-1,-1,-1):
    if not solve[j]:
      point = (j+1) * 100
      p,c = pc[j]
      must = math.ceil(res / point)
      if must <= p:
        tmp += must
        ans = min(ans, tmp)
      break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main (void) {
    int S, W;
    cin >> S >> W;
    if (W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl;

}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdbool.h>

int calculate_digit_sum (int target, int* digit_sum)
{
    // STEP.01
    // initialize the variable to store the digit sum
    *digit_sum = (int)0;

    // STEP.03
    // calculate the digit sum
    while (target > (int)0)
    {
        *digit_sum += target % (int)10;
        target     /= (int)10;
    }

    // STEP.END
    // declare the return value of this function
    return 0;
}

bool is_multiple (int target, int base)
{
    if (target % base == (int)0) { return true;  }
    else                         { return false; }
}

int main (void)
{
    // variables for `main`
    int int_given;
    int digit_sum;
    int rtvl_scanf;

    // STEP.01
    // read out the given string
    rtvl_scanf = scanf("%d", &int_given);

    // STEP.02
    // calculate the digit sum of the given integer
    calculate_digit_sum(int_given, &digit_sum);

    // STEP.03
    // output whether the digit sum of given integer is the multiple of the given integer or not
    if ( is_multiple( int_given, digit_sum ) )
    { printf("%s\n", "Yes"); }
    else
    { printf("%s\n", "No"); }

    // STEP.END
    return 0;
}

Measured memory_bytes: 128