akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int H, W, K, cnt = 0;
  char ctmp;
  cin >> H >> W >> K;
  vector<vector<bool>> c(H, vector<bool>(W, false));
  vector<pair<int, int>> black;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> ctmp;
      if (ctmp == '#') black.push_back(make_pair(i, j));
    }
  }

  int mhm = pow(2, H), mwm = pow(2, W);
  for (int hmask = 0; hmask < mhm; hmask++) {
    for (int wmask = 0; wmask < mwm; wmask++) {
      int bc = 0;
      for (auto ij : black) {
        if ((((hmask >> get<0>(ij)) & 1) == 0) &&
            (((wmask >> get<1>(ij)) & 1) == 0))
          bc++;
      }
      if (bc == K) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define Liny "Yes\n"
#define Linn "No\n"

int N,t;
map<int,int> b;
int a[3][3];

int solve(){
  int a[3][3]; REP(i,3){REP(j,3){cin>>a[i][j];}}
  int N; cin>>N; REP(i,N){cin>>t;b[t]=1;}
  bool ok;
  REP(i,3){
    ok=true;
    REP(j,3){
      if(!b[a[i][j]]){ ok=false;break;}
    }
    if(ok){return true;}
  }
  REP(i,3){
    ok=true;
    REP(j,3){
      if(!b[a[j][i]]){ ok=false;break;}
    }
    if(ok){return true;}
  }
  ok=true;
  REP(i,3){
    if(!b[a[i][i]]){ok=false;break;}
  }
  if(ok){return true;}
  ok=true;
  REP(i,3){
    if(!b[a[i][2-i]]){ok=false;break;}
  }
  if(ok){return true;}
  return false;
}

int main(){
  cout << (solve()?Liny:Linn);
  
}

Measured memory_bytes: 256
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>


using namespace std;
 
 
const int N = 505;
int a[N * N];
int check[N * N];
int b[N];
int num[N];
int n;

bool cmp(int i, int j)
{
    return b[i - 1] < b[j - 1];
}
 
int main() 
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        b[i]--;
        num[i] = i + 1;
        a[b[i]] = i + 1;
    }
    sort(num, num + n, cmp);
    int i = 0;
    int j = 0;
    int cnt = 1;
    while (i < n)
    {
        while (a[j])
        {
            j++;
        }
        if (cnt + 1 <= num[i])
        {
            a[j] = num[i];
            cnt++;
        }
        if (cnt == num[i])
        {
            i++;
            cnt = 1;
        }
    }
    i = 0;
    j = 0;
    cnt = num[0];
    while (i < n)
    {
        while (a[j])
        {
            j++;
        }
        if (cnt + 1 <= n)
        {
            a[j] = num[i];
            cnt++;
        }
        if (cnt == n)
        {
            i++;
            cnt = num[i];
        }
    }
    j = 0;
    for (int i = 0; i < n * n; i++)
    {
        if (a[i] == 0)
        {
            cout << a[i] << endl;
        }
        check[a[i]]++;
        if (i == b[num[j] - 1])
        {
            if (check[num[j]] != num[j])
            {
                cout << "No" << endl;
                exit(0);
            }
            j++;
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n * n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;


 
 
 
 
}

























Measured memory_bytes: 2176
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << "\n";
#else
#define DEBUG(message)
#endif

struct Solver {
  void solve() {
    int n;
    cin >> n;
    vector<int> a(26, -1);
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      vector<int> b(26, 0);
      for (auto ch : s) {
        b[ch - 'a'] += 1;
      }
      if (i == 0) {
        a = b;
      } else {
        for (size_t j = 0; j < 26; j++) {
          a[j] = min(a[j], b[j]);
        }
      }
    }
    string res;
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < a[i]; j++) {
        res += 'a' + i;
      }
    }
    cout << res << "\n";
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    Solver().solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int x,y,z = 0;
    for(int a = 0; a < 3000; a++){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y){
            z = x;
            x = y;
            y = z;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 2976
#B - ATCoder(ABC122)
S=input()
A=[]
c=0
for i in range(len(S)+1):
    for v in range(1,len(S)+1):
        A.append(c)
        c=0
        for s in S[i:v]:
            if s=="A"or s=="C" or s=="G" or s=="T":
                c+=1
            else:
                break
print(max(A))

Measured memory_bytes: 3060
#include <stdio.h>
int strcmp(const char *a, const char *b){

//	printf("%s %s", a, b);
//	printf("%c %c", *a, *b);

	while (*a == *b && *a && *b){
//		printf("%c %c", *a, *b);
		*a++;
		*b++;
		//if (*a == "\n"){ return -1; }
		//if (*b == "\n"){ return 1; }
	}

	return  (*a == *b) ? 0 : (*a > *b) ? -1 : 1;

//	if (*a == *b){ return 0; }
//	return (*a > *b) ? 1 : -1;
//	return 0;
}

int main(){
	int n;
	int i;

	int taro=0, hanako =0;
	char a[100], b[100];

	//	カードの数 n の入力 / n行の入力が続く 
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s %s", &a, &b);
	//	printf("%s, %s", a,b);
	//	printf("%d", strcmp(a, b));
		switch (strcmp(a, b)){
		case  0: taro += 1; hanako += 1; break;
		case -1: taro += 3; break;
		case  1: hanako += 3; break;
		}
	}
	
	printf("%d %d\n", taro, hanako);
	return 0;
}


Measured memory_bytes: 2072
a, b, c, d = map(int, input().split())

from fractions import gcd

def lcm(x, y):
   return (x * y) // gcd(x, y)

ac = (a - 1) // c
ad = (a - 1) // d
acd = (a - 1) // lcm(c, d)
x = (a - 1) - ac - ad + acd

bc = b // c
bd = b // d
bcd = b // lcm(c, d)
y = b - bc - bd + bcd

ans = y - x
print(ans)


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

int main() {
  int n ,k;
  cin >> n >> k;
  double sum = 0;
  for(int i = 1;i<=n;i++){
    int N = i;
    double seki = 1;
    for(int j = 0; j<10000;j++){
      if( N >= k){
        sum +=  seki;
        break;
      }
      N *= 2;
      seki /= 2;
    }
  }
  printf("%.12f", sum/n);
      
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 1e5 + 17;

int n;
ll ans;
int a[maxn];
vector<int> d = {-1, 0, 1};

bool read() {
    if (scanf("%d", &n) != 1)
        return false;

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

    return true;
}

void gen(int i, ll prod) {
    if (i == n) {
        if (prod % 2 == 0)
            ++ans;

        return ;
    }

    for (auto t : d)
        gen(i + 1, prod * (a[i] + t));
}

void solve() {
    gen(0, 1ll);
    printf("%lld\n", ans);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 256
### main

while true
  n = gets.strip.to_i
  break if n == 0

  chlds = []
  n.times.each do
    d, v = gets.strip.split(' ').map{|s| s.to_i}
    chlds << Rational(v, d)
  end

  ngcd = chlds.map{|c| c.numerator}.inject{|ng, cn| ng.gcd(cn)}
  dlcm = chlds.map{|c| c.denominator}.inject{|dl, cd| dl.lcm(cd)}

  chlds.map{|c| (c * dlcm / ngcd).numerator}.each do |cn|
    puts cn
  end
end

Measured memory_bytes: 6144
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a[10];
	for(int i=0;i<10;i++)
		cin>>a[i];
	for(int i=0;i<9;i++){
      for(int j=9;j>i;j--){
	    if(a[j]>a[j-1]){
	    int t=a[j];
	    a[j]=a[j-1];
	    a[j-1]=t;
	   }
      }
    }
	cout<<a[0]<<endl;
	cout<<a[1]<<endl;
	cout<<a[2]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#define P pair<double,double>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
bool cmp_x(const P& p, const P& q)
{
	if(p.first !=q.first) return p.first<q.first;
	return p.second>q.second;
}
double det(P p,P q){
	return add(p.first*q.second,-p.second*q.first);
}
P operator+(P p,P q){
	return P(p.first+q.first,p.second+q.second);
}
P operator-(P p,P q){
	return P(p.first-q.first,p.second-q.second);
}
P p[100];
vector<P> v;
vector<int> num;
int n;
bool used[100];
void make_convex(int l,int r)
{
	for(int i=l ;(r>l ? i<r : i>=r);(r>l ? i++ : i--))
	{
		if(used[i]) continue;
		for(bool loop=true;loop; )
		{
			loop=false;
			if(v.size()<2) {v.push_back(p[i]),num.push_back(i),used[i]=true; continue;}
			if(v.size()==2){
				if(det(v[1]-v[0],p[i]-v[1])<=0) v.push_back(p[i]),num.push_back(i),used[i]=true;
				else used[num[1]]=false,num.pop_back(),v.pop_back(),loop=true;
				continue;
			}
			int len=v.size();
			if(det(v[len-1]-v[len-2],p[i]-v[len-1])<=0) v.push_back(p[i]),num.push_back(i),used[i]=true;
			else used[num[len-1]]=false,num.pop_back(),v.pop_back(),loop=true;
		}
	}
}
int main()
{
	while(1)
	{
		cin >> n; if(!n) break;
		v.clear(); num.clear(); memset(used,false,sizeof(used));
		for(int i=0;i<n;i++) scanf("%lf,%lf",&p[i].first,&p[i].second);
		sort(p,p+n,cmp_x);
		//pはxの昇順、yの降順。時計回りで見ること
		make_convex(0,n);
		int tmp=v.size(); v.clear(),num.clear(); memset(used,false,sizeof(used));
		make_convex(n-1,0);
		cout << n-(tmp+v.size()-2) << '\n' ;
	}
}

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

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

  int ans=0;
  
  for(int i=1;i<n;i++){
    map< char , int > A,B;
    for(int j=0;j<i;j++)A[ s[j] ]++;
    for(int j=i;j<n;j++)B[ s[j] ]++;

    int cnt=0;
    for(int j=0;j<26;j++){
      char ch='a'+j;
      if( A[ch] > 0 && B[ch] > 0 ){
        cnt++;
      }
    }
    ans=max(ans,cnt);
  }

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


Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
h = list(map(int, input().split()))


def dfs(l, r):
    global h
    if l >= r:
        return 0
    for i in range(l, r):
        if h[i] == 0:
            return dfs(l, i) + dfs(i + 1, r)
    m = min(h[l:r])
    h = [h[i] - m * (l <= i < r) for i in range(N)]
    return m + dfs(l, r)
        

print(dfs(0, N))


Measured memory_bytes: 3188
fun main(args: Array<String>) = abc155c()

fun abc155c() {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second

    val answer = StringBuilder()

    for (it in map.filter { it.second == max }.map { it.first }.sorted()) {
        answer.appendln(it)
    }

    print(answer)
}


Measured memory_bytes: 113768
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int A, B, T, count = 0;
	cin >> A >> B >> T;
	
	
	while(T >= A){
        T -= A;
        count += B;
	}
	
	cout << count << endl;
}

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

struct P {
  int x, y, next;
  P(){}
  P(int x, int y) : x(x), y(y){}
};

int _abs(int n)
{
  return (n >= 0 ? n : n * (-1));
}

int h, w, d, q;
int l, r;
int mas[301][301];
P p[100000];
int dist[100001] = {};

int main()
{
  cin>> h >> w >> d;
  for(int i = 0; i < h; i++) 
    for(int j = 0; j < w; j++) {
      cin>> mas[i][j];
      p[mas[i][j]] = P(j, i);
    }
  
  for(int i = d + 1; i <= h * w; i++) {
    dist[i] = dist[i - d] + _abs(p[i].x - p[i - d].x) + _abs(p[i].y - p[i - d].y);
  }
  
  cin>> q;
  for(int i = 0; i < q; i++) {
    cin>> l >> r;
    cout<< dist[r] - dist[l] <<endl;
  }

  return 0;
}


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

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

  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)){
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
using namespace std;
int b[105];
vector<int> ans;
const int INF = 100000;
int n;
void del(int j) {
  for(int i = 1; i <= n; i++) {
    if(i >= j) {
      b[i] = b[i+1];
    }
  }

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

  for(int i = 1; i <= n; i++) cin >> b[i];

  for(int i = 0; i < n; i++) {
    for(int j = 1; j <= n - i; j++) {
      if(j < b[j]) {
	cout << "-1" << endl;
	return 0;
      }
      if(j == b[j]) {
	bool ok = true;
	for(int k = j + 1; k <= n - i ; k++) {
	  if(k - 1 < b[k]) {
	    ok = false;
	    break;
	  }
	}
	if(ok) {
	  ans.push_back(j);
	  del(j);
	}
      }
    }
  }

  for(int i = ans.size() - 1; i >= 0; i--) {
    cout << ans[i] << endl;
  }
	
	
  
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[-1]*n
d=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    d[a-1].append(b-1)
    d[b-1].append(a-1)
from collections import deque
q=deque()
q.append(0)
while q:
    now=q.popleft()
    for x in d[now]:
        if l[x]==-1:
            l[x]=now
            q.append(x)
if -1 in l:
    print("No")
else:
    print("Yes")
    for i in l[1:]:
        print(i+1)


Measured memory_bytes: 94880
#include<stdio.h>

int main(void){
  char n[5];
  int i,j;
  scanf("%s",n);
  for(j=0;n[j]!='\0';j++);
  for(i=0;i<j;i++){
    if(n[i]=='9'){
      n[i]='1';
    }else if(n[i]=='1'){
      n[i]='9';
    }
  }
  printf("%s",n);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long g(vector<long long> &b, long long th) {
    long long lb = 0;
    long long ub = b.size()-1;
    while (true){
        long long cur = (lb+ub+1)/2;
        if (b[cur] < th) {
            if (lb == cur) break;
            lb = cur;
        } else {
            if (ub == cur) break;
            ub = cur;
        }
    }
    if (b[lb] >= th) {
        lb -= 1;
    }
    return lb;
}

int main() {
    long long res = 0;
    long long n; cin >> n;
    vector<long long> a0(n); for (long long i = 0; i < n; ++i) cin >> a0[i];
    vector<long long> b0(n); for (long long i = 0; i < n; ++i) cin >> b0[i];
    vector<long long> a(n), b(n);
    for (long long k=0; k < 32; ++k) {
        long long T = 1<<k;
        for (long long i = 0; i < n; ++i) a[i] = a0[i] % (2*T);
        for (long long i = 0; i < n; ++i) b[i] = b0[i] % (2*T);
        sort(b.begin(), b.end());
        long long v = 0;
        for (long long i = 0; i < n; ++i) {
            v += g(b, 2*T-a[i]) - g(b, T-a[i]) + g(b, 4*T-a[i]) - g(b, 3*T-a[i]);
        }
        res += (v % 2) * T;
    }
    cout << res << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
vector<int> vec1,vec2;
typedef pair<int,int> p;
vector<p> ans1,ans2;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int n=read();
	for (int i=1; i<=n; i++) {
		if (i&1) vec1.push_back(read());
		else vec2.push_back(read());
	}
	int cnt1=vec1.size(),cnt2=vec2.size();
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	int cnt=1;
	for (int i=1; i<cnt1; i++) {
		if (vec1[i]==vec1[i-1]) ++cnt;
		else {
			ans1.push_back(p(cnt,vec1[i-1]));
			cnt=1;
		}
	}
	ans1.push_back(p(cnt,vec1[cnt1-1]));
	ans1.push_back(p(0,100001));
	cnt=1;
	for (int i=1; i<cnt2; i++) {
		if (vec2[i]==vec2[i-1]) ++cnt;
		else {
			ans2.push_back(p(cnt,vec2[i-1]));
			cnt=1;
		}
	}
	ans2.push_back(p(cnt,vec2[cnt2-1]));
	ans2.push_back(p(0,100002));
	sort(ans1.begin(),ans1.end());
	sort(ans2.begin(),ans2.end());
	int len1=ans1.size(),len2=ans2.size();
	if (ans1[len1-1].second!=ans2[len2-1].second) {
		printf("%d\n", cnt1-ans1[len1-1].first+cnt2-ans2[len2-1].first);
	}
	else {
		int ans=1<<30;
		ans=min(ans,cnt1-ans1[len1-1].first+cnt2-ans2[len2-2].first);
		ans=min(ans,cnt1-ans1[len1-2].first+cnt2-ans2[len2-1].first);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int N, M;
    string s[110], t[110];
    cin >> N;
    for (int i=0; i<N; i++) cin >> s[i];
    cin >> M;
    for (int i=0; i<M; i++) cin >> t[i];

    int res=0;
    for (int i=0; i<N; i++) {
        int tmp_res=0;
        for (int j=0; j<N; j++) {
            if (s[i] == s[j]) tmp_res++;
        }
        for (int k=0; k<M; k++){
            if (s[i] == t[k]) tmp_res--;
        }
        res = max(res, tmp_res);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<int> answer(N);
	for (int i = 0; i > N; ++i)
	{
		answer.at(i) = 0;
	}

	for (int i = 0, n = N - 1; i < n; ++i)
	{
		int temp = 0;
		std::cin >> temp;
		answer.at(temp - 1)++;
	}

	for (int i = 0, n = answer.size(); i < n; ++i)
	{
		std::cout << answer.at(i) << "\n";
	}

	return 0;
}

Measured memory_bytes: 4052
def solve(h,w,n,black_list):
  if len(black_list) == 0:
    return [(h-2)*(w-2)]+[0]*9
  idx_list = []
  for idx, (a,b) in enumerate(black_list):
    left = max(0, b-3)
    top = max(0, a-3)
    for row in range(top, a):
      if row+2 >= h:
        continue
      for col in range(left, b):
        if col+2 >= w:
          continue
        idx_list.append(row*w+col)

  set_count = set(idx_list)
  idx_list = sorted(idx_list)

  ans = [0]*9
  now = idx_list[0]
  count = 0
  for item in idx_list:
    if item == now:
      count += 1
    else:
      now = item
      if count == 10:
        print(item)
      ans[count-1] += 1
      count = 1
  ans[count-1] += 1
  return [(h-2)*(w-2)-len(set_count)]+ans


if __name__ == "__main__":
  h,w,n = map(int,input().split())
  black_list = [tuple(map(int,input().split())) for _ in range(n)]
  ret = solve(h,w,n,black_list)
  for i in ret:
    print(i)


Measured memory_bytes: 108388
N = int(input())
C, S, F = zip(*[tuple(map(int, input().split())) for _ in range(N-1)])
S = list(s for s in S) + [0]
for i in range(N-1):
    for j in range(i, N-1):
        S[i] = max(S[i], S[j])
        while S[i] % F[j]:
            S[i] += 1
        S[i] += C[j]
print(*S, sep="\n")

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long k = scanner.nextLong();
        long sum = 0;
        int a;
        long b;
        Map<Integer,Long> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            a = scanner.nextInt();
            b = scanner.nextInt();
            if (map.containsKey(a)){
                b += map.get(a);
                map.put(a,b);
            }else {
                map.put(a,b);
            }
        }
        for (int key:map.keySet()) {
            sum += map.get(key);
            if (sum >= k){
                System.out.println(key);
                break;
            }
        }
    }
}


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

ll A, B;

void input(){
  cin >> A >> B;
}

void solve(){
  input();
  ll ans = A - 2 * B;
  if(ans < 0){
    ans = 0;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<vector<int>>cnt(26,vector<int>(n));
    rep(i, 0, n){
        string s;
        cin >> s;
        int  m = s.size();
        rep(j, 0, m){
            cnt[s[j]-'a'][i]++;
        }
    }
    string ans;
    rep(i, 0, 26){
        int cnt2 = 100;
        rep(j, 0, n){
            cnt2 = min(cnt2, cnt[i][j]);
        }
        rep(j, 0, cnt2){
            ans += (i + 'a');
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    ld ans=0;
    lli n;
    cin>>n;
    rep(i,n){
        ld x;
        string u;
        cin>>x>>u;
        if(u=="JPY"){ 
            ans+=x;
        }
        else{ 
            ans+=x*380000;
        }
    }
    out(ans);
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N, K, X, Y;
    long long ans;
    scanf("%d %d %d %d", &N, &K, &X, &Y);
    if(N <= K){
        ans = X * N;
    }else{
        ans = X * K;
        ans += Y * (N - K);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 764
N = int(input())
List = [0 for _ in range(10000)]

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      k = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if k<=N:
        List[k-1] += 1
        
for i in range(N):
  print(List[i])


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

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ss = new int[n].Select(_ => Console.ReadLine()).OrderBy(s => s.Length).ToArray();

		var r = 0L;
		var root = new Node();

		foreach (var s in ss)
		{
			var node = root;
			for (int i = s.Length - 1; i >= 0; i--)
			{
				if (i == 0)
					if (node.Ends.ContainsKey(s[i])) node.Ends[s[i]]++;
					else node.Ends[s[i]] = 1;
				else
					foreach (var (c, v) in node.Ends)
						if (s.IndexOf(c, 0, i + 1) >= 0) r += v;

				if (!node.Nexts.ContainsKey(s[i]))
					node.Nexts[s[i]] = new Node();
				node = node.Nexts[s[i]];
			}
		}

		Console.WriteLine(r);
	}
}

class Node
{
	public Dictionary<char, int> Ends = new Dictionary<char, int>();
	public Dictionary<char, Node> Nexts = new Dictionary<char, Node>();
}


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

int n;
int x[10], y[10];

double dist(int i,int j){
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return sqrt(dx*dx + dy*dy);
}

int main(){
  cin>>n;
  for (int i = 1;i<=n;i++){
    cin>>x[i]>>y[i];
  }
  vector<int> v(n);
  rep(i,n) v.at(i) = i+1;
  double sum = 0.0;
  do{
    rep(i,n-1){
      sum += dist(v[i],v[i+1]);
    }
  }while (next_permutation(v.begin(),v.end()));
  int mot = 1;
  for (int i = 2;i<=n;i++){
    mot *= i;
  }
  cout << fixed << setprecision(10) << sum/mot << endl;
}

Measured memory_bytes: 256
object Main{
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val arr = List.fill(26)(0).toArray
    while (sc.hasNext){
      val chars = sc.next.toLowerCase.toCharArray
      for (c <- chars){
        if ('a' <= c && c <= 'z'){
          arr(c - 'a') += 1
        }
      }
    }
    for (i <- 'a' to 'z'){
      println(i + " : " + arr(i - 'a'))
    }
  }
}

Measured memory_bytes: 45664
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

for i in range(n-k):
  if t[i] == t[i+k]:
    t[i+k] = 0

print(sum([t.count("r")*p, t.count("s")*r, t.count("p")*s]))

Measured memory_bytes: 4084
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << '\n';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll h,w; cin >> h >> w;
    string s[h];
    rep(i,h)cin >> s[i];
    auto h_check = [&](int x){
        bool ok = true;
        for(auto &c : s[x])ok &= c == '.';
        return ok;
    };
    auto w_check = [&](int x){
        bool ok = true;
        rep(i,h)ok &= s[i][x] == '.';
        return ok;
    };

    vector<string> ans;
    rep(i,h){
        if(h_check(i))continue;
        string tmp;
        rep(j,w){
            if(w_check(j))continue;
            tmp += s[i][j];
        }
        ans.emplace_back(tmp);
    }

    print(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main(void){
  int n;
  std::cin >> n;

  std::vector<int> L(n);
  for(int i=0; i<n; i++){
    std::cin >> L[i];
  }

  std::sort(L.begin(), L.end(), std::greater<int>());

  long long int count_2 = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(L[i] - L[j] >= L[j]) break;
      //std::cout << "i " << i << " j " << j << std::endl;

      const auto iter = std::upper_bound(std::next(L.begin(), j), L.end(), L[i] - L[j]  + 1, std::greater<int>());
      //std::cout << iter - std::next(L.begin(), j) - 1 << " " << (*iter) << std::endl;
      count_2 += iter - std::next(L.begin(), j) - 1;
      
    }
  }

  std::cout << count_2 << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,k,h;
	cin>>n>>k;
	int ans=0;
	for(int i=0; i<n; i++){
		cin>>h;
		if(h>=k){
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

int main(){
    string S;
    cin >> S;
    int cnt_n=0;
    int cnt_s=0;
    int cnt_e=0;
    int cnt_w=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='N') cnt_n++;
        else if(S[i]=='S') cnt_s++;
        else if(S[i]=='E') cnt_e++;
        else cnt_w++;
    }
    if(cnt_n>0&&cnt_s>0&&cnt_e>0&&cnt_w>0){
        cout << "Yes" << endl;
    }else if(cnt_n==0&&cnt_s==0&&cnt_e>0&&cnt_w>0){
        cout << "Yes" << endl;
    }else if(cnt_n>0&&cnt_s>0&&cnt_e==0&&cnt_w==0){
        cout << "Yes" << endl;
    }else if(cnt_n==0&&cnt_s==0&&cnt_e==0&&cnt_w==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

const int MAXN = 302;

double dp[MAXN][MAXN][MAXN];
int N,vis[MAXN][MAXN][MAXN];

double solve(int x,int y,int z){
	
	if(vis[x][y][z]) return dp[x][y][z];
	//printf("Solving %d %d %d\n",x,y,z);
	vis[x][y][z] = 1;

	if(x == 0 && y == 0 && z == 0) return dp[x][y][z] = 0;

	int soma = x + y + z;
	double convertido = (double)soma;
	double tot = (N - soma)/convertido;
	
	//printf("Tot antes %d %d %d %d %lf\n",N - soma,x,y,z,tot);

	if(x != 0) tot += x*((solve(x-1,y,z) + 1)/convertido);
	if(y != 0) tot += y*((solve(x+1,y-1,z) + 1)/convertido);
	if(z != 0) tot += z*((solve(x,y+1,z-1) + 1)/convertido);

	//printf("Tot (%d,%d,%d) = %lf\n",x,y,z,tot);

	return dp[x][y][z] = tot;

}

int main(){

	int a[4] = {0,0,0,0};

	cin >> N;

	for(int i = 1;i<=N;i++){
		int x;
		cin >> x;
		a[x]++;
	}

	printf("%.9lf\n",solve(a[1],a[2],a[3]));

	return 0;
}

Measured memory_bytes: 165836
#include <cstdio>
#include <iostream>
using namespace std;
int pd[110][110];
int main(){
	int h,w,n,x=0;
	cin>>h>>w>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		for(int j=0;j<a[i];j++){
			if((x/w)%2==0) pd[x/w][x%w]=i+1;
			else pd[x/w][w-(x%w)-1]=i+1;
			x++;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==w-1) printf("%d\n",pd[i][j]);
			else printf("%d ",pd[i][j]);
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

void rotation(vector<int> &v,int fin)
{
    int tmp = v[fin];
    for(int c=fin;c>=1;c--)
    {
        v[c]=v[c-1];
    }
    v[0]=tmp;
}

int main()
{
    int n,r;
    while(cin>>n>>r)
    {
        if(n==0) break;
        vector<int> v(n);
        for(int c=0;c<n;c++) v[c]=n-c;
        for(int c=0;c<r;c++)
        {
            int a,b;
            cin>>a>>b;
            for(int c2=0;c2<b;c2++)
            {
                rotation(v,b+a-2);
            }
        }
        cout<<v[0]<<endl;
    }
}

Measured memory_bytes: 1196
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

void solve() {
  int desire;
  cin >> desire;
  desire--;
  vector<pii> edge;
  vector<int> weight;
  {
    int a = 1;
    for(int i = 19; i >= 2; i--) {
      edge.push_back({i, i+1}); weight.push_back(0);
      edge.push_back({i, i+1}); weight.push_back(a);
      a *= 2;
    }
  }
  int a = (1 << 18) - 1;
  int d = 2;
  while(desire > 0) {
    while(desire >= a) {
      edge.push_back({1, d});
      weight.push_back(desire - a);
      desire -= a + 1;
    }
    a /= 2;
    d++;
  }
  if(desire == 0) {
    edge.push_back({1, 20});
    weight.push_back(0);
  }
  cout << 20 << " " << edge.size() << "\n";
  for(int i = 0; i < edge.size(); i++) {
    cout << edge[i].first << " " << edge[i].second << " " << weight[i] << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
import java.util.*;

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

		int K = sc.nextInt();
		String S = sc.next();
		int len = S.length();
		
		if(len <= K){
			System.out.println(S);
			return;
		}

		String ans = "";
		for(int i = 0; i < K; i++){
			ans += S.charAt(i);
		}
		ans += "...";
		
		System.out.println(ans);
		return;

	}
}

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

int main(void){
      int N;cin >> N;
      int A[N];
      for(int i=0;i<N;i++){
            cin >> A[i];
      }
      
      for(int i=0;i<N;i++){
            if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0){
                  cout << "DENIED" << endl;
                  return 0;
            }
      }
      cout << "APPROVED" << endl;
}


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

using namespace std;

typedef struct Card{
  int number;
  struct Card *next;
} card;

void print(card*);
void lift(int , card*);
void cut(int , int ,card*,card**);


int main(){
  int n,m, k;
  card *firstnode, *lastnode, *newnode, *thisnode, *lastcardnode;
  
  firstnode = (card*)malloc(sizeof(card));
  firstnode->number = 0;
  lastnode = (card*)malloc(sizeof(card));
  lastnode->number = 0;
  thisnode = firstnode;
  cin >> n >> m;
  
  for(int i = 1; i< 2*n+1 ; i++){
    //cout << i<<endl;
    newnode = (card*)malloc(sizeof(card));
    newnode->number = i;
    thisnode->next = newnode;
    thisnode = newnode;
    if(i == 2*n) {
      thisnode->next = lastnode;
      lastcardnode = thisnode;
    }
  }
  
  for(int i = 0; i< m; i++){
    cin >> k;
    if(k == 0) lift(n, firstnode);
    else cut(n,k, firstnode,&lastcardnode);
    // cout <<" "<<lastcardnode->number<<endl; 
  }
  
  
  print(firstnode->next);
  
  return 0;
}

void print(card* a){
  card *thisnode = a;
  while(thisnode->number){
    cout << thisnode->number<< endl;
    thisnode = thisnode->next;
  }
}

void lift(int n, card *firstnode){
  card *thisnode;
  card *odd, *even, *p,*q;
  thisnode = firstnode->next;  
  for(int i = 0; i< n; i++){
    thisnode = thisnode->next;
  }
  //cout <<thisnode->number<<endl;
  
  odd = firstnode->next;
  even = thisnode;
  while(1){
    if(odd->next == thisnode) {
      odd->next = even;
      break;
    }
    p = odd->next;
    q = even->next;
    odd-> next = even;
    even->next = p;
    even = q;
    odd = p;
  }
}

//n枚のカード上k枚目で切る
void cut(int n, int k,card *firstnode, card **lastcardnode){
  //cout<<lastcardnode->number <<endl;
  card *knode, *k1node, *thisnode;
  card *p, *q;
  thisnode = firstnode->next;
  
  for(int i = 0; i<k+1 ; i++){
    if(i == k-1) knode = thisnode;
    if(i == k) k1node = thisnode;
    thisnode = thisnode->next;
  }
  //cout <<lastcardnode->number <<"\n"<<k1node->number<<endl;
  q = (*lastcardnode)->next;
  p = firstnode->next;
  firstnode->next = k1node;
  (*lastcardnode)->next = p;
  knode ->next = q;
  //以下の１行でlastcardnode が指す値を変えようとしているが、関数からでると保持されない
  *lastcardnode = knode;
  //cout<<" "<<lastcardnode->number <<endl;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e5 + 7;///

int main(){
    TIME
    string s;
    cin >> s;
    if(s.size() % 2 == 1){
        cout << "No";
        r_0;
    }
    for(int i = 0; i < s.size() - 1; i ++){
        if(s[i] == 'h' && s[i + 1] == 'i'){
                ++i;
            continue;
        }
        cout << "No";
        r_0;
    }
    cout << "Yes";
}
///...


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ot(x) cout<<x<<" ";
#define out(x) cout<<x<<"\n";
#define pb push_back
#define in insert
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define fa(i,a) for(auto i:a)
#define f(i,x,a) for(i=x;i<a;i++)
#define next cout<<"\n";
#define sp(n) cout<<fixed<<setprecision(n);
#define  gcd(a,b)    __gcd(a,b)
#define bs  binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test int t;cin>>t;while(t-->0)
#define mod 1000000007



int main()
{
   fast
  int n,i,c=0,g=0;cin>>n;
  int a[n],b[n];
  f(i,0,n){
  cin>>a[i]>>b[i];
  }
  f(i,0,n-2){
  if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2] ){
    c++;
  }

  }
  if(c!=0){
    Yes
  }
  else{
    No
  }
  return 0;
}





Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;


int main()
{
	int N; cin >> N;
	int S = 0;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		S ^= A[i];
	}
	for (int i = 0; i < N; ++i) {
		cout << (S ^ A[i]) << ' ';
	}
	cout << endl;
	
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
unordered_set<ll> a;

bool ok(ll x){
    while(x){
        if(a.count(x%10)){
            return false;
        }
        x/=10;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>x;
        a.insert(x);
    }
    while(!ok(n))n++;
    cout<<n;


    return 0;
}

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

int main() {
  for (int h, w; cin >> h >> w;) {
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++)
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
          cout << "#";
        else
          cout << ".";
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  
  vector<int> a(q);
  for (int i=0; i<q; i++){
    cin >> a.at(i);
  }

  vector<int> p(n, k-q);
  for (int i=0; i<q; i++){
    p.at(a.at(i)-1)++;
  }

  for(int i=0; i<n; i++){
//    cout << p.at(i) << endl;

    if (p.at(i) > 0) {
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

  }

  return 0;
}

Measured memory_bytes: 1408
from collections import deque
s=deque(list(input()))
q=int(input())
rev=0
for i in range(q):
  t=list(input().split(" "))
  if t[0]=="1":
    rev=rev+1
  else:
    if t[1]=="1":
      if rev%2==0:
        s.appendleft(t[2])
      else:
        s.append(t[2])
    else:
      if rev%2==0:
        s.append(t[2])
      else:
        s.appendleft(t[2])
if rev%2==0:
  print("".join(s))
else:
  s.reverse()
  print("".join(s))

Measured memory_bytes: 8676
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 18:40:35 2020

@author: Kanaru Sato
"""

n,m = list(map(int,input().split()))
slist = [[] for i in range(m)]
for i in range(m):
    _ = list(map(int,input().split()))
    for j in range(len(_)-1):
        slist[i].append(_[j+1]-1)
p = list(map(int,input().split()))

ans = 0
for state in range(2**n):
    Allbright = 1
    for light in range(m):
        count = 0
        for switch in range(n):
            if switch in slist[light]:
                count += (state&(1<<switch))>>switch
        if count%2 != p[light]%2:
            Allbright = 0
            break
    if Allbright == 1:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

const int MAX_V = 1e5+10;
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];

void DS(int s) {
	priority_queue<P,vector<P>,greater<P>> que;
	for(int i = 0; i <= V; i++) d[i] = INF; d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto e : G[v]) {
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	vector<P> vvv;
	while(1){
		for(int i = 0; i < MAX_V; i++) G[i].clear();
		V = 0;
		cin >> E;
		if(E == 0) break;
		for(int i = 0; i < E; i++){
			int f,t,c;
			cin >> f >> t >> c;
			G[f].push_back({t,c});
			G[t].push_back({f,c});
			V = max({V,f,t});
		}
		E *= 2;
		V++;
		int a1 = -1,a2 = INF;
		for(int i = 0; i < V; i++){
			DS(i);
			int sum = 0;
			for(int j = 0; j < V; j++){
				if(d[j] != INF) sum += d[j];
			}
			if(sum < a2) {a1 = i,a2 = sum;};
		}
		vvv.push_back(P(a1,a2));

		//cout << a1 << " " << a2 << endl;
	}
	for(int i = 0; i  <vvv.size(); i++){
		cout << vvv[i].first << " " << vvv[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 5408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >

int q,x,y,z;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>q;
    ll sum=0;
    ll sum1=0,sum2=0;
    ll sum3=0;
    priority_queue <int> maxx;
    priority_queue <int,vector<int>,greater<int> > minn;
    rep(i,0,q-1)
    {
        cin>>x;
        if(x==1)
        {
            cin>>y>>z;
            sum+=z;
            if(maxx.empty()|| y<maxx.top())
            {
                maxx.push(y);
                sum1+=y;
            }
            else
            {
                minn.push(y);
                sum2+=y;
            }
            if(maxx.size()>minn.size()+1)
            {
                int t=maxx.top();maxx.pop();
                sum1-=t;sum2+=t;
                minn.push(t);
            }
            if(minn.size()>maxx.size())
            {
                int t=minn.top();minn.pop();
                sum1+=t;sum2-=t;
                maxx.push(t);
            }
        }
        else
        {
            ll u=maxx.size();
            ll v=minn.size();
            sum3=sum-sum1+sum2+maxx.top()*u-maxx.top()*v;
            cout<<maxx.top()<<" "<<sum3<<"\n";

        }

    }


    return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,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 mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int 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())


int main(){
  int n;
	cin>>n;
  if(n%111==0){cout<<n<<endl;}
  else{
  int di;
  di = n/111;

  cout <<(di+1)*111<< endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
        long long  a,b,i,idx,tmp,gca,ans=1;
        cin >> a >> b;
        while(1){
                tmp = b%a;
                if(tmp==0) break;
                b = a;
                a = tmp;
        }
        gca = a;
        vector<long long> v((long long)sqrt(gca)+1);
        for(i=2;i<(long long)sqrt(gca)+1;++i){
                if(v.at(i)==1 || a%i!=0) continue;
                else{
                        ++ans;
                        idx = i;
                        while(idx<(long long)sqrt(gca)+1){
                                v.at(idx) = 1;
                                idx += i;
                        }
                        while(a%i==0) a /= i;
                }
        }
        if(a>1) ++ans;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 11032