akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h" // 提出時こちらで問題なし
//#include <iostream>
//#include <string>
//#include <typeinfo>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REP2(i, s, n) for (int i=(int)(s); i<(int)(n); i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
#define SORT(c) sort((c).begin(),(c).end())
#define R_SORT(c) sort((c).begin(),(c).end(),greater<>())
using G = vector<vector<int>>;
using M = map<int, int>;
using P = pair<int, int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
using V = vector<int>;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


// C - Step

int ctoiii(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

// B - Multiple of 9 
int main()
{
	int num = 0;
	string n;
	cin >> n;
	REP(i, n.length()) {
		num += ctoiii(n.at(i));
	}

	if (num % 9 == 0) {
		cout << "Yes" << endl;
	}
	
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 3716
#include <stdio.h>
 
void Set(int a[3], int max, int mid, int min){
  a[0] = max;
  a[1] = mid;
  a[2] = min;
}
 
int Count(int a[3], int N){
  int i, j, I, J, K, c;
  c = 0;
  for(i = N / a[0];i >= 0;i--){
    I = i * a[0];
    for(j = (N - I) / a[1];j >= 0;j--){
      J = j * a[1];
      K = N - I - J;
      if(K % a[2] == 0) c++;
    }
  }
  return c;
}
 
int main(void){
  int R, G, B, N;
  int a[3];
  scanf("%d %d %d %d", &R, &G, &B, &N);
  if(R > G){
    if(G > B) Set(a, R, G, B);
    else{
      if(R > B) Set(a, R, B, G);
      else Set(a, B, R, G);
    }
  }else{
    if(R > B) Set(a, G, R, B);
    else{
      if(G > B) Set(a, G, B, R);
      else Set(a, B, G, R);
    }
  }
  printf("%d\n", Count(a, N));
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>

#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int sum;
    int cnt=0;
    for(int i=0;i<=A;i++){
        for(int  j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                sum=500*i+100*j+50*k;
                if(sum==X){
                    cnt++;
                }
                if(sum>X){
                    break;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
  int X,Y;
  cin >> X >> Y;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i*2+j*4==Y && i+j==X){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  while(cin >> m >> n,m){
    vb year(7368791+1,false);
    REP(i,m) year[i] = true;
    int id = m;
    REP(i,n){
      FOR(j,id,7368791+1){
        if(!year[j]){
          id = j;
          break;
        }
      }
      for(int j = id;j<7368791+1;j+=id){
        year[j] = true;
      }
    }
    FOR(j,id,7368791+1){
      if(!year[j]){
        cout << j << endl;
        break;
      }
    }
  }
}



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

using namespace std;
const int maxn = 1e5+10;
int a[maxn],b[maxn];

int main()
{
    int t,n;
    scanf ("%d%d",&n,&t);
    for (int i = 1; i <= n; i++) scanf ("%d",&a[i]);
    int m_ax = a[1];
    for (int i = 1; i <= n; i++) {
        m_ax = max(m_ax,a[i]);
        b[i] = t/m_ax + 1;
        if (t%m_ax >= a[i]) b[i]++;
        t -= a[i];
        if (t < 0) break;
    }
    for (int i = 1; i <= n; i++) cout << max(1,b[i]) << endl;
    return 0;
}



Measured memory_bytes: 4004
function Main(input){
	var sum = 0;
	input = input.split(" ").map(Number);
	for(var i=input[0];i<=input[1];i++){
		var n = String(i).split("");
		var p = [];
		for(var k=0;k<n.length;k++){
		    p.push(n[n.length-1-k])
		}
		if(n.join("")==p.join("")) sum++;
	}
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

#define ll long long int 
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main()
{
	_fastio
	ll ar[6],sv;
	for1(i,5)
	{
		si(ar[i]);
		if(ar[i]==0)
			sv=i;

	}
	cout<<sv<<en;
}

Measured memory_bytes: 3704
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var fibo = new int[num+1];
        fibo[0] = 1;
        fibo[1] = 1;
        for (var i = 2; i <= num; i++)
            fibo[i] = fibo[i - 1] + fibo[i - 2];
        WriteLine(fibo[num]);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 15944
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL){
      root=i;
    }
  }
  printf("Preorder\n");
  preParse(root);
  printf("\nInorder\n");
  inParse(root);
  printf("\nPostorder\n");
  postParse(root);printf("\n");
  return 0;
}



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

#include<atcoder/all>
using namespace atcoder;

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

const int MAX_A = 300005;

int op(int a, int b) { return max(a,b);} 
int e() { return 0;}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    segtree<int, op, e> dp(MAX_A);
    rep(i, n) {
        int x = a[i];
        int l = x-k, r = x+k+1;
        l = max(l, 0);
        r = min(r, MAX_A);
        int now = dp.prod(l, r)+1;
        dp.set(x, now);
    }
    int ans = dp.prod(0, MAX_A);
    cout << ans << endl;
    return 0; 
}
 

Measured memory_bytes: 9604
// AOJ 3043: Donut Hole
// 2019.2.22 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int W, H, w, h, x, y;
	int xl, xr, yl, yu;

	scanf("%d%d%d%d%d%d", &W, &H, &w, &h, &x, &y);
	W >>= 1, H >>= 1, w >>= 1, h >>= 1;
	xl = x - w; if (-W > xl) xl = -W;
	xr = x + w; if ( W < xr) xr =  W;
	yl = y - h; if (-H > yl) yl = -H;
	yu = y + h; if ( H < yu) yu =  H;
	printf("%.10lf\n", (double)(yl + yu) / (xl + xr));
	return 0;
}


Measured memory_bytes: 2064
#include<cstdio>

int main() {
    int K,S;
    scanf("%d",&K);
    scanf("%d",&S);

    int cnt = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            if(0 <= S-x-y && S-x-y <= K){
                cnt++;
            }
        }
    }
    printf("%d\n",cnt);
}


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

const int N = 1e5 + 100;

int n, l, a[N];
vector<int> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> l;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i > 1 && a[i - 1] + a[i] >= l)
			vec.push_back(i - 1);
	}
	if (vec.empty()) {
		cout << "Impossible";
		return 0;
	}
	cout << "Possible\n";
	for (int i = 1; i < vec[0]; i++)
		cout << i << '\n';
	for (int i = n - 1; i >= vec[0]; i--)
		cout << i << '\n';
}


Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define null NULL

using namespace std;

const ll MOD = 1e9 + 7;

const int lg = 30;
const int mx = 3e5;
int n, a[mx], b[mx];

ll sum_on_seg(vector<int> &v, int l, int r) {
	ll res = lower_bound(v.begin(), v.end(), r + 1) - lower_bound(v.begin(), v.end(), l);
	return res;
}

int get(int bit_num) {
	int d = (1 << bit_num);
	//cout << "d = " << d << endl;
	vector<int> t, t1;
	for (int i = 0; i < n; ++i) {
		int rgt = (a[i] & (2 * d - 1));
		t.push_back(rgt);
	}
	for (int i = 0; i < n; ++i) {
		int rgt = (b[i] & (2 * d - 1));
		t1.push_back(rgt);
	}
	//cout << "t" << endl;
	sort(t.begin(), t.end());
	/*cout << t.size() << endl;
	for (int i = 0; i < n; ++i) {
		cout << t[i] << " ";
	}
	cout << endl;*/
	ll res = 0;
	for (int i = 0; i < n; ++i) {
		int x = t1[i];
		//cout << "x = " << x << endl;
		if (t1[i] < d) {
			ll cur = sum_on_seg(t, d - x, 2 * d - x - 1);
			//cout << "cur = " << cur << endl;
			res += cur;
		}
		else {
			ll cur = sum_on_seg(t, 0, 2 * d - x - 1) + sum_on_seg(t, 3 * d - x, 2 * d - 1);
			//cout << "cur = " << cur << endl;
			res += cur;
		}
		//cout << "res = " << res << endl;
	}
	//cout << "res = " << res << endl;
	return res % 2;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	int ans = 0;
	for (int i = 0; i < lg; ++i) {
		ans += get(i) * (1 << i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5660
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

const int MAXN = 100500;

int n;
string s;
int node = 0;
vector < pair<int, int> > ans;
int l, r;

bool can(int pos) {
  return s[pos - 1] == '1';
}

void connect(int a, int b) {
  ans.push_back(make_pair(a, b));
}

int main() { 

  getline(cin, s);
  n = sz(s);

  if (!can(1) || !can(n - 1) || can(n)) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (can(i) && !can(n - i)) {
      puts("-1");
      return 0;
    }
  }

  l = 2, r = n - 2;
  while (!can(l)) {
    l++;
  }
  while (!can(r)) {
    r--;
  }

  if (r == 1) {
    connect(1, 2);
    for (int i = 0; i < n - 2; i++) {
      connect(2, 2 + i + 1);
    }
  } else {
    connect(1, 2);
    node = 3;
    for (int i = 0; i < l - 1; i++) {
      connect(1, node);
      node++;
    }
    int rightNode = 2;
    while (true) {
      int prev = r;
      r--;
      while (!can(r)) {
        r--;
      }
      if (r <= l) {
        while (node <= n) {
          connect(rightNode, node);
          node++;
        }
        break;
      } else {
        for (int i = 0; i < prev - r; i++) {
          connect(rightNode, node);
          node++;
        }
        rightNode = node - 1;
      }
    }
  }

  for (auto p : ans) {
    printf("%d %d\n", p.first, p.second);
  }

  return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int a,b,c,x; cin>>a>>b>>c>>x;
  	int count=0;
  	for(int i=0;i<=a;i++){
  		for(int j=0;j<=b;j++){
        	for(int k=0;k<=c;k++){
              if((i*500+j*100+k*50)==x){
                	count++;	
                }
            }
        }
    }
  		cout<<count<<endl;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll x;
    cin >> x;
    int m = 200000;
    vector<bool> prime(m, true);
    prime[0] = false;
    prime[1] = false;

    FOR(i, 2, m){
        if(prime[i]){
            for(int j=2; i*j<m; j++){
                prime[i*j] = false;
            }
        }
    }

    FOR(i, x, m){
        if(prime[i]){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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

int main(){
  string n;
  cin >> n;
  int l = n.size() - 1;
  if (n.at(l) == '2' || n.at(l) == '4' || n.at(l) == '5' || n.at(l) == '7' || n.at(l) == '9'){
    cout << "hon" << endl;
  }else if(n.at(l) == '0' || n.at(l) == '1' || n.at(l) == '6' || n.at(l) == '8'){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3612
process.stdin.resume();
process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", function(chunk) {input += chunk;});
process.stdin.on("end", function() {main(input.split("\n"));});

function allocNode(key) {
	let p = {};
	p.key = key;
	p.left = null;
	p.right = null;
	return p;
}

function insert(p,c) {
	if (p === null) return c;
	if (c.key < p.key) p.left = insert(p.left,c);
	else p.right = insert(p.right,c);
	return p;
}

function find(p,key) {
	if (p !== null && p.key !== key) {
		if (key < p.key) p = find(p.left,key);
		else p = find(p.right,key);
	}
	return p;
}

function inset(p,ary) {
	if (p === null) return;
	inset(p.left,ary);
	ary.push(p.key);
	inset(p.right,ary);
}

function preset(p,ary) {
	if (p === null) return;
	ary.push(p.key);
	preset(p.left,ary);
	preset(p.right,ary);
}

function dump(p,setfunc) {
	let ary = [];
	setfunc(p,ary);
	console.log(ary.map(x => ` ${x}`).join(""));
}

function main(lines){
	const n = Number(lines[0]);
	let root = null;
	let p, key, line;
	for (let i = 0; i < n; i++) {
		line = lines[i+1].split(" ");
		switch(line[0][0]) {
		case "i":
			key = Number(line[1]);
			p = allocNode(key);
			root = insert(root,p);
			break;
		case "p":
			dump(root,inset);
			dump(root,preset);
			break;
		case "f":
			key = Number(line[1]);
			if (find(root,key) !== null) console.log("yes");
			else console.log("no");
			break;			
		}
	}
}



Measured memory_bytes: 214780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll a, b;
    cin >> a >> b;
    if(a > 9 || b > 9)cout << -1 << endl;
    else cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
if K == 0:
    print(A,B)
elif A >= K:
    A = A - K
    print(A,B)
elif A < K:
    K = K - A
    A = 0
    if B > K:
        B = B - K
        print(A,B)
    else:
        B = 0
        print(A,B)


Measured memory_bytes: 3064
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    printf("%d\n", n*(n-1)/2 + m*(m-1)/2);
    
return 0;
}

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

int main() {
  int N;
  string coror;
  cin >> N;
  for(int i=0; i < N; i++){
    cin >> coror;
    if(coror == "Y")
      break;
  }
  if(coror == "Y")
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define EPS 1e-6
#define pi 3.14159265358979323846
int main()
{
    fast;
    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=0; i<n-1; i++){
        int x;
        cin>>x;
        mp[x]++;
    }
    vector<int> ans(n+1);
    for(auto i: mp){
       ans[i.ff]=i.ss;
    }
    for(int i=1; i<=n; i++) cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 13476
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int n, cnt = 0;

int solve(int g, int a, int b, int c) {
	if(g > n) return 0;

	if(a * b * c == 1) cnt++;
	solve(g*10+3, 1, b, c);
	solve(g*10+5, a, 1, c);
	solve(g*10+7, a, b, 1);
	return cnt;
}

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

	cin >> n;
	cout << solve(0, 0, 0, 0) << endl;
	return 0;
}

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

namespace AtCoder.Abc
{
    class Question4
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long n = long.Parse(Console.ReadLine());
            int i;
            String[] s = new string[n];

            for (i= 0;i< n; i++)
            {
                s[i] = Console.ReadLine();
            }


            Console.WriteLine(s.Distinct().Count());

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 48264
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
s.sort()
ans = 0
for i in range(n):
  if sum(s)%10 != 0:
    ans = sum(s)
    break
  else:
    for i in range(n):
      if s[i]%10 != 0:
        s.remove(s[i])
        ans = sum(s)
        break
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main ()
{
	int a=0,b=0,c=0;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<c&&b>c)
	{printf("Yes\n");
	}
	else if(a==c&&b==c)
	{printf("Yes\n");
	}
	else 
	{printf("No\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        double ans = 0;
        for (int i = 1; i <= n; i++) {
            int cnt = 0;
            while (i * Math.pow(2, cnt) < k)
                cnt += 1;
            ans += (1/(double)n) * 1/Math.pow(2, cnt);
        }
        System.out.println(ans);
    }
}


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

int main(){
  int P,Q,R,result;
  cin >> P >> Q >> R;
  
  vector<int> vec(3);
  
  vec.at(0) = P;
  vec.at(1) = Q;
  vec.at(2) = R;
  
  sort(vec.begin(),vec.end());
  
  result += vec.at(0) + vec.at(1);
  cout << result << endl;
}

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

int main() {
	u64 N;
	u64 A, B, C;
	cin >> N >> A >> B >> C;

	vector<string> S(N);
	for(u64 i=0; i<N; i++) cin >> S[i];

	for(u64 i=0; i<N; i++) {
		if(S[i] == "AC") {
			if(A == 0 && C == 0) {
				cout << "No" << endl;
				return 0;
			} else if(A > C) {
				A--; C++; S[i] = "C";
			} else if(C > A) {
				A++; C--; S[i] = "A";
			} else if(i < N - 1 && S[i+1] == "BC") {
				A--; C++; S[i] = "C";
			} else {
				A++; C--; S[i] = "A";
			}
		} else if(S[i] == "AB") {
			if(A == 0 && B == 0) {
				cout << "No" << endl;
				return 0;
			} else if(A > B) {
				A--; B++; S[i] = "B";
			} else if(B > A) {
				A++; B--; S[i] = "A";
			} else if(i < N - 1 && S[i+1] == "AC") {
				A++; B--; S[i] = "A";
			} else {
				A--; B++; S[i] = "B";
			}
		} else {
			if(B == 0 && C == 0) {
				cout << "No" << endl;
				return 0;
			} else if(B > C) {
				B--; C++; S[i] = "C";
			} else if(C > B) {
				B++; C--; S[i] = "B";
			} else if(i < N - 1 && S[i+1] == "AB") {
				B++; C--; S[i] = "B";
			} else {
				B--; C++; S[i] = "C";
			}
		}
	}
	

	cout << "Yes" << endl;
	for(u64 i=0; i<N; i++) {
		//cout << S[i] << ":" << ABC[0][i] << " " << ABC[1][i] << " " << ABC[2][i] << endl;
		cout << S[i] << endl;
	}
	return 0;
	
}


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

use std::collections::HashSet;

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    let mut startMap = HashSet::new();
    let mut endMap = HashSet::new();
    for _ in 0..M {
        let a: usize = read();
        let b: usize = read();
        if a == 1 {
            startMap.insert(b);
        }
        if a == N {
            endMap.insert(b);
        }
        if b == 1 {
            startMap.insert(a);
        }
        if b == N {
            endMap.insert(a);
        }
    }
    if startMap.intersection(&endMap).count() != 0 {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 11204
import sys
s = int(input())
a = []
for i in range(1,1000001):
  if i ==1:
    a.append(s)
  else:
    if a[i-2]%2 ==0:
      x = a[i-2]/2
      if x in a:
        print(i)
        sys.exit()
      a.append(x)
    else:
      x = 3 * a[i-2] + 1
      if x in a:
        print(i)
        sys.exit()
      a.append(x)

Measured memory_bytes: 62212
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  bool ok = true;
  for (int i = 0; i < N; ++i) {
    if (A[i] % 2 == 0) {
      if (!(A[i] % 3 == 0 || A[i] % 5 == 0)) {
        ok = false;
        break;
      }
    }
  }
  if (ok) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m = 256;

    while (cin >> n && n) {
        VI i(n);
        REP(j,n) cin >> i[j];
        double mi = 1e9;
        int sa, aa, ca;
        REP(s,16) REP(a,16) REP(c,16) {
            VI r(n+1), o(n);
            r[0] = s;
            REP(j,n) r[j+1] = (a*r[j] + c) % m;
            REP(j,n) o[j] = (i[j] + r[j+1]) % m;
            vector<double> p(m);
            REP(j,n) p[o[j]] += 1.0;
            double h = 0.0;
            REP(j,m) if(p[j]>0) h -= p[j]/n * log(p[j]/n);
            if (h < mi - 1e-10) {
                mi = h;
                sa = s;
                aa = a;
                ca = c;
            }
        }
        printf("%d %d %d\n", sa, aa, ca);
    }

    return 0;
}

Measured memory_bytes: 3404
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, m;
  cin>>n>>m;
  if(n == m){
    cout<< "Yes" <<endl;
  }else{
    cout<< "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
//
//  main.c
//  Dirichlet's Theorem on Arithmetic Progressions
//
//  Created by x15071xx on 2016/06/06.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//
//dm+a=n
//n???d??§?????£???a?????????&&?´???°?????°
#include <stdio.h>
#include <math.h>
#define NUM 1000000

int main(int argc, const char * argv[]) {
    
    int a,d,n,i,j;
    int hurui[NUM] = {0},count_n = 0;
    
    for (i=0; i<=NUM; i++) {
        hurui[i]=1;
    }
    hurui[1]=0;
    
    for (i=2; i<= NUM; i++) {
        if (hurui[i] == 1) {
            for(j = 2 * i; j <= NUM; j += i)
                hurui[j] = 0;
            
        }
    }
    
    while (1) {
        
        scanf("%d %d %d",&a,&d,&n);
        
        if(a==0&&d==0&&n==0){
            break;
        }
        
        for (i = a; i < NUM; i+=d) {
            if (hurui[i] == 1) {
                count_n++;
                if (count_n==n) {
                    printf("%d\n",i);
                    break;
                }
            }
        }
        count_n=0;
        
    }
    return 0;
}

Measured memory_bytes: 4944
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

int main() {
	ll r, D, x2;

	cin >> r >> D >> x2;

	ll x = x2;
	rep(i, 10) {

		cout << r * x - D << endl;
		x = r * x - D;
	}


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int n,a,b,c,d,e,f,g,h,x,y,z,w;
	while(1){
		cin >> n ;
		if(n==0){
			return 0;
		}
		for(int t=0;t<n;t++){
			cin >>a>>b>>c>>d>>e>>f>>g>>h;
			x=a*e-b*f-c*g-d*h;
			y=a*f+b*e+c*h-d*g;
			z=a*g-b*h+c*e+d*f;
			w=a*h+b*g-c*f+d*e;
			printf("%d %d %d %d\n",x,y,z,w);
		}
	}
	
return 0;
}

Measured memory_bytes: 1144
#coding:utf-8

n = int(input())
mtrx = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    data = list(input().split())
    adjs = int(data[1])
    for adj in range(adjs):
        j = int(data[adj+2]) - 1
        mtrx[i][j] = 1
for col in mtrx:
    print(" ".join([str(num) for num in col]))



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

using namespace std;

#define ll long long
#define ull unsigned long long

int h, w, k, s[11][1005], dp[1005];
string t;

bool check(int mask, int l, int r) {
    for (int i = 0, c = 0; i < h; i++) {
        c += s[i][r] - s[i][l];
        if (c > k) return false;
        if (mask >> i & 1) c = 0;
    }
    return true;
}

int solve(int mask) {
    for (int i = 1; i <= w; i++) dp[i] = 2e6;
    for (int i = 0; i < w; i++) {
        int j = i;
        for (int k = 512; k > 0; k >>= 1) {
            if (j + k <= w && check(mask, i, j + k)) j += k;
            if (j > i) dp[j] = min(dp[j], dp[i] + 1);
        } 
    }
    return dp[w] - 1;
}

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

    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) {
        cin >> t;
        t = '#' + t;
        for (int j = 1; j <= w; j++) {
            s[i][j] = s[i][j - 1] + (t[j] - '0');
        }
    }

    int res = 1e6;
    for (int mask = 0; mask < (1 << h - 1); mask++) {
        res = min(res, solve(mask) + __builtin_popcount(mask));
    }

    cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string s;
	cin >> s;
	int q;
	int start, end;
	cin >> q;
	while (q--) {
		string c;
		cin >> c;
		if (c == "replace") {
			string p;
			cin >> start >> end >> p;
			rep(i, p.size()){
				s[i + start] = p[i];
			}
		}
		else if (c == "reverse") {
			cin >> start >> end;
			reverse(s.begin() + start, s.begin() + end + 1);
		}
		else {
			cin >> start >> end;
			cout << s.substr(start, end - start + 1) << endl;
		}
	}
}



Measured memory_bytes: 3252
N = int(input())
A = list(map(int,input().split()))
R = [0]     #Rは累積和を格納するリストです
for i in range(N):
    R.append(R[i]+A[i])     #累積和を入れます
R.sort()
R.append(10**18)     #カウントを止めます（番兵）
cnt = 1
ans = 0
cur = R[0]     #curは今見ている累積和を表します
for i in range(1,N+2):     #番兵の所で止まるように、N+1まで数えます
    if cur == R[i]:
        cnt += 1     #curと新たに見たR[i]が等しければインクリメント
    else:
        ans += cnt*(cnt-1)//2
        cur = R[i]    #違っていたら、curをR[i]に更新
        cnt = 1     #cntを1に戻す
print(ans)

Measured memory_bytes: 26136
#include <bits/stdc++.h>
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 all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
typedef long long ll;
//
int main(){
    ll k;cin>>k;
    int ans=0;
    if(k%2==0||k%5==0){
        cout<<-1<<endl;
        return 0;
    }else{
        int t=1;
        int a=10;
        while(t<1000000){
        int b=7*a-7;
        ans=t;
        a*=10;
        a%=9*k;
        if(b%(9*k)==0)break;
        t++;
    }
    }
    if(ans!=1000000)    cout<<ans<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n; cin>>n;
    ll t; double a; cin>>t>>a;
    vector<double> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    double nin=1e10;
    ll res=-1;
    for(int i=0;i<n;i++){
        double tmp=t-h[i]*0.006;
        if(abs(tmp-a)<nin){
            nin=abs(tmp-a);
            res=i+1;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#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 <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S, T;
    cin >> S;
    cin >> T;
    unordered_map<char, int> Sbox, Tbox;
    int num = 0;
    rep(i, S.size()) {
        if (Sbox.count(S[i]) != Tbox.count(T[i])) {
            cout << "No" << endl;
            return 0;
        }
        if (Sbox.count(S[i]) > 0) {
            if (Sbox[S[i]] != Tbox[T[i]]) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            Sbox[S[i]] = num;
            Tbox[T[i]] = num;
            num++;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 916
import java.util.*;
public class Main {
	
	static int cmp=0;
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),A[]=new int[n];
		
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		
		margeSort(A,0,A.length-1);
		for(int i=0;i<n-1;i++)System.out.print(A[i]+" ");
		System.out.println(A[n-1]);
		System.out.println(cmp);
	}
	
	static void margeSort(int A[],int left,int right) {
		int middle=(left+right)/2;
		if(left<right) {
			margeSort(A,left,middle);
			margeSort(A,middle+1,right);
		}
		else return;
		
		int k=left,l=middle+1,cnt=0,B[]=new int[right-left+1];
		while(k<=middle && l<=right) {
			if(A[k]<=A[l])B[cnt++]=A[k++];
			else B[cnt++]=A[l++];
			cmp++;
		}
		
		while(k<=middle) { 
			B[cnt++]=A[k++];
			cmp++;
		}
		while(l<=right) {
			B[cnt++]=A[l++];
			cmp++;
		}
		
		for(int i=0;i<B.length;i++)A[left+i]=B[i];
	}

}




Measured memory_bytes: 110132
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++){
            cin>>a[i];
    }
    vector<bool> col(h,0);
    vector<bool> row(w,0);
    for(int i=0;i<h;i++){
        if(count(a[i].begin(),a[i].end(),'.')==w)col[i]=1;
    }
    for(int i=0;i<w;i++){
        int count=0;
        for(int j=0;j<h;j++){
            if(a[j][i]=='.')count++;
        }
        if(count==h)row[i]=1;
    }
    for(int i=0;i<h;i++){
        if(col[i])continue;
        for(int j=0;j<w;j++){
            if(!row[j])cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: n, t, a, h(1000), i, cand
  real(8) :: di, d

  read(*, *) n
  read(*, *) t, a
  read(*, *) h(1:n)

  di = abs(a - (t - h(1) * 0.006d0))
  cand = 1
  do i = 2, n
    d = abs(a - (t - h(i) * 0.006d0))
    if (di > d) then
      di = d
      cand = i
    end if
  end do
  write(*, "(i0)") cand
end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    cout << min(n%k,abs(n%k-k)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int max=0,a,i;
int count[101]={0};

while(scanf("%d",&a)!=EOF){
count[a]++;
if(max<count[a]) max=count[a];
}
for(i=0;i<100;i++){
if(max==count[i]){
printf("%d\n",i);
}
}
return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<vector>
#include<map>
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

#define INF 100000000
typedef pair<int,int> P;
int v,e,r;
int s[1000000],t[1000000],d[10000000];
int vec[500000][3];
/*
   void dijkstra(){
   priority_queue<P,vector<P>,greater<P> > pq;
   pq.push(P(0,r));
   int res[v];
   fill(res,res+v,INF);
   res[r]=0;

   while(!pq.empty()){
   P tmp=pq.top(); pq.pop();
   if(tmp.first>res[tmp.second]) continue;
   for(int i=0;i<vec[tmp.second].size();i++){
   if(res[vec[tmp.second][i].first]>res[tmp.second]+vec[tmp.second][i].second){
   res[vec[tmp.second][i].first]=res[tmp.second]+vec[tmp.second][i].second;
   pq.push(P(res[vec[tmp.second][i].first],vec[tmp.second][i].first));
   }
   }
   }
   for(int i=0;i<v;i++){
   if(res[i]==INF) printf("INF\n");
   else  printf("%d\n",res[i]);
   }
   }

*/

void bellman(){
  int res[v];
  fill(res,res+v,INF);
  res[r]=0;

  for(int i=0;i<v;i++){
    bool update=false;

    for(int cookies=0;cookies<e;cookies++){

      if(res[vec[cookies][1]]>res[vec[cookies][0]]+vec[cookies][2] && res[vec[cookies][0]]!=INF){
        res[vec[cookies][1]]=res[vec[cookies][0]]+vec[cookies][2];
        update=true;
        if(i==v-1){ printf("NEGATIVE CYCLE\n"); return;}

      }
    }
    if(!update){
      for(int i=0;i<v;i++){
        if(res[i]==INF) printf("INF\n");
        else  printf("%d\n",res[i]);
      }
      return;
    }
  }
}

  int main(){
    scanf("%d%d%d",&v,&e,&r);
    for(int i=0;i<e;i++){
      scanf("%d%d%d",&vec[i][0],&vec[i][1],&vec[i][2]);
    }



    /*  for(int i=0;i<e;i++){
        s[i+e]=t[i];
        t[i+e]=s[i];
        d[i+e]=d[i];
        }
        */

    bellman();


    return 0;
  }

Measured memory_bytes: 1220
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

N=int(input())
A=[int(i) for i in input().split()]

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

ans=1
for i in range(N):
    c=mygcd(L[i],R[i])
    ans=max(ans,c)

print(ans)


Measured memory_bytes: 16160
import math

a, b, c, x, y = map(int, input().split())

# ans = 0
# if (a + b) < 2 * c:
#     ans = a * x + b * y
# else:
#     if x > y:
#         ans = 2 * c * y + a * (x - y)
#     else:
#         ans = 2 * c * x + a * (y - x)

ans1 = a * x + b * y
ans2 = 0
if x > y:
    ans2 = 2 * c * y + a * (x - y)
else:
    ans2 = 2 * c * x + b * (y - x)
ans3 = 2 * c * max(x, y)
print(min(ans1, ans2, ans3))

        


Measured memory_bytes: 3060
using System;
using System.Text;

namespace abc148_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[]ss = Console.ReadLine().Split(' ');
            string S = ss[0];
            string T = ss[1];

            StringBuilder sb = new StringBuilder();
            for(int i=0;i<S.Length;i++) {
                    sb.Append(S[i]);
                    sb.Append(T[i]);
            }

            Console.WriteLine(sb.ToString());
        }
    }
}


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

#define INF 1e8
#define MAX_V 400

struct status {
    int cnt;
    ll fuel;
};
bool operator<(const status& x0, const status& x1) {
    return (x0.cnt == x1.cnt ? x0.fuel > x1.fuel : x0.cnt < x1.cnt);  //<で昇順
}
status d[MAX_V][MAX_V];
bool visited[MAX_V];
ll cost[MAX_V][MAX_V];
ll V, E, L;

// 頂点rからの最小距離
void dijkstra(int r) {
    for (int i = 0; i < V; i++) {
        d[r][i] = (status){(int)INF, 0};
    }
    fill(visited, visited + MAX_V, false);
    d[r][r] = (status){0, L};

    while (true) {
        int v = -1;
        for (int u = 0; u < V; u++) {
            if (!visited[u] && (v == -1 || d[r][u] < d[r][v])) v = u;
        }
        if (v == -1) break;
        visited[v] = true;

        for (int u = 0; u < V; u++) {
            ll remain = d[r][v].fuel;
            if (remain >= cost[v][u])
                d[r][u] = min(d[r][u], (status){d[r][v].cnt, remain - cost[v][u]});
            else if (L >= cost[v][u])
                d[r][u] = min(d[r][u], (status){d[r][v].cnt + 1, L - cost[v][u]});
        }
    }
}

int main() {
    cin >> V >> E >> L;
    fill(cost[0], cost[MAX_V], 1e18);
    for (int i = 0; i < E; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        cost[a][b] = c;
        cost[b][a] = c;
    }
    for (int i = 0; i < V; i++) {
        dijkstra(i);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        if (d[s][t].cnt == INF)
            cout << -1 << endl;
        else
            cout << d[s][t].cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define F 204514810
using namespace std;
int h,w,n;
vector<pair<int,int> >v;
priority_queue<int,vector<int>,greater<int> > Q;
int main(){
	cin>>h>>w>>n;
	for(int i=0;i<n;i++){
		int a,b,c,d;int k[4]={0,0,0,0};
		cin>>a>>b>>c>>d;
		if(a==0||a==h)k[0]=1;
		if(b==0||b==w)k[1]=1;
		if(c==0||c==h)k[2]=1;
		if(d==0||d==w)k[3]=1;
		if(k[0]+k[1]>0&&k[2]+k[3]>0){
			if(b==0)k[0]=a;
			if(a==h)k[0]=F+b;
			if(b==w)k[0]=3*F-a;
			if(a==0)k[0]=4*F-b;
			
			if(d==0)k[1]=c;
			if(c==h)k[1]=F+d;
			if(d==w)k[1]=3*F-c;
			if(c==0)k[1]=4*F-d;
			
			if(k[0]>k[1]){
				int t=k[0];
				k[0]=k[1];
				k[1]=t;
			}
			v.push_back(make_pair(k[0],k[1]));
		}
	}
	sort(v.begin(),v.end());
	bool ok=true;
	for(int i=0;i<v.size()-1;i++){
		Q.push(v[i].second);
		while(!Q.empty()){
			if(Q.top()>v[i+1].first)break;
			Q.pop();
		}
		if(!Q.empty()){
			if(Q.top()>v[i+1].first&&Q.top()<v[i+1].second){
				ok=false;
			}
		}
	}
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 1524
package main

import (
  "fmt"
)

func main() {
  var n int 
  var s, t string 
  fmt.Scan(&n, &s, &t)
  res := ""
  for i := 0; i < n; i++ {
    res += string(s[i]) + string(t[i])
  }
  fmt.Println(res)
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
    char a;
    char b;
    char c;
    char d;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    if( a == b || b==c || c==d){
        cout << "Bad";
    }else{
        cout << "Good";
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const long long INF = 1E18;

long long x,y;
int n;
long long MIN_1 = INF, MIN_2 = INF;
long long MAX_1 = -INF, MAX_2 = -INF;

int main()
{
    fastIO
    cin>>n;
    
    for (int i = 1;i <= n;++i) 
    {
        cin>>x>>y;
        MIN_1 = min(MIN_1,(x+y));
        MAX_1 = max(MAX_1,(x+y));
        MIN_2 = min(MIN_2,(x-y));
        MAX_2 = max(MAX_2,(x-y));
    }
    
    cout<<max(abs(MIN_1-MAX_1),abs(MIN_2-MAX_2));
}

Measured memory_bytes: 3648