akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    in_arr(string, s, h);
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#')
                continue;
            int sum = 0;
            for(int k = max(i - 1, 0); k < min(h, i + 2); ++k){
                for(int l = max(j - 1, 0); l < min(w, j + 2); ++l){
                    if(s[k][l] == '#')
                        ++sum;
                }
            }
            s[i][j] = (char)(sum + '0');
        }
    }
    for_each(s.begin(), s.end(), [](string s){ cout << s << endl; });
    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(2*M);
  int x=0;
  
  for(int i=0;i<2*M;i++) {
    cin >> a.at(i);
  }
  
  for(int i=0;i<N;i++) {
    for(int l=0;l<2*M;l++) {
      if(a.at(l)==i+1) {
        x++;
      }
    }
    cout << x << endl;
    x=0;
  }
}
      


Measured memory_bytes: 256
<?php
$char[0] = str_split(trim(fgets(STDIN))); //一文字ずつ配列に
$char[1] = str_split(trim(fgets(STDIN)));
$char[2] = str_split(trim(fgets(STDIN)));

//print_r($char);
echo($char[0][0].$char[1][1].$char[2][2]);
?>

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, M; cin >> N >> M; ll sum = 0;
  vll a(N); FOR(i,N){ cin >> a[i]; sum += a[i]; }
  
  //main
  ll ans = 0;
  if(sum%(4*M)==0){
    FOR(i,N){ 
      if(a[i]>=(sum/(4*M))){
        ans ++;
      }
    }
  }else{
    FOR(i,N){ 
      if(a[i]>(sum/(4*M))){
        ans ++;
      }
    }
  }
  
  // output
  if(ans >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No"  << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        //全2点間の距離を加算
        double sum = 0;
        for(int i = 0; i < N - 1; i++){
            for(int j = i + 1; j < N; j++){
                sum += Math.sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
            }
        }

        //どの2点間に関しても、2(n-1)!回通る。
        //全通りはn!
        //sum*2(n-1)!/n!=sum*2/n;

        System.out.println(sum*2/N);
    }
}

Measured memory_bytes: 22740
while input = gets
    h, w = input.chomp.split(" ").map(&:to_i)
    
    if h == 0 && w == 0
        exit
    end
    
    for i in 1..h
        for j in 1..w
            if i % 2 != 0
                if j % 2 != 0
                    print "#"
                else
                    print "."
                end
            else
                if j % 2 != 0
                    print "."
                else
                    print "#"
                end
            end
        end
        puts ""
    end
    puts ""
end


Measured memory_bytes: 6876
s = input()
n = len(s)
MOD=2019
ls=[0]*n
ls[-1] = int(s[-1])
freq=[0]*2019
for i in reversed(range(1,n)):
    ls[i-1] = (ls[i]+int(s[i-1])*pow(10,n-i,MOD))%MOD
    
for i in range(n):
    freq[ls[i]]+=1
ans=0
for i in range(2019):
    if i==0:
        ans+=freq[i]*(freq[i]+1)//2
    else:
        ans+=freq[i]*(freq[i]-1)//2

print(ans)




Measured memory_bytes: 75512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int a[100];
int main()
{
  int n,m,sum = 0;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+n,greater<int>());
  sum+=4*m-1;
  sum/=4*m;
  for(int i=0;i<m;i++){
    if(a[i] < sum){cout<<"No";return 0;}
  }
	cout<<"Yes";
	
}

Measured memory_bytes: 256
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    mi = n[1]*(n[0]-1)+n[2]
    ma = n[2]*(n[0]-1)+n[1]
    print(ma-mi+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
/*
vector<string> split(const string& input, char delimiter)
{
  istringstream stream(input);

  string field;
  vector<string> result;
  while (getline(stream, field, delimiter)) {
    result.push_back(field);
  }
  return result;
}
*/
int main() {
  string str, word;
  int i = 0;

  getline(cin, str);
  while(str[i] != '\0'){
    if(str[i] == '.' || str[i] == ',')
      str[i] = ' ';
    i++;
  }

/*
  for (const string& s : split(str, ' ')) {
    int size = s.size();
    if(size > 2 && size < 7) {
      cout << s << ' ';
    }
  }
 */
    
  stringstream ss(str);
  
    i=0;
  while (ss >> word) {
    int len = word.length();
      if(len>=3&&len<=6){
        if(i==0){cout<<word;i++;}
        else    cout<<' '<<word;
    }
  }
    
  cout << endl;
  return 0;
}


Measured memory_bytes: 3156
#include <iostream>

#include <algorithm>
using namespace std;
int main(void){
   long H, W;
   cin >> H >> W;
 
   if (H < 2 || W < 2)
   {
       cout << 1 << endl;
       return 0;
   }
 
   long row_max = H % 2 == 0 ? long(H / 2) : long(H / 2) + 1;
   long row_min = long(H / 2);
   
   long result = 0;
   for (long c = 0; c < W; ++c)
   {
       result += (c % 2 == 0) ? row_max : row_min;
   }
   cout << result << endl;
   
   return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque


def grouping(n, N, d):
    group = [-1]*(N+1)
    group[n] = 1

    q = deque([n])
    while q:
        s = q.popleft()
        for t in d[s]:
            if group[t]!=-1:continue
            group[t] = group[s] + 1
            q.append(t)

    for k, v in d.items():
        for j in v:
            if not abs(group[j]-group[k])==1:
                return False
    
    return group


def solve():
    N = int(input())
    d = defaultdict(list)
    for i in range(1, N+1):
        for j, s in enumerate(input(), start=1):
            if s=="1":
                d[i].append(j)
    

    ans = -1
    for i in range(1, N+1):
        res = grouping(i, N, d)
        if res != False:
            ans = max(ans, max(res))
    
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3700
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1;
		cin >> n;
		if (n < 0) return 0;
		vector<int> a(n);
		map<int, LL> m;
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
			m[a[i]] += 1;
		}
		LL tot = 0;
		for (auto kv : m) {
			tot += (kv.second * (kv.second - 1)) / 2;
		}
		for (int i = 0; i < n; ++i) {
			LL cnt = tot;
			LL c = m[a[i]];
			if (c > 1) {
				cnt -= (c * (c - 1)) / 2;
				--c;
				cnt += (c * (c - 1)) / 2;
			}
			cout << cnt << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 10240
using System;
public class AtZ {
    public static void Main() {
        string read = Console.ReadLine();
        int start = 0;
        int end = 0;
        for (int i = 0; i < read.Length; i++) {
            if (read.Substring(i, 1) == "A") {
                start = i;
                break;
            }
        }
        for (int i = read.Length - 1; i >= 0; i--) {
            if (read.Substring(i, 1) == "Z") {
                end = i;
                break;
            }
        }
        Console.WriteLine(end-start+1);
    }
}

Measured memory_bytes: 7512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n[] = new int[6];
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 6; i++) {
			n[i] = sc.nextInt();
		}
		String s = sc.next();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'N') {
				n = north(n);
			} else if (s.charAt(i) == 'S') {
				n = south(n);
			} else if (s.charAt(i) == 'E') {
				n = east(n);
			} else if (s.charAt(i) == 'W') {
				n = west(n);
			}
		}
		System.out.println(n[0]);

	}

	public static int[] north(int[] n) {
		int temp = n[0];
		n[0] = n[1];
		n[1] = n[5];
		n[5] = n[4];
		n[4] = temp;
		return n;
	}

	public static int[] south(int[] n) {
		int temp = n[0];
		n[0] = n[4];
		n[4] = n[5];
		n[5] = n[1];
		n[1] = temp;
		return n;
	}

	public static int[] west(int[] n) {
		int temp = n[0];
		n[0] = n[2];
		n[2] = n[5];
		n[5] = n[3];
		n[3] = temp;
		return n;
	}

	public static int[] east(int[] n) {
		int temp = n[0];
		n[0] = n[3];
		n[3] = n[5];
		n[5] = n[2];
		n[2] = temp;
		return n;
	}
}



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

int H, W;

int allblank(vector<vector<char>> table,int i, int j);

int main() {
  
  cin >> H >> W;
  
  vector<vector<char>> table(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }
  
  int count = 0;
  for (int i = 0; i < H; i++) {
    count = 0;
    for (int j = 0; j < W; j++) {
      if (allblank(table, i, j) != 1) {
        cout << table.at(i).at(j);
        count ++;
      }
      if (j == W - 1 && count != 0) cout << endl;
      
    }
  }
}

int allblank(vector<vector<char>> table,int i, int j) {
  int countW = 0, countH = 0;
  
  for (int h = 0; h < H; h++) {
    if (table.at(h).at(j) != '.') {
      countH++;
      break;
    }
  }
  
  for (int w = 0; w < W; w++) {
    if (table.at(i).at(w) != '.') {
      countW++;
      break;
    }
  }
  
  if (countH * countW > 0) return 0;
  return 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int main(){
   int N, M, C;
   cin >> N >> M >> C;
   vector<int> B(M);
   for(int i = 0; i < M; i++){
      cin >> B[i];
   }
   vector<vector<int>> A;
   for(int i = 0; i < N; i++){
      vector<int> a_tmp(M);
      for(int j = 0; j < M; j++){
         cin >> a_tmp[j];
      }
      A.push_back(a_tmp);
   }

   int ans = 0;
   for(int i = 0; i < N; i++){
      int sum = 0;
      for(int j = 0; j < M; j++){
         sum += A[i][j]*B[j];
      }
      if(sum + C > 0){
         ans++;
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif
int a,b;
cin>>a>>b;
int ans=-1;
for(int i=1;i<=10000;i++){
    if((i*8)/100 == a && (i*10)/100==b){
        ans=i;
       break;
    }

}
cout<<ans<<endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	int a, b;
	while (cin >> a){
		cin >> b;
		int sum = a + b;
		stringstream ss;
		ss << sum;
		string str(ss.str());
		cout << str.size() << endl;
	}
}

Measured memory_bytes: 3104
from math import atan, degrees
a,b,x = map(int,input().split())
o = 2 * x / (a*a) - b
if o < 0:
    h = 2 * (x / a) / b
    print(degrees(atan(b/h)))
else:
    print(degrees(atan((b-o)/a)))


Measured memory_bytes: 3060
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque

MOD = 10 ** 9 + 7

S = input()

l = [S[0]]

for s in S:
    if l[-1] != s:
        l.append(s)

print(len(l) - 1)

sys.exit(0)


Measured memory_bytes: 4588
#include<iostream>
#include<climits>
#include<math.h>
using namespace std;
int main(){

 int n,*x,i,smallest = INT_MAX,largest=INT_MIN,min_sum=INT_MAX,min_number = INT_MAX,number,sum;
 long int sum_square=0;
 cin>>n;
 x = new int[n];
 
 for(i=0;i<n;i++){
	 cin>>x[i];
         smallest = min(smallest,x[i]);
	 largest = max(largest,x[i]);
 }

 for(number = smallest;number<=largest;number++){
  
	 sum=0;

         for(i=0;i<n;i++){
	  
		 sum+=(x[i]-number);
	 }
        
	 sum = abs(sum);
	 if(sum<min_sum){
	   
		 min_sum = sum;
		 min_number = number;
	 }

 }

 for(i=0;i<n;i++){
 
	 sum_square+=pow(abs(x[i]-min_number),2);
 }
 cout<<sum_square;

}


Measured memory_bytes: 3648
#include <stdio.h>

#define INFTY 20000
#define Max 100
#define White 0
#define Gray 1
#define Black 2

int num,M[Max][Max];

int prim(){

  int sum;
  int u,minv;
  int d[Max],p[Max],color[Max];
  int i,v;
  
  for(i=0;i<num;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=White;
  }


  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;

    for(i=0;i<num;i++){
      if(minv>d[i]&&color[i]!=Black){
	u=i;
	minv=d[i];
      }
    }

    if(u==-1)break;

    color[u]=Black;
    for(v=0;v<num;v++){
      if(color[v]!=Black && M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=Gray;
	}
      }
    }
  }

  sum=0;
  for(i=0;i<num;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }

  return sum;
}

int main(){
  int e,i,j;
  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      scanf("%d",&e);
      M[i][j]= (e==-1)?INFTY:e;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct UFTree2 {
private:
	vector<int> mNode;
	vector<int> mRank;
	vector<int> mNodeNum;

public:
	UFTree2(int n) : mNode(n), mRank(n), mNodeNum(n)
	{
		for (int i = 0; i < n; i++) {
			mNode[i] = i;
			mNodeNum[i] = 1;
		}
	}

	int find(int x)
	{
		if (mNode[x] == x) {
			return x;
		}
		else {
			mNode[x] = find(mNode[x]);
			return mNode[x];
		}
	}

	void unite(int x, int y)
	{
		int idxX = find(x);
		int idxY = find(y);

		if (idxX == idxY) {
			return;
		}

		if (mRank[idxX] > mRank[idxY]) {
			mNode[idxY] = idxX;
			mNodeNum[idxX] += mNodeNum[idxY];
		}
		else {
			mNode[idxX] = idxY;
			mNodeNum[idxY] += mNodeNum[idxX];
			if (mRank[idxX] == mRank[idxY]) {
				mRank[idxY]++;
			}
		}
	}

	bool isSameSet(int x, int y)
	{
		return find(x) == find(y);
	}

	int getNodeNum(int x)
	{
		auto node = find(x);
		return mNodeNum[node];
	}
};


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

	UFTree2 t(N);
	vector<int> ans(N, -1);
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		t.unite(A, B);
		--ans[A];
		--ans[B];
	}

	for (auto i = 0; i < N; ++i)
	{
		ans[i] += t.getNodeNum(i);
	}

	for (auto i = 0; i < K; ++i)
	{
		int C, D;
		cin >> C >> D;
		--C;
		--D;
		if (t.isSameSet(C, D))
		{
			--ans[C];
			--ans[D];
		}
	}

	for (auto i = 0; i < N; ++i)
	{
		cout << max(0, ans[i]);
		if (i < N - 1)
		{
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <stdlib.h>
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */
#include <vector>
#include <stack>
#include <algorithm>
#include <string>
#include <climits>

typedef std::vector<int> liste;
typedef liste::const_iterator iter;

void print_array(liste list) {
    for(int i = 0; i < list.size(); ++i){
        if(i>0) std::cout << " ";
        std::cout << list[i];
    }
    std::cout << std::endl;
}

bool solve(int i,int m,liste& list) {
    if(m==0) {
        return true;
    }
    if(i>=list.size()||m<0) {
        return false;
    }
    bool res = (solve(i+1,m,list)||solve(i+1,m-list[i],list));
    return res;
} 
    
int main(void){
        
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int value;
    liste list,question;
    int n;
    std::cin >> n;
    for(int i=0; i<n; i++) {
        std::cin >> value;
        list.push_back(value);
    } 
    std::cin >> n;
    for(int i=0; i<n; i++) {
        std::cin >> value;
        question.push_back(value);
    } 

    for(int i=0; i<question.size(); i++) {
        if(solve(0,question[i],list)) {
            std::cout << "yes" << std::endl;            
        } else {
            std::cout << "no" << std::endl;            
        }
    } 
    
    return 0;
}

Measured memory_bytes: 1216
import itertools

D,G = list(map(int,input().split()))
PC = []
for i in range(D):
    PC.append(list(map(int,input().split())))

#ボーナスをどの問題でもらうか
#bonus=[0]*D

a = [0,1]
Ls = list(itertools.product(a, repeat=D))

#最大数 更新していく
out=1000

for L in Ls:
    count=0
    score=0

    for i in range(D):
        if L[i]==1:
            count+=PC[i][0]
            score+=100*(i+1)*PC[i][0]
            score+=PC[i][1]

    hanpa = D-1
    while (L[hanpa]==1) and (hanpa>=0):
        hanpa-=1
    if hanpa==-1:
        cnt=0
    else:
        cnt=0
        while (score<G) and (cnt<PC[hanpa][0]):
            cnt+=1
            count+=1
            score+=(hanpa+1)*100
    if (score>=G) and (count<out):
        out=count
print(out)

Measured memory_bytes: 40944
#include<bits/stdc++.h>
using namespace std;
#define     ll      long long
ll v[400001];


int main()
{
    ll a,b,c,d,sum=0,sum2=0;
    cin>>a>>b>>c>>d;
    if(c%b==0){
        sum+=c/b;
    }
    else sum=(c/b)+1;

    if(a%d==0){
        sum2=a/d;
    }
    else sum2+=(a/d)+1;
    if(sum>sum2) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3620
package main

import (
    "fmt"
)

var n int 
var l [][]int
var r [][]int

const w = int(0)
const b = int(1)

func main() {
    fmt.Scan(&n)
    l = make([][]int, n)
    r = make([][]int, n)
    for i := 0; i < n-1; i++ {
        var x, y int 
        fmt.Scan(&x, &y) 
        l[x-1] = append(l[x-1], y-1)
        l[y-1] = append(l[y-1], x-1)
    }   
    for i := range l { 
        r[i] = make([]int, 2)
        r[i][w] = -1
        r[i][b] = -1
    }   

    //fmt.Println(l, r)

    var res int 
    for _, color := range []int{w, b} {
        res += calc(0, -1, color) % mod 
    }   
    res = res % mod 
    //fmt.Println("res: ", i, res)

    fmt.Println(res)
}

const mod = 1000000000 + 7 

func calc(k, pk, color int) int {
    //fmt.Println("calc input: ", k, pk, color)
    if r[k][color] != -1 {
        return r[k][color]
    }   
    if len(l[k]) == 1 && l[k][0] == pk {
        r[k][color] = 1 
        //fmt.Println("calc root: ", 1, k, color)
        return r[k][color]
    }   
    res := 1
    for _, nk := range l[k] {
        if nk == pk {
            continue
        }   
        if color == w { 
            res *= (calc(nk, k, w) + calc(nk, k, b)) 
        } else if color == b { 
            res *= calc(nk, k, w)
        }   
        res = res % mod 
        //fmt.Println("calc k: ", res, k, color, pk, nk)
    }   
    r[k][color] = res % mod 
    return r[k][color]
}


Measured memory_bytes: 38400
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A
  * Array - Reversing Numbers
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val result = io.StdIn.readLine().split(" ").map(_.toInt).reverse.mkString(" ")
    println(result)
  }
}

Measured memory_bytes: 43956
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

char s[100100];
int n;

int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    if ((s[1]=='0') || (s[n]=='1')) {puts("-1");return 0;}
    rep(i,1,n-1)
        if (s[i]!=s[n-i]) {puts("-1");return 0;}
    int now=1;
    rep(i,2,n)
    {
        printf("%d %d\n",now,i);
        if (s[i-1]=='1') now=i;
    }
    return 0;
}

Measured memory_bytes: 1536
n=int(input())
h=list(map(int,input().split()))
cnt=0
for i in range(100):
    prev = bool(h[0])
    h[0] = h[0] - prev
    for j in range(1,n):
        if bool(h[j]) == prev:
            h[j] = h[j] - prev
            continue
        else:
            cnt += prev
            prev = bool(h[j])
            h[j] = h[j] - prev
    cnt+=prev
print(cnt)

Measured memory_bytes: 3064
#!/usr/bin/python3
# import bisect
# from collections import Counter, deque, OrderedDict, defaultdict
# from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    ll=[0]*(n+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            ll[j]+=1
    

    ans=0
    for i in range(1,n+1):
        ans+=i*ll[i]

    print(ans)
        

    
resolve()

Measured memory_bytes: 145912
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b,c,d = map(int, input().split())
v1 = c//b + int(c%b!=0)
v2 = a//d + int(a%d!=0)
if v1<=v2:
    ans = "Yes"
else:
    ans = "No"
print(ans)

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

int main(){
	string s,t;
  	cin >> s >> t;
  	sort (s.begin(),s.end());
  	sort (t.begin(),t.end());
  	reverse (t.begin(),t.end());
  	if (s<t) cout << "Yes" << endl;
  	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

i64 modpow(i64 a, i64 n, i64 mod)
{
  i64 res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  string S;
  cin >> S;
  i64 ans = 0, now = 0;
  vector<i64> cnt(2019);
  cnt[0]++;
  int size = S.size();
  for (i64 i = size - 1; 0 <= i; i--)
  {
    (now = now + (S[i] - '0') * modpow(10, size - i - 1, 2019)) %= 2019;
    ans += cnt[now];
    cnt[now]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>


int main(void){
    int n;
    scanf("%d", &n);
    if(n == 1){
        printf("Hello World\n");
    }
    else if(n == 2){
        int a, b;
        scanf("%d", &a);
        scanf("%d", &b);
        printf("%d", a + b);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
int main()
{
	std::string S;
	std::cin >> S;
	std::cout << (((S[2] == S[3]) && (S[4] == S[5])) ? "Yes" : "No") << std::endl;
	return 0;
}

Measured memory_bytes: 3600
class Integer
  
  attr_accessor :mod
  @@mod = 10 ** 9 + 7
  @@h = Hash.new
  
  def +@(other)
    super(other) % @@mod
    # res %= @@mod if res < 0 || res >= @@mod
    # res
  end
  
  def -@(other)
    super(other) % @@mod
    # res %= @@mod if res < 0 || res >= @@mod
    # res
  end
  
  alias_method :primitive_times, :*
  def *(other)
    self.primitive_times(other) % @@mod
  end
  
  def /(other)
    @@h[other] ||= other.pow(@@mod-2, @@mod)
    self * @@h[other] % @@mod
  end
  
  alias_method :primitive_inspect, :inspect
  def inspect
    (self % @@mod).primitive_inspect
  end
  
  alias_method :primitive_to_s, :to_s
  def to_s
    (self % @@mod).primitive_to_s
  end
end

# ABC163
n, k = gets.to_s.split.map{|e|e.to_i}

ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum

puts ans
# p 1.class.instance_methods
# p 1.class.superclass.instance_methods

Measured memory_bytes: 15976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {


        public void Calc()
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var a = new string(ab[0].ToString()[0], ab[1]);
            var b = new string(ab[1].ToString()[0], ab[0]);

            var list = new string[2];
            list[0] = a;
            list[1] = b;


            Console.WriteLine(list.OrderBy(x => x).ToArray()[0]);
        }
    }
}

Measured memory_bytes: 13664
from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().strip().split()]
    lista = [1]*(n+1)
    vis = [False]*(n+1)
    vis[1] = True
    for w in range(m):
        x,y = [int(z) for z in stdin.readline().strip().split()]
        if(vis[x]):
            lista[y]+=1;
            lista[x]-=1;
            vis[y] = True
            if(lista[x] == 0):
                vis[x] = False
        else:
            lista[y]+=1;
            lista[x]-=1;
    print(vis.count(True))

main()


Measured memory_bytes: 4596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		String str[];
        double r;
        double area,circumference;
        String a,c;


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        str = br.readLine().split(" ");
        r = Double.parseDouble(str[0]);

        area = r * r * Math.PI;
        circumference = (r + r) * Math.PI;
        a = String.format("%.6f", area);
        c = String.format("%.6f", circumference);
        System.out.println(a + " " + c);
	}
}

Measured memory_bytes: 24636
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,K;cin>>N>>K;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  SORT(a);
  ll ans = 0;
  for(ll i = N - 1; i >= N - K; i--){
    ans += a[i];
  }
  cout<<ans<<endl;

}


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

int main() {
	// your code goes here
	int h, n;
	cin >> h >> n;
	int cnt = 0;
	while(true)
    {
        //h -= n;
        if(h != 0)
        {
            h -= n;
            cnt++;
        }
        if(h <= 0){
            break;
        }
    }
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define MODNUM (INT(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

unordered_map<ll, ll> memo;
ll solve(ll h) {
	if(h == 1) {
		return 1;
	}
	if(memo[h] != 0) {
		return memo[h];
	}
	return memo[h] = 1 + 2 * solve(h / 2);
}

int main() {
	ll h;
	scanf("%lld", &h);
	printf("%lld\n", solve(h));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define CLR(array) memset( array, 0, sizeof array )
typedef long long int ll;

int n;
#define MAXN 10
int fac[MAXN];
int P[MAXN];
int Q[MAXN];

void initFAC(){
	fac[0] = 1;
	fac[1] = 1;
	for( int i = 2; i <= 8; i++ )
		fac[i] = i * fac[i-1];
}

int permutation( int A[] ){
	int R[MAXN];
	CLR(R);
	int res = 0;

	for( int i = 1; i <= n-1; i++ ){
		int t = 0;
		for( int j = i+1; j <= n; j++ ){
			if( A[j] < A[i] )	t++;
		}
		R[i] = t;
		res += t * fac[n-i];
		// printf("%d ", R[i]);
	}
	// printf("\n");

	return res;
}

int main(){
	initFAC();

	std::cin >> n;
	for( int i = 1; i <= n; i++ )
		std::cin >> P[i];
	
	for( int i = 1; i <= n; i++ )
		std::cin >> Q[i];

	int a = permutation(P);
	// printf("a = %d\n", a);
	int b = permutation(Q);
	// printf("b = %d\n", b);

	std::cout << std::abs( a-b ) << std::endl;
}


Measured memory_bytes: 256
def resolve():
    S = str(input())
    ans = 0
    for i in range(len(S)):
        if (S[0] == '0'):
            if i % 2 == 1 and S[i] != '1':
                ans += 1
            elif i % 2 == 0 and S[i] != '0':
                ans += 1
            else:
                pass
        if S[0] == '1':
            if i % 2 == 1 and S[i] != '0':
                ans += 1
            elif i % 2 == 0 and S[i] != '1':
                ans += 1
            else:
                pass
    print(ans)
    return

resolve()

Measured memory_bytes: 3244
#include <cstdlib>
#include <iostream>
#include <set>
using namespace std;

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

	for(int n; cin >> n, n;) {
		set<int> cards[2];
		for(int i = 1; i <= 2 * n; ++i)
			cards[1].insert(i);

		for(int i = 0; i < n; ++i) {
			int card;
			cin >> card;
			cards[0].insert(card);
			cards[1].erase(cards[1].find(card));
		}

		int turn = 0;
		int field = 0;
		while(true) {
			set<int>::iterator it = cards[turn].upper_bound(field);
			if(it == cards[turn].end())
				field = 0;

			else {
				field = *it;
				cards[turn].erase(it);
				if(cards[turn].size() == 0)
					break;
			}

			turn ^= 1;
		}

		cout << cards[1].size() << "\n" << cards[0].size() << endl;
	}


	return EXIT_SUCCESS;
}

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

#define PI 3.141592653589793

int main(void) {
	int x, n;
	int p[101];
	int i;
	int a=0;
	int b=0,c=0;

	scanf("%d%d", &x,&n);

	if (n == 0)
	{
		printf("%d\n", x);
	}
	else
	{
		for (i = 0; i < n; i++)
		{
			scanf("%d", &p[i]);
		}
		i = 0;
		while (i < n)
		{
			if (p[i]  == x-a)
			{
				b=1;
			}
			if (p[i] == x+a)
			{
				c=1;
			}
			if (b == 1 && c == 1)
			{
				a++;
				i = -1;
				b = 0;
				c = 0;
			}
			i++;
		}
		if (b == 0)
		{
			printf("%d\n", x - a);
		}
		else if (c == 0)
		{
			printf("%d\n", x + a);
		}
	}
	return 0;
}

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

#define ll long long

 
int main(void){
    vector<ll>v(3);
    cin >> v[0]>>v[1]>>v[2];
    sort(v.rbegin(),v.rend());
    cout << 10*v[0] + v[1] + v[2]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    string n;
    cin >> n;
    int ans = 0;
    FOR(i,0,n.size())if(n[i] == '2')ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

int gcd(int x, int y) {
    if(x < y) swap(x, y);
    while(y > 0) {
        int tmp = x;
        x = y;
        y = tmp % y;
    }
    return x;
}
int main() {
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


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

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;


int main(){
    int N,W;
    cin >> N >> W;
    long *w,*v;
    long **t;
    w = new long[N];
    v = new long[N];
    t = new long*[N];
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
        t[i]=new long[W+1];
        t[i][0]=0;
    }
    
    for(int _w=1;_w<=W;_w++){
        t[0][_w]=0;
        if(w[0]<=_w){
            t[0][_w]=v[0];
        }
        for(int i=1;i<N;i++){
            if(_w<w[i]){
                t[i][_w]=t[i-1][_w];
            }
            else{
                t[i][_w]=max(t[i-1][_w],t[i-1][_w-w[i]]+v[i]);
            }
        }
    }
    
    cout<<t[N-1][W];
    
    for(int i=0;i<N;i++){
        delete[] t[i];
    }
    delete[] w;
    delete[] v;
    delete[] t;
    return 0;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    string s; cin >> s;
    int ans = 700;
    rep(i,3){
        if (s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int aa = 0;
	int bb = 0;
	vint ans(n);
	rep(i,n){
		if(s[i]=='a'){
			if(aa+bb<a+b){
				ans[i] = 1;
				aa++;
			}
		}
		else if(s[i]=='b'){
			if(aa+bb<a+b && bb < b){
				ans[i] = 1;
				bb++;
			}
		}
	}
	rep(i,n){
		cout<<(ans[i]?"Yes":"No")<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
map<string,int>mp;
ll a[maxn];
int main() {
	ll n,x;
	cin>>n>>a[0];
	for(int i=1;i<=n;i++){
		//scanf("%lld",&a[i]);
		cin>>a[i]; 
	}
	sort(a,a+n+1);
	ll temp=a[1]-a[0];
	for(int i=2;i<=n;i++){
		temp=__gcd(temp,a[i]-a[i-1]);
	}
	cout<<temp;
	return 0;
}


Measured memory_bytes: 1024
<?php

$players = array('t', 'h');
$score   = array_fill_keys($players, 0);

fscanf(STDIN, '%d', $n);

for ($i = 0; $i < $n; $i++) {
    $card = array_combine(
        $players,
        explode(' ', trim(fgets(STDIN)))
    );

    foreach (getPoint($card) as $player => $point) {
        $score[$player] += $point;
    }
}

echo implode(' ', $score), PHP_EOL;

function getPoint($card)
{
    if (count(array_unique($card)) == 1) {
        return array_fill_keys(array_keys($card), 1);
    }

    return array(array_search(max($card), $card) => 3);
}

Measured memory_bytes: 6644
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(){
  int K, X;
  cin >>K>>X;
  int min=X-(K-1);
  int max=X+(K-1);
  for(int i=min; i<=max; i++) cout << i <<" ";
  cout <<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	hl := make([]int, n)

	for i := 0; i < n; i++ {
		hl[i] = nextInt()
	}
	sort.Ints(hl)

	minrun := hl[k-1] - hl[0]

	for i := 1; i < n-k+1; i++ {
		runsum := hl[k-1+i] - hl[i]
		minrun = min(minrun, runsum)
	}

	fmt.Println(minrun)
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4412
#include <iostream>

using namespace std;

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

    string S; cin >> S;
    int N = S.length();

    int ans = N;
    for (int k = 1; k < N; k++)
        if (S[k-1] != S[k])
            ans = min(max(k, N-k), ans);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  vector<pair<int, int>> tasks;
  int N;
  cin >> N;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    tasks.push_back(make_pair(b, a));
  }
  sort(tasks.begin(), tasks.end());
  int sum = 0;
  bool c = true;
  REP(i, N) {
    sum += tasks[i].second;
    if (tasks[i].first < sum) {
      c = false;
      break;
    }
  }
  cout << (c ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
#define N 100

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

void dfs_visit(int);
void dfs();

static int n, M[N][N], color[N], d[N], f[N], tt;;

int main(){
  int u, k, v, i, j;

  scanf("%d", &n);

  for (i = 0; i < n; i++){
    for (j = 0; j < n; j++){
        M[i][j] = 0;
    }
  }
  
  for (i = 0; i < n; i++){
    for (j = 0; j < n; j++){
        M[i][j] = 0;
    }
  }
  
  for (i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    u--;
    for (j = 0; j < k; j++){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs();
  return 0;
}

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  tt++;
  d[u] = tt;
  for (v = 0; v < n; v++){
    if (M[u][v] == 0) continue;
    if (color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int i, u;
  for (i = 0; i < n; i++){
      color[i] = WHITE;
  }
  tt = 0;
  for (u = 0; u < n; u++){
    if (color[u] == WHITE){
        dfs_visit(u);
    }
  }
  for (i = 0; i < n; i++){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
}


Measured memory_bytes: 2744
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int cul(int a, int b, int op){
	switch (op) {
		case 0:
			return a + b;
		case 1:
			return a - b;
		case 2:
			return a * b;
	}
	return -1;
}

const char op[] = {'+', '-', '*'};

int main(){
	vector<int> a(4);
	auto f = [&](){
		rep(i,3){
			rep(j,3){
				rep(k,3){
					do{
						if(cul(cul(cul(a[0],a[1],i),a[2],j),a[3],k) == 10){
							printf("(((%d %c %d) %c %d) %c %d)\n", a[0], op[i], a[1], op[j], a[2], op[k], a[3]);
							return;
						}
					}while(next_permutation(all(a)));
					do{
						if(cul(cul(a[0],a[1],i),cul(a[2],a[3],j),k) == 10){
							printf("((%d %c %d) %c (%d %c %d))\n", a[0], op[i], a[1], op[k], a[2], op[j], a[3]);
							return;
						}
					}while(next_permutation(all(a)));
				}
			}
		}
		cout << 0 << endl;
		return;
	};
	while(cin >> a[0] >> a[1] >> a[2] >> a[3], a[0]){
		f();
	}
}



Measured memory_bytes: 3240
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b&&b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26360
def main():
    N = int(input())
    st = [0]*N
    for i in range(N):
        s,t = input().split()
        st[i] = [s,int(t)]
    X = input()
    ans = 0
    flag = False
    for i in range(N):
        if flag:
            ans += st[i][1]
        if st[i][0] == X:
            flag = True
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38352