akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int h[n];
    int sum = 0; 
    REP(i,n){
        cin >> h[i];
        sum += h[i];
    }
    int count = 0;
    while(sum!=0){
        bool flag = false;
        sum = 0;
        REP(i,n){
            if(h[i]!=0&&flag==0){
                h[i]--;
                flag = true;
                count++;
            }
            else if(flag==1&&h[i]!=0) h[i]--;
            else if(h[i]==0)flag = 0;
            
            sum += h[i];
        }
    }
    COUT(count);
    return 0;
} 

Measured memory_bytes: 256
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
#define int ll

vector<pair<int, int> > graph[100005];
int dist[100005];

void dfs(int nd, int parent){
	for(auto x: graph[nd]){
		if(x.ff == parent)	continue;
		dist[x.ff] = dist[nd] + x.ss;
		dfs(x.ff, nd);
	}
}

signed main(){
	fast_io();
	int n;	cin >> n;
	for(int i = 0; i < n; i++){
		int a, b, w;
		cin >> a >> b >> w;
		graph[a].pb({b,w});
		graph[b].pb({a,w});
	}
	dist[1] = 0;
	dfs(1, -1);
	for(int i = 1; i <= n; i++){
		cout << dist[i]%2 << "\n";
	}
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 r, g, b, n;
  cin >> r >> g >> b >> n;
  i64 ans = 0;
  for (i64 i = 0; i <= n; ++i) {
    for (i64 j = 0; j <= n; ++j) {
      i64 k = n - i * r - j * g;
      if (k >= 0 && k % b == 0) ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
s = int(input())
a = 0
b = 0
if s%100 <= 12 and s%100 != 0:
  a = 1
if int(s/100) <= 12 and int(s/100) != 0:
  b = 1
if a == 1:
  if b == 1:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if b == 1:
    print('MMYY')
  else:
    print('NA')

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

int main() {
    int H, W;

    while (true) {
        cin >> H >> W;
        if (!(H | W)) {
            break;
        }

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl; 
    }
}





Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template<int p = 1000000007>
class Z {
	ll x;
public:
	Z(ll X) :x((X + p) % p) { ; }
	Z() :x(0) { ; }
	Z operator+(ll y) {
		return Z(x + y);
	}
	Z operator-(ll y) {
		return Z(x - y + p);
	}
	Z operator*(ll y) {
		return Z(x * y);
	}
	Z operator/(ll y) {
		return *this * Z(y).pow(p - 2);
	}
	Z operator+(const Z &r) {
		return *this + r.x;
	}
	Z operator-(const Z &r) {
		return *this - r.x;
	}
	Z operator*(const Z &r) {
		return *this * r.x;
	}
	Z operator/(const Z &r) {
		return *this / r.x;
	}
	Z pow(int i) {
		if (i == 0) return Z(1);
		if (i % 2) return *this * pow(i - 1);
		Z tmp = pow(i / 2);
		return tmp * tmp;
	}
	ll get() {
		return x;
	}
};

ll fact[100001];

Z<> C(int n, int r) {
	return Z<>(fact[n]) / fact[r] / fact[n - r];
}



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

	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	SORT(A);
	Z<> res(0);
	fact[0] = 1;
	REP(i, N) fact[i + 1] = (Z<>(i + 1) * fact[i]).get();
	REP(i, N - K + 1) {
		res = res - C(N - i - 1, K - 1) * A[i];
	}
	FOR(i, K - 1, N) {
		res = res + C(i, K - 1) * A[i];
	}
	cout << res.get() << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

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

#define max_n 100

int N;
string S;
vector<pair<int, int>> A[15];

int main() {

	cin >> N >> S;

	int ans = 0;
	int abc = -1;
	rep(i, S.size()) {
		if(S[i]=='A'){
			abc = 1;
		}
		else if (S[i] == 'B'&&abc==1) {
			abc = 2;
		}
		else if (S[i] == 'C'&&abc == 2) {
			abc = -1;
			ans++;
		}
		else { abc = -1; }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string>
#include <queue>
#include <math.h>

using namespace std;

int main(void){
    long long N;
    cin >> N;
    long long A[3*N+5];
    priority_queue<long long, vector<long long>, greater<long long> > pq_b;
    priority_queue<long long> pq_a;
    long long b_sum[N+5];
    long long a_sum[N+5];
    long long tmp_sum_b = 0;
    long long tmp_sum_a = 0;

    for(long long i=0;i<3*N;i++){
        cin >> A[i];
    }
    for(long long i=0;i<N;i++){
        tmp_sum_b = tmp_sum_b + A[i];
        tmp_sum_a = tmp_sum_a + A[2*N+i];
    }
    for(long long i=0;i<N;i++){
        pq_b.push(A[i]);
        pq_a.push(A[i+2*N]);

    }
    b_sum[0] = tmp_sum_b;
    a_sum[N] = tmp_sum_a;
    for(long long i=0;i<N;i++){
        pq_b.push(A[i+N]);
        pq_a.push(A[2*N-1-i]);
        b_sum[i+1] = tmp_sum_b - pq_b.top() + A[i+N];
        a_sum[N-1-i] = tmp_sum_a - pq_a.top() + A[2*N-1-i];
        pq_b.pop();
        pq_a.pop();
        tmp_sum_b = b_sum[i+1];
        tmp_sum_a = a_sum[N-1-i];
    }
    long long max_sum = log(0.0);
    for(long long i=0;i<=N;i++){
        max_sum = max(max_sum, b_sum[i] - a_sum[i]);
    }
    cout << max_sum << endl;
    return 0;
}

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

void print(int d) { printf("%d\n", d); }

int main(){
    int m, k;
    scanf("%d%d", &m, &k);
    int n = std::pow(2, m);
    
    if (n <= k || (m == 1 && k == 1)) { print(-1); return 0; }
    if (m == 1 && k == 0) { printf("1 0 0 1\n"); return 0; }
    for (int d = 0; d < n; d++) if (d != k) { print(d); } print(k);
    for (int d = n-1; d >= 0; d--) if (d != k) { print(d); } print(k);
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

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

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int cnt[100];

int main(){
	int n;
	string s;
	while(cin >> n && n){
		cin >> s;
		rep(i, n){
			string s2;
			int sz = s.size();
			int j = 0;
			while(j < sz){
				int w = 1;
				char ch = s[j];
				if(j == sz - 1){
					s2.push_back('1');
					s2.push_back(s[j]);
					break;
				}

				while(j < sz - 1 && s[j] == s[j+1]){
					w++;
					j++;
				}
				string num;
				while(w > 0){
					num.push_back((char)('0' + w % 10));
					w /= 10;
				}
				reverse(num.begin(), num.end());
				s2 += num;
				j++;
				s2.push_back(ch);
			}
			s = s2;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 0
# frozen_string_literal: true

n = gets.to_i
routes = n.times.map { gets.split.map(&:to_i) }
routes.unshift([0, 0, 0])

answer =
  routes.each_cons(2).all? {|pair|
    diff_t = pair[1][0] - pair[0][0]
    diff_x = pair[1][1] - pair[0][1]
    diff_y = pair[1][2] - pair[0][2]

    next false unless diff_x + diff_y <= diff_t

    if diff_t.even?
      (diff_x + diff_y).even?
    else
      (diff_x + diff_y).odd?
    end
  }

puts answer ? "Yes" : "No"


Measured memory_bytes: 9724
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;
long long int n;
string str;
int main() {
	cout << fixed << setprecision(18);
    cin>>str;
    if(str=="SUN"){cout<<7;}
    else if(str=="MON"){cout<<6;}
    else if(str=="TUE"){cout<<5;}
    else if(str=="WED"){cout<<4;}
    else if(str=="THU"){cout<<3;}
    else if(str=="FRI"){cout<<2;}
    else if(str=="SAT"){cout<<1;}
    
} 


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

int n;

int main(void) {
	vector<int> v;
	int i, q, b, e, x;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		v.push_back(x);
	}
	cin >> q;
	while (q--) {
		cin >> b >> e;
		reverse(v.begin() + b, v.begin() + e);
	}
	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << v[i];
	}
	cout << endl;
}


Measured memory_bytes: 3160
import math
a, b, x = map(int, input().split())

if x <= a*a*b/2:
  print(math.degrees(math.asin(a*b*b/((b**4)*(a**2)+4*x*x)**0.5)))
else:
  print(math.degrees(math.asin((2*a*a*b-2*x)/(a**6+4*(a*a*b-x)**2)**0.5)))
        

Measured memory_bytes: 3060
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A_collection = collections.Counter(A)
bars = []
for key in A_collection.keys():
    if A_collection[key] > 1:
        bars.append(key)

ans = 0
bars.sort(reverse = 1)
if len(bars) > 1:
    ans = bars[0] * bars[1]
    if A_collection[bars[0]] > 3:
        ans = bars[0] ** 2
print(ans)


Measured memory_bytes: 24140
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int cmp(const void* p, const void* q) {
	return *(int*)p - *(int*)q;
}

int cmp2(const void* p, const void* q) {
	return *(int*)q - *(int*)p;
}


int main(void) {
	int n, m;
	int a[100000] = { 0 };
	int dis[100000] = { 0 };
	int ans = 0;

	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) scanf("%d", &a[i]);

	qsort(a, m, sizeof(int), cmp);
	for (int i = 0; i < m - 1; i++)dis[i] = a[i + 1] - a[i];
	qsort(dis, m - 1, sizeof(int), cmp2);
	for (int i = n - 1; i < m; i++)ans += dis[i];
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 1276
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 1; i <= N; i+=2) {
        int d = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) d++;
        }
        if (d == 8) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

#define ll long long

void solve(){
	ll k,a,b;
	scanf("%lld%lld%lld",&k,&a,&b);
	ll ret = k+1;
	if(a<b && a<=k){
		ll tmp = a;
		k -= a-1;
		tmp += (b-a)*(k/2);
		k%=2;
		tmp += k;
		ret = max(ret,tmp);
	}
	printf("%lld\n",ret);
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

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

int main(void) {
  int h, w;
  cin >> h >> w;
  
  string board[50];
  
  for (int i = 0; i < h; ++i) cin >> board[i];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (board[i][j] == '#') continue;

      int num = 0;
      for (int d = 0; d < 8; ++ d) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        
        if (ni < 0 or h <= ni) continue;
        if (nj < 0 or w <= nj) continue;
        if (board[ni][nj] == '#') num++;
      }
      board[i][j] = char(num + '0');
    }
  }
  for (int i = 0; i < h; ++i) cout << board[i] << endl;
  
  return 0;
}

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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double maxexp = 0;
		int p[] = new int[N];
		double exp[] = new double[N];
		double kexp[] = new double[N-K+1];
		
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			exp[i] = ((double)1+p[i])/(double)2;
		}
		kexp[0]=0;
		for(int i=0;i<K;++i) {
			kexp[0]=kexp[0]+exp[i];
		}
			
		for(int j=1;j<N-K+1;j++) {
			kexp[j] = kexp[j-1]-exp[j-1]+exp[j+K-1];
		}
		maxexp = kexp[0];
		
		for(int i=0;i<N-K+1;++i) {
			if(kexp[i]>maxexp) {
				maxexp=kexp[i];
			}
		}
		
		
//		for(int i=0;i<N-K+1;i++) {
//			float checkexp =0;
//			
//			for(int j=0;j<K;j++) {
//				checkexp+=exp[i+j];
//			}
//			
//			if(checkexp > maxexp) {
//				maxexp=checkexp;
//			}		
//		}
		
		System.out.println(maxexp);
	}	
}


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



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,w,k,mod=1e9+7;
    cin>>h>>w>>k;
    vector<ll>combi{1,1,1,2,3,5,8,13,21};

    ll dp[110][10]={};// [h][w]
    dp[0][1]=1;
    rep(i,h+1){
        forx(j,1,w+1){
            dp[i][j]%=mod;

            dp[i+1][j]+=dp[i][j]*combi[j]*combi[w+1-j];
            dp[i+1][j-1]+=dp[i][j]*combi[j-1]*combi[w+1-j];
            dp[i+1][j+1]+=dp[i][j]*combi[j]*combi[w-j];

            dp[i+1][j]%=mod;
            dp[i+1][j-1]%=mod;
            dp[i+1][j+1]%=mod;
        }
    }

    cout<<dp[h][k]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;



/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main(){
    string s; cin >> s;
    int length = s.size();
    string ans = "";
    rep(i, length){
        ans.push_back('x');
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll,v1,v2,v3;
ll num[ten52],num2[ten52];
//priority_queue<pair<ll,ll>> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,k1=0;
    string s;
    cin>>n;
    v1.pb(0);v2.pb(0);v3.pb(0);
    for(i=0;i<n;i++)
    {
        cin>>m;
        v1.pb(m);
    }
    for(i=0;i<n;i++)
    {
        cin>>m;
        v2.pb(m);
    }
    for(i=0;i<n;i++)
    {
        cin>>m;
        v3.pb(m);
    }
    sort(all(v1));
    sort(all(v2));
    sort(all(v3));
    for(i=1,j=1;i<=n && j<=n;i++)
    {
        num[i]=num[i-1];
        k=0;
        while(v2[i]>v1[j])
        {
            j++;
            k++;
            if(j>n) break;
        }
        num[i]+=k;
    }
    for(i=1;i<=n;i++)
        if(num[i]==0)
            num[i]=num[i-1];
    k=0;
    for(i=1,j=1;i<=n && j<=n;i++)
    {
        num2[i]=num2[i-1];
        while(v3[i]>v2[j])
        {
            num2[i]+=num[j];
            j++;
            if(j>n) break;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(num2[i]==0)
            num2[i]=num2[i-1];
            k+=num2[i];
    }
    cout<<k;
    return 0;
}





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

using namespace std;

int selectionSort(int A[], int N){
    int count = 0;
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj = j;
            }
        }
        if(minj==i)continue;
        int tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        count++;
    }
    for(int i=0;i<N;i++){
        cout << A[i];
        if(i!=N-1)cout << " ";
        
    }
    cout << endl;
    cout << count << endl;
    return count;
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    selectionSort(A,N);

}


Measured memory_bytes: 3096
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a+b<c)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int i, j;
    int num[3][8];
    double time[3][8];
    int num1[4], num2[4], num3[3];
    double time1[4], time2[4], time3[3];
    
    for (i = 0; i < 3; i++) {
        for (j = 0; j < 8; j++) {
            scanf("%d %lf", &num[i][j], &time[i][j]);
        }
    }
    
    for (i = 0; i < 3; i++) {
        time1[i] = 60.0;
        for (j = 0; j < 8; j++) {
            if (time[i][j] < time1[i]) {
                time1[i] = time[i][j];
                num1[i] = num[i][j];
            }
        }
    }
    
    for (i = 0; i < 3; i++) {
        time2[i] = 60.0;
        for (j = 0; j < 8; j++) {
            if (time[i][j] > time1[i]) {
                if (time[i][j] < time2[i]) {
                    time2[i] = time[i][j];
                    num2[i] = num[i][j];
                }
            }
        }
    }
    
    for (i = 0; i < 3; i++) {
        time3[i] = 60.0;
        for (j = 0; j < 8; j++) {
            if (time[i][j] > time2[i]) {
                if (time[i][j] < time3[i]) {
                    time3[i] = time[i][j];
                    num3[i] = num[i][j];
                }
            }
        }
    }
    
    time1[3] = 60.0;
    for (i = 0; i < 3; i++) {
        if (time3[i] < time1[3]) {
            time1[3] = time3[i];
            num1[3] = num3[i];
        }
    }
    
    time2[3] = 60.0;
    for (i = 0; i < 3; i++) {
        if (time1[3] < time3[i]) {
            if (time3[i] < time2[3]) {
                time2[3] = time3[i];
                num2[3] = num3[i];
            }
        }
    }

    for (i = 0; i < 4; i++) {
        printf("%d %.2f\n", num1[i], time1[i]);
        printf("%d %.2f\n", num2[i], time2[i]);
    }
    
    return 0;
}

Measured memory_bytes: 652
def main():
    dist = []
    import numpy as np
    from collections import deque
    n, x, y = map(int,input().split())
    g = [[] for _ in range(n)] 
    for i in range(n-1):

        g[i] += i+1,
        g[i+1] += i,
    g[x-1] += y-1,
    g[y-1] += x-1,
    a = [0]*n
    for start in range(n):
        d = [-1] * n
        d[start] = 0
        q = deque([start])
        add,pop=q.append,q.popleft
        while q:
            v = pop()
            for nv in g[v]:
                if d[nv] < 0:
                    d[nv] = d[v]+1
                    add(nv)
        # for i in d:
        #     a[i] += 1
        dist.extend(d)
    for i in dist:
        a[i] += 1
    # dist = np.array(dist).flatten()
    # for i in range(1,n):
    #     print(int(len([x for x in dist if x==i])/2))
    for i in range(1,n):
        print(int(a[i]/2))
main()

Measured memory_bytes: 141148
#include <iostream>
using namespace std;
int C[60] = {0},a,b,N,M;

int main(){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    C[a]++; C[b]++;
  }
  for(int i=1;i<=N;i++){
    cout << C[i] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g; cin >> r >> g;
    cout << 2*g-r;
    cout << endl;
    return 0;
}



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


using namespace std;


int main(){
   int n;
   cin >> n;
   long long ans =0;
   for(int i=1; i<=n; i++){
       if(i%3 != 0 && i%5 !=0) ans+=i;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int a = 0, b = 0;
	rep(i, n) if (s[i] == 'R') ++a;
	int ans = max(a, b);
	rep(i, n) {
		if (s[i] == 'R') --a;
		else ++ b;
		int now = max(a, b);
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3740
if __name__ == '__main__':
    N = int(input())
    C = []
    S = []
    F = []
    for _ in range(N - 1):
        c, s, f = map(int, input().split())
        C.append(c)
        S.append(s)
        F.append(f)

    ans_list = []

    for i in range(N - 1):
        tmp_ans = 0
        while i < N - 1:
            if tmp_ans <= S[i]:
                tmp_ans = S[i] + C[i]
            else:
                if tmp_ans % F[i] != 0:
                    tmp_ans += F[i] - (tmp_ans % F[i])
                tmp_ans += C[i]

            i += 1

        ans_list.append(tmp_ans)

    # print(ans_list)
    ans_list.append(0)
    for answer in ans_list:
        print(answer)


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

int main(){

    vector<int> x(5);
    rep(i,5){
        cin >> x[i];
    }

    rep(i,5){
        if(x[i]==0){
            cout << i +1 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MOD (long long)1000000007
int fact[200010], inv[200010], ifact[200010];

int main() {
	int i;
	long long exp, P;
	fact[0] = 1;
	inv[1] = 1;
	ifact[0] = 1;
	for (i=1;i<200010;i++) {
		P = (long long)fact[i-1] * i;
		fact[i] = P % MOD;
	}
	for (i=2;i<200010;i++) {
/*		exp = 1000000005;
		P = i;
		while (exp>0) {
			if (exp&2) {
				P *= P;
				P %= MOD;
			}
			exp>>=1;
		}*/
		inv[i] = (long long)inv[MOD%i]*(MOD-MOD/i)%MOD;
	}
	for (i=1;i<200010;i++) {
		P = (long long)ifact[i-1] * inv[i];
		ifact[i] = P % MOD;
	}
//	for (i=0;i<10;i++) printf("%d %d %d\n", fact[i], inv[i], ifact[i]);

	int A, B, H, j, W;
	long long T=0;
	scanf("%d%d%d%d", &H, &W, &A, &B);

	for (i=0;i<W-B;i++) {
		P  = (long long)fact[W-i+H-A-2];
		P *= (long long)ifact[W-i-1];		P %= MOD;
		P *= (long long)ifact[H-A-1];		P %= MOD;
		P *= (long long)fact[A+i-1];		P %= MOD;
		P *= (long long)ifact[A-1];			P %= MOD;
		P *= (long long)ifact[i];			P %= MOD;
		T += P;								T %= MOD;
	}
	printf("%lld\n", T);

	return 0;
}


Measured memory_bytes: 2560
def main():
    W,H,N = map(int,input().split())
    X = 0 #a=1初期値
    Y = 0 #a=3初期値
    for _ in range(N):
        x,y,a = map(int,input().split())
        if a == 1:
            X = max(X,x)
        elif a == 2:
            W = min(W,x)
        elif a == 3:
            Y = max(Y,y)
        elif a == 4:
            H = min(H,y)
    #Sを求める
    S = max((W-X),0) * max((H-Y),0)
    print(S)
if __name__ == '__main__':
    main()



Measured memory_bytes: 9060
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)


int main() {

   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n , k;
   cin >> n >> k;
   int cnt = 0;
   while (n--){
      int x;
      cin >> x;
      cnt += (x >= k);
   }
   cout << cnt << "\n";

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, a, b;
    
    cin >> n;
    a = n / 100;
    b = n % 10;
    
    if(a == b) {
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#define MIN(a,b) ((a<b)?(a):(b))
using namespace std;
typedef pair<string,int> ps;
int main(void){
	queue<ps> q;
	string s;
	int a;
	int t=0;
	int n,qt;
	cin>>n>>qt;
	for(int i=0;i<n;i++){
		cin>>s>>a;
		q.push(ps(s,a));
	}
	
	while(n){
		ps temp=q.front();
		q.pop();
		if(temp.second-qt>0){
			temp.second-=qt;
			t+=qt;
			q.push(temp);
		}else{
			t+=temp.second;
			cout<<temp.first<<" "<<t<<endl;
			n--;
		}
	}
	return 0;
}

Measured memory_bytes: 6276
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nItems := scanInt(sc)
	capacity := scanInt(sc)

	ws := make([]int, nItems+1)
	vs := make([]int, nItems+1)
	for i := 1; i <= nItems; i++ {
		ws[i] = scanInt(sc)
		vs[i] = scanInt(sc)
	}

	dp := make([][]int64, nItems+1)
	dp[0] = make([]int64, capacity+1)

	for i := 1; i <= nItems; i++ {
		dp[i] = make([]int64, capacity+1)

		for w := 1; w <= capacity; w++ {
			if ws[i] > w {
				dp[i][w] = dp[i-1][w]
			} else {
				dp[i][w] = max(
					dp[i-1][w-ws[i]]+int64(vs[i]),
					dp[i-1][w],
				)
			}
		}
	}

	fmt.Println(dp[nItems][capacity])
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 81536
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int price = 700;
      
      for(int i=0; i<str.length(); i++){
      	if(str.charAt(i) == 'o'){
        	price += 100;
        }
      }
      
      System.out.println(price);
	}
}


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


int main()
{
    long long int n,i,j,k=0,p,c=0;
    cin>>n;
    while(n--)
    {
        cin>>p;
        if(p%2==0)
        {
            while(p%2==0)
            {
                c++;
                p=p/2;
            }
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
a = []
for _ in range(n):
  a.append(0)
w = a.copy()
x = a.copy()
for _ in range(m):
  q,r = input().split()
  q = int(q)-1
  if r == "WA" and a[q] != 1:
    w[q] += 1
  elif r == "AC" and a[q] != 1:
    x[q] = w[q]
    a[q] = 1
print(sum(a), sum(x))

Measured memory_bytes: 5528
using System;
using System.Collections.Generic;
using System.Linq;

class Prop
{
    public TimeSpan TS
    {
        get
        {
            return new TimeSpan(2, 0, 0);
        }
    }
}

class Program
{
    static void Main()
    {
        var p = new Prop();
        Read().ToList().ForEach(delegate (TimeSpan dt)
        {
            var ans = p.TS - dt;
            Console.WriteLine("{0}\n{1}", ans, TimeSpan.FromSeconds(ans.TotalSeconds * 3));
        });
    }

    private static IEnumerable<TimeSpan> Read()
    {
         List<int> line;
        while ((line = Console.ReadLine().Split().Select(int.Parse).ToList()).Any(x => x != -1))
            yield return new TimeSpan(line[0], line[1], line[2]);
    }
}


Measured memory_bytes: 16388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int n;
    cin >> n;
    if(n%10 == 9){
        cout << "Yes" << endl;
        return 0;
    }
    n /= 10;
    if(n%10 == 9){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int h,n;
    cin>>h>>n;
    int a[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll A, B, C;
	cin >> A >> B >> C;

	ll g = gcd(A, B);

	if (C%g == 0) { cout << "YES"; }
	else { cout << "NO"; }
	
	system("PAUSE");
}


Measured memory_bytes: 504
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        var b = new bool[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim()) - 1;
        var pre = 0;
        var count = 1;
        while (true)
        {
            var w = a[pre];
            if (w == 1) { Console.WriteLine(count); goto end; }
            if (b[w]) { Console.WriteLine(-1); goto end; }
            else b[w] = true;
            pre = w;
            count++;
        }
        end:;
    }
}


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

int main(){

    string str;
    int num, temp;
    cin >> str;
    cin >> num;


    for(int i = 0; i < str.length(); ++i){
        if(i+1 == str.length() && num > 0){
            temp = str[i] - 'a';
            str[i] = (temp + num)%26 + 'a';
            break;
        }
        else if('z' + 1 - str[i] > num)continue;
        else if(str[i] == 'a')continue;
        else{
            num -= 'z' + 1 - str[i];
            str[i] = 'a';
        }
    }
    cout << str << endl;

return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n;
	scanf("%d", &n);
	printf("%d\n", n*n*n);
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let a: i32 = scan.next();
    let b: i32 = scan.next();
    writeln!(out, "{} {} {}", a/b, a%b, a as f64/b as f64).ok();
}


Measured memory_bytes: 5052
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    auto red = vector<int>(a);
    auto green = vector<int>(b);
    auto colorless = vector<int>(c);
    for (int i = 0; i < a; ++i) {
        cin >> red[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> green[i];
    }
    for (int i = 0; i < c; ++i) {
        cin >> colorless[i];
    }
    int len_red = red.size();
    int len_green = green.size();
    // if len_red == 5, and x == 5, we take nth at 0 and take everything from nth
    int nth_red = len_red - x;
    int nth_green = len_green - y;
    nth_element(red.begin(), red.begin() + nth_red, red.end());
    nth_element(green.begin(), green.begin() + nth_green, green.end());
    for (int i = nth_red; i < len_red; ++i) {
        colorless.push_back(red[i]);
    }
    for (int i = nth_green; i < len_green; ++i) {
        colorless.push_back(green[i]);
    }
    int len_all = colorless.size();
    int nth_all = len_all - x - y;
    nth_element(colorless.begin(), colorless.begin() + nth_all, colorless.end());
    long long int sum = 0;
    for (int i = nth_all; i < len_all; ++i) {
        sum += colorless[i];
    }
    cout << sum << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;

int main() {
	cin >> s;
	cout << s.substr(0,4) << " " << s.substr(4,8) << ln;
}

Measured memory_bytes: 256
using System;

namespace ABC057D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = Int32.Parse(bufs[0]);
            int A = Int32.Parse(bufs[1]);
            int B = Int32.Parse(bufs[2]);
            long[] v = new long[N];

            bufs = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                v[i] = Int64.Parse(bufs[i]);
            }

            Array.Sort(v);

            double max = 0.0;
            for (int i = 1; i <= A; i++)
            {
                max += v[N - i];
            }

            Console.WriteLine((max / A).ToString("F6")); // Max of average

            long res = 0;

            long cur = v[N - A];
            int same = 1;
            int right = 1;
            int j = N - A - 1;
            while (j >= 0 && cur == v[j]) // Left
            {
                same++;
                j--;
            }
            j = N - A + 1;
            while (j < N && cur == v[j]) // Right
            {
                same++;
                right++;
                j++;
            }

            int term = N - (A - right);

            res = Combination(same, right);

            A++;
            while ((N >= A) && (B >= A) && (v[N - A] == v[N - 1]))
            {
                res += Combination(same, A);
                A++;
            }

            Console.WriteLine(res);
        }

        static long Combination(int tot, int num)
        {
            long res = 1;
            int tmp = 1;
            if ((tot / 2) < num)
            {
                num = tot - num;
            }

            for (int i = 0; i < num; i++)
            {
                res = res * tot / tmp;
                tot--;
                tmp++;
            }

            return res;
        }
    }
}


Measured memory_bytes: 13268
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    answer = [0]*N
    linked_list = [[] for _ in range(N)]
    for i in range(N-1):
        linked_list[a[i]-1].append(b[i]-1)
        linked_list[b[i]-1].append(a[i]-1)
    
    c = [0]*N
    is_Visited = [False]*N

    for j in range(Q):
        c[p[j]-1] += x[j]
    answer[0] = c[0]
    
    def dfs(node,counter):
        counter += c[node]
        is_Visited[node] = True
        for n in linked_list[node]:
            if is_Visited[n] == False:
                answer[n] = dfs(n,counter)
        
        return counter
        
    dfs(0,0)
    print(*answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    x = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()


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

int main ()
{
  int a,b;
  cin >> a >> b;
  if (a <= b)
  {
    for (int i = 0; i < b;i++)cout << a;
  }
  else
  {
    for (int i = 0; i < a;i++)cout << b;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,p[100001],i,t;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);p[i]=i+1==t;}
  t=0;for(i=0;i<n;i++)if(p[i]){t++;p[i]=p[i+1]=0;}
  printf("%d",t);
}


Measured memory_bytes: 2108
# coding: utf-8

mojiretsu = input().rstrip()

stk = []
ans = 0

for i in mojiretsu:
    if len(stk) > 0 and stk[len(stk)-1] != i:
        stk.pop()
        ans += 2
    else:
        stk.append(i)


print(ans)

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

int main() {
	int a, b, c, sum;
	cin >> a >> b >> c;
	sum = 0;

	for (int i = a; i <= b; i++) {
		if (c%i == 0)	sum++;
	}

	cout << sum << endl;
	return 0;
}

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

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

  int N; cin >> N;
  string S; cin >> S;
  int left = 0, right = 0;
  for (int i = 1; i < N; i++) if (S[i] == 'E') right++;
  int ans = right;
  for (int i = 1; i < N; i++) {
    if (S[i-1] == 'W') left++;
    if (S[i] == 'E') right--;
    ans = min(ans, left + right);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s[0]=='Y' && s[1]=='A' &&s[2]=='K' && s[3]=='I'){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();

int main() {
    int n,k,d;cin>>n>>k;
    vector<int> p(n);
    rep0(i,k){
        cin>>d;
        vector<int> v(d);
        rep0(j,d){
            cin>>v[j];
            p[v[j]-1]=1;
        }
   }
   int count=0;
   rep0(i,n){
       if(p[i]==0){
           count++;
       }
   }
   cout<<count<<endl;
}

Measured memory_bytes: 3620
#partition

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(r):
        if A[j] <= x:
            i += 1
            a = A[j]
            A[j] = A[i]
            A[i] = a
    a = A[i+1]
    A[i+1] = A[r]
    A[r] = a

    return i+1

n = int(input())
A = list(map(int, input().split()))
p = partition(A, 0, len(A)-1)

result = ''
for i in range(len(A)):
    if i == p:
        result += '['+str(A[i])+'] '
    else:
        result += str(A[i]) + ' '

print(result[:-1])


Measured memory_bytes: 16384
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

ll calc(ll h, ll w) {
    ll ans = INFL;
    for (int i = 1; i < h; i++) {
        ll s1 = i * w;
        ll s2 = ((h - i) / 2) * w;
        ll s3 = h * w - s1 - s2;
        ll s4 = (h - i) * (w / 2);
        ll s5 = h * w - s1 - s4;
        ans = min({ ans,
            max({ s1, s2, s3 }) - min({ s1, s2, s3 }),
            max({ s1, s4, s5 }) - min({ s1, s4, s5 }) });
    }
    return ans;
}

int main() {
    ll h, w;
    cin >> h >> w;

    ll ans = min(calc(h, w), calc(w, h));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  ll x, y;
  std::cin >> x >> y;

  ll now = x;
  ll cnt = 0;

  while (x <= y) {
    x *= 2;
    cnt++;
  }

  print(cnt);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int K, S;
    int i, j, k, check=0;

    cin >> K >> S;
    
    for(i=0;i<=K;i++){
        for(j=0;j<=K;j++){
                
                k = S-i-j;
                
                if(0<=k && k<=K)
                {
                    check++;
            }
        }
    }
    
        cout << check << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

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

    vector<map<char, int>> v(n);

    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;

        for(int j = 0; j < (int)s.size(); ++j)
        {
            ++v[i][s[j]];
        }
    }

    map<map<char,int>,int> m;

    for(int i = 0; i < n; ++i)
    {
        ++m[v[i]];
    }

    ll resenje = 0LL;

    for(map<map<char,int>,int>::iterator it = m.begin(); it != m.end(); ++it)
    {
        ll vrednost = (ll)it->se;
        resenje += vrednost * (vrednost-1LL) / 2LL;
    }

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 93312
#include <iostream>
#include <cstdio>

using namespace std;

const int N = 200005;

typedef long long LL;

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

LL ans = 0;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i), cnt[a[i]]++;
	for (int i = 1; i <= n; i++) {
		ans += (LL) cnt[i] * (cnt[i] - 1) / 2;
	}
	for (int i = 1; i <= n; i++) {
		LL v = ans - (LL)cnt[a[i]] * (cnt[a[i]] - 1) / 2;
		int k = cnt[a[i]] - 1;
		printf("%lld\n", v + (LL)k * (k - 1) / 2);
	}
	return 0;
}

Measured memory_bytes: 3712