akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < maxbits; j++)
		{
			dp[(i ^ 1) & 1][j][0][0] = 0;
			dp[(i ^ 1) & 1][j][0][1] = 0;
			dp[(i ^ 1) & 1][j][1][0] = 0;
			dp[(i ^ 1) & 1][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = (dp[s][j][0][0] + dp[s][j][1][0]) % 100000;
			int sum1 = (dp[s][j][0][1] + dp[s][j][1][1]) % 100000;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxt]][0][0] += sum0;
				dp[t][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxt + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxt + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxt + 1]][1][0] %= 100000;
					dp[t][conv[nxt + 1]][1][1] %= 100000;

					dp[t][conv[nxt]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxt]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
					dp[t][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
				}

				dp[t][conv[nxt]][1][1] += sum1;
			}

			dp[t][conv[nxt]][1][0] %= 100000;
			dp[t][conv[nxt]][1][1] %= 100000;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= 100000;
	}

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

	return 0;
}

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

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

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

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

const int maxn = 2e5 + 100;


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

ll a[maxn];
int main()
{
  ios::sync_with_stdio(0);
  ll h;
  cin >> h;
  ll ans = 0;
  ll cnt = 1;
  while(h)
  {
    ans += cnt;
    cnt *= 2;
    // cout << cnt << endl;
    h /= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
N, *AB = map(int, open(0).read().split())

A = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[0])
B = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[1])

if N % 2 == 1:
    L = A[N // 2][0]
    R = B[N // 2][1]
else:
    L = A[N // 2 - 1][0] + A[N // 2][0]
    R = B[N // 2 - 1][1] + B[N // 2][1]

print(R - L + 1)

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

int main(void){
  int t[5];
  int a[5];
  int x = 0;
  int a_max = 9;
  for(int i = 0; i < 5; i ++) {
    scanf("%d", &t[i]);
    a[i] =  t[i] % 10;
    if(a[i] == 0)
        continue;
    int tmp = a[i];
    //printf("tmp = %d a_max = %d\n", tmp, a_max);
        if( tmp < a_max ){
            x = i;
            a_max = tmp;
        }
    //printf("x = %d\n", x);
  }
  //printf("a = %d", a[x]);
  int ans = 0;
  for(int i = 0; i < 5; i++){
    if(i == x)
        continue;
    if(a[i] != 0)
      ans = ans + t[i] + abs((a[i] - 10));
    else
      ans = ans + t[i];
    //printf("ans = %d\n", ans);
  }
  //printf("t = %d, a = %d\n", t[x], a[x]);
  ans = ans + t[x];
  printf("%d", ans);
  return 0;
}

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

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

     if(weather == "Sunny")
     cout << "Cloudy" << endl;

     if(weather == "Cloudy") 
     cout << "Rainy" << endl;

     if(weather == "Rainy")
     cout << "Sunny" << endl;

     return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)


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

    int n; cin >> n;
    vector<int> a(n), dp(n, 0);
    for(int i=0; i<n; ++i) cin >> a[i];

    for(int i=n-1; i>=0; --i){
        if(i == n-1 || a[i] < a[i+1]) dp[i] = 0;
        else dp[i] = dp[i+1]+1;
    }

    int ans = 0;
    for(int i=0; i<n; ++i) chmax(ans, dp[i]);
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

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

int a[200100],b[200100];

int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int l=b[n/2],r=b[n/2+1];
	for(int i=1;i<=n;i++){
		if(a[i]<=l){
			printf("%d\n",r);
		}
		else printf("%d\n",l);
	}
	return 0;
}


Measured memory_bytes: 3712
n = int(input())
L = []
 
for x in range(3,n+1):
    if x % 3 == 0:
        L.append(x)
    else:
        i = x
        while i != 0:
            if i % 10 == 3:
                L.append(x)
                break
            else : i /= 10
 
print "",
 
while L != []:
    print L.pop(0),

Measured memory_bytes: 6544
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


N = int(input())
cnt = 0
for i in range(1, N+1):
    for j in range(1, N + 1):
        for k in range(1, N + 1):
            cnt += gcd(i, j, k)
print(cnt)

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

int n;
vector<int> out[200010];
int cycle[200010];
int grundy[200010];
int st = -1;
const int CYCLE = 42;

int dfs(int x) {
	cycle[x] = 1;
	for(int i : out[x]) {
		if(cycle[i] == 1) {
			st = i;
			cycle[x] = CYCLE;
			return CYCLE;
		}
		else if(cycle[i] == 0) {
			if(dfs(i) == CYCLE) {
				cycle[x] = CYCLE;
				if(x == st) return 0;
				else return CYCLE;
			}
		}
	}
	cycle[x] = 2;
	return 0;
}

int getgrundy(int x) {
	set<int> s;
	for(int i : out[x])
		if(cycle[i] != CYCLE)
			s.insert(getgrundy(i));
	int ans = 0;
	auto it = s.begin();
	while(it != s.end()) {
		if(*it == ans) {
			++ans;
			++it;
		}
		else return grundy[x] = ans;
	}
	return grundy[x] = ans;
}

bool chk(int x, int val, int res) {
	if(x == st) return res == val;
	int nxt = -1;
	for(int i : out[x]) {
		if(cycle[i] == CYCLE) {
			nxt = i;
		}
	}
	return chk(nxt, grundy[nxt] + (grundy[nxt] == val), res);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	memset(cycle, 0, sizeof cycle);
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		--x;
		out[x].push_back(i);
	}
	for(int i = 0; st == -1 and i < n; ++i) if(cycle[i] == 0) dfs(i);
	for(int i = 0; i < n; ++i) if(cycle[i] == CYCLE) getgrundy(i);
	int nxt;
	for(int i : out[st]) {
		if(cycle[i] == CYCLE) {
			nxt = i;
		}
	}
	if(st == nxt or chk(nxt, grundy[nxt] + (grundy[st] == grundy[nxt]), grundy[st])) cout << "POSSIBLE" << endl;
	else if (chk(nxt, grundy[nxt] + ((grundy[st] + 1) == grundy[nxt]), grundy[st] + 1)) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 19584
#include<iostream>
using namespace std;
int main()
{
int n,t;
cin>>n>>t;
int ct[n][2];
for(int i=0;i<n;i++){
for(int j=0;j<2;j++){
cin>>ct[i][j];
}
}
int min = 100000;
for(int i=0;i<n;i++){
if(ct[i][1]<=t&&ct[i][0]<min){
min = ct[i][0];
}
}
if(min>10000){cout<<"TLE"<<endl;}
else{
cout<<min<<endl;;
}

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i = 0; i <n; i++) cin>>h[i];
  //dp[i] = min cost to reach ith stone
  // dp[i] = min(h[i]-h[i-1] + dp[i-1], h[i]-h[i-2] + dp[i-2]);
  //dp[0] = 0, dp[1] = h[1] - h[0];
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2;i<n;i++) {
    dp[i] = min((abs(h[i]-h[i-1]) + dp[i-1]),(abs(h[i]-h[i-2]) + dp[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		System.out.println(s[0] + (s.length-2) + s[s.length-1]);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
  char ch;
  while (1)
  {
    scanf("%c", &ch);
    if('a' <= ch && ch <= 'z') {
      printf("%c", ch-32);
    }
    else if('A' <= ch && ch <= 'Z') {
      printf("%c", ch+32);
    } else {
      printf("%c", ch);
    }
    if(ch == '\n') break;
  }
  
  return 0;
}


Measured memory_bytes: 2620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<functional>
using namespace std;

signed main() {
	int a; cin >> a;
	int b[100];
	for (int c = 0; c < a; c++)cin >> b[c];
	int sum = 0;
	for (int c = 0; c < a - 1; c++) {
		int MIN = b[c],n=c;
		for (int d = c + 1; d < a; d++) {
			if (b[d] < MIN) {
				MIN = b[d]; n = d;
			}
		}
		if (n == c)continue;
		swap(b[c], b[n]);
		sum++;
	}
	for (int i = 0; i < a; i++) {
		if (i)cout << " ";
		cout << b[i];
	}
	cout <<endl<< sum << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());
using ll = long long;
using P = pair<int,int>;

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

vector<pair<long long, long long>> enum_divisor(long long n)
{
  vector<pair<long long, long long>> dst;
  long long N = n;
  for(long long i = 2; i * i <= n; i++)
  {
    if(N % i != 0)
      continue;

    dst.push_back(make_pair(i, 0));
    while(N % i == 0)
    {
      dst.back().second++;
      N /= i;
    }
  }
  if(N >= 2)
    dst.push_back(make_pair(N, 1));
  sort(dst.begin(), dst.end());
  return dst;
}
int main()
{
  long long N, p;
  cin >> N >> p;
  long long ans = 1;
  auto factors = enum_divisor(p);
  rep(i, factors.size())
  {
//    cout << factors[i].first << ", " << factors[i].second << endl;
    if(factors[i].second >= N)
      ans *= pow(factors[i].first, factors[i].second / N);
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {
    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '0') {
            ++a;
        }
        else {
            ++b;
        }
    }
    cout << 2 * min(a, b);
    return 0;
}

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

using namespace std;

int main()
{
	const int Max = 100005;
	int table[Max] = { 0 };
	int N, a;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a;

		table[a]++;
		table[a + 1]++;
		table[a + 2]++;
	}

	int ans = 0;
	for (int i = 0; i < Max; i++)
	{
		if (ans < table[i])
			ans = table[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ll N;
  cin >> N;
  ll left = 0, right = N-1;
  string ls, rs;
  string S;
  
  for(int tmp = 0; tmp < 20; tmp++){
    if(tmp == 0){
      
      cout << left << endl;
      cin >> S;
      if(S == "Vacant") break;
      ls = S;
    }
    else if(tmp == 1){
      cout  << right << endl;
      cin >> S;
      if(S == "Vacant") break;
      rs = S;
    }
    else{
      ll next = (right + left) / 2;
      cout << next << endl;
      cin >> S;
      if(S == "Vacant") break;
      if((next % 2 == 0 && S == ls) || (next % 2 != 0 && S == rs)) left = next;
      else right = next;
    }
  }
}

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

using namespace std;

#define MAX_V 150
#define INF (1LL<<55)
typedef long long ll;

struct Edge {
    int to;
    ll cap, rev;
    Edge(int to, ll cap, ll rev) :
        to(to), cap(cap), rev(rev) {}
};

vector<Edge> G[MAX_V];
ll level[MAX_V], iter[MAX_V];

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

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

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

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

void init()
{
    for (int i = 0; i < MAX_V; i++) {
        G[i].clear();
    }
}

int main()
{
    ll N, W;
    string in;
    map<string, int> mp = {
        {"Monday",    0},
        {"Tuesday",   1},
        {"Wednesday", 2},
        {"Thursday",  3},
        {"Friday",    4},
        {"Saturday",  5},
        {"Sunday",    6}
    };
        
    while (cin >> N >> W, N) {
        init();
        
        ll t, c, sum = 0;
        int S = N + 7, T = S + 1;
        for (int i = 0; i < N; i++) {
            cin >> t >> c;
            sum += t;
            add_edge(S, i, t);
            for (int j = 0; j < c; j++) {
                cin >> in;
                add_edge(i, N + mp[in], INF);
            }
        }
        for (int i = 0; i < 7; i++) {
            add_edge(N + i, T, W);
        }
        cout << (max_flow(S, T) >= sum ? "Yes" : "No") << endl;
    }
    return 0;
}

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

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

    int ans = 0;
    for(int i = a; i <= b; i++){
        int num = i;
        int x = num / 1000;
        int y = num % 10 * 10;
        num /= 10;
        y += num % 10;
        if(x == y) ans++;
    }
    cout << ans << endl;
}

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

ll check(ll a,ll b,ll c){
    if(a*a+b*b+c*c+a*b+b*c+c*a <= 1e4) return a*a+b*b+c*c+a*b+b*c+c*a;
    else return 0;
}

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

    ll n;
    cin >> n;

    vector<ll> count_vec(1e4+7,0);

    rep1(a,100)rep1(b,100)rep1(c,100){
        ll culc = check(a,b,c);
        if(culc != 0){
            count_vec[culc-1]++;
        }
    }
    
    rep(i,n){
        cout << count_vec[i] << "\n";
    }
}

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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string n;
    cin >> n;
    ll a = 0;
    rep(i, n.size()) {
        a += n.at(i) - '0';
    }
    if (a % 9 == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3720
x[31],a,b,i,j;main(w){for(scanf("%d%*d",&w);i++<w;)x[i]=i;for(;~scanf("%d,%d",&a,&b);x[b]=i)i=x[a],x[a]=x[b];for(;j++<w;)printf("%d\n",x[j]);exit(0);}

Measured memory_bytes: 0
x,n=map(int,input().split())

p=list(map(int,input().split()))

s=[]
ans=0
for i in range(201):
    if x+i in p:
        ans+=1
    else:
        s.append(x+i)

t=[]
for j in range(201):
    if x-j in p:
        ans+=1
    else:
        t.append(x-j)

cnt=min(abs(min(s)-x),abs(max(t)-x))
if abs(min(s)-x)==abs(max(t)-x):
    print(x-cnt)
else:
    if cnt+x in p:
        print(abs(cnt-x))
    else:
        print(cnt+x)

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <climits> // INT_MAX
#include <cmath> // ceil()
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;
const int INF = INT_MAX;

int p[11];
int c[11];

int main() {
	int d, g;
	cin >> d >> g;
	
	rep(i, d) cin >> p[i] >> c[i];

	int ans = INF;
	for (int bit = 0; bit < (1 << d); ++bit) {
		int score = 0, num = 0, no_selected = 0;
		rep(i, d) {
			if ((1 << i) & bit) {
				score += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else {
				no_selected = i;
			}
		}

		if (score < g) {
			int base_score = 100 * (no_selected + 1);
			int need_plb_num = (g - score + base_score - 1) / base_score; // うまいこと切り上げできるように-1する
			if (need_plb_num >= p[no_selected]) {
				continue;
			}
			num += need_plb_num;
		}

		ans = min(ans, num);
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n - 1];
        for (int i = 0 ; i < n - 1 ; i++) {
            b[i] = sc.nextInt();
        }
        int [] a = new int [n];
        a[0] = b[0];
        for (int i = 1 ; i < n - 1 ; i++) {
            a[i] = Math.min(b[i - 1], b[i]);
        }
        a[n - 1] = b[n - 2];
        int ans  = 0;
        for (int i = 0 ; i < n ; i++ ) {
            ans += a[i];
        }
        System.out.println(ans);
    }

}

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


int main(){
    int n,t1,t2;
  	ll k;
  	ll mod = 1000000007;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j]){
                t1++;
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(a[i]>a[j]){
                t2++;
            }
        }
    }
    ll c1 = k;
  	ll c2 = k * (k-1) / 2; c2 %= mod;
    cout << (t1*c1 + t2 * c2) % mod << endl;
    return 0;
}


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


int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  int D = 0;
  int ans = 0;
  for(int i=1;i<N+1;i++){
    D += L.at(i-1);
    if(D>X){
      ans = i;
      break;
    }
  }
  if(D<=X) ans = N+1;
  cout << ans << endl;
}



Measured memory_bytes: 384
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll A, V, B, W, T, length;
    cin >> A >> V >> B >> W >> T;
    if (A > B) {
      rep(i,T){
        A-=V;
        B-=W;
        if(A<=B){
          cout<<"YES"<<endl;
          return 0;
        }
      }
      cout<<"NO"<<endl;
      return 0;
    }
  if(A<B){
    rep(i, T) {
        A += V;
        B += W;
        if (A>=B) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
  }
 }


Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>
void swap(int *a,int *b);
int main(){
	int data[8];
	int i,j,n,num,max,min;
	scanf("%d",&n);
	while(n--){
		max=min=0;
		scanf("%d",&num);
		for(i=0;i<8;i++){
			data[i] = num%10;
			num /= 10;
		}
		for(i=0;i<8;i++){
			for(j=i;j<8;j++){
				if(data[j]>data[i]) swap(&data[i],&data[j]);
			}
		}
		for(i=0;i<8;i++){
			max += pow(10.0,7-(double)i)*(data[i]);
			min += pow(10.0,(double)i)*(data[i]);
		}
		printf("%d\n",max-min);

	}
	return 0;
}

void swap(int *a,int *b){
	int t;
	t = *a;
	*a = *b;
	*b = t;
}

Measured memory_bytes: 1072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC2019_15
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s1=Read();
            string s2;
            List<int> res = new List<int>();
            while (s1[0] != '.')
            {
                s2 = Read();
                string[] s1s = s1.Split('\"');
                string[] s2s = s2.Split('\"');
                if (s1s.Length != s2s.Length)
                {
                    res.Add(2);
                }
                else
                {
                    int comDifCnt = 0;
                    int litelDifCnt = 0;
                    for(int i =0; i < s1s.Length; i++)
                    {
                        if (!s1s[i].Equals(s2s[i]))
                        {
                            if (i % 2 == 0) comDifCnt++;
                            else litelDifCnt++;
                        }
                    }

                    if (comDifCnt == 0 && litelDifCnt == 0) res.Add(0);
                    else if (comDifCnt == 0 && litelDifCnt == 1) res.Add(1);
                    else res.Add(2);
                }
                s1 = Read();
            }


            for(int i =0; i < res.Count; i++)
            {
                switch (res[i])
                {
                    case 0:
                        WriteLine("IDENTICAL");
                        break;
                    case 1:
                        WriteLine("CLOSE");
                        break;
                    case 2:
                        WriteLine("DIFFERENT");
                        break;
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 19856
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll H,W;cin>>H>>W;
    if(H==1 or W==1)cout<<1<<endl;
    else if(H%2==0 or W%2==0)cout<<H*W/2<<endl;
    else cout<<(H-1)*W/2+W/2+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

def main():
  mod = 10 ** 9 + 7

  n = int(input())
  nums = [-1]
  for _ in range(n):
      tmp = int(input())
      if nums[-1] != tmp:
          nums.append(tmp)
  #print(nums)

  m = len(nums)

  dp = [1 for _ in range(m)] # i番目の石までは操作を行い、i+1番目以降の石は操作をしない時の場合の数
  colors = [0 for _ in range(max(nums) + 1)] #その時各色が何個、i番目以前にあるのか

  for i in range(1, m):
    dp[i] = (dp[i - 1] + colors[nums[i]]) % mod #i番目の石を利用可能にすることで作れる数列の数は、i - 1番目まででできるものに、i番め以前の数列を利用したもの？
    colors[nums[i]] = dp[i]
    #print(dp, colors)


  print(dp[-1])
  

if __name__ == '__main__':
  main()


Measured memory_bytes: 30352
def solve():
    MOD = 10**9 + 7

    N = int(input())
    As = list(map(int, input().split()))

    ans = 0
    for d in range(60):
        mask = 1<<d
        num1 = len([1 for A in As if A & mask])
        ans += num1 * (N-num1) * mask
        ans %= MOD

    print(ans)


solve()


Measured memory_bytes: 51140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> adj[2005];
ll d,ans;
void dfs(ll u,ll pr,ll dist){
    if(dist>d/2)ans++;
    for(auto &v:adj[u])if(v!=pr)dfs(v,u,dist+1);
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n>>d;
    for(ll i=0,u,v;i<n-1;i++)cin>>u>>v,adj[u].push_back(v),adj[v].push_back(u);
    ll fin = n;
    if(d%2==0){
        for(ll i=1;i<=n;i++){
            ans=0;
            dfs(i,i,0);
            fin=min(fin,ans);
           // cout<<i<<"-->"<<ans<<endl;
        }
    }
    else{
        for(ll i=1;i<=n;i++){
            for(auto &j:adj[i]){
                ans=0;
                dfs(i,j,0);
                dfs(j,i,0);
                fin=min(fin,ans);
               // cout<<i<<","<<j<<"-->"<<ans<<endl;
            }
        }
    }
    cout<<fin;
}




Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#pragma warning( disable:4996 )
using namespace std;
typedef long long ll;
typedef long long Int;
#define MOD 1000000007
#define MOD2 10000003

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
ll mypow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
	}
	return ans;
}
ll hash1(char* s) {
	ll ans = 0;
	for (ll i = 0; i < 10; i++) {
		if(s[i]==0){
			break;
		}
		ans += mypow(26, i)*(s[i]-'a');
		ans %= MOD2;
	}
	return ans;
}
int countt[20000001];
int main(void) {
	/*int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if ((a == b && a!=c) || (b == c && a!=c) || (c == a && a!=b)) {
		printf("Yes\n");
		
	}
	else {
		printf("No\n");
	}*/

	/*int n;
	int a[101];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)) {
			printf("DENIED\n");
			return 0;
		}
	}
	printf("APPROVED\n");*/
	/*char st[20000001][11];
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char s[11];
		scanf("%s", s);
		int h = hash1(s);
		countt[h]++;
		strcpy(st[h], s);
	}
	int max = 0;
	for (int i = 0; i < MOD2; i++) {
		if (countt[max] < countt[i]) {
			max = i;
		}
	}
	vector<string> v;

	for (int i = 0; i < MOD2; i++) {
		if (countt[i] == countt[max]) {
			//printf("%s\n", st[i]);
			string str = st[i];
			v.push_back(str);
		}
	}
	sort(v.begin(), v.end());
	for(vector<string>::iterator it=v.begin();it!=v.end();it++){
		printf("%s\n", (*it).c_str());
	}*/
	char st[20000001][11];
	int n;
	vector<string> v;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char s[11];
		scanf("%s", s);
		string str = s;
		v.push_back(str);
	}
	sort(v.begin(), v.end());
	if (n >= 2) {
		/*for (vector<string>::iterator it = v.begin() + 1; it != v.end(); it++) {
			
		}*/
		countt[0] = 1;
		int max = 0;
		for (int i = 1; i < n; i++) {
			if (v[i - 1] == v[i]) {
				countt[i] = countt[i - 1] + 1;
			}
			else {
				countt[i] = 1;
			}
			if (countt[i] > max) {
				max = countt[i];
			}
		}
		for (int i = 0; i < n; i++) {
			if (countt[i] == max) {
				printf("%s\n", v[i].c_str());
			}
		}
		
	}
	else {
		printf("%s\n", v[0].c_str());
	}
	

	return 0;
}

Measured memory_bytes: 13680
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll l,r;
    cin>>l>>r;
    ll mod=2019;
    vector<ll> v(0);
    for(ll i=l; i<=min(r,l+2*mod);i++){
        v.push_back(i%mod);
    }
    ll ans=INF;
    for(ll i=0;i<v.size()-1;i++){
        for(ll j=i+1;j<v.size();j++){
            ans=min(ans,v[i]*v[j]%mod);
        }
    }
    cout<<ans<<endl;

}

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

int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  int count = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
      if (a.at(i).at(j) == '#') count++;
    }
  }
  if (count == H+W-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A,B,C;

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

    if (((A == B) && (C!=A) || ((A == C) && (B != A) || ((B == C) && (A != B)))))
        printf("\nYes");
    else
        printf("\nNo");
    return 0;
}

Measured memory_bytes: 128
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//うーん

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[1 << 18];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int n = (1 << N);
	int S[1 << 18];
	rep(i, (1 << N)) {
		S[i] = getint();
	}
	pakuri_sort(n, S);
	int A[1 << 17];
	A[0] = S[n - 1];
	int OK = 1;
	rep(i, N - 1) {
		int p = n - 1;
		for (int j = (1 << i) - 1; j >= 0; j--) {
			while (p >= 0 && S[p] >= A[j]) p--;
			if (p < 0) {
				OK = 0;
				break;
			}
			A[j + (1 << i)] = S[p];
			S[p] = 1e9;
			p--;
		}
		if (!OK) break;
		pakuri_sort(1 << (i + 1), A);
	}
	int i = N - 1;
	int p = n - 1;
	for (int j = (1 << i) - 1; j >= 0; j--) {
		while (p >= 0 && S[p] >= A[j]) p--;
		if (p < 0) {
			OK = 0;
			break;
		}
		p--;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 2816
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;

    return 0;
}

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

int n;
long long niz[200010];
long long levo[200010];
long long desno[200010];
int pos[200010];
stack<int> stek;

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

    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> niz[i];
        pos[niz[i]] = i;

        while(!stek.empty() && stek.top() > niz[i]){
            stek.pop();
        }

        if(stek.empty()){
            levo[i] = i+1;
        }
        else{
            levo[i] = i - pos[stek.top()];
        }
        stek.push(niz[i]);
    }

    while(!stek.empty()){
        stek.pop();
    }
    stek.push(0);
    pos[0] = n;

    for(int i = n-1; i >= 0; --i){
        while(!stek.empty() && stek.top() > niz[i]){
            stek.pop();
        }

        if(stek.empty()){
            desno[i] = n - i;
        }
        else{
            desno[i] = pos[stek.top()] - i;
        }
        stek.push(niz[i]);
    }

    long long resenje = 0;
    for(int i = 0; i < n; ++i){
        //cout << levo[i] << " " << desno[i] << "\n";
        resenje += levo[i] * desno[i] * niz[i];
    }
    cout << resenje << "\n";
}


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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	int n;
	cin >> n;
	vector<int> V(n);
	rep(i, n - 1)
	{
		int x;
		cin >> x;
		V.at(x - 1)++;
	}
	rep(i, n)
			cout
		<< V.at(i) << endl;
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3992
S=int(input())
DP=[0]*(S+11)
mod=10**9+7
DP[0]=1
DP[1]=0
DP[2]=0
DP[3]=1
C=2
for i in range(4,S+1):
  DP[i]=(C-DP[i-1]-DP[i-2])%mod
  C=(C+DP[i])%mod
print(DP[S])


Measured memory_bytes: 9192
from sys import stdin
from math import ceil

#  def solve(nums):
    #  num_person, *caps = nums
    #  caps = caps + [0]
    #  #  (人数, 乗り物のキャパシティ) のタプルの配列
    #  cities = list(zip([num_person] + ([0] * (len(caps) - 1)), caps))
    #  time = 0

    #  # 最後の都市に全員が移動したら終了
    #  while cities[-1][0] < num_person:
        #  print('|'.join([str(n) for n, cap in cities[:-1]]))
        #  mov_nums = [min(*city) for city in cities[:-1]]
        #  for i, mov_num in enumerate(mov_nums):
            #  city = cities[i]
            #  next_city = cities[i + 1]
            #  cities[i] = (city[0] - mov_num, city[1])
            #  cities[i + 1] = (next_city[0] + mov_num, next_city[1])
        #  time = time + 1
    #  return time


def solve(nums):
    num_person, *caps = nums
    return 4 + ceil(num_person / min(*caps))


def main():
    nums = [int(l) for l in stdin.readlines()]
    ans = solve(nums)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N, Q = map(int, input().split())
S = input()

count = [0 for _ in range(N)]

for i in range(N):
    count[i] = count[i-1]
    if S[i-1] == "A" and S[i] == "C":
        count[i] += 1

#print(count)

for i in range(Q):
    l, r = map(int, input().split())
    ans = count[r-1] - count[l-1]
    print(ans)


Measured memory_bytes: 6180
n, y = map(int, input().split())
flg = 0
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            a = i
            b = j
            c = n-i-j
            flg = 1
            break
        else: 
            pass
if flg == 1:
    print(a,b,c)
else:
    print(-1,-1,-1)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
rout = []
for i in range(n):
    ans += b[a[i]-1]
    rout.append(a[i]-1)

for i in range(n-1):
    if rout[i] + 1 == rout[i+1]:
        ans += c[rout[i]]
print(ans)

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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  deque< char > S;
  string x;
  cin >> x;
  for(auto &p : x) S.emplace_back(p);

  int Q;
  cin >> Q;
  bool f = false;
  while(Q--) {
    int t;
    cin >> t;
    if(t == 1) {
      f ^= 1;
    } else {
      int p;
      cin >> p;
      --p;
      char c;
      cin >> c;
      if(f ^ p ^ 1) S.emplace_front(c);
      else S.emplace_back(c);
    }
  }
  if(f) reverse(begin(S), end(S));
  for(auto &c : S) cout << c;
  cout << endl;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<ll> line(n);
  foreach(i,line)i=in();
  ll ans = -INFLL;
  function<ll(int,int,int)> func =
    [&](int place,int used,int back)->ll{
      static vector<map<pll,ll>> dp(n);
      if(place/2-3>used or used>place/2+3)return -INFLL;
      if(place==n){
        return n/2==used?0:-INFLL;
      }
      if(dp[place].count(pll(used,back)))return dp[place][pll(used,back)];
      ll res = -INFLL;
      if(!back)chmax(res,func(place+1,used+1,true)+line[place]);
      chmax(res,func(place+1,used,false));
      return dp[place][pll(used,back)] = res;
    };
  ans = func(0,0,false);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 142416
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

int n;
pair<double, double> ps[222];

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> ps[i].first >> ps[i].second;
  sort(ps, ps + n, [](auto a, auto b) {
      return atan2(a.first, a.second) < atan2(b.first, b.second);
  });
  for(int i = 0; i < n; ++i) ps[i + n] = ps[i];

  double ans = 0.0;
  for(int L = 0; L < n; ++L) {
    for(int R = L; R < L + n; ++R) {
      double x = 0.0, y = 0.0;
      for(int i = L; i <= R; ++i) x += ps[i].first, y += ps[i].second;
      ans = max(ans, x*x + y*y);
    }
  }
  cout << fixed << setprecision(15) << sqrt(ans);
  return 0;
}

Measured memory_bytes: 512
hwd = list(map(int, input().split()))
a = []
for i in range(hwd[0]):
    a.append(list(map(int, input().split())))
q = int(input())
lr = []
for i in range(q):
    lr.append(list(map(int, input().split())))

xy = [None] * hwd[0] * hwd[1]
for i in range(hwd[0]):
    for j in range(hwd[1]):
        xy[a[i][j] - 1] = [i, j]
        
power_accumulation = []
for i in range(hwd[2]):
    power = [0]
    number = 0
    place = i
    while place < hwd[0] * hwd[1] - hwd[2]:
        power.append(power[number] + abs(xy[place + hwd[2]][0] - xy[place][0]) + abs(xy[place + hwd[2]][1] - xy[place][1]))
        number = number + 1
        place = place + hwd[2]
    power_accumulation.append(power)

for i in range(q):
    test_power = power_accumulation[(lr[i][1] - 1) % hwd[2]][(lr[i][1] - 1) // hwd[2]] - power_accumulation[(lr[i][0]- 1) % hwd[2]][(lr[i][0] - 1) // hwd[2]]
    print(test_power)

Measured memory_bytes: 45116