akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
#define Pdd pair<double, double>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    vector< Pdd > v;
    double n, tmp, second = 0.25;
    rep(4){
        cin >> tmp;
        v.pb(Pdd(tmp * (2.0/second), second));
        second *= 2;
    }
    cin >> n;

    sort(all(v));
    ll ans = 0;
    rep(4){
        Pdd p = v[i];
        //cout << p.first << " " << p.second << endl;
        double price = p.first * (p.second/2.0);
        ll tmp = n / p.second;
        n -= (double)tmp * p.second;
        ans += (ll)price * tmp;
        if(n == 0) break;
    }
    cout << ans;
}


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

//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	bool cmp_y(const P &a, const P &b){
		return a.imag() != b.imag() ? a.imag() < b.imag() : a.real() < b.real();
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
P n_vector(P a){
  double l = abs(a);
  return P(-a.imag(), a.real())/l;
}

// line
struct L : public vector<P> {
	L(const P& a, const P& b) {
		push_back(a); push_back(b);
	}
};

P projection(const L &l, const P &p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const L &l, const P &p) {
	return abs(p - projection(l, p));
}

// circle
struct C {
	P p; double r;
	C(const P& p, double r) : p(p), r(r) {}
};

int intersectCC(const C& a, const C& b) {
	double dist = sqrt(norm(a.p-b.p)), r1 = a.r + b.r, r2 = abs(a.r - b.r);
	if(r1 < dist) return 4;		//??\?????????
	if(dist == r1) return 3;	//?????\
	if(r2 < dist && dist < r1) return 2; //?????????
	if(dist == r2) return 1; //?????\
	return 0;	//??????
}

vector<P> crossPointCL(C c, L l) {
	double d = distanceLP(l, c.p), r = c.r;
	P m = projection(l, c.p);
	P x = sqrt(r*r-d*d)/abs(l[1]-l[0])*(l[1]-l[0]);
	vector<P> ret(2,m);
	ret[0] -= x;
	ret[1] += x;
	sort(ret.begin(), ret.end());	//!!!
	return ret;
}

vector<P> crossPointCC(C a, C b) {
	double d = abs(a.p-b.p);
	double t = (a.r*a.r-b.r*b.r+d*d)/2/d, h = sqrt(a.r*a.r-t*t);
	P m = t/abs(b.p-a.p)*(b.p-a.p)+a.p;
	P n = n_vector(a.p-b.p);
	vector<P> ret(2, m);
	ret[0] -= h*n;
	ret[1] += h*n;
	sort(ret.begin(), ret.end());	//!!!
	return ret;
}	

int main() {
	double x1, y1, r1, x2, y2, r2;
	cin >> x1 >> y1 >> r1 >> x2 >> y2 >>r2;
	C c1(P{x1, y1}, r1), c2(P{x2, y2}, r2);
	vector<P> ans = crossPointCC(c1, c2);
	cout << fixed << setprecision(15) << ans[0].real() << " " << ans[0].imag() << " " << ans[1].real() << " " << ans[1].imag() << endl;
}

Measured memory_bytes: 3352
#include<stdio.h>
#include<string.h>
//言語は「C++14(GCC 5.4.1)」
//AtCoder Beginner Contest 156-A

int main(void) 
{
	int N, R;
	scanf("%d", &N); 
	scanf("%d", &R);
	if (N < 10)
	{
		printf("%d", R + 100 * (10 - N));
	}
	else
	{
		printf("%d", R);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e14;

int n, m;
vector<int> h;
vector<P> m1, m2; 
int dp[100010], dp2[100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n, n){
        h.resize(n);
        m1.clear();
        m2.clear();
        rep(i, 0, n){
            cin >> h[i];
        }
        cin >> m;
        rep(i, 0, m){
            string s1;
            int mp, damage;
            cin >> s1 >> mp >> s1 >> damage;
            if(s1 == "Single"){
                m1.push_back(P(mp, damage));
            }else if(s1 == "All"){  
                m2.push_back(P(mp, damage));
            }
        }
        rep(i, 0, 100010){
            dp[i] = dp2[i] = INF;
        }
        dp[0] = dp2[0] = 0;
        rep(i, 0, m1.size()){
            rep(j, 0, 100001){
                if(dp[j] == INF) continue;
                int next = j + m1[i].second;
                if(next > 100000) next = 100001;
                chmin(dp[next], dp[j] + m1[i].first);
            }
        }
        rep(i, 0, m2.size()){
            rep(j, 0, 100001){
                if(dp2[j] == INF) continue;
                int next = j + m2[i].second;
                if(next > 100000) next = 100001;
                chmin(dp2[next], dp2[j] + m2[i].first);
            }
        }
        int MIN = INF;
        repb(i, 100001, 0){
            chmin(MIN, dp[i]);
            dp[i] = MIN;
        }
        MIN = INF;
        repb(i, 100001, 0){
            chmin(MIN, dp2[i]);
            dp2[i] = MIN;
        }
        int ans = INF;
        rep(i, 0, 100001){
            int sum = dp2[i];
            rep(j, 0, n){
                sum += dp[max(0LL, h[j] - i)];
            }
            chmin(ans, sum);
        }
        cout << ans << endl;
    }
}


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

using namespace std;
typedef long long ll;

int main() {
  string S; cin >> S;
  char pre = ' ';
  bool flag = false;
  for (char ch : S) {
    if (ch == pre) {
      flag = true;
      break;
    }
    pre = ch;
  }
  cout << (flag ? "Bad" : "Good") << endl;
  return 0;
}


Measured memory_bytes: 256
import math as m


n = int(input())

l = [0] * 10000

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if  ans <= 10000:
                l[ans-1] += 1

for i in range(n):
    print(l[i])


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

const ll mod = 1e9 + 7;

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> dp(k + 1);
    vector<ll> exact(k + 1);
    for (ll g = 1; g <= k; g++) {
        dp[g] = modpow(k / g, n);
    }
    ll ans = 0;
    for (ll g = k; g >= 1; g--) {
        exact[g] = dp[g];
        for(ll gg = 2*g; gg <= k; gg += g){
            exact[g] -= exact[gg];
        }
        exact[g] %= mod;
        ans += exact[g] * g;
        ans %= mod;
    }
    if (ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;
lld dp[50][5555];
lld n,m;
lld ma[50][5555];
lld solve(lld i,lld j){
	
	
	if(i==n-1 && j==m-1){
		return ma[i][j];	
	}
	
	
	if(i>=n || j>=m || i<0 || j<0){
		return 0;
	}
	
	lld ans=ma[i][j]+max(solve(i+1,j),solve(i,j+1));
	return ans;
}

int main(){
	std::ios::sync_with_stdio(false);
	lld t=1;
	//cin>>t;
	
	while(t--){
		cin>>m;
		n=2;
		
		for(lld i=0;i<n;i++){
			for(lld j=0;j<m;j++){	
				cin>>ma[i][j];
			}
		}
		cout<<solve(0,0);
		
	}
	
}

Measured memory_bytes: 2304
import java.util.Arrays;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int H = scanner.nextInt();
		int[]a = new int[N];
		int[]b = new int[N];

		for(int i = 0;i < N;i++){
			a[i] = scanner.nextInt();
			b[i] = scanner.nextInt();
		}

		Arrays.sort(b);
		
		int amax = 0;
		for(int i =0 ;i < N;i++){
			amax = Math.max(amax, a[i]);
		}

		int ans = H;
		for(int k = N-1;k >= 0;k--){
				H -= b[k];
			
			int cnt = 0;

			if(H > 0){
				if(H%amax != 0){
					cnt = (H /amax)+1 ;
				}else{
					cnt = (H /amax);
				}
			}
			ans = Math.min(ans, N-k + cnt);
			

		}
		System.out.println(ans);


	}
}
class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 85404
#include <bits/stdc++.h>
using namespace std;
int a,b,k;
int main(){
    cin>>a>>b;
    for(int i=0;i<2;i++){
        if(a<b){
            k+=b;
            b--;
        }
        else{
            k+=a;
            a--;
        }
    }
    cout<<k<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dist[5050][35];
long long sum[5050][35],maxi[5050][35];
int P[5050];
int C[5050];
int main()
{
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
		P[i]--;
	}
	for(int i=0;i<N;i++)
		cin>>C[i];
		for(int j=0;j<=30;j++)
	for(int i=0;i<N;i++)
			if(!j)
				dist[i][j]=P[i];
			else
			{
				dist[i][j]=dist[dist[i][j-1]][j-1];
			
			}
		for(int j=0;j<=30;j++)
	for(int i=0;i<N;i++)
			if(!j)
				sum[i][j]=C[P[i]];
			else	sum[i][j]=sum[i][j-1]+sum[dist[i][j-1]][j-1];
		for(int j=0;j<=30;j++)
	for(int i=0;i<N;i++)
			if(!j)
				maxi[i][j]=C[P[i]];
			else	maxi[i][j]=max(maxi[i][j-1],maxi[dist[i][j-1]][j-1]+sum[i][j-1]);
	long long ans=-1000000000;
	for(int i=0;i<N;i++)
	{
		int Tmp=K;
		long long summ=0,ret=-1000000000;
		int now=i;
		for(int j=29;j>=0;j--)
			if((1<<j)<=Tmp)
			{
				ret=max(ret,maxi[now][j]+summ);
	//			cout<<now<<" ";
				summ+=sum[now][j];
				now=dist[now][j];
	//			cout<<j<<" "<<now<<" "<<ret<<endl;
				Tmp-=(1<<j);
			}
		ans=max(ans,ret);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7104
import sys
stdin = sys.stdin
from itertools import accumulate, groupby
import math

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = na()
s = list(accumulate(a))
s.sort()
ans = 0
for key, group in groupby(s):
    n = len(list(group))
    if key == 0:
        ans += n
    ans += n*(n-1)//2
print(ans)


Measured memory_bytes: 27260
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double x=0.0,y=0.0,sum=0.0,z=0.0;
    double a[1000]={0.0};
    int i=0;
    while(1){
        scanf("%lf",&x);
        if(x==0.0){
            break;
        }
        for(i=1;i<=x;i++){
            scanf("%lf",&a[i]);
            sum+=a[i];
        }
        sum = sum/x;
        for(i=1;i<=x;i++){
            y+=(a[i]-sum)*(a[i]-sum);
        }
        z=sqrt(y/x);
        printf("%.8lf\n",z);
        x=0.0;
        y=0.0;
        z=0.0;
        sum=0.0;
        
    }
    return 0;
}

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

using namespace std;

int gcd(int a, int b){
    while(a != 0 && b != 0){
        if(a > b){
            a = a % b;
        } else {
            b = b % a;
        }
    }
    return a + b;
}



int n, k;
vector < int > a;

int main()
{
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; ++i)cin >> a[i];
    int gc = a[0];
    int mx = a[0];
    for(int i = 1; i < n; ++i){
        gc = gcd(gc, a[i]);
        mx = max(mx, a[i]);
    }
    if(k % gc == 0 && k <= mx){
        cout << "POSSIBLE";
    } else {
        cout << "IMPOSSIBLE";
    }

}


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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //角度をラジアンに変換する
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int n, m;
    cin >> n >> m;
    CL((n + m) % 24);
    return (0);
}


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

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

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

     int a[n], b[n], c[n];

     rep(i,n) cin >> a[i] >> b[i] >> c[i];

     int dp[n][3];

     // initialization
     rep(i, 3) dp[0][i] = 0;

     for (int i = 0; i < n; i++) {
         dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i];
         dp[i+1][1] = max(dp[i][0],  dp[i][2]) + b[i];
         dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i];
     }

     cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

     return 0;
 }


Measured memory_bytes: 5456
// compile in C++11. use -std=c++11.
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& vec){
    os << "[";
    for(const auto& v : vec){
        os << v << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

int main(){
    const int FIELD_SIZE = 10;
    const int PADDING = 2;
    const int DATA_SIZE = FIELD_SIZE + 2*PADDING;
    vector<vi> field(DATA_SIZE,vi(DATA_SIZE));
    {
        int y,x,size;char comma;
        while(cin >> x >> comma >> y >> comma >> size){
            x += PADDING;
            y += PADDING;

            field[y][x] += 1;
            vi dx,dy;
            if(size == 1){
                dx = {1,0,-1,0};
                dy = {0,-1,0,1};
            }else{
                for(int i=-1;i<=1;i++){
                    for(int j=-1;j<=1;j++){
                        if(i == 0 and j == 0) continue;
                        dx.push_back(i);
                        dy.push_back(j);
                    }
                }
                if(size == 3){
                    vi ax = {2,0,-2,0};
                    vi ay = {0,-2,0,2};
                    repeat(i,4){
                        dx.push_back(ax[i]);
                        dy.push_back(ay[i]);
                    }
                }
            }
            repeat(i,dx.size()){
                field[y+dy[i]][x+dx[i]]++;
            }
        }
    }

    int maxi = -1;
    int no = 0;

    for(int y=PADDING;y<FIELD_SIZE+PADDING;y++){
        for(int x=PADDING;x<FIELD_SIZE+PADDING;x++){
            maxi = max(maxi,field[y][x]);
            no += field[y][x]==0;
        }
    }

    cout << no << endl << maxi << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str,arr[];
		List<String> list = new ArrayList<String>();
		while(null!=(str = in.readLine())){
			arr = str.split(",",0);
			list.add(arr[1]);
		}
		System.out.println(count("A",list));
		System.out.println(count("B",list));
		System.out.println(count("AB",list));
		System.out.println(count("O",list));
	}

	private static long count(String bl,List<String> list){
		List<String> lis = new ArrayList<String>(list);
		int i=0;
		while(lis.remove(new String(bl)))i++;
		return i;
	}
}

Measured memory_bytes: 16916
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
using namespace std;

bool func(string s)
{
	int n = s.size();
	f(i, 0, n)
	{
		if(s[i] != s[n-i-1]) return false;
	}
	return true;
}

int main()
{
    IOS
    string s;
    cin>>s;
    int n = s.size();
    if(func(s) && func(s.substr(0, (n-1)/2)) && func(s.substr((n+1)/2, (n-1)/2))) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,k,a[100005],f[100005];
int main(){
    in(n);in(k);
    for(int i=1;i<=n;i++)in(a[i]);
    memset(f,0x3f,sizeof(f));
    f[1]=0;
    f[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++){
        for(int j=1;j<=k&&i-j>=1;j++){
            f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
        }
    }
    printf("%d\n",f[n]);
	return 0;
}


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

using namespace std;

const int N = 2e5 + 3;

int n, a[N], cnt[N];

long long f(int x) {
    return (x - 1) * 1ll * x / 2;
}

int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
        cnt[ a[i] ]++;
    }

    long long ans = 0;

    for (int i = 1; i <= n; i++) {
        ans += f(cnt[i]);
    }

    for (int i = 1; i <= n; i++) {
        int x = a[i];
        ans -= f(cnt[x]);
        cnt[x]--;
        ans += f(cnt[x]);
        cout << ans << endl;
        ans -= f(cnt[x]);
        cnt[x]++;
        ans += f(cnt[x]);
    }
}


Measured memory_bytes: 3712
n = int(input())
s = input()
mod = 998244353
ans = 1
z, o, t = n, 0, 0
pre = ["", ["", ""]]
for i in range(3*n):
  if t != 0 and s[i] not in pre[1]:
    ans *= t
    ans %= mod
    t -= 1
    if t == 0:
      pre[1] = ["", ""]
  elif s[i] == pre[0] or o == 0:
    o += 1
    ans *= z
    ans %= mod
    z -= 1
    pre[0] = s[i]
  else:
    t += 1
    ans *= o
    ans %= mod
    o -= 1
    pre[1] = [pre[0], s[i]]
    if o == 0:
      pre[0] = ""

print(ans)

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()


typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    VI x(n);
    REP(i, n) {
        cin >> x[i];
        x[i] -= a;
    }

    vector<VL> dp(n, VL(6000, 0));
    if(x[0] == 0) {
        dp[0][x[0] + 3000] = 2;
    } else {
        dp[0][x[0] + 3000] = 1;
        dp[0][0 + 3000] = 1;
    }
    FOR(i, 1, n - 1)REP(s, 6000) {
        if(s - x[i] < 0 or s - x[i] >= 6000)
            dp[i][s] = dp[i - 1][s];
        else
            dp[i][s] = dp[i - 1][s] + dp[i - 1][s - x[i]];
    }

    cout << dp[n - 1][0 + 3000] - 1 << endl;
    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a, e;
	char b;
	cin >> a;
	for (int i = 1; i <= a; i++) {
		cin >> b;
		if (b == 'Y') {
			goto park;
		}
	}
	park:
	if (b == 'Y') {
		cout << "Four" << "\n";
	}
	else {
		cout << "Three" << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int bricks_count;

  cin >> bricks_count;
  
  int current_count = 1;
  int break_count = 0;
  for(int i = 0; i < bricks_count; i++){
	int b;
    cin >> b;

    if(b == current_count){
      current_count += 1;
    }else{
      break_count += 1;
    }
  }
  
  if(break_count == bricks_count){
    cout << -1 << endl;
  }else{
    cout << break_count << endl;
  }
  
  return 0;
}

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

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  string res;
  for (int i = 0; i < n; i++) {
    res.push_back(s[i]);
    res.push_back(t[i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];

    vector<ll> b(N);
    rep(i,N) b[i] = max(a[i],0ll);

    // as[i] = a[0] + ... + a[i-1]
    // a[i] + ... + a[j] = as[j+1] - as[i]
    vector<ll> as(N+10,0),bs(N+10,0);

    for(int i=0;i<N;i++) as[i+1] = as[i] + a[i];
    for(int i=0;i<N;i++) bs[i+1] = bs[i] + b[i];

    ll ans = 0;
    for(int i=0;i<N;i++){
        int s = i;
        int t = i+K;
        if(t>N) break;
        ll p = bs[s] + (bs[N]-bs[t]);
        ll x = p;
        ll y = p + as[t] - as[s];
        //cerr << s << " " << t << endl;
        //cerr << p << " " << x << " " << y << endl;
        chmax(ans,x);
        chmax(ans,y);
    }
    cout << ans << endl;
}

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

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

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	ll r = 0, g = 0, b = 0;
	for (char c : s) {
		if (c == 'R') r++;
		else if (c == 'G') g++;
		else b++;
	}

	ll all = r * g * b;

	ll cnt = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int k = 2 * j - i;

			if (k >= n || s[i] == s[j] || s[j] == s[k] || s[k] == s[i]) continue;
			//cout << i << " " << j << " " << k << endl;
			cnt++;
		}
	}

	cout << all - cnt << endl;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
#define N 1005
char ss[maxn];
int cnt[10];
start{
    ll n=read;
    int num1=0,num2=0;
    int x,y;
    for(int i=1;i<=n;i++)
    {
        x=read;
        num1=num1*10+x;
    }
    for(int i=1;i<=n;i++)
    {
        y=read;
        num2=num2*10+y;
    }
    ///printf("%d %d\n",num1,num2);
    if(num1>num2) swap(num1,num2);
    int ans=0;
    for(int i=num1;i<=num2;i++)
    {
        memset(cnt,0,sizeof(cnt));
        int temp=i;
        bool flag=true;
        while(temp){
            cnt[temp%10]=1;
            temp/=10;
        }
        for(int i=1;i<=n;i++)
            if(cnt[i]==0)
            {
                flag=false;
                break;
            }
        if(flag) ans++;
    }
    cout<<ans-1;
	end;
}


Measured memory_bytes: 256
N = int(input())
steps = [int(i) for i in input().split()]
dp = [float('inf')]*N
for i in range(N):
  if i == 0:
    dp[0] = 0
    if N > 1:
    	dp[1] = abs(steps[1] - steps[0])
    if N > 2:
    	dp[2] = abs(steps[2] - steps[0])
  else:
    # 現在位置までのコスト + 隣に行くコスト　を登録済みのDPテーブルと比較し、小さい方で更新
    if i+1 < N:
    	dp[i+1] = min(abs(steps[i] - steps[i+1]) + dp[i], dp[i+1])
    if i+2 < N:
    	dp[i+2] = min(abs(steps[i] - steps[i+2]) + dp[i], dp[i+2])
print(dp[-1])

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

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

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  int N,M;cin>>N>>M;
  priority_queue<ll> q;
  // vector<ll> AS(N);
  REP(i,N) {
    ll a;cin>>a;
    q.push(a);
  }
  REP(i,M) {
    ll cur = q.top();q.pop();
    cur /= 2;
    q.push(cur);
  }
  ll ans = 0;
  REP(i,N) {
    ans+=q.top();
    q.pop();
  }
  OUT(ans);

  return 0;
}

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

template <class Abel>
struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;  // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) {
        for (int iter = 0; iter < 2; ++iter)
            dat[iter].assign(n + 1, UNITY_SUM);
    }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i)
            cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N;
    cin >> N;
    int Q;
    cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) { return rights[i] < rights[j]; });

    BIT<int> bit(N + 5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]] + 2, r + 2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i)
        cout << res[i] << endl;
}


Measured memory_bytes: 21732
use std::io::{self, BufRead};
use std::collections::HashSet;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let x: usize = line.parse().unwrap();
  let mut s: HashSet<String> = HashSet::new();
  for _ in 0..x {
    s.insert(lines.next().unwrap().unwrap());
  }
  println!("{}", s.len());
}

Measured memory_bytes: 15280
n,m = map(int,input().split())
a = list(map(int,input().split()))

w = [2,5,5,4,5,6,3,7,6]

min_w = 10
for i in a:
    min_w = min(min_w,w[i-1])

dp = [0 for i in range(n+1)]


for i in range(0,n):
    if 1 <= i < min_w:
            dp[i] = -1
    for j in a:
        if i + 1 - w[j-1] >= 0 and dp[i + 1 - w[j-1]] != -1:
            dp[i+1] = max(dp[i+1],dp[i+1-w[j-1]]*10+j)
print(dp[n])

Measured memory_bytes: 14516
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

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

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, b[MXN];
llong pr[MXN];

llong dif(int l, int r, llong sum){
    llong x = pr[r] - pr[l - 1];
    sum -= x;
    return abs(sum - x);
}

llong ters(int L, int R){
    llong sum = pr[R] - pr[L - 1];
    int l = L, r = R - 1;
    while(r - l > 2){
        int tm1 = l + (r - l) / 3, tm2 = r - (r - l) / 3;
        if(dif(L, tm1, sum) <= dif(L, tm2, sum)){
            r = tm2;
        }else{
            l = tm1;
        }
    }
    //cout << "ternary " << l << ' ' << r << ' ';
    llong mn = INF, ans = 0;
    for(int i = l; i <= r; i++){
        llong x = dif(L, i, sum);
        //cout << i << ' ' << x << ' ';
        if(x < mn){
            mn = x;
            ans = i;
        }
    }
    //cout << nl;
    return ans;
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        pr[i] = pr[i - 1] + b[i];
    }
    llong ans = INF;
    for(int i = 2; i <= n - 2; i++){
        llong L = ters(1, i);
        llong R = ters(i + 1, n);
        llong mx = max(max(pr[n] - pr[R], pr[R] - pr[i]), max(pr[i] - pr[L], pr[L] - pr[0]));
        llong mn = min(min(pr[n] - pr[R], pr[R] - pr[i]), min(pr[i] - pr[L], pr[L] - pr[0]));
        ans = min(mx - mn, ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2560
# import math
a, b = map(int, input().split(' '))

# ans = math.ceil(a*12.5)
# if int(ans*0.1) != b:
#     print('-1')
#     exit()

# print(ans)

for i in range(1100):
    if int(i*0.08) == a and int(i*0.1) == b:
        print(i)
        exit()

print('-1')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n,a[10000];
int main(){
	while(true){
		cin>>n;if(n==0)break;for(int i=0;i<n;i++)cin>>a[i];
		sort(a,a+n);int minx=1000000;
		for(int i=0;i<n-1;i++){
			minx=min(minx,a[i+1]-a[i]);
		}
		cout<<minx<<endl;
	}
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>X(N);
    vector<ll>X2(N);
    rep(i,N){
        cin>>X[i];
    }
    X2 = X;
    sort(all(X));
    ll ans1 = X[N/2-1];
    ll ans2 = X[N/2];

    rep(i,N){
        if(X2[i]<=ans1){
            cout<<ans2<<endl;
        }else{
            cout<<ans1<<endl;
        }
    }



    return 0;
    

}

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

using namespace std;

const int MAXN = 305;
int dp[MAXN][MAXN][MAXN];

int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    for(int sz = 1; sz <= s.size(); sz++){
        for(int l = 0; l < s.size() - sz + 1; l++){
            int r = l + sz - 1;
            for(int j = 0; j <= k; j++){
                if(r == l){
                    dp[l][r][j] = 1;
                    continue;
                }
                if(r - l == 1){
                    if(j == 0){
                        if(s[l] == s[r]){
                            dp[l][r][j] = 2;
                        }
                        else{
                            dp[l][r][j] = 1;
                        }
                    }
                    else{
                        dp[l][r][j] = 2;
                    }
                    continue;
                }
                dp[l][r][j] = max(dp[l + 1][r][j], dp[l][r - 1][j]);
                if(s[l] == s[r]){
                    dp[l][r][j] = max(dp[l][r][j], dp[l + 1][r - 1][j] + 2);
                }
                else if(j != 0){
                    dp[l][r][j] = max(dp[l][r][j], dp[l + 1][r - 1][j - 1] + 2);
                }
            }
        }
    }
    cout << dp[0][s.size() - 1][k];
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int> (n));
  for (int i = 0; i < 2; i ++) {
    for (int j = 0; j < n; j ++) {
      cin >> a.at(i).at(j);
    }
  }

  int ans = 0, res = 0;
  for (int i = 0; i < n; i ++) {
    res += a.at(0).at(i);
    int tmp = res;
    for (int j = i; j < n; j ++) {
      tmp += a.at(1).at(j);
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;
}


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

using namespace std;
const int N=1005;
int ok[N];
int cur[N];
int a[N][N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    queue<int>q;
    for(int i=1;i<=n;i++)
        for(int j=0;j<n-1;j++)
            cin>>a[i][j];

    int ans=0,cnt=0;
    vector<int>v,t;
    for(int i=1;i<=n;i++)
        v.push_back(i);
    while(1)
    {
        if(v.empty())
            break;
        ans++;
        for(auto i:v)
        {
            int p=a[i][cur[i]];
            if(ok[i]==ans||ok[p]==ans)
                continue;
            if(a[p][cur[p]]==i)
            {
                cnt++;
                cur[i]++;
                cur[p]++;
                if(cur[i]!=n-1)
                    t.push_back(i);
                if(cur[p]!=n-1)
                    t.push_back(p);
                ok[p]=ok[i]=ans;
            }
        }
        t.swap(v);
        t.clear();
    }
    if(n*(n-1)/2!=cnt) ans=-1;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N = 1e4+5,M = 2e5 + 5,mod = 99999997;

bool MOP1;

int vis[5000005];

bool MOP2;

inline void _main(void) {
	int k=Raed(),x=Raed();
	rep(i,-k+1,k-1)vis[x+i+2000001]=1;
	rep(i,0,5000001)if(vis[i])printf("%d ",i-2000001);
}

signed main() {
#define offline1
#ifdef offline
	freopen("truck.in", "r", stdin);
	freopen("truck.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
    string ans = "Good";
    cin >> s;
    vector<int> num(4);
    for (int i = 0 ;i< 4;i++){
        num[i] = s % 10 ;
        s = s/10;
    }
    for (int i = 0;i < 3;i++){
        if (num[i] == num[i+1]){
            ans = "Bad";
        }
    }

    cout << ans << endl;
}

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

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

  int64_t ans = 0;

  if (n == 1) {
    cout << 1 << endl;
  }
  else {
  for (int i = 1; i <= n / 2; i++)
  {
    int64_t tmp;
    tmp = i * i;
    if (tmp <= n) {
      ans = tmp;
    }
    else {
      break;
    }
  }

  cout << ans << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  set<int> s;
  for(int i=0;i<N;i++){
    s.insert(a.at(i));
  }
  if(s.size()==N) cout<<"YES";
  else cout<<"NO";
  return 0;
}
    
  


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }

int main(){
    ll N=ii();
    ll t=ii();
    ll ret=0;

    REP(i,0,N-1){
        ll a=ii();
        if(a>t){
            t=a;
        }else{
            ret+=t-a;
        }
    }
    oie(ret);
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    vector<int> s;
    int sum = 0;
    int ans;

    cin >> N;
    REP(i, N)
    {
    	int t;
    	cin >> t;
    	s.push_back(t);
    	sum += t;
    }

    if (sum % 10 != 0) 
    {
    	ans = sum;
    }
    else
    {
    	// s を昇順に並びかえる
    	sort(s.begin(), s.end());
    	// 全ての要素の和がが10の倍数なので
    	// sum から10の倍数ではない最小の要素を引いた数が答え
    	// もし全ての要素が10 の倍数なら答えは0
    	bool allTenFlag = true;
    	for(auto itr = s.begin(); itr != s.end(); ++itr)
    	{
    		int element = *itr;
    		if (element % 10 == 0)
    		{
    			continue;
    		}
    		else
    		{
    			sum -= element;
    			allTenFlag = false;
    			break;
    		}
    	}

    	if (allTenFlag) ans = 0;
    	else ans = sum;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

struct P{ll x,y;};
vector<string> ss;

ll H,W,d[21][21];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};

bool used[23][23];

ll bfs(ll s,ll t){
  ll res=0;
  REP(i,21)REP(j,21)d[i][j]=0,used[i][j]=false;
  used[s][t]=true;
  d[s][t]=0;
  queue<P> que;
  que.push((P){s,t});
  while(!que.empty()){
    P p=que.front();
    que.pop();
    REP(i,4){
      ll x=p.x,y=p.y,nx=p.x+dx[i],ny=p.y+dy[i];
      if(nx>=0 && nx<=H-1 && ny>=0 && ny<=W-1 && ss[nx][ny]=='.' && !used[nx][ny]){
        d[nx][ny]=d[x][y]+1;
        used[nx][ny]=true;
        que.push((P){nx,ny});
        if(res<d[nx][ny]){
          res=d[nx][ny];
        }
      }
    }
  }
  return res;
}

int main(){
  cin>>H>>W;
  REP(i,H){
    string str;
    cin>>str;
    ss.push_back(str);
  }
  ll ans=0;
  REP(i,H){
    REP(j,W){
      if(ss[i][j]=='.'){
        ans=max(ans,bfs(i,j));
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll GCD(ll a, ll b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}

ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        ans = GCD(a, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
	
int main()
{
	ll n;
	cin>>n;
	ll ans=n%1000;
	if(ans)
	cout<<1000-ans;
	else
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 3628
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict, deque

    n = int(readline())
    edge = defaultdict(list)

    for i in range(n - 1):
        a, b, c = map(int, readline().split())
        edge[a].append((b, c))
        edge[b].append((a, c))

    q, k = map(int, readline().split())

    que = deque()
    que.append((k, 0))
    dists = dict()

    while que:
        u, dist = que.popleft()
        for v, w in edge[u]:
            if v not in dists:
                dists[v] = dist + w
                que.append((v, dist + w))

    for i in range(q):
        x, y = map(int, readline().split())
        print(dists[x] + dists[y])


if __name__ == '__main__':
    main()


Measured memory_bytes: 115972