akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
switch_list=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    result=[0]*m
    for j in range(n):
        if (i>>j)&1:
            for k in range(m):
              if j+1 in switch_list[k][1:]:
                  result[k]+=1
    for l in range(m):
        if (result[l]%2)!=p[l]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 9156
n,l = map(int, input().split())
a = list(map(int, input().split()))

sumax=0
for i in range(n-1):
    if sumax < a[i]+a[i+1]:
        sumax=a[i]+a[i+1]
        ind=i

if sumax < l:
    print("Impossible")
    exit()

print("Possible")

for i in range(1,n):
    if i>ind:
        break
    print(i)

for i in reversed(range(n)):
    if i==ind:
        break
    print(i)

Measured memory_bytes: 14060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int i;
    for(i=0;i<s.length();i++) {
        if(count(s.begin(), s.end(), s[i]) != 2) {
            cout << "No" <<"\n";
            return 0;
        }
    }
    cout << "Yes" << '\n';
}

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




//-----------------------------------------------------------------
#define rrep(i,a,b) for(int i=a;i>=b;i--)
vector<int> mul9(vector<int> s) {
	int n = s.size(), carry = 0;
	vector<int> ret;
	rrep(i, n - 1, 0) {
		int c = s[i] * 9 + carry;
		carry = c / 10;
		c %= 10;
		ret.push_back(c);
	}
	while (0 < carry) {
		ret.push_back(carry % 10);
		carry /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}
vector<int> add(vector<int> s, int x) {
	int n = s.size(), carry = x;
	vector<int> ret;
	rrep(i, n - 1, 0) {
		int c = s[i] + carry;
		carry = c / 10;
		c %= 10;
		ret.push_back(c);
	}
	while (0 < carry) {
		ret.push_back(carry % 10);
		carry /= 10;
	}

	return ret;
}
//-----------------------------------------------------------------
vector<int> N;
bool chk(int k) {
	auto n = add(mul9(N), k);
	int cnt = 0;
	for (int c : n) cnt += c;

	return cnt <= k;
}
//-----------------------------------------------------------------
int main() {
	string s; cin >> s;
	for (char c : s) N.push_back(c - '0');

	int lo = 0, hi = 4501010;
	while (lo + 1 != hi) {
		int mi = (lo + hi) / 2;
		if (chk(mi)) hi = mi;
		else lo = mi;
	}
	int ans = hi / 9;
	if (hi % 9) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 10924
#include <stdio.h>
int main(){
  int i,j,n[5][14],maisuu,num;
  char mark,dummy;
  scanf("%d",&maisuu);

  for(i=0; i < 5; i++){
    for(j=0; j < 14; j++){
      n[i][j]=0;
    }
  }

  for(i=0; i < maisuu; i++){
    scanf("%c",&dummy);
    scanf("%c %d",&mark,&num);

    if(mark == 'S'){
      n[0][num] = 1;
    }
    if(mark == 'H'){
      n[1][num] = 1;
    }
    if(mark == 'C'){
      n[2][num] = 1;
    }
    if(mark == 'D'){
      n[3][num] = 1;
    }
  }
  for(i = 0; i < 4; i++){
    for(j=1; j < 14; j++){
      
      if(n[i][j]==0 && i == 0) printf("S %d\n",j);
      if(n[i][j]==0 && i == 1) printf("H %d\n",j);
      if(n[i][j]==0 && i==2) printf("C %d\n",j);
      if(n[i][j]==0 && i==3) printf("D %d\n",j);
    }
  }
  
  return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B
 * @author wsKmatsuda
 *
 */
public class Main{

	public static void main(String[] args) {

		new Main().run();

	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ThreeNumberTotalCheck?????????
	 * n???x?????????????????????
	 * 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°????±???????
	 */
	class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	}

}

Measured memory_bytes: 24252
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    long double A, B;
    string str1, str2;
    cin >> A >> B;
    ll ans = floor(A * B);
    cout << ans << endl;
    
}

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

int main() {
  string a,b,c;
  cin >> a >>b >> c;
  int aa,bb;
  aa = a.size() -1;
  bb =b.size()-1;
  if(a.at(aa) == b.at(0) && b.at(bb) == c.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
     }
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = pair<ll,ll>;


//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp

vector<vector<ll>> capacity;
vector<vector<ll>> flow;
vector<ll> pred;

//増加させることができる経路を探す
//可能経路は，predに保存される ex. pred[v] = u ... u->vの経路
bool findPath(ll s, ll t){
    ll N = capacity.size();
    pred.assign(N,-1);
    
    //幅優先探索
    queue<ll> que; que.push(s);
    while(!que.empty()){
        ll u = que.front(); que.pop(); 

        //Flowネットワークを調べる
        for(ll v=0;v<N;v++){
            //「経路がある」「先の点が未探索」「増加可能」
            if(capacity[u][v]>0 && pred[v]==-1 && capacity[u][v]>flow[u][v]){
                pred[v] = u;
                if (v== t) return true;
                que.push(v);
            }
        }
        //残余ネットワークを調べる
        for(ll v=0;v<N;v++){
            if(capacity[v][u]>0 && pred[v]==-1 && flow[v][u]>0){
                pred[v] = u;
                que.push(v);
            }
        }
    }
    return false;
}

//ネットワークを更新する．
void update(ll s, ll t){
    ll tmp,u,v,delta = INF;//増加分

    //最小の増加量をtargetから遡って探す
    v = t;
    while(v!=s){
        u = pred[v];
        if(capacity[u][v]>0) tmp = capacity[u][v] -flow[u][v];
        else if (capacity[v][u]>0) tmp = flow[v][u];
        delta = min(delta,tmp);
        v = u;
    }
    //求まった増加量を実際のネットワークに反映させる
    v = t;    
    while(v!=s){
        u = pred[v];
        if(capacity[u][v]>0) flow[u][v] += delta;
        else if (capacity[v][u]>0) flow[v][u] -= delta;
        v = u;
    }
}

ll edmonds_karp(ll s, ll t){    
    //増加経路を探索し，見つかったら更新する
    while(1){
        if(findPath(s,t)==false) break;
        else update(s,t);
    }
    ll ans = 0;
    for(ll v=0;v<capacity.size();v++) ans += flow[s][v];
    return ans;
}

int main(){
    ll N;
    cin >> N;
    ll nodeNum = N+N+2;
    capacity.assign((nodeNum),vector<ll>((nodeNum),0));
    flow.assign((nodeNum),vector<ll>((nodeNum),0));

    vector<ipair> red(N),blue(N);
    rep(i,0,N) cin >> red[i].first >> red[i].second;
    rep(i,0,N) cin >> blue[i].first >> blue[i].second;
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());

    //条件を満たすノードを追加
    rep(i,0,N){//blue
        rep(j,0,N){//red
            if(blue[i].first<=red[j].first) break;
            else if(blue[i].second>red[j].second) capacity[i][N+j]=1;
        }
    }
    //start[2N] -> blue -> red -> end[2N+1]
    rep(i,0,N){
        capacity[nodeNum-2][i] = 1;
        capacity[N+i][nodeNum-1] = 1;
    }

    cout << edmonds_karp(nodeNum-2,nodeNum-1) << endl;
}



Measured memory_bytes: 896
from collections import defaultdict,Counter
n = int(input())
s = list(input())
c = Counter(s)


for i in range(1,n):
    s = list(input())
    d = defaultdict(int)
    for ss in s:
        d[ss] += 1
    for cc in c.keys():
        if c[cc] > d[cc]:
            c[cc] = d[cc]

ans = []
for cc in c.keys():
    for i in range(c[cc]):
        ans.append(cc)
ans.sort()
print(''.join(ans))

Measured memory_bytes: 75140
#include <stdio.h>

int main()
{
    int A,B,C,X;
    int sum=0,count=0;
    int i,j,k;

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

    for(i=0;i<A+1;i++){
        for(j=0;j<B+1;j++){
            for(k=0;k<C+1;k++){
                sum = 500 * i + 100 * j + 50 * k;
                if(sum == X){
                    count++;
                }
            }
        }
    }

    printf("%d\n",count);

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MS(x,y) memset(x,y,sizeof x);
#define FOR(i,x,y) for(int i = x; i <= y; ++i)
#define rFOR(i,x,y) for(int i = x; i >= y; --i)
#define pb push_back
#define ll long long
using namespace std;

int A,B,C,D,E,F;
set<int> su;
set<int> wa;


int main()
{
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
    su.clear();
    wa.clear();
    FOR(i,0,F) if(i * A * 100 <= F)
    {
        int p1 = i * A * 100;
        FOR(j,0,F) if(p1 + j * B * 100 <= F)
        {
            wa.insert(p1 + j * B * 100);
        }
    }

    FOR(i,0,F) if(i * C <= F)
    {
        int p1 = i * C;
        FOR(j,0,F) if(p1 + j * D <= F)
        {
            su.insert(p1 + j * D);
        }
    }
    double maxn = -1;
    int ans;
    int ans1;
    for(int k1:su)
    {
        for(int k2:wa) if(k1 + k2 <= F)
        {
            if(k1 * 100 <= k2 * E)
            {
                double ck = 0.0;
                if(k1 + k2 > 0.0) ck = (double)k1 / (double)(k1 + k2);
                if(ck >= maxn)
                {
                    maxn = ck;
                    ans = k1 + k2;
                    ans1 = k1;
                }
            }
        }
    }
    printf("%d %d\n",ans,ans1);

    return 0;
}


Measured memory_bytes: 384
# coding: utf-8
S=list(input())
N=len(S)

ans=[0 for i in range(N)]

cntR=0
for i in range(N):
    if S[i]=="R":
        cntR+=1
    else:
        ans[i-1]+= -(-cntR//2)
        ans[i]+= cntR+(-cntR//2)
        cntR=0

cntL=0
for j in range(N):
    i=-(j+1)
    if S[i]=="L":
        cntL+=1
    else:
        ans[i+1]+= -(-cntL//2)
        ans[i]+= cntL+(-cntL//2)
        cntL=0

print(*ans)


Measured memory_bytes: 7092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int N, K;
  	cin >> N >> K;
  	string S;
  	cin >> S;
  	
  	vector<int> Nums;
  	int now = 1;
  	int cnt = 0;
  	for (int i = 0; i< N;i++)
    {
      if (S[i] ==(char)('0' +now)) cnt++;
      else{
      	Nums.push_back(cnt);
        now = 1 - now;
        cnt = 1; 
      }
    }
	

	if (cnt != 0) Nums.push_back(cnt);
	if (Nums.size()%2 == 0) Nums.push_back(0);

	int Add = 2*K +  1;
	
	vector<int> sum(Nums.size() +1);

	for (int i =  0; i < Nums.size(); i++)
    {
    	sum[i+1] = sum[i] + Nums[i];
    }
		
	int ans = 0 ;
	
	for (int i = 0; i < Nums.size(); i+=2)
    { 
    	int left = i;
      	int right =  min(i + Add,(int)Nums.size());
        int tmp = sum[right] - sum[left]; 
		ans = max(tmp, ans);
    }
	cout << ans << endl;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=0;
    sort(arr,arr+n);
    int cnt=n-2;
    ans+=arr[n-1];
    for(int i=n-2;i>=0;i--)
    {if(cnt==0)
    break;
        if(cnt>=2)
        {
            ans+=2*arr[i];
            cnt-=2;
            continue;
        }
        if(cnt>=1)
        {
            ans+=arr[i];
            cnt-=1;
            continue;
        }


    }
    cout<<ans<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
    return 0;
}


Measured memory_bytes: 5208
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

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

int main() {
	string s, l;

	cin >> s;

	l = "2019/04/30";

	if (s <= l) {
		cout << "Heisei";
	}
	else {
		cout << "TBD";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <vector>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
typedef string::const_iterator State;
int mx=1<<10;
int expr(State &be);
int num(State &be){
	if(!isdigit(*be)) return -1;
	int ret=0;
	while(isdigit(*be)){
		ret*=2;
		ret+=(*be-'0');
		if(ret>=mx) return -1;
		be++;
	}
	return ret;
}
int factor(State& be){
	int ret;
	if(*be=='('){
		be++;
		ret=expr(be);
		if(*be!=')') return -1;
		be++;
		return ret;
/*		cout << ret << endl;
		if(ret==-1) return -1;
		int k=-1;
		cout << *be << endl;
		if(*be=='+') k=0;
		if(*be=='-') k=1;
		if(*be=='*') k=2;
		if(k==-1) return -1;
		be++;
		int ret1=expr(be);
		if(ret1==-1) return -1;
		be++;
		if(k==0) return ret+ret1;
		if(k==1) return max(-1,ret-ret1);
		if(k==2) return ret*ret1;
		cout << "hoge";*/
	}
	return num(be);
}
int term(State& be){
	int ret=factor(be);
	if(ret==-1) return -1;
	while(*be=='*'){
		be++;
		int a=factor(be);
		if(a<0) return -1;
		ret*=a;
		if(ret>=mx) return -1;
	}
	return ret;
}
int expr(State& be){
	int ret=term(be);
	if(ret==-1) return -1;
	while(true){
		if(*be=='+'){
			be++;
			int a=term(be);
			if(a==-1) return -1;
			ret+=a;
			if(ret>=mx) return -1;
		}else if(*be=='-'){
			be++;
			int a=term(be);
			if(a==-1) return -1;
			ret-=a;
			if(ret<0 || ret>=mx) return -1;
		}else break;
	}
	return ret;
}
int main(){
	string s,ch="01+-*()";
	vector<int> vc;
	cin >> s;
	State be=s.begin();
	rep(i,s.size()) if(s[i]=='.') vc.push_back(i);
	int n=vc.size(),p7=1,ans=-1;
	rep(i,n) p7*=7;
	rep(i,p7){
		string t=s;
		int tmp=i;
		rep(j,n){
			t[vc[j]]=ch[tmp%7];
			tmp/=7;
		}
//		cout << t << "  ";
		stack<int> id;
		int cal[101]={};
		bool ok=true;
		rep(i,t.size()){
			if(t[i]=='('){
				id.push(i);
				cal[i]=-1;
			}
			if(t[i]==')'){
				if(id.empty()){
					ok=false;
					break;
				}
				id.pop();
			}
			if(t[i]=='+' || t[i]=='-' || t[i]=='*'){
				if(!id.empty()) cal[id.top()]++;
			}
		}
		if(!id.empty()) ok=false;
		rep(i,t.size()) if(cal[i]<0) ok=false;
//		cout << (ok ? "valid" : "invalid\n");
		if(!ok) continue;
		State be=t.begin();
		int h=expr(be);
		if(be!=t.end()){
//			cout << endl;
			continue;
		}
//		cout << "     " << h << endl;
		ans=max(ans,h);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
int main()
{
    int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
 
  vector<P> ps(n);
  rep(i, n) ps[i] = make_pair(a[i], b[i]);
  sort(ps.begin(), ps.end());
  ll ans = 0;
  rep(i, n) {
    if (m == 0) break;
    ans += (ll)ps[i].first * min(m, ps[i].second);
    m -= min(m, ps[i].second);
  }
  cout << ans << endl;
    return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  cout << min(n * a, b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d; cin >> a >> b >> c >> d;
    (a-1)/d >= (c-1)/b ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <fstream>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 10;

vector<vector<bool> > f(int N, int K, vector<int> a) {
	vector<vector<bool> > dp(N + 1, vector<bool>(K));
	dp[0][0] = true;
	rep(i, N) rep(x, K) if (dp[i][x]) {
		dp[i + 1][x] = true;
		if (x + a[i] < K) dp[i + 1][x + a[i]] = true;
	}
	return dp;
}

int main() {
	int N, K; cin >> N >> K;
	vector<int> a;
	while (N--) {
		int x; cin >> x;
		if (x < K) a.pb(x);
	}
	N = a.size();
	vector<vector<bool> > dp1 = f(N, K, a);
	reverse(a.begin(), a.end());
	vector<vector<bool> > dp2 = f(N, K, a);
	reverse(dp2.begin(), dp2.end());
	reverse(a.begin(), a.end());
	int ans = 0;
	rep(i, N) {
		vector<int> unko(K + 1);
		unko[0] = -1;
		rep(x, K) {
			unko[x + 1] = unko[x];
			if (dp2[i + 1][x]) unko[x + 1] = x;
		}
		bool ok = false;
		rep(x, K) if (dp1[i][x]) {
			int y = K - 1 - x;
			if (y >= 0 && x + unko[y + 1] + a[i] >= K) ok = true;
		}
		if (!ok) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6912
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define pb push_back
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll n,ans=0,i,j;
	cin>>n;
	ll a[n];
	map<ll,ll>mp;
	for(i=0;i<n;i++){
	cin>>a[i];
	//mp[i+a[i]]++;
	mp[i+a[i]]++;
//	ans+=mp[i+a[i]]-1;
	//ans+=mp[i-a[i]];
	}
	for(j=1;j<n;j++)
	ans+=mp[j-a[j]];
	cout<<ans;
}


Measured memory_bytes: 27856
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var g = int.Parse(Console.ReadLine().Trim());
            if (g == 0) break;
            for (int i = 0; i < 9; i++)
                g -= int.Parse(Console.ReadLine().Trim());
            Console.WriteLine(g);
        }
    }
}

Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

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

int main()
{
	int n;
	string s;
	cin>>n>>s;
	int left = 0,right = 0;
	string ans=s;
	for (int i = 0; i < n; i++){
		if(s[i] == ')'){
			// cout<<s[i]<<endl;
			if(left>0) left--;
			else ans = '('+ans;
		}else{
			left++;
		}
		// cout<< i << s <<left<< endl;
	}

	for (int l = 0; l < left; l++){
		ans += ')';
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::*;

fn read<T: str::FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|a| a.parse().ok().unwrap())
        .collect()
}

fn read_vec2d<T: str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n: u32 = read();
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include<stdio.h>
void swap(int *a,int *b,int *c){
	int temp=*a;
	*a=*b;
	*b=temp;
	(*c)++;
}

int main(){
	int i,n,j,k,count=0,flag;
	int a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(i=0;i<n-1;i++){
		int min=a[i];
		for(j=i+1;j<n;j++){
			if(min>a[j]){
				min=a[j];
				flag=j;
				
			}
		}
		if(min<a[i])
		swap(&a[i],&a[flag],&count);
	}
	
	for(i=0;i<n-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[i]);
	printf("%d\n",count);
} 


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF INT_MAX/3
#define mod 1000000007
#define MAX_V 2000

struct edge{ int to,cap,rev; };
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> que;
  level[s]=0;
  que.push(s);
  while(!que.empty()){
    int v=que.front(); que.pop();
    for(int i=0;i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[e.to]<0){
        level[e.to]=level[v]+1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  for(int &i=iter[v];i<(int)G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  while(1){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,INF))>0){
      flow+=f;
    }
  }
}

int R,C;
string s[25];
int prof=0,cnt=0;;

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

  cin>>R>>C;
  rep(i,R){
    cin>>s[i];
    rep(j,C)if(s[i][j]=='#')cnt++;
  }

  int source=2*R*C,sink=2*R*C+1;
  rep(i,R)rep(j,C){
    if(i<R-1&&s[i][j]=='#'&&s[i+1][j]=='#'){
      add_edge(source,i*C+j,1);
      add_edge(i*C+j,i*C+j+R*C,INF);
      add_edge(i*C+j,i*C+j-1+R*C,INF);
      add_edge(i*C+j,(i+1)*C+j-1+R*C,INF);
      add_edge(i*C+j,(i+1)*C+j+R*C,INF);
      prof++;
    }
    if(j<C-1&&s[i][j]=='#'&&s[i][j+1]=='#'){
      add_edge(i*C+j+R*C,sink,1);
      prof++;
    }
  }
  prof-=max_flow(source,sink);
  cout<<cnt-prof<<endl;

  return 0;
}



Measured memory_bytes: 3384
N = input()

if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9120
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Long, Long> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            if (map.containsKey(a)) {
                map.put(a, map.get(a) + b);
                continue;
            }
            map.put(a, b);
        }
        long cnt = 0;
        long ans = 0;
        long k = 0;
        for (Long key : map.keySet()) {
            cnt += map.get(key);
            ans += key * map.get(key);
            if (cnt >= m) {
                k = key;
                break;
            }
        }

        ans -= k * (cnt - m);
        System.out.println(ans);
    }
}


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

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

  int ans = 1;
  int x = 0;
  for (int i=0; i<N; ++i) {
    int l;
    cin >> l;
    x += l;
    if (X < x) break;
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

L=input().strip()
mod=10**9+7

if L=="1":
    print(3)
    sys.exit()


LEN=len(L)

ANS=pow(3,LEN-1,mod)
#print(ANS)

count=1
for i in range(1,LEN-1):
    if L[i]=="1":
        ANS=(ANS+pow(2,count,mod)*pow(3,LEN-i-1,mod)%mod)%mod
        count+=1

    #print(ANS)

if L[-1]=="1":
    ANS+=pow(2,count,mod)*3
else:
    ANS+=pow(2,count-1,mod)*2
    
print(ANS%mod)




Measured memory_bytes: 39772
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int bitcount(int x){
	int s=0;while(x) s++,x/=2;
	return s;
}
int main(){
	int i,j,n;cin>>n;int v[n][n];vi d(1<<n,0);
	for(i=0;i<n;i++) for(j=0;j<n;j++) cin>>v[i][j];
	for(i=1;i<(1<<n);i++){
		int x=bitcount(i);
		d[i]+=(d[i^(1<<(x-1))]);
		for(j=x-2;j>=0;j--){
			if((1<<j)&i) d[i]+=v[x-1][j];
		}
	}
	for(int k=0;k<(1<<n);k++){
		for(j=k;j;j=(j-1)&k){
			d[k]=max(d[k],d[j]+d[k-j]);
		}
	}cout<<d.back()<<endl;
	//	for(i=0;i<d.size();i++) cout<<i<<' '<<d[i]<<endl;
}


Measured memory_bytes: 3776
def ascan; gets.split.map(&:to_i);end

str = gets.chomp

if str == "zyxwvutsrqponmlkjihgfedcba"
    p -1
else
    str_un = (("a".."z").to_a - str.chars).sort
    unless (str_un.empty?)
        puts str+str_un[0]
    else
        strs = str.chars.to_a
        h = []
        while true
            h << strs.pop
            next if h.max < strs[-1]
            t = strs.pop
            strs.push(h.select{|e|e>t}.min)
            break
        end
        puts strs*""
    end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    string s;
    cin >> s;
    int n = s.length();
    int c_count = 0;
    int large = 0;
    rep(i,n){
        if(i != 0 && s[i] <= 90 && s[i] != 'C')large ++;
    }
    for(int i=2;i<n-1;i++){
        if(s[i] == 'C')c_count++;
    }

    if(s[0] != 'A'){
        cout << "WA" << endl;
    }else if (large == 0 && c_count == 1)
    {
        cout << "AC" << endl;
    }else {
        cout << "WA" << endl;
    }
    
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/ 

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const int mxn = 1e3+7;

int a[mxn];

int main(){
	setIO();
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a+n);
	int sum = 0;
	for (int i = 0; i < k; i++) sum += a[i];
	cout << sum << endl;
}

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

#define STR_MAX  500000
char a[STR_MAX];

int main() 
{
    string S;
    int front = 200000;
    int back = 200000;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
       a[back++] = S[i];
    }
    
    int Q;
    cin >> Q;
    
    bool flip = false;
    
    for(int i = 0; i < Q; i++){
	    int T;
	    cin >> T;
	    if(T == 1){
			flip = !flip;
	    }else{
		    int F;
		    char C;
	    	cin >> F >> C;
	    	if((F == 1) ^ flip){
			    a[--front] = C;
	    	}else{
			    a[back++] = C;
	    	}
	    }
    }
    
    if(flip){
    	for(int i = back; front < i; i--){
			cout << a[i - 1];
    	}
    }else{
    	for(int i = front; i < back; i++){
			cout << a[i];
    	}
    }
	cout << endl;
    
    return 0;
}


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

int n;
vector<int> a;

void solve() {
  int i, ans = 0;
  map<int, int> mp;

  for (i = 0; i < n; i++) {
    mp[a[i] - 1]++;
    mp[a[i]]++;
    mp[a[i] + 1]++;
  }

  for (auto p : mp) {
    ans = max(ans, p.second);
  }

  cout << ans << "\n";

  return;
}

int main() {
  int i;

  cin >> n;

  a.resize(n);

  for (i = 0; i < n; i++) {
    cin >> a[i];
  }

  solve();
  return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int N=1e5+9;

int n,k,ans;
int to[N],nxt[N],beg[N],tot;
int fa[N],dep[N];
bool vis[N];

inline void add(int u,int v)
{
	to[++tot]=v;
	nxt[tot]=beg[u];
	beg[u]=tot;
}

inline int dfs(int u)
{
	vis[u]=1;
	int ret=0;
	for(int i=beg[u],v;i;i=nxt[i])
		if(!vis[v=to[i]])
		{
			int tmp=dfs(v)+1;
			if(tmp>k-(u!=1))
				ans++;
			else	
				ret=max(ret,tmp);
		}	
	return ret;
}

int main()
{
	n=read();
	k=read();

	for(int i=1;i<=n;i++)
	{
		fa[i]=read();
		if(i==1 && fa[i]!=1)
			fa[i]=1,ans++;
		add(fa[i],i);
	}
		
	dfs(1);

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
//#define int long long
#include <algorithm>
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int D, T, S;
    cin >> D >> T >> S;

    if (S * T >= D)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define mod 1000000007

ll v[100],c[100];

int main(){
  ll n;
  cin >>n;
  rep(i,n){
    cin >> v[i];
  }
  rep(i,n)cin >> c[i];
  ll ans=0;
  ll x=0,y=0;
  rep(i,n){
    if(v[i]-c[i]>=0)ans+=v[i]-c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
function main(){
	var n = scan();
	var x = Array(n);
	rep(n, function(i){
		x[i] = scan();
	});

	var y;
	for(var i = n - 2; i >= 0; --i){
		if(y === undefined || y < x[i + 1] - x[i]){
			y = x[i + 1] - x[i];
		}
		x[i] = Math.max(x[i], x[i + 1]);
	}
	print(y);
}

function rep(n, func){
	for(var i = 0; i < n; ++i){
		func(i);
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input = '';
var input_index = 0;

function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}

function print(val){
	console.log(val);
}

process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

Measured memory_bytes: 41500
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  } 
   int ans=1000000000;
   for(int i=1;i<=100;i++)
   {
    int temp=0;
    for(int j=0;j<n;j++)
    {
     temp+=(arr[j]-i)*(arr[j]-i);
    }
    ans=min(temp,ans);
   }
   cout<<ans<<endl;
   return 0;
} 

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

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

    if(num == 1) {
        cout << 1.0 << endl;
        return 0;
    }

    if(num % 2 == 0) {
        cout << 0.5 << endl;
        return 0;
    }

    int odd = (num / 2) + 1;
    double ans = (double)odd / (double)num;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	return !printf("%d\n", min(A, B) + min(C, D));
}

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

using namespace std;


int main(void){
	int N;
	cin >> N;
	vector<long long > A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	sort(A.begin(),A.end());
	int ok = N;
	int ng = -1;
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		long long now = A[mid];
		bool can = 1;
		for(int i=0;i<N;i++){
			if(i==mid)continue;
			if(now*2>=A[i])now += A[i];
			else {
				can = 0;
				break;
			}
		}
		if(can)ok = mid;
		else ng = mid;
	}
	cout << N - ok << endl;
}

Measured memory_bytes: 1024
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        S: Chars,
        T: Chars,
    }
    let mut ans = 0;
    for i in 0..S.len() {
        if S[i] != T[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/



  int N;

  cin>>N;

  double a[101];

  double A=0,B=0;

  cin>>a[0];

  A=1;

  B=a[0];
  
  for(int i=1;i<N;i++){

    cin>>a[i];

    
    A=A*a[i]+B;
    
    B=a[i]*B;

    int temp=(__gcd((int)A,(int)B));

    A=A/temp;

    B=B/temp;

      
  }


  cout<<((double)B)/A<<endl;

  
  
    
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    int n = in<int>();
    if (n == 0)
        cout << 0 << "\n";

    string s = "";
    int i = 1;
    int b = 1;
    while (abs(n) / b >= 1)
    {
        b = pow(2, i);
        if (abs(n % b) > 0)
        {
            s += '1';
            n -= pow(-2, i - 1);
        }
        else
            s += '0';
        i++;
    }
    reverse(s.begin(), s.end());
    cout << s << "\n";
}

Measured memory_bytes: 256
S = input()
Q = int(input())
#query = [input().split() for _ in range(Q)]

rev = False
forw = ""
back = ""
for i in range(Q):
  query = input().split()
  if query[0] == "1":
    rev = not rev
  else:
    if (not rev and query[1] == "1") or (rev and query[1] == "2"):
      forw = query[2] + forw
    else:
      back += query[2]
#S = forw + S + back
if rev:
  S = back[::-1] + S[::-1] + forw[::-1]
else:
  S = forw + S + back
print(S)


Measured memory_bytes: 4452
#include <stdio.h>
#include <stdlib.h>

long *tree[100001];
long *node_num[100001];
long *colored_check[100001];

int main(void) {

  long n;
  scanf("%ld", &n);
  long tree_s[n+1];
  for (long i = 1; i <= n; i++) {
    tree_s[i] = 0;
  }
  long max = 0;
  long a,b;
  for (long i = 0; i < n-1; i++) {
    scanf("%ld %ld", &a, &b);
    tree_s[a]++;
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    node_num[a] = realloc(node_num[a], sizeof(long)*(tree_s[a]+1));
    colored_check[a] = realloc(colored_check[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
    node_num[a][tree_s[a]] = i;
    colored_check[a][tree_s[a]] = 0;
    if (tree_s[a] > max) {
      max = tree_s[a];
    }
    tree_s[b]++;
    tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    node_num[b] = realloc(node_num[b], sizeof(long)*(tree_s[b]+1));
    colored_check[b] = realloc(colored_check[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
    node_num[b][tree_s[b]] = i;
    colored_check[b][tree_s[b]] = 0;
    if (tree_s[b] > max) {
      max = tree_s[b];
    }
  }
  printf("%ld\n", max);

  long node_color[n-1];
  for (long i = 0; i < n-1; i++) {
    node_color[i] = 0;
  }

  long vertice_root[n+1];
  long vertice_color[n+1];
  for (long i = 1; i <= n; i++) {
    vertice_root[i] = -1;
    vertice_color[i] = 0;
  }
  vertice_root[1] = 0;

  long visited[n];
  visited[0] = 1;
  long head = 0;
  long tail = 0;
  long cur_tail = 0;
  long cur;
  long next;

  while (1) {
    if (tail >= n-1) {
      break;
    }
    for (long i = head; i <= tail; i++) {
      cur = visited[i];
      for (long j = 1; j <= tree_s[cur]; j++) {
        next = tree[cur][j];
        if (vertice_root[next] != -1) {
          continue;
        }
        vertice_root[next] = cur;
        for (long k = 1; k <= tree_s[cur]; k++) {
          if (k == vertice_color[cur]) {
            colored_check[cur][k] = 1;
            continue;
          }
          if (colored_check[cur][k] == 0) {
            colored_check[cur][k] = 1;
            node_color[node_num[cur][j]] = k;
            vertice_color[next] = k;
            break;
          }
        }
        cur_tail++;
        visited[cur_tail] = next;
      }
    }
    head = tail+1;
    tail = cur_tail;
  }

  for (long i = 0; i < n-1; i++) {
    printf("%ld\n", node_color[i]);
  }

  return 0;
}

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

int main() {
	int A,B;
	cin >> A >> B;
  cout << max(0, A-B*2) << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

L = [0] * N
for i in range(N):
    L[i] = (p[i] + 1) * p[i] / (2 * p[i])

L2 = [0] * (N + 1)
for i in range(N):
    L2[i+1] = L2[i] + L[i]

x = 0
for i in range(N - K + 1):
    x = max(x, L2[i+K] - L2[i])

print(x)

Measured memory_bytes: 24804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll tmp = n;
  vector <ll> res;
  for (ll i = 2; i*i <= tmp; i++) {
    if (tmp%i == 0) {
      while (tmp%i == 0) {
        res.push_back(i);
        tmp /= i;
      }
    }
  }
  if (tmp != 1) res.push_back(tmp);
  sort(res.begin(), res.end());
  cout << n << ':';
  rep(i, res.size()) cout << ' ' << res.at(i);
  cout << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cstdlib>
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define REP(i,n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vint;

int main() {
	int n, h;
	scanf("%d", &n);
	int count{}, max{INT_MIN};
	for(int i = 0; i < n; i++) {
		scanf("%d", &h);
		if(h >= max) {
			max = h;
			count++;
		}
	}
	printf("%d\n", count);

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//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;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll n, k;
    ll digit = 0;
    cin >> n >> k;


    while(1){
        digit++;
        n = n/k;
        if(n == 0) break;
    }

    cout << digit << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    stop
        return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,memo[300][300],ans[300][300],sum;
bool hoge[300][300];

signed main() {
    cin >> n;
    rep(i,n) rep(j,n) cin >> memo[i][j],ans[i][j] = memo[i][j];
    rep(k,n) rep(i,n) rep(j,n) ans[i][j] = min(ans[i][j],ans[i][k]+ans[k][j]);
    rep(i,n) rep(j,n) if (memo[i][j] != ans[i][j]) {cout << -1 << endl;return 0;}
    rep(k,n) rep(i,n) rep(j,n) if (ans[i][j] == ans[i][k] + ans[k][j] && ans[i][k] && ans[k][j]) hoge[i][j] = true;
    rep(i,n) rep(j,n) if (!hoge[i][j]) sum += ans[i][j];
    cout << sum/2<< endl;
}

Measured memory_bytes: 1792
uses math;
var i,a,t,m:longint;
    c:ansistring;
begin
  readln(a);
  readln(c);
  for i:=1 to a do
  begin
    if c[i]='I' then
      inc(t)
    else
      dec(t);
    m:=max(m,t);
  end;
  writeln(m);
end.

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){

int x = 0, y = 0, s = 0, a = 0;
double sy = 0  , i = 0;

while(scanf("%d,%d",&x,&y)+1){
s = s + x * y;
sy = sy + y;
i++;
}

a=int(sy / i + 0.5);

cout <<  s  <<  endl <<  a  <<  endl;

return 0;
}

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


int main(){
	int M,N;
	int ans;
	scanf("%d %d",&N,&M);
	if(N != 0 && M!= 0){
		ans = N*(N-1)/2 + M*(M-1)/2;
	}
	else if(N != 0 && M==0){
		ans = N*(N-1)/2;
	}
	else{
		ans = M*(M-1)/2;
	}

		printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
	string s1,s2;
	cin>>s1>>s2;
	string s3;
	for(int i=0;i<s2.length()-1;i++)
	{
		s3+=s2[i];
	}
	if(s1==s3)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main()
{
   int a,b,c;

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

   if(b-a==c-b)
   {
       cout<<"YES"<<endl;
   }
   else
   {
       cout<<"NO"<<endl;
   }
   return 0;


}


Measured memory_bytes: 256
import Control.Monad                                                                                                       
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [n,m] <- map read . words <$> getLine                                                                                    
  ab <- concat <$> replicateM m (map read . words <$> getLine)                                                             
  mapM_ print $ map (length . flip filter ab . (==)) [1..n]

Measured memory_bytes: 892
#include <iostream>
using namespace std;
//A と T、C と G 
int main(){
  char M[20];
  cin >> M;
  int count=0,max=0;
  for(int i=0;i<20;i++){
    if(M[i]=='A'||M[i]=='T'||M[i]=='C'||M[i]=='G'){
      count++;
    }else if(M[i]!='A'&& M[i]!='T'&& M[i]!='C'&& M[i]!='G'){
      if(max<count){
        max=count;
      }
      count = 0;
    }
  }
  cout << max << endl;
  return 0;
}
      

Measured memory_bytes: 256