akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int d, g, in, inn;
	vi p, c;
	cin >> d >> g;
	rep(i, d) {
		cin >> in >> inn;
		p.push_back(in);
		c.push_back(inn);
	}
	int best = INF;
	rep(i, 1 << d) {
		int score = 0;
		int num = 0;
		rep(j, d) {
			if (i&(1 << j)) {
				score += (c[j] + 100 * (j + 1) * p[j]);
				num += p[j];
			}
		}
		for (int j = d - 1; j >= 0; j--) {
			if (!(i&(1 << j))) {
				rep(k, p[j] - 1) {
					if (score < g) {
						score += (100 * (j + 1));
						num++;
					}
				}
			}
		}
		if(score>=g)best = min(best, num);
	}
	cout << best << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;};


typedef struct node * Node;
#define NIL NULL
 
Node root;
int count=0,count2=0;

Node treeMinimum(Node x){
  while (x->left != NIL){
    x = x->left;}
   
  return x;
}
 
 
 
Node IterativetreeSearch(Node u, int k){
  while(u !=NIL && k !=u->key){
    if(k < u->key){
      u = u->left;
 
    }
 
    else u = u->right;
  }
  return u;
 
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
 
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}


void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  if(z->left == NIL || z->right == NIL){
    y = z;
  }
  else {
    y = treeSuccessor(z);
  }
 
  if(y->left != NIL){
    x = y->left;
  } 
  else {
    x = y->right;
  }
 
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }
  else if(y == y-> parent ->left){
    y->parent->left =x;
  }
  else y-> parent -> right = x;
 
   
  if(y != z){
    z->key = y->key;
  } 
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right; 
  }
  z->parent = y;
 
  if(y == NIL){
    root = z;
  }
  else if (z->key < y->key){
    y->left = z;
  }
   
  else y->right = z;
}
 
void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
  
}
 
 
 
 
void preorder(Node u){
   
   
  if (u != NIL) {
    printf(" ");
    printf("%d",u->key); 
    preorder(u->left);
    preorder(u->right);
     
  
     
  }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);


  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = IterativetreeSearch(root, x);
      if ( t != NIL ){
	printf("yes\n");}

      
      else {
	printf("no\n");
      }
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
     
 
    else if ( com[0] == 'p' ){
     
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      count = 0;
     
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(IterativetreeSearch(root, x));
    }
  }
 
  return 0;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;

ll a[maxn];

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

ll lcm(ll a, ll b)
{
  return a * (b / __gcd(a,b));
}

char f(char c)
{
  if(c == 'r')
    return 'p';
  else if(c == 'p')
    return 's';
  else
    return 'r';
}

int main()
{

  ios::sync_with_stdio(0);
  int n,k,r,s,p;
  string t;
  cin >> n >> k >> r >> s >> p;
  cin >> t;
  map<char,int>vals;
  vals['r'] = r;
  vals['s'] = s;
  vals['p'] = p;
  string history;
  int res = 0;
  for(int i = 0; i < k; i++)
    history += 'a';
  for(int i = 0; i < n ; i++)
  {
    char x = f(t[i]);
    if(i - k >= 0)
    {
      char y = history[i % k];
      if(y != x)
      {
        history[i % k] = x;
        res += vals[x];
      }
      else
        history[i % k] = 'a';
    }
    else
    {
      res += vals[x];
      history[i % k] = x;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3788
#include<iostream>

using namespace std;

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


	int K = N;
	int ans = 100 * (10 - K);

	if (N >= 10) {
		cout << R << endl;
	}
	else cout << R + ans << endl;

	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e6 + 5;
const int MOD = 1e9 + 7;

int pow(int a, int b, int m)
{
  int ans=1;
  while(b)
  {
    if(b&1)
      ans=(ans*a)%m;
    b/=2;
    a=(a*a)%m;
  }
  return ans;
}

int fact[N], invfact[N];

int modinv(int k)
{
  return pow(k, MOD-2, MOD);
}

void precompute()
{
  fact[0]=fact[1]=1;
  for(int i=2;i<N;i++)
  {
    fact[i]=fact[i-1]*i;
    fact[i]%=MOD;
  }
  invfact[N-1]=modinv(fact[N-1]);
  for(int i=N-2;i>=0;i--)
  {
    invfact[i]=invfact[i+1]*(i+1);
    invfact[i]%=MOD;
  }
}

int nCr(int x, int y)
{
  if(y>x)
    return 0;
  int num=fact[x];
  num*=invfact[y];
  num%=MOD;
  num*=invfact[x-y];
  num%=MOD;
  return num;
}

int n, k;
string s;

int32_t main()
{
  IOS;
  precompute();
  cin >> k >> s;
  n = s.size();
  int ans = 0;
  for(int len = n; len <= n + k; len++)
  {
    int cur = pow(26, n + k - len, MOD) * pow(25, len - n, MOD);
    cur %= MOD;
    cur *= nCr(len - 1, n - 1);
    cur %= MOD;
    ans += cur;
    ans %= MOD;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 35492
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <functional>
#include <algorithm>
using namespace std;

const int N = 16;

int n, k;
char a[N], b[N], buf[N];

bool ok() {
  for(int i = 0; buf[i]; i++) if(b[buf[i]]) return false;
  return true;
}

int main() {
  cin >> n >> k;
  for(int i = 0; i < k; i++) scanf(" %c", &a[i]), b[a[i]] = true;
  sprintf(buf, "%d", n);
  while(!ok()) n++, sprintf(buf, "%d", n);
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool ac[100001];
int points[100001];
int main() {
    int n,m;
    cin>>n>>m;
    int x;
    string s;
    int ans1=0,ans2=0;
    while (cin>>x>>s) {
        if (ac[x]==true)
            continue;
        if (s=="AC") {
            ac[x]=true;
            ans1++;
            continue;
        }
        points[x]++;
    }
    for (int i=1;i<=100000;i++)
        if (ac[i]==true)
        ans2+=points[i];
    cout<<ans1<<" "<<ans2<<endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main
{

	// 絶対値を求める関数
	static int abs(int a)
	{
		if (a < 0) {
			a = -a;
		}
		return a;
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int p[] = new int[200];

		int m = sc.nextInt();
		int nMin = sc.nextInt();
		int nMax = sc.nextInt();

		while (m + nMin + nMax > 0) {

			// 得点を入力
			for (int i = 0;i < m;i++) {
				p[i] = sc.nextInt();
			}

			// ギャップの最大値（最初は0を入れておく）
			int bestGap = 0;

			// ギャップが最大になるときの合格者数
			int bestN = nMin;

			for (int n = nMin;n <= nMax;++n) {
				// 合格者の中の最低点
				int x = p[n - 1];

				// 不合格者の中の最高点
				int y = p[n];

				// ギャップが最大ならば更新
				// （タイの場合も合格者数を最大にしたいので更新）
				if (x - y >= bestGap) {
					bestGap = x - y;
					bestN = n;
				}
			}

			System.out.println(bestN);

			m = sc.nextInt();
			nMin = sc.nextInt();
			nMax = sc.nextInt();
		}
	}
}



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

int main() {
    int h, w;
    cin >> h >> w;
    int a[h][w];
    rep(y, h) rep(x, w) cin >> a[y][x];
    vector<vector<int>> actions;

    int ans = 0;
    rep(y, h) rep(x, w) {
        if (a[y][x] % 2 == 0 || (y == h - 1 && x == w - 1)) continue;

        int dy = y + 1, dx = x + 1;
        if (dx < w && a[y][dx] % 2 == 1) {
            a[y][x]--;
            a[y][dx]++;
            actions.push_back({y + 1, x + 1, y + 1, dx + 1});
        } else if (dy < h && a[dy][x] % 2 == 1) {
            a[y][x]--;
            a[dy][x]++;
            actions.push_back({y + 1, x + 1, dy + 1, x + 1});
        } else if (dx < w) {
            a[y][x]--;
            a[y][dx]++;
            actions.push_back({y + 1, x + 1, y + 1, dx + 1});
        } else if (dy < h) {
            a[y][x]--;
            a[dy][x]++;
            actions.push_back({y + 1, x + 1, dy + 1, x + 1});
        }

        ans++;
    }

    cout << ans << endl;
    for (auto e : actions) {
        rep(i, 3) cout << e[i] << ' ';
        cout << e[3] << endl;
    }
    return 0;
}


Measured memory_bytes: 9904
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,P;
  cin>>A>>P;
  cout<<(3*A+P)/2<<endl;
}


Measured memory_bytes: 256
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 2e6 + 10;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p = M)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}

vector<int> graph[MAX];
int vis[MAX];

void dfs(int v)
{
	vis[v] = 1;

	for (auto x : graph[v]) {

		if (vis[x] == 0)
		{
			dfs(x);
		}

	}
}

void solve()
{ 
    int n;
    cin>>n;
	
	if(n==1)
	cout<<0<<"\n";
	else
	cout<<1<<"\n";

}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	//cerr << "\n" << "Time elapsed : " << time_passed << "\n";
	return 0;
}

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

public class Main {
	
	public static long gcd(long a, long b) {
		if(a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if(b == 0)return 1;
		long r = a % b;
		if(r == 0)return b;
		return gcd(b, r);
	}
	
	public static long lcm(long t[]) {
		int n = t.length;
		long ans = t[0];
		for(int i = 0; i < n; ++i) {
			long g = gcd(t[i], ans);
			long tmp = ans;
			if(tmp <= 0)tmp = 1;
			ans = t[i] / g;
			ans *= tmp;
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n;
		long t[];
		n = sc.nextInt();
		t = new long[n];
		for(int i = 0; i < n; ++i)t[i] = sc.nextLong();
		sc.close();
		
		Arrays.sort(t);
		long ans = lcm(t);
		System.out.println(ans);;
		
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
using namespace std;

int main() {
  int r;
  cin >> r;
  cout << r * 2 * 3.14;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   string a,b;
   cin>>a>>b;
   int c=stoi(a+b);
   bool s=false;

   for(int i=1;i<1000;i++){
      if(i*i==c) s=true;
   }
   (s)? cout<<"Yes":cout<<"No";


   


   
   return 0;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P, X = [0] * M, [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())

for i in range(M):
    t_sum = X[i]
    for j in range(N):
        if j == P[i] - 1:
            continue
        t_sum += T[j]
    print(t_sum)

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int a , b , c ;
  scanf("%d %d %d", &a, &b,&c) ; 

  for(int i = 1 ;i<=101 ; i++){
    if((a*i)%b == c){
      printf("YES") ;
      return 0 ;
    }
  }
  printf("NO") ;
	
  return 0 ;
}



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

const int MaxM = 3000;
const int MaxN = 3000;
const int M = 1000000007;

int n, m;

int f[MaxM + 1][MaxN + 1][2];

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

	for (int i = 0; i <= n; ++i)
		f[0][i][i == 0] = 1;
	for (int i = 1; i <= m; ++i)
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k < 2; ++k)
			{
				int cur = f[i - 1][j][k];
				if (cur == 0)
					continue;

				if (j > 0)
				{
					int l = j - 1;
					int x = k || (j == 1);

					f[i][j][x] += cur;
					if (f[i][j][x] >= M)
						f[i][j][x] -= M;

					f[i][l][x] += cur;
					if (f[i][l][x] >= M)
						f[i][l][x] -= M;
				}

				if (j < n)
				{
					int l = j + 1;
					int x = k;

					f[i][j][x] += cur;
					if (f[i][j][x] >= M)
						f[i][j][x] -= M;

					f[i][l][x] += cur;
					if (f[i][l][x] >= M)
						f[i][l][x] -= M;
				}
			}

	int res = 0;
	for (int i = 0; i <= n; ++i)
		res = (res + f[m][i][1]) % M;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 70656
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		char[] X = sc.next().toCharArray();
		
		int pop = popcount(X);
		int[] baseMod1 = new int[N];
		int[] baseMod2 = new int[N];
		for(int i=N-1; i>=0; i--) {
			if(pop+1<=N)
				baseMod1[i] = (i==N-1 ? 1 : baseMod1[i+1]*2)%(pop+1);
			if(pop-1>0)
				baseMod2[i] = (i==N-1 ? 1 : baseMod2[i+1]*2)%(pop-1);
		}
		
		int mod1 = 0;
		int mod2 = 0;
		for(int i=0; i<N; i++) {
			if(pop+1<=N)
				mod1 = (mod1 + (X[i]-'0')*baseMod1[i])%(pop+1);
			if(pop-1>0)
				mod2 = (mod2 + (X[i]-'0')*baseMod2[i])%(pop-1);
		}
		
		for(int i=0; i<N; i++) {
			if(X[i]=='0') {
				pw.println(1 + f((mod1+baseMod1[i])%(pop+1)));
			} else {
				pw.println(pop==1 ? 0 : 1 + f(((mod2-baseMod2[i]+pop-1))%(pop-1)));
			}
		}
		
		pw.close();
		sc.close();
	}
	
	static int f(int x) {
		int ans = 0;
		while(x>0) {
			x = x%popcount(x);
			ans++;
		}
		return ans;
	}
	
	static int popcount(int x) {
		int ans = 0;
		while(x>0) {
			ans += x&1;
			x>>=1;
		}
		return ans;
	}
	
	static int popcount(char[] x) {
		int ans = 0;
		for(char c : x)
			if(c=='1')
				ans++;

		return ans;
	}
}


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

int func(string s, char c)
{
  int ret = 0, l = s.size(), cnt = 0;
  for(int i = 0; i < l; i++) if(s[i] == c) cnt++;
  if(cnt == l) return 0; 

  while(l > 1){
    ret++;
    
    cnt = 0;
    for(int i = 0; i < l-1; i++){
      if(s[i] == c or s[i+1] == c){
        s[i] = c;
        cnt++;
      }
    }

    if(cnt == l-1) return ret;
    l--;
  }

  return s.size()-1;
}

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

  int ans = 1e+9;
  for(int i = 0; i < 26; i++){
    ans = min(ans, func(s, 'a' + i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq

n, m = [int(i) for i in input().split()]

a = [-int(i) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, heapq.heappop(a) / 2)
print(-sum([int(heapq.heappop(a)) for _ in range(n)]))


Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=b*10; i<=10*b+9; i++){
    if((i*8)/100==a){
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    const int MXX = 100 + 5;

    int a[MXX];
    int main ()
    {
        int n;
        cin>>n;
        int mx = -200; ll ans = 1e9;
        for(int i = 0; i<n; i++)cin>>a[i], mx = max(a[i], mx);
        for(int i = -100; i<=mx; i++)
        {
            ll make = i, cost = 0;
            for(int j = 0; j<n; j++)
            {
                if(a[j] == make)continue;
                ll x = a[j] - make;
                x*=x;
                cost+=(x);
            }
            ans = min(cost, ans);
        }
        if(ans == 1e9) ans = 0;
        cout<<ans<<endl;
        return 0;
    }


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

#define rep(x, n) for(int i = x; i < (n); ++i)

using namespace std;
using ll = long long;

int main(void)
{
  int k;
  cin >> k;
  int res = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i % 2 == 0 && j % 2 == 1) ++res;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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

int b[1000000];

int main(){
  int N;
  cin >> N;
  int a[N+1];
  rep(i,N) cin >> a[i+1];
  for(int i = N; i > 0; i--){
    int cnt = N/i;
    int sum = 0;
    rep(j,cnt){
      sum += b[(j+1)*i];
      sum %= 2;
    }
    if(sum == a[i]) b[i] = 0;
    else b[i] = 1;
  }
  vector<int> v;
  int ans = 0;
  rep(i,N+1) if(b[i]){
    ans++;
    v.push_back(i);
  } 
  cout << ans << endl;
  if(ans){
    rep(i,N){
      if(b[i+1]) cout << i+1 << " ";
    }
  }
  return 0;
}




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



bool has3(int i){
    while(i){
        if(i % 10 == 3){
            return true;
        }
        i /= 10;
    }
    return false;
}

void call(int n){
    for(int i = 3; i <= n; i++){
       if(i % 3 == 0 || has3(i)){
           cout << " " << i;
       }
    }
    cout << endl;
}



int main(){
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 1160
//#include "pch.h"
#include <iostream>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

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

	int n;
	cin >> n;
	
	vector<string> s(n);
	vector<int> p(n);
	FOR(i,0,n) cin >> s[i] >> p[i];
	
	vector<string> s_c = s;
	sort(s_c.begin(), s_c.end());
	auto iter = unique(s_c.begin(), s_c.end());
	s_c.erase(iter, s_c.end());
	
	//cout << "s_c:" << endl;
	//FOR(i,0,s_c.size()) cout << s_c[i] << endl;
	//cout << endl;
	
	
	vector<vector<int>> vals(n);
	FOR(i,0,n){
	    auto iter = find(s_c.begin(), s_c.end(), s[i]);
	    int index = distance(s_c.begin(), iter);
	    //cout << index << endl;
	    vals[index].push_back(p[i]);
	}
	
	
	
	//各sに対してソート
	FOR(s, 0, n) {
		sort(vals[s].begin(), vals[s].end(), greater<int>());
	}
	
	//cout << "vals:" << endl;
	//FOR(i,0,n){
	//    FOR(j,0,vals[i].size()) cout << vals[i][j] << ", ";
	//    cout << endl;
	//}
	//cout << endl;
	
	//cout << "p:" << endl;
	//FOR(i,0,n) cout << i << ", " << p[i] << endl;
	//cout << endl;
	
	FOR(si,0,s_c.size()) FOR(pi,0,vals[si].size()){
	    int tmp = vals[si][pi];
	    
	    //cout << "tmp: " << tmp << endl;
        //vals[v]の中からp以上の値が出てくる最初のイテレータを返す
        auto iter2 = find(p.begin(), p.end(), tmp);
	    int index2 = distance(p.begin(), iter2);
        
	    cout << index2 + 1 << endl;
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n, m;
  cin >> n >> m;
  int p[100000], y[100000];
  vector<ll> yd[100001];
  rep(i,m) {
    int pi, yi;
    cin >> pi >> yi;
    p[i] = pi;
    y[i] = yi;
    yd[pi].push_back(yi);
  }
  //rep (i,m) scanf ("%d%d",&p[i],&y[i]), yd[p[i]].push_back(y[i]);
  rep (i,n) sor(yd[i+1]);
  rep (i,m) printf ("%012lld\n", ll(p[i])*1000000+ int(lb(yd[p[i]], y[i]) - yd[p[i]].begin())+1);
  return 0;
}


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

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << max(a, max(b, c)) * 9 + a + b + c << endl;
}

Measured memory_bytes: 256
# coding: utf-8
N=int(input())
L=["AC","WA","TLE","RE"]
cnt=[0,0,0,0]

for i in range(N):
    s=input()
    for j in range(4):
        if s==L[j]:
            cnt[j]+=1

for i in range(4):
    print("{} x {}".format(L[i],cnt[i]))

Measured memory_bytes: 8948
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll n;
  std::cin >> n;
  std::vector< ll > va(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> va[i];
  }

  // +, -, +, -, ...
  ll ans1 = 0;
  ll sum1 = 0;
  for (int i = 0; i < n; i++) {
    sum1 += va[i];
    if (i % 2 == 0) {  // sum +
      if (sum1 > 0) {
	ans1 += 0;
	sum1 += 0;
      } else {
	ans1 += std::fabs(sum1) + 1;
	sum1 = +1;
      }
    } else {           // sum -
      if (sum1 < 0) {
	ans1 += 0;
	sum1 += 0;
      } else {
	ans1 += std::fabs(sum1) + 1;
	sum1 = -1;
      }
    }
    //std::cout << i << " " << sum1 << " ans1 " << ans1 << std::endl;
  }

  // -, +, -, +, ...
  ll ans2 = 0;
  ll sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum2 += va[i];
    if (i % 2 == 0) {  // sum -
      if (sum2 < 0) {
	ans2 += 0;
	sum2 += 0;
      } else {
	ans2 += std::fabs(sum2) + 1;
	sum2 = -1;
      }
    } else {           // sum +
      if (sum2 > 0) {
	ans2 += 0;
	sum2 += 0;
      } else {
	ans2 += std::fabs(sum2) + 1;
	sum2 = +1;
      }
    }
    //std::cout << i << " " << sum2 << " ans2 " << ans2 << std::endl;
  }
  
  std::cout << std::min(ans1, ans2) << std::endl;

  return 0;
}



Measured memory_bytes: 1024
'use strict';
const main = input => {
  input = input[0].split(' ').map(val => parseInt(val, 10));
  const a = input[0], b = input[1];
  console.log(Math.max(a+b,a-b,a*b));
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
import scala.io.StdIn.{readLine, readInt}

object Main {

  def factorize(p:Long,d:Long,l:Set[Long]):Set[Long] = {
    if(d >= Math.sqrt(p)+1) {
      if(p != 1) l+p else l
    } else {
      if(p%d == 0)
        factorize(p/d,d,l+d)
      else if(d==2)
        factorize(p,d+1,l)
      else
        factorize(p,d+2,l)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    val l = factorize(n,2,Set())
    var pi = n.toLong
    for(i <- l) {
      pi = (pi*(i-1))/i
    }
    println(pi)
  }
}

Measured memory_bytes: 43768
#include <bits/stdc++.h>
using namespace std;
int main(void) {
   int n;
   std::cin >> n;
   std::vector<int> a(n);
   int count = 0;
   for (size_t i = 0; i < n; i++) {
      std::cin >> a.at(i);
   }

   for (size_t i = 1; i < n; i++) {
      if (a.at(i) == a.at(i-1)) {
         a.at(i) = 0;
         count++;
      }
   }

   std::cout << count << '\n';

   return 0;
}


Measured memory_bytes: 256
n = int(input())
dic = {}

for i in range(n):
    inp = list(map(int, input().split()))
    dic[inp[0]] = inp[1]

dic = sorted(dic.items())
ans = 1
pre = dic[0][0]+dic[0][1]
fidx = 0
for i in range(1, n):
    n_s = dic[i][0]+dic[i][1]
    if pre > n_s:
        pre = n_s
        fidx = i
idx = fidx

for i in range(fidx+1, n):
    if dic[idx][0]+dic[idx][1] > dic[i][0]-dic[i][1]:
        if dic[idx][0]+dic[idx][1] > dic[i][0]+dic[i][1]:
            idx = i
    else:
        ans += 1
        idx = i


print(ans)


Measured memory_bytes: 23072
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):
	a(x,3,x)
	for t in r(i,i+30):b(p:=t+1);a(q:=p+1,3,q),*map(b,r(q,v:=i+31));a(v,x,t,1);b(p);a(q,t,q)
p(3934)
a(0,1,3)
a(2,3,3,1)
d(0,9)
d(1,50)
for t in r(60):a(2,2,2);[t-31<s<30!=(a(8+t-s,50+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9336
#include<cstdio>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	int res = 0;
	for(int i = 0; i < n; i++){
		int a; scanf("%d", &a);
		res += a - 1;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
<?php
$h=(int)fgets(STDIN);
$w=(int)fgets(STDIN);
$n=(int)fgets(STDIN);
if($n<=$h&&$n<=$w){
echo 1;exit();
}
if($h<$w){
  $s=$h;$l=$w;
}else{
  $s=$w;$l=$h;
}
if($n<=$l){echo 1;exit();}
$c=floor($n/$l);
$a=(int)($n%$l!=0);
echo $c+$a;




Measured memory_bytes: 4728
import java.util.Scanner;
public class Main{
    public static void main(String[] args)
   {
	Scanner scan = new Scanner(System.in);
	
	int num1 = scan.nextInt();
	int num2 = scan.nextInt();

	int sum,length;

	sum = num1*num2;
	length = num1*2+num2*2;

	System.out.println(sum+" "+length);

	
    }
}

Measured memory_bytes: 26100
open System

let A = stdin.ReadLine()
let B = stdin.ReadLine()

let comp (s :String) (t :String) = 
    match (s, t) with
        | (s, t) when s.Length <> t.Length -> s.Length.CompareTo t.Length
        | (s, t) -> s.CompareTo t

let show x = 
    match x with
        | 1 -> "GREATER"
        | -1 -> "LESS"
        | _ -> "EQUAL"

comp A B |> show |> printfn "%s"


Measured memory_bytes: 14172
import sys
for n in sys.stdin:
    num = 0
    n = int(n.replace("\n",""))
    for i in range(0, 10000):
        s = sum([i%10, int(i/10)%10, int(i/100)%10, int(i/1000)])
        if n == s:
            num += 1
    print(num)

Measured memory_bytes: 7624
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    map<char, int> data;
    rep(i, n) {
        data[s[i]]++;
    }
    string ans = "Yes";
    if (data['E'] + data['W'] != 0 && data['E'] * data['W'] == 0) {
        ans = "No";
    }
    if (data['N'] + data['S'] != 0 && data['N'] * data['S'] == 0) {
        ans = "No";
    }
    cout << ans << endl;
 	return 0;
}

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

using ll = long long;

int main() {
	int n;
	scanf("%d", &n);
	vector<ll> v(n);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	queue<ll> q;
	q.push(v.back());
	for(int i=n-2;i>=0;i--) {
		ans += q.front();q.pop();
		q.push(v[i]);
		q.push(v[i]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	string s;
	cin>>a>>s;
	if(a>=3200) cout<<s<<'\n';
	else cout<<"red"<<'\n';
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc128/tasks/abc128_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        restaurants: [(chars, i32); n]
    };
    let mut restaurants = restaurants.into_iter().zip(0..n).map(|(r, idx)| (r.0, -r.1, idx)).collect::<Vec<_>>();
    restaurants.sort();
    for r in restaurants {
        println!("{}", r.2+1);
    }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] v = new long[n];
    for(int i = 0; i < n; i++) {
      v[i] = sc.nextLong();
    }
    long ans = 0;
    for(int a = 0; a <= Math.min(n, k); a++) {
      for(int b = 0; a + b <= Math.min(n, k); b++) {
        ArrayList<Long> list = new ArrayList<Long>();
        for(int c = 0; c < a; c++) {
          list.add(v[c]);
        }
        for(int c = n - 1; c >= n - b; c--) {
          list.add(v[c]);
        }
        Collections.sort(list);
        long sum = 0;
        for(int i = 0; i < a + b; i++) {
          sum += list.get(i);
        }
        for(int i = 0; i < Math.min(k - a - b, a + b); i++) {
          if(list.get(i) < 0) sum -= list.get(i); 
        }
        ans = Math.max(ans, sum);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long


int main()
{
	int N, M, T[110], P[110], X[110];
	int sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i]; 
		sum += T[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) cin >> P[i] >> X[i];
	for (int i = 0; i < M; i++) {
		cout << sum - T[P[i] - 1] + X[i] << endl;
	}
}


Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    stores = [string_to_int(i) for i in inputs]
    wants = M
    money = 0
    for price, num in sorted(stores, key=lambda i: i[0]):
        if wants > num:
            money += price * num
            wants -= num
        else:
            money += price * wants
            break

    return money


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N))
    print(ret)


Measured memory_bytes: 37264
#include <stdio.h>
long long dp[101][100000];
long long max(long long x,long long y){
    if(x>y) return x;
    else return y;
}
int main(void){
    int n,w,i,j;
    scanf("%d%d",&n,&w);
    long long weight[n],value[n];
    for(i=0;i<n;i++) scanf("%lld%lld",&weight[i],&value[i]);
    for(i=0;i<n;i++){
        for(j=0;j<=w;j++){
            if(j-weight[i]>=0){
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
            }
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    printf("%lld",dp[n][w]);
}

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

string S;

int main() {
    cin >> S;

    long long ans = 0;
    int s_size = S.size();

    stack<char> st;
    for (int i = 0; i < s_size; i++) {
        if (st.empty()) {
            st.push(S[i]);
            continue;
        }

        if (st.top() == S[i]) {
            st.push(S[i]);
            continue;
        }

        // 異なるなら消す
        st.pop();
        ans += 2;
        // cout <<  st.top() << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int parent(int i){ return i/2;}
int left(int i){ return i*2;}
int right(int i){ return i*2+1;}
int main(){
  int H,tree[100001];
  scanf("%d",&H);
  for(int i=1;i<=H;i++) scanf("%d",&tree[i]);
  for(int i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,tree[i]);
    if(parent(i)>=1) printf("parent key = %d, ",tree[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",tree[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",tree[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
	int r, c;
	int matrix[101][101] = {};

	cin >> r >> c;

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> matrix[i][j];
		}
	}

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			matrix[i][c] += matrix[i][j];
		}
	}

	for (int j = 0; j < c + 1; j++) {
		for (int i = 0; i < r; i++) {
			matrix[r][j] += matrix[i][j];
		}
	}


	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			printf("%d", matrix[i][j]);

			if (j != c) cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
using System;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            float t, x;
            float ans;
            string[] str = Console.ReadLine().Split(' ');
            t = float.Parse(str[0]);
            x = float.Parse(str[1]);
            ans = t / x;
            Console.WriteLine(ans);
        }
    }
}

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



int main() {
  long long N,count=0;
  cin >> N;
  
  for(long long i = 1;i <= N;i++){
    if(i % 3 == 0 || i % 5 == 0){
    }else{
      count += i;
    }
  }
  cout << count << endl;
 
  

}


Measured memory_bytes: 3640
/*
ID: lyr14721
PROG: 
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int a[N];
int n;
int main() {
	int n;
	vector<int> v;
	v.clear();
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int k=1;
	for(int i=1;i<=n;i++) {
		if(a[i]==k) {
			v.push_back(a[i]);
			k++;
		}
	}
	int ans=v.size();
	if(v.empty()) cout<<-1;
	else cout<<n-ans;
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char> (w));
    vector<vector<int>> dp(h,vector<int> (w,0));
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    bool wall = false;
    rep(i,h){
        if(a[i][0]=='#'){
            wall=true;
        }
        if(wall){
            dp[i][0] = 0;
        }
        else{
            dp[i][0] = 1;
        }
    }
    wall= false;
    rep(j,w){
        if(a[0][j]=='#'){
            wall=true;
        }
        if(wall){
            dp[0][j] = 0;
        }
        else{
            dp[0][j] = 1;
        }    
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(a[i][j]=='.'){
                dp[i][j]= (dp[i-1][j]+dp[i][j-1])%big;
            }
        }
    }
    /*
    rep(i,h){
        rep(j,w){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 5248
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int H, W;
            while(true)
            {
                string[] str = Console.ReadLine().Split(' ');
                H = int.Parse(str[0]);
                W = int.Parse(str[1]);

                if((H == 0)&&(W == 0))
                    break;

                for(int i = 0;i < H; ++i)
                {
                    for(int j = 0;j < W;++j)
                        Console.Write("#");
                    Console.Write("\n");
                }

                Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 5296
import sys
import re
import math
import itertools
def create_edge(fr,to,weight,si):
    edges = []
    if si == '-':
        edges.append((fr,to,weight if to else 0))
        edges.append((to,fr,0))
    else:
        edges.append((to,fr,-weight))
    return edges
#????????????????????´???-1?????????
def bellmanford(edges, length):
    start_vertex = 0
    
    distance = [float('inf')] * length
    distance[start_vertex] = 0
    
    for i in range(length):
        for fr, to, weight in edges:
            if distance[to] > distance[fr] + weight:
                distance[to] = distance[fr] + weight

    for fr, to, weight in edges:
        if distance[to] > distance[fr] + weight:
           return -1
    if min(distance[1:]) < 0:
        return -1
    return max(distance)
f = sys.stdin


n,c = map(int, f.readline().split())

p = re.compile('(\d+)(\D+)(\d+)(\D+)(\d+)')
constraints = [p.match(line).groups() for line in f]

fixed_edges = []
floating_edges = []
for ai, oi, bi, si, di in constraints:
    fr,to,weight = int(ai) - 1,int(bi) - 1,int(di)

    if oi == '*':
        if fr and to:
            floating_edges.append((create_edge(fr,to,weight,si),create_edge(to,fr,weight,si)))
            continue
        oi = '<=' if fr < to else '>='

    if oi == '>=':
        fr, to = to, fr
    
    fixed_edges.extend(create_edge(fr,to,weight,si))
distance = []
for edges in itertools.product(*floating_edges):
    distance.append(bellmanford(fixed_edges + [y for x in edges for y in x], n))
print(max(distance))

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

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back
#define ll  long long
#define mod 1000000007
#define pii pair<int, int>
#define pie 2.0*acos(0.0)

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

    int x = a * b;
    if (x % 2) cout << "Odd" << endl;
    else cout << "Even" << endl;
}

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

P=[0]*(N+1)
C=[0]*(N+1)
L=[[0]for i in range(N+1)]
#print(L)

for i in range(2,N+1):
    a=int(input())
    P[i]=a
    C[a]+=1
#print(P)
#print(C)

A=[]
for i in range(2,N+1):
    if C[i]==0:
        A.append(i)
#print(A)
for i in range(10**6):
    if len(A)<=i:
        break
    else:
        L[A[i]].sort(reverse=True)
        for j in range(len(L[A[i]])):
            L[A[i]][j]+=j+1
        L[P[A[i]]].append(max(L[A[i]]))
        C[P[A[i]]]-=1
        if C[P[A[i]]]==0:
            A.append(P[A[i]])
print(max(L[0])-1)
#print(L)

Measured memory_bytes: 66848
#include<stdio.h>

int main()
{
int h,m,s,S;
scanf("%d",&s);
h = s / 3600;
m = s / 60 - 60*h;
S = s - 3600 * h - 60 * m;
printf("%d:%d:%d\n",h,m,S);
return 0;
}

Measured memory_bytes: 592
cnt = gets.chomp.to_i
numbers = gets.chomp.split
cnt.times do |i|
	numbers[i]=numbers[i].to_f
end
numbers.sort!
if numbers[0]==numbers[cnt-1]
	puts numbers[0]
else
	result=numbers[0]
	(cnt-1).times do |i|
		result=(result+numbers[i+1])/2
	end
	puts result
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define REV(i,a,b) for(i=a-1;i>=b;i--)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define mp make_pair
#define ord(v) sort(v.begin(),v.end());
const ll MAXN=2*1e5+10;
#define MAX 2*1e9
#define fi first
#define se second
#define pi 3.141592653589793238
#define rem 1000000007
#define eps 1e-9
// fflush(stdout);
//lower_bound,upper_bound,equal_range
void dfs(int x,vector<vector<int>>&v,vector<bool>&visit,vector<int>&dp)
{
	visit[x]=true;
	for(int i=0;i<v[x].size();i++)
	{
		if(!visit[v[x][i]])dfs(v[x][i],v,visit,dp);
		dp[x]=max(dp[x],1+dp[v[x][i]]);
	}
	return;
}
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int i,x,y;
    int n,m;
    cin>>n>>m;
    vector<vector<int>>v(n+1);
    vector<bool>visit(n+1,false);
    rep(i,m)
    {
    	cin>>x>>y;
    	v[x].pb(y);
    }
    // int q=0;
    vector<int>dp(n+1,0);
    for(int i=1;i<=n;i++)
    {
    	if(!visit[i])dfs(i,v,visit,dp);
    }
    cout<<(*max_element(dp.begin(),dp.end()));
	return 0;
}

Measured memory_bytes: 12496
using System;
using System.Linq;

namespace aoj {
	public class _0060 {
		public _0060() {
		}

		public void Run() {
			string str;
			while((str = Console.ReadLine()) != null) {
				var vs = str.Split().Take(3).Select(s => byte.Parse(s)).ToArray();
				var uc = (new byte[10]).Select(v => 1).ToArray();
				uc[vs[0] - 1] = uc[vs[1] - 1] = uc[vs[2] - 1] = 0;
				Console.WriteLine(((double)(uc.Take((20 - vs[0] - vs[1] > 10) ? 10 : 20 - vs[0] - vs[1]).Sum()) / 7.0 < 0.5) ? "NO" : "YES");
			}
		}
	}
	public class Program {
		public static void Main() {
			var program = new _0060();
			program.Run();
		}
	}
}

Measured memory_bytes: 10020