akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n;
	cin >> n;
	char s;
	bool f = 0;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == 'Y')f = 1;
	}
	cout << (f ? "Four" : "Three") << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
que = deque()
ans = ''
s = list(input())
for i in range(len(s)):
    que.append(s[i])
q = int(input())
flag = 0# if head->0 elif tail ->1
for i in range(q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        if flag == 0:
            flag =1
        else:
            flag = 0
    elif a[0] == '2':
        if a[1] == '1':
            if flag == 0:
                que.appendleft(str(a[2]))
            else:
                que.append(str(a[2]))
        elif a[1] == '2':
            if flag == 1:
                que.appendleft(str(a[2]))
            else:
                que.append(str(a[2]))
if flag == 0:
    for i in range(len(que)):
        ans += str(que.popleft())
elif flag == 1:
    for i in range(len(que)):
        ans += str(que.pop())
print(ans)


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

int minReach(int arr[], int n)
{
    int dp[n+1];

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

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

        dp[i] = min(ans1,ans2);
    }

    return dp[n];
}

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

    int arr[n+1];

    for(int i=1; i<=n; i++)
        cin>>arr[i];

    cout<<minReach(arr,n)<<endl;

    return 0;
}


Measured memory_bytes: 4228
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    int N, M;
    cin >> N >> M;

    i64 x = 1900*M + 100*(N-M);
    cout << (x << M) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

string s;

int main() {
    bool f1 = true;
    bool f2 = true;

    cin >> s;

    for (int i = 0; i < s.size(); i += 2) {
        if (s[i] == 'L') f1 = false;
    }
    for (int i = 1; i < s.size(); i += 2) {
        if (s[i] == 'R') f2 = false;
    }

    if (f1 && f2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
A, B, K = map(int, input().split())

while K > 0:
    if A % 2 == 1:
        A -= 1
    B = B + (A//2)
    A = A // 2
    K -= 1
    if K < 1:
        break
    if B % 2 == 1:
        B -= 1
    A = A + (B//2)
    B = B // 2
    K -= 1

print("{0} {1}".format(A, B))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<bool> b(n+1,0);
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    b.at(a)=1;
  }
  vector<int> c(n+1);
  c[0]=1;
  c[1]=(b.at(1)?0:1);
  for(int i=2;i<=n;i++)
    c[i]=(b.at(i)?0:(c[i-2]+c[i-1])%1000000007);
  cout<<c.at(n)<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 10)

int a[MAXN];

int main() {
	int n, k;
	cin >> n >> k;
	
	for (int i = 1; i <= n; i++) {
		a[i] = 1;
	}
	for (int i = 0; i < k; i++) {
		int t;
		cin >> t;
		for (int j = 0; j < t; j++) {
			int cur;
			cin >> cur;
			a[cur] = 0;
		}
	}
	int ret = 0;
	for (int i = 1; i <= n; i++) {
		ret += a[i];
	}
	cout << ret << endl;
	
	return 0;
}


Measured memory_bytes: 3580
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);

    int n, t, s;
    cin >> n >> t >> s;
    vector<int> v(n), w(n);
    for(int i : in(n)) cin >> v[i] >> w[i];
    vector<vector<int>> dp(n + 1, vector<int>(s + 1));

    for(int i : in(n)) for(int j : in(s + 1)) {
        if(j < w[i])
          dp[i + 1][j] = dp[i][j];
        else
          dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    }

    vector<int> memo(n + 1, 0);
    for(int i : in(n + 1)) memo[i] = *max_element(dp[i].begin(), dp[i].end());
    
    dp.assign(n + 1, vector<int>(t - s + 1, 0));
    for(int i : in(n - 1, -1)) for(int j : in(t - s + 1)) {
        if(j < w[i])
          dp[i][j] = dp[i + 1][j];
        else
          dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
    }
    
    int ans = 0;
    for(int i : in(n + 1)) {
        int ma = *max_element(dp[i].begin(), dp[i].end());
        ans = max(ans, ma + memo[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38156
#include <stdio.h>

int main(){

    int A;
    int B;
    int C;
    int D;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);

    
    while(A>0){
        A = A-D;
        C = C-B;
    }

    if(C>0){
        printf("No");
    }else
    printf("Yes");


    return 0;

}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  char x,y;
  cin>>x>>y;

  int a=x,b=y;
//  cout<<a<<b<<endl;
	if(a>b)cout<<">"<<endl;
  else if(a<b)cout<<"<"<<endl;
  else cout<<"="<<endl;





return 0;}


Measured memory_bytes: 256
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;

#pragma GCC Optimize("Ofast")

ll a[maxn];

int main(){
	ll n;cin>>n;
	REP(i,n)
		cin>>a[i];
	ll r=0,ans=0,num=0;
	REP(i,n){
		while(r<n&&((num&a[r])==0)){
			num|=a[r++];
		}
		ans+=r-i;
		num^=a[i];
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
using namespace std;

int main() {
    int a;
    scanInt(a);
    if (a % 10 == 3) printf("bon\n");
    else if (a % 10 == 0 ||
        a % 10 == 1 ||
        a % 10 == 6 ||
        a % 10 == 8) printf("pon\n"); 
    else printf("hon\n");
    return 0;
}


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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;
static long long INF = (1LL<<62);
using LLPair = pair<LL, LL>;

int main(int argc, char* argv[]){
	int H, W, N;
	vector<int> A;
	vector<int> B;

	cin >> H >> W;
	cin >> N;
	for(int i=0; i<N; i++){
		int a; cin >> a;
		A.push_back(a);
	}

	for(int i=0; i<A.size(); i++){
		for(int j=0; j<A[i]; j++){
			B.push_back(i+1);
		}
	}

	int dir = 1;
	for(int i=0; i<H; i++){
		vector<string> S;
		for(int j=0; j<W; j++){
			int c = B[B.size()-1]; B.pop_back();
			string s = to_string(c);
			S.push_back(s);
			if(j != W-1){
				S.push_back(" ");
			}
		}
		if(dir == -1){
			reverse(S.begin(), S.end());
		}
		for(int i=0; i<S.size(); i++){
			printf("%s", S[i].c_str());
		}
		printf("\n");
		dir *= (-1);
	}
	return 0;
}

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

ll dp[200001][2][3];

int main() {
  int n;
  cin >> n;
  int eo = 2 + n%2;
  ll a;
  rep(k, n) rep(i, 2) rep(j, eo) dp[k][i][j] = 0;
  cin >> a;
  dp[0][1][0] = a + 1000000001;
  for (int i=1; i<n-1; i++) {
    cin >> a;
    rep(j, eo) {
      dp[i][0][j] = dp[i-1][1][j];
      if (j > 0) dp[i][0][j] = max(dp[i][0][j], dp[i-1][0][j-1]);
      dp[i][1][j] = dp[i-1][0][j] + a + 1000000001;
    }
  }
  dp[n-1][0][eo-1] = max(dp[n-2][0][eo-2], dp[n-2][1][eo-2]);
  cin >> a;
  dp[n-1][1][eo-1] = dp[n-2][0][eo-1] + a + 1000000001;
  ll ans = max(dp[n-1][0][eo-1], dp[n-1][1][eo-1]) - 1000000001 * ll(n/2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12932
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0;
    	long hunt = 0;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= Btmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = Btmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
}

Measured memory_bytes: 85732
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int a[10];

bool check(int x) {
	while(x) {
		int q = x%10;
		if (a[q]==1) return false;
		x/=10;
	}
	return true;
}

int main() {
	IO
	int n, k;
	cin>>n>>k;
	for (int i=0;i<k;++i) {
		int x;
		cin>>x;
		a[x]=1;
	}
	while(1) {
		if(check(n)) {
			cout<<n<<endl;
			break;
		}
		++n;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
#define PI 3.141592653589793
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double hkaku,mkaku;
    hkaku = 30.0*h+m/2.0;
    mkaku = 6.0*m;
    double sa = min(abs(hkaku-mkaku),abs(mkaku-hkaku));
    sa = min(sa,360-sa);
    double cji = pow(a,2)+pow(b,2)-2*a*b*cos(sa*PI/180.0);
    cout << setprecision(15) <<  sqrt(cji) << endl;

        
}

Measured memory_bytes: 4240
N, K = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(N)]

xy.sort()
ans = 10**20
for l in range(N - K + 1):
  for r in range(l + K - 1, N):
    tb = xy[l: r + 1]
    tb.sort(key = lambda x: x[1])
    for b in range(len(tb) - K + 1):
      t = b + K - 1
      ans = min(ans, (xy[r][0] - xy[l][0]) * (tb[t][1] - tb[b][1]))

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void) {
	int num, A=0, B=0, O=0, AB=0;
	char blood[3];
	while(scanf("%d,%s", &num, &blood) != EOF){
		if(strcmp(blood, "A") == 0) A++;
		else if(strcmp(blood, "B") == 0) B++;
		else if(strcmp(blood, "O") == 0) O++;
		else if(strcmp(blood, "AB") == 0) AB++;
	}
	printf("%d\n%d\n%d\n%d\n", A, B, AB, O);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std;

const int mod = 1e9 + 7;
const int maxn = (1<<21) + 5;
int dp[30][maxn];
int a[30][30], b[30];
vector<int> can[30];
int main() {
    //freopen("in.in", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
            b[i] += (1<<j)*a[i][j];
        }
    }
   for (int i = 1; i < (1<<n); i++) {
       if ((i | b[0]) == b[0]) {
           dp[0][i] = 1;
       }
   }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!a[i][j]) continue;
            int x = 1<<j;
            for (int k = 1; k < (1<<n); k++) {
                if((x & k) != 0 || !dp[i - 1][k]) continue;
                dp[i][x | k] += dp[i - 1][k];
                dp[i][x | k] %= mod;
            }
        }
    }
    cout << dp[n - 1][(1<<n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 166144
function f()
    s = chomp(readline())
    #s = map(x->parse(String, x), split(chomp(readline()), " "))

    #print(input)
    #input = map(x->parse(Int, x), split(chomp(readline()), " "))
    #a = input[1]
    #b = input[2]

    if s <= "2019/04/30"
        print("Heisei")
    else
        print("TBD")
    end

end
f()

Measured memory_bytes: 166632
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;
string s[1001];
bool b[1001];
vector<P>v;
vector<string>a;
int n,m;
main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>s[i];

  for(int i=0;i<n;i++)if(!b[i]){
    reverse(s[i].begin(),s[i].end());

    for(int j=i+1;j<n;j++)if(!b[j]&&s[j]==s[i]){
      reverse(s[j].begin(),s[j].end());
      v.push_back(P(s[i],s[j]));
      b[j]=b[i]=1;
      break;
    }
  }
  for(int i=0;i<n;i++)if(!b[i]){
    string t=s[i];
    reverse(s[i].begin(),s[i].end());
    if(s[i]==t)a.push_back(t);
  }

  for(int i=0;i<v.size();i++)
    if(v[i].second<v[i].first)swap(v[i].first,v[i].second);

  sort(a.begin(),a.end());
  sort(v.begin(),v.end());

  for(int i=0;i<v.size();i++)cout<<v[i].first;
  if(a.size())cout<<a[0];
  for(int i=v.size()-1;i>=0;i--)cout<<v[i].second;
  cout<<endl;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	vector<pair<int,int> > v;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	bool flag = false;
	for(int i=0;i<n-2;i++){
		if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second){
			flag = true;
			break;
		}
	}
	if(flag==true){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	int A = 0, B = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) A += a.at(N - 1 - i);
		else B += a.at(N - 1 - i);
	}
	
	cout << A - B << endl;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int amax = a > b ? a : b;
    amax = amax > c ? amax : c;
    int amin = a < b ? a : b;
    amin = amin < c ? amin : c;
    cout << amin << " " << amax << "\n";

    return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
double startTime;
double getCurrentTime()
{
	return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

lli pwr(lli x,lli n)
{
	lli res=1;
	for(; n!=0;n>>=1)
	{
		if(n&1)
			res=(res*x)%MOD;
		x=(x*x)%MOD;
	}
	return res;
}
lli inver(lli num)
{
	return pwr(num,MOD-2);
}
lli findncr(lli n,lli r)
{
	r=min(r,n-r);
	if(n==0||n==1||r==0)
		return 1;
	lli numer=1;
	for(lli i=n;i>=n-r+1;i--)
		numer=(numer*i)%MOD;
	lli den=1;
	for(lli i=2;i<=r;i++)
		den=(den*i)%MOD;
	den=inver(den);
	lli res=(numer*den)%MOD;
	return res;
}
lli gcd(lli a,lli b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	int n,k;
	cin>>n>>k;
	vector<int>hei(n+1,0);
	for(int i=1;i<=n;i++)
	{
		cin>>hei[i];
	}
	vector<int>cost(n+1,INT_MAX);
	cost[0]=0;
	cost[1]=0;

	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>=max(1,i-k);j--)
			cost[i]=min(cost[i],cost[j]+abs(hei[j]-hei[i]));

	}
	cout<<cost[n]<<endl;
}

Measured memory_bytes: 1024
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
cnt = 0
if N >= 3:
    for edges in combinations(L, 3):
        a, b, c = edges
        if len(set(edges)) == 3 and a < b + c and b < c + a and c < a + b:
            cnt += 1
print(cnt)


Measured memory_bytes: 9152
#include<iostream>
using namespace std;
long long gcd(int a,int b);
int main(){
  long long int left,right;
  long long int a,b;
  cin>>left>>right;
  cin>>a>>b;
  
  long long int A_left=(left-1)/a;
  long long int A_right=right/a;
  long long int A_div=A_right-A_left;
  long long int B_left=(left-1)/b;
  long long int B_right=right/b;
  long long int B_div=B_right-B_left;
  long long int AB_left=(left-1)/(a*b/gcd(a,b));
  long long int AB_right=right/(a*b/gcd(a,b));
  long long int AB_div=AB_right-AB_left;
  
  cout<<right-left-A_div-B_div+AB_div+1<<endl;
  return(0);
}
  
long long gcd(int a,int b){
  while(b!=0){
    int temp=a%b;
    a=b;
    b=temp;
  }
  return(a);
}


Measured memory_bytes: 256
n = int(input())

ans = dict()
for x in range(1,10**2 + 1):
    for y in range(1,10**2 + 1):
        for z in range(1,10**2 + 1):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x

            current = ans.get(v, 0)
            ans.update({v: current+1})

for i in range(n):
    print(ans.get(i+1, 0))

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

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

  int n;
  cin >> n;
  int m=n/100;
  if(n>m*100+m*10+m)m++;

  cout << m*100+m*10+m << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)
#define pi 3.141592653589793238

ll find(vector<ll> &v, ll a, ll b, ll c){
    if(b < a+c) return 1;
    else return 0;
}

void solve(){
    ll n, m;cin >> n >> m;
    ll sum = 0;
    while(m--){
        ll x; cin >> x;
        sum += x;
    }
    if(sum > n) cout << -1 << endl;
    else cout << n-sum << endl;
}

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


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int k;
    ll a[112345];

    cin >> k;

    a[0] = 1;
    REP(i, k)
    cin >> a[i + 1];

    if (a[k] != 2)
    {
        cout << -1 << endl;
        return 0;
    }

    ll l = 2, r = 2;

    for (int i = k; i > 0; i--)
    {
        if (l % a[i] && r % a[i] && (l / a[i] - r / a[i]) == 0)
        {
            cout << -1 << endl;
            return 0;
        }

        l = ((l / a[i - 1]) * a[i - 1] + (l % a[i - 1] > 0) * a[i - 1]);
        r = (((r + a[i] - 1) / a[i - 1]) * a[i - 1]);

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

    cout << l << " " << r << endl;
    return 0;
}

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

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

#define USE_COLORED 1

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

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

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

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

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string s;
	std::cin >> s;
	
	std::string result;
	for (auto ch : s) {
		if (ch == 'B') {
			if (result.size() > 0) {
				result.resize(result.size() - 1);
			}
		} else {
			result += ch;
		}
	}
	
	std::cout << result << "\n";
}


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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
  static_assert(I >= 1);
  static_assert(N >= 1);
  if constexpr (I == 1){
    return std::vector<T>(a[N - I], value);
  }else{
    return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
  }
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}


namespace haar_lib {}

namespace solver {
  using namespace haar_lib;

  constexpr int m1000000007 = 1000000007;
  constexpr int m998244353 = 998244353;

  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  void solve(){
    int N; std::cin >> N;
    std::vector<bool> check(N);
    for(int i = 0; i < N; ++i){
      int D1, D2; std::cin >> D1 >> D2;
      check[i] = (D1 == D2);
    }

    bool ok = false;

    for(int i = 0; i < N - 2; ++i){
      if(check[i] and check[i + 1] and check[i + 2]) ok = true;
    }

    std::cout << (ok ? "Yes" : "No") << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


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

typedef long long ll;

int main() {
    ll N, M;
    cin >> N >> M;
    if (N > M / 2) cout << M / 2 << "\n";
    else cout << (N * 2 + M) / 4 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n,k;
	cin >> n >> k;
	int p[200010];
	FOR(i,n){
		cin >> p[i];
	}
	int cnt=0;
	FOR(i,k){
		cnt+=p[i];
	}
	int ans=0;
	FOR(i,n-k){
		chmax(ans,cnt);
		cnt-=p[i];
		cnt+=p[i+k];
	}
	chmax(ans,cnt);
	cout << fixed << setprecision(12);
	cout << (double)(ans+k)/2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const int INF = 1e9;
int g[101][101];
int dist[101][101];
struct edge{ int from,to,cost;};

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,n) rep(j,n) {
    if (i == j) dist[i][i] = 0;
    else dist[i][j] = INF;
  }
  vector<edge> e(m);
  vector<bool> edges(m,false);
  for (int i = 0; i < m;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    e[i].from = a; e[i].to = b; e[i].cost = c;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (int i = 0;i < n;i++){
    for (int j = 0;j < n;j++){
      for (int k = 0; k < n;k++){
        dist[j][k] = min(dist[j][k],dist[j][i] + dist[i][k]);
      }
    }
  }
  //rep(i,n){
  //  rep(j,n) if (dist[i][j] == INF) cout << "f"; else cout << dist[i][j];
  //  cout << endl;
  //}
  int cnt = 0;
  for (int i = 0;i < m;i++){
    for (int s = 0; s < n;s++){
      for (int t = 0; t < n;t++){
        if (dist[s][t] == dist[s][e[i].from] + e[i].cost + dist[e[i].to][t]) {
          edges[i] = true;
          //printf("(s,t) = (%d, %d)\n",s,t);
        }
        if (dist[s][t] == dist[s][e[i].to] + e[i].cost + dist[e[i].from][t]){
          edges[i] = true;
          //printf("(s,t) = (%d ,%d)\n",s,t);
        }
      }
    }
  }
  for (int i = 0; i < m;i++){
     if (!edges[i]) cnt++;
  }

  cout << cnt << endl;

  


  return 0; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100][100];
bool vis[1001][100];
int main()
{
    int n,m;
    cin>>n>>m;
    for (int i=0;i<n;i++)
        for (int j=0;j<m;j++)
            cin>>a[i][j];
    if (a[0][0]!='#')
        cout<<"Impossible"<<endl;
    else
    {
        int x=0,y=0;
        vis[x][y]=1;
        while(1)
        {
            if (x+1<n && a[x+1][y]=='#' ) vis[x+1][y]=1,x++;
            else if (y+1<m && a[x][y+1]=='#' ) vis[x][y+1]=1,y++;
            else break;
        }
        if (x!=n-1 && y!=m-1){
            cout<<"Impossible"<<endl;
            return 0;
        }
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<m;j++)
            {
                if (vis[i][j]==0 && a[i][j]=='#')
                {
                    cout<<"Impossible"<<endl;
                    return 0;
                }
            }
        }
        cout<<"Possible"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace Abc138
{
    //https://atcoder.jp/contests/abc139/tasks/abc139_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int result = 0;
            // スペース区切りの整数の入力
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == t[i])
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;

vector<int> operator*(const vector<int>& a, const vector<int>& b) {
    int sz = a.size();
    vector<int> c(sz);
    for (int i = 0; i < sz; i++) {
        c[i] = a[b[i]];
    }
    return c;
}
vector<int> inv(const vector<int>& a) {
    int sz = a.size();
    vector<int> c(sz);
    for (int i = 0; i < sz; i++) {
        c[a[i]] = i;
    }
    return c;
}
vector<int> vpow(vector<int>& a, int exp) {
    int sz = a.size();
    vector<int> c(sz);
    iota(c.begin(), c.end(), 0);
    for (; exp; exp>>=1) {
        if (exp&1)
            c = c * a;
        a = a * a;
    }
    return c;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n+1);
    vector<int> q(n+1);
    p[0] = q[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> q[i];
    }
    vector<int> ip = inv(p);
    vector<int> iq = inv(q);
    int exp = (k-1) / 6;
    int rem = (k-1) % 6;
    vector<int> base = q*ip*iq*p;
    vector<int> lhs = vpow(base, exp);
    vector<int> rhs = inv(lhs);
    vector<int> mid;
    if      (rem == 0) mid = p;
    else if (rem == 1) mid = q;
    else if (rem == 2) mid = q*ip;
    else if (rem == 3) mid = q*ip*iq;
    else if (rem == 4) mid = q*ip*iq*p*iq;
    else if (rem == 5) mid = q*ip*iq*p*p*iq;
    vector<int> res = lhs * mid * rhs;
    for (int i = 1; i <= n; i++) {
        cout << res[i] << ' ';
    }
}

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


Measured memory_bytes: 5096
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = input()
    L = len(S)
    A = [0] * (L+1)
    for i in range(L):
        if S[i]=='<':
            A[i+1] = max(A[i] + 1, A[i+1])
    for i in range(L)[::-1]:
        if S[i]=='>':
            A[i] = max(A[i],A[i+1]+1)
    print(sum(A))



if __name__ == '__main__':
    main()

Measured memory_bytes: 23348
#include <iostream>
#include <string>

int main()
{
	std::string A;
  	std::string B;
  	std::string C;
  	std::cin >> A >> B >> C;
  	int alice = 0;
  	int bob = 0;
  	int charlie = 0;
  	char last = 'a';
  	while(true)
    {
    	if(last == 'a')
        {
          	if(alice == A.size())
            {
            	std::cout << 'A';
              	return 0;
            }
          	last = A[alice];
          	++alice;
        }
      	else if(last == 'b')
        {
          	if(bob == B.size())
            {
            	std::cout << 'B';
              	return 0;
            }
        	last = B[bob];
          	++bob;
        }
      	else if(last == 'c')
        {
          	if(charlie == C.size())
            {
            	std::cout << 'C';
              	return 0;
            }
        	last = C[charlie];
          	++charlie;
        }
    }
  	return -1;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    string c, e; cin >> c >> e;

    if (c.size()>e.size()) {
        for (int i=0;i<c.size();i++)
        {
            if (i==c.size()-1) { cout << c[i]; }
            else { cout << c[i] << e[i]; }
        }
    } else {
        for (int i=0;i<c.size();i++)
        {
            cout << c[i] << e[i];
        }
    }
    
    cout << endl;

	return 0;
}


Measured memory_bytes: 3560
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;

void main()
{
  auto n = readln.chomp.to!int;
  long sum;
  foreach (int i; 1..n+1) {
    if (i % 3 && i % 5) {
      sum += i;
    }
  }
  sum.writeln;
}


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

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

  set<int> d;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    d.insert(tmp);
  }
  cout << d.size() << endl;
  return 0;
}

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

const int MAXN = 100000 + 5;

int N, M;
vector <int> Adj[MAXN];
int fa[MAXN], col[MAXN], dep[MAXN];

bool hasCircle;
int circA, circB;

inline void addEdge(int u, int v)
{
	Adj[u].push_back(v);
	Adj[v].push_back(u);
}

void DFS(int cur)
{
	dep[cur] = dep[fa[cur]] + 1;
	col[cur] = (dep[cur] & 1 ? 1 : -1);

	for(int to : Adj[cur])
	{
		if(to == fa[cur])
			continue;
		if(dep[to])
		{
			if(!hasCircle)
				circA = cur, circB = to, hasCircle = true;
		}
		else
			fa[to] = cur, DFS(to), col[cur] += col[to];
	}
}

int solveAcyclic()
{
	if(col[1])
		return -1;

	int ret = 0;
	for(int i = 1; i <= N; i++)
		ret += abs(col[i]);
	return ret;
}

int solveOddCircle()
{
	if(col[1] & 1)
		return -1;

	int delta = -col[1] / 2, ret = abs(delta), cur;
	cur = circA;
	while(cur)
		col[cur] += delta, cur = fa[cur];
	cur = circB;
	while(cur)
		col[cur] += delta, cur = fa[cur];

	for(int i = 1; i <= N; i++)
		ret += abs(col[i]) ;
	return ret;
}

int solveEvenCircle()
{
	if(col[1])
		return -1;

	int circle[MAXN] = {0}, top = 0;
	for(int cur = circA; cur != circB; cur = fa[cur])
		circle[++top] = col[cur], dep[cur] = 0;

	int mid = (top + 1) >> 1, delta, ret;
	nth_element(&circle[1], &circle[mid], &circle[top+1]);

	if(top & 1)
		delta = (circle[mid]);
	else
		delta = (circle[mid] + circle[mid+1]) >> 1;
	ret = abs(delta);

	for(int i = 1; i <= N; i++)
		if(dep[i])
			ret += abs(col[i]);
	for(int i = 1; i <= top; i++)
		ret += abs(circle[i] - delta);
	return ret;
}

int main()
{
	//printf("%d %d\n", 1 & 1, -1 & 1);
	fflush(stdout);

	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		addEdge(u, v);
	}

	DFS(1);

	if(!hasCircle)
		printf("%d\n", solveAcyclic());
	else
	{
		if((dep[circA] - dep[circB] + 1) & 1)
			printf("%d\n", solveOddCircle());
		else
			printf("%d\n", solveEvenCircle());
	}

	return 0;
}


Measured memory_bytes: 11520
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();

        int dp[][] = new int[n][2];

        dp[0][0] = sc.nextInt();
        dp[0][1] = 0;

        dp[1][0] = sc.nextInt();
        dp[1][1] = Math.abs(dp[1][0] - dp[0][0]);

        for(int i = 2;i < n;i++){
            dp[i][0] = sc.nextInt();
            dp[i][1] = Math.min(dp[i-2][1] + Math.abs(dp[i-2][0] - dp[i][0]),dp[i-1][1] + Math.abs(dp[i-1][0] - dp[i][0]));
        }


        System.out.println(dp[n-1][1]);




    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 24592
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)
bool tbl[100];
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    REP(i, 10) {
        REP(j, 10) {
            tbl[i*j] = true;
        }
    }
    ll N;
    cin >> N;
    cout << ((tbl[N])?"Yes":"No") << endl;
}


Measured memory_bytes: 888
f a b = if a==b then"EQUAL"else if(length a)>(length b)then"GREATER"else if(length a)<(length b)then"LESS"else if(head a)>(head b)then"GREATER"else if(head a)<(head b)then"LESS"else f(tail a)(tail b)
main=getContents>>=putStrLn.(\[a,b] ->f a b).lines

Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC140A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(N * N * N);
        }
    }
}


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

// 青a個　赤b個
//　全部で10^100回
//　先頭からn個(1~10^18)
int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;

    //セット数 n/(a+b)
    //セット数*a + min(n%(a+b), a)
    cout << (n/(a+b))*a + min(n%(a+b), a) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = int.Parse(Console.ReadLine());
            Console.Write(imp / 3);
        }
    }
}


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) {
    if(!n) return 0;
    rep(i, 0, n) {
      int s, e, k;
      cin >> s >> e >> k;
      if(s == 100 || e == 100 || k == 100 || (s + e) / 2 >= 90 || (s + e + k) / 3 >= 80) cout << 'A' << endl;
      else if((s + e + k) / 3 >= 70 || ((s + e + k) / 3 >= 50 && (s >= 80 || e >= 80))) cout << 'B' << endl;
      else cout << 'C' << endl;
    }
  }
}

Measured memory_bytes: 3048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 3e5 + 100, INF = 1e9 * 1e9 + 10;
ll n, x, m, q;

ll tree[SIZE * 8][2];
void upd(int v, int l, int r, int askl, int askr, ll val, int ind) {
	tree[v * 2 + 1][ind] = min(tree[v * 2 + 1][ind], tree[v][ind]);
	tree[v * 2 + 2][ind] = min(tree[v * 2 + 2][ind], tree[v][ind]);

	if (l >= askr || r <= askl) return;

	if (l >= askl && r <= askr) {
		tree[v][ind] = min(tree[v][ind], val);
		return;
	}

	int mid = (l + r) / 2;

	upd(v * 2 + 1, l, mid, askl, askr, val, ind);
	upd(v * 2 + 2, mid, r, askl, askr, val, ind);
}

ll get(int v, int l, int r, int askl, int askr, int ind) {
	tree[v * 2 + 1][ind] = min(tree[v * 2 + 1][ind], tree[v][ind]);
	tree[v * 2 + 2][ind] = min(tree[v * 2 + 2][ind], tree[v][ind]);

	if (l >= askr || r <= askl) return n;

	if (l >= askl && r <= askr) return tree[v][ind];

	int mid = (l + r) / 2;

	return min(get(v * 2 + 1, l, mid, askl, askr, ind), get(v * 2 + 2, mid, r, askl, askr, ind));
}
int main()
{
	fastInp;

	cin >> n >> q;

	ll ans = (n - 2) * (n - 2);
	set<ll> rs, us;

	for (int i = 0; i < n * 8; i++) {
		tree[i][0] = n - 1;
		tree[i][1] = n - 1;
	}
	while (q--) {
		int t, l;
		cin >> t >> l;
		if (t == 1) {
			rs.insert(l);

			ll ind = get(0, 0, n, l - 1, l, 0);

			ans -= ind - 1;
			upd(0, 0, n, 0, ind + 1, l - 1, 1);
		}
		else {
			us.insert(l);

			ll ind = get(0, 0, n, l - 1, l, 1);
			
			ans -= ind - 1;
			upd(0, 0, n, 0, ind + 1, l - 1, 0);
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 37524
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
count=0
for i in range(n-1):
    count+=b[a[i]-1]
    if a[i+1]-1==a[i]:
        count+=c[a[i]-1]
print(count+b[a[-1]-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4018)
#define ll long long

int d[101];
vector<int> v;
int main(void)
{
	int N; scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int a; scanf("%d", &a);
		if (v.size() >= a - 1) {
			if(a-1 == v.size()) v.push_back(a);
			else v.insert(v.begin() + a - 1, a);
		}
	}
	if (v.size() < N) {
		printf("-1\n"); return 0;
	}
	for (int i = 0; i < N; i++) {
		printf("%d\n", v[i]);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
double H;
int N, A[1000001], sum=0,ct=0;
int main()
{
    cin >> H >> N;
	while ((H<1||H>10000000000)&&(N < 1 || N>1000000))
	{
		cin >> H >> N;
	}
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		while (A[i] < 1 || A[i]>100000)
		{
			cin >> A[i];
		}
		sum += A[i];
	}
	if ((H - sum) <= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640