akhauriyash/Code-Regression huggingface dataset:
#define HAVE_STRUCT_TIMESPEC
#include <bits/stdc++.h>
using namespace std;
int a[7];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[1]==a[2]&&a[2]!=a[3])
        cout<<"Yes";
    else if(a[2]==a[3]&&a[1]!=a[2])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define rep_cs(i, l, n) for (int i = (l); i <= (n); i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

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

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

int main()
{
    ll N;
    cin >> N;
    vll a(N - 1);
    rep(i, 0, N - 1) cin >> a[i], a[i]--;

    vll ans(N, 0);
    rep(i, 0, N - 1) ans[a[i]]++;

    rep(i, 0, N)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 6428
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

P=primes(10**6)

def f(n):
    arr = []
    temp = n
    j=0
    while P[j]**2<=temp:
        i=P[j]
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
        j=j+1

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


B=[0]*(10**6+10)
n=int(input())
A=list(map(int,input().split()))
for i in range(n):
  if A[i]==1:
    continue
  D=f(A[i])
  for j in range(len(D)):
    B[D[j][0]]+=1
f=0
for i in range(10**6+5):
  if B[i]>1:
    f=1
if f==0:
  print("pairwise coprime")
  exit()
for i in range(10**6+5):
  if B[i]>=n:
    f=0
if f==1:
  print("setwise coprime")
else:
  print("not coprime")

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

#define ll long long int

using namespace std;

int main(void) {
    ll n, p;
    ll ans = 1;
    cin>>n>>p;

    if(p==1){
        cout<<1<<endl;
        return 0;
    }else if(n==1){
        cout<<p<<endl;
        return 0;
    }

    map<ll, ll> prime_division;
    /*
    for(ll i=2; p>1; i++) {
        while((p % i) == 0) {
            prime_division[i]++;
            p /= i;
            if(prime_division[i]==n){
                ans*=i;
                prime_division[i]=0;
            }
        }
    }
    */

    for (int i = 1; pow(i, n) <= p; i++) {
        if (p % (ll)pow(i, n) == 0)
            ans = i;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n==1)
        cout<<0;
    else
        cout<<1;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
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


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


	int N;
	cin >> N;
	map<int, int> MP;
	rep(i, (1 << N)) {
		int s;
		cin >> s;
		MP[s]++;
	}

	int S[600000];
	auto itr = MP.end();
	itr--;
	S[1] = (*itr).first;
	MP[(*itr).first] -= 1;
	if ((*itr).second == 0) MP.erase(itr);

	int OK = 1;
	rep1(i, (1 << N) - 1) {
		auto itr = MP.lower_bound(S[i]);
		if (itr == MP.begin()) {
			OK = 0;
			break;
		}
		itr--;
		S[2 * i] = S[i];
		S[2 * i + 1] = (*itr).first;
		MP[(*itr).first] -= 1;
		if ((*itr).second == 0) MP.erase(itr);
	}
	if (OK) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define PI 3.14159265358979323846
using namespace std;
const int MOD = 1e9 + 7 ;
const int N=1005;

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

      int n;
      cin>>n;
      int a[2*n];
      for(int i=0;i<2*n;i++) cin>>a[i];
      sort(a,a+2*n);
      int ans=0;
      for(int i=0;i<2*n;i++) if(i%2==0) ans+=a[i];
      cout<<ans;
} 
/* If today were the last day of my life,would I want to do what I'm about to do today? */

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
const ll MOD = 1e9+7;

// テーブルを作る前処理
void COMinit() {
 fac[0] = fac[1] = 1;
 finv[0] = finv[1] = 1;
 inv[1] = 1;
 for (int i = 2; i < MAX; i++){
     fac[i] = fac[i - 1] * i % MOD;
     inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
     finv[i] = finv[i - 1] * inv[i] % MOD;
 }
}

// 二項係数計算
long long COM(int n, int k){
 if (n < k) return 0;
 if (n < 0 || k < 0) return 0;
 return fac[n] * (finv[n - k] % MOD) % MOD;
}
ll n,k;

vector<vector<ll>> edges(1e5+1);

ll dfs(ll p, ll now){
    ll res = 1;
    for (auto e : edges[now]) {
        if(e==p) continue;
        res *= dfs(now, e)%MOD;
        res%=MOD;
    }

    if(p == -1){
        res *= COM(k-1, edges[now].size())%MOD;
    }else{
        res *= COM(k-2, edges[now].size()-1)%MOD;
    }

    return res%MOD;
}

int main() {
    COMinit();
    std::cin >> n>>k;
    
    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;
        b--;
        
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    std::cout << k*dfs(-1,0)%MOD << std::endl;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int;
const LL mod = 1000000007;
 
int main() {
    int D, N;
    cin >> D >> N;
    int n = pow(100,D);
 
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += n;
        if((ans/(int)pow(100,D))%100 == 0) {
            i--;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
//作成日：4/20
using System;

class Program
{
  static void Main(){
		//日付を受け取る変数
		int day = int.Parse(Console.ReadLine());
		//条件分岐
		if (day == 25){
		  Console.Write("Christmas");
		}
		else if (day == 24){
  		Console.Write("Christmas Eve");
		}
		else if (day == 23){
 		 Console.Write("Christmas Eve Eve");
		}
		else{
  		Console.Write("Christmas Eve Eve Eve");
		}
  }
}

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

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 3, INF = 1e9 * 100;
vector<vector<pair<ll, ll>>> gr;

ll used[SIZE], usedEdge[SIZE], dir[SIZE];
vector<ll> vec, ret;
ll cnt[SIZE];
vector<pair<ll, ll>> edge;

void dfs(int v) {
    used[v] = 1;

    vector<pair<ll, ll>> edgs;
    for (auto to : gr[v]) {
        bool k = 0;
         if (!usedEdge[to.second])  {
            edgs.push_back(to);
            k = 1;
            usedEdge[to.second] = 1;
        }
        if (!used[to.first]) {
            dfs(to.first);
        } 
        if (k && cnt[to.first] != 0) {
            dir[to.second] = to.first;
            edgs.pop_back();
            cnt[to.first] = 0;
        }
    }

    if (edgs.size() % 2 == 1) {
        pair<ll, ll> cr = edgs.back();
        edgs.pop_back();
        dir[cr.second] = v;
        cnt[v] = 1;
    }

    for (int i = 0; i < edgs.size(); i += 2) {
        dir[edgs[i].second] = v;
        dir[edgs[i + 1].second] = v;
    }
}

int main() {
    fastInp;
    ll n, m;
    cin >> n >> m;

    if (m % 2 != 0) {
        cout << "-1";
        return 0;
    }

    gr.resize(n);

    for (int i = 0; i < m; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        edge.push_back({u, v});
        gr[u].push_back({v, i});
        gr[v].push_back({u, i});
    }

    dfs(0);

    for (int i = 0; i < m; i++) {
        ll u = edge[i].first, v = edge[i].second;

        if (u != dir[i]) swap(u, v);

        u++; v++;
        cout << u << " " << v << "\n";
    }


    return 0;
}


Measured memory_bytes: 30496
def main():
    S = list(input())

    N = len(S)

    if (S[0] == '0') or (S[-1] == '1'):
        print (-1)
        return 0

    lst = []
    for i in range((N - 1) // 2):
        if S[i] != S[N - 2 - i]:
            print (-1)
            return 0
        if S[i] == '1':
            lst.append(i + 1)
    if N % 2 == 0 and S[N//2 - 1] == '1':
        lst.append(N//2)
    # print (lst)

    if lst[-1] * 2 != N:
        center = lst[-1] + 1
        for x in range(lst[-1] * 2 + 2, N + 1):
            print (center, x)

        before = 1
        n = lst[-1] * 2 + 2
        tmp = 1
        for tmp in lst[1:]:
            print (before, tmp)
            print (n - before, n - tmp)
            for x in range(tmp - before - 1):
                print (before + 1 + x, tmp)
                print (n - (before + 1 + x), n - tmp)
            before = tmp
        print (tmp, center)
        print (n - tmp, center)

    if lst[-1] * 2 == N:
        before = 1
        n = lst[-1] * 2 + 1
        tmp = 1
        for tmp in lst[1:]:
            print (before, tmp)
            print (n - before, n - tmp)
            for x in range(tmp - before - 1):
                print (before + 1 + x, tmp)
                print (n - (before + 1 + x), n - tmp)
            before = tmp
        print (tmp, n - tmp)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7688
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;
vector<int> G[100];
vector<int> vis(100, 0);
int F, N;
void dfs(int y, unordered_map<int, int> mp)
{
    // cout<<y<<endl ;
    mp[y]++;
    // for(auto h : mp)
    // cout<<h.ff<<" "<<h.ss<<endl;
    // cout<<endl;
    for (auto h : G[y])
    {
        if (mp.size() == N)
        {
            F++;
            return;
        }
        if (mp.find(h) == mp.end())
        {
             dfs(h, mp);
        }
    }
}
int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, x, y, b, d;
    cin >> n >> m;
    N = n;
    for (i = 0; i < m; i++)
        cin >> a >> b, G[a].pb(b), G[b].pb(a);
    unordered_map<int, int> mp;
    dfs(1, mp);
    cout << F << endl;

    return 0;
}


Measured memory_bytes: 3628
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c = inpl()
now = 0
for i in range(10**5):
    now += a
    if now%b == c:
        print('YES')
        break
else:
    print('NO')

Measured memory_bytes: 5332
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int a[100][100],d[100][100],inf=1e8,n,s,t;
bool q[100];
typedef vector<double> vd;
typedef vector<vd> mat;
double eps=1e-9;
bool is0(double x){
	return abs(x)<eps;
}
vd calc(mat ex,vd b){
	bool used[100]={};
	rep(i,n){
		int j=0;
		for(;j<n;j++) if(!used[j]&&!is0(ex[j][i])) break;
		assert(j!=n);
		used[j]=true;
		double div=ex[j][i];
		for(int k=i;k<n;k++){
			ex[j][k]/=div;
		}
		b[j]/=div;
		rep(k,n){
			if(k==j) continue;
			double coef=ex[k][i];
			rep(l,n){
				ex[k][l]-=ex[j][l]*coef;
			}
			b[k]-=b[j]*coef;
		}
	}
	return b;
}
int main(){
	while(true){
		cin>>n>>s>>t;
		if(n==0) break;
		s--,t--;
		rep(i,n) cin>>q[i];
		rep(i,n) rep(j,n) cin>>a[i][j];
		rep(i,n) rep(j,n) if(i!=j) d[i][j]=a[i][j];
		rep(i,n) rep(j,n) if(i!=j&&d[i][j]==0) d[i][j]=inf;
		rep(i,n) rep(j,n) rep(k,n) d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
		bool can=false;
		vector<int> vs;
		rep(i,n) if(d[s][i]!=inf){
			vs.pb(i);
			if(i==t) can=true;
		}
		if(!can){
			puts("impossible");
			continue;
		}
		n=vs.size();
		rep(i,n) rep(j,n) a[i][j]=a[vs[i]][vs[j]];
		rep(i,n) rep(j,n) d[i][j]=d[vs[i]][vs[j]];
		rep(i,n) q[i]=q[vs[i]];
		rep(i,n){
			if(vs[i]==s) s=i;
			if(vs[i]==t) t=i;
		}
		bool used[100]={};
		mat co(100,vd(100,0));
		vd b;
		rep(i,n){
			if(i==t){
				co[i][i]=1;
				b.pb(0);
				continue;
			}
			int cnt=0;
			double c=0;
			vector<int> to;
			if(q[i]){
				rep(j,n){
					if(a[i][j]==0) continue;
					if(d[i][t]==d[j][t]+a[i][j]){
						cnt++;
						c+=a[i][j];
						to.pb(j);
					}
				}
			}else{
				rep(j,n){
					if(a[i][j]==0) continue;
					cnt++;
					c+=a[i][j];
					to.pb(j);
				}
			}
			rep(j,to.size()) co[i][to[j]]=1.0/to.size();
			b.pb(-c/to.size());
			co[i][i]-=1.0;
		}
//		rep(i,n){
//			rep(j,n) cout<<co[i][j]<<" ";
//			cout<<"  b[i]= "<<b[i]<<endl;
//		}
		vd ans=calc(co,b);
		printf("%.12f\n",ans[s]);
	}
}

Measured memory_bytes: 1460
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#define INF 10050
using namespace std;
int main()
{
	int n,k;
//	cin>>n>>k;
	while(~scanf("%d %d",&n,&k))
	{
		int sum = (1+n-2)*(n-2)/2;
		if(k>sum) {
			cout<<"-1"<<endl;
		}else{
			cout << (n-1) + sum - k <<endl;
			for(int i=2;i<=n;i++) {
				cout<<"1 "<<i<<endl;
			}
			
			for(int i=2; i<=n; i++) {
				for(int j=i+1; j<=n; j++) {
					if(sum == k)	return 0;
					cout<<i<<" "<<j<<endl;
					sum--;
				}
			}
		}
	}
	
	
	
	
	
	
	
	return 0;

}

Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, m = map(int, input().split())
    a = 1
    d = n - 1
    for _ in range(m):
        if d % 2 == 1 and (d == n // 2 or d == n // 2 - 1):
            d -= 1
        print(a, a + d)
        a += 1
        d -= 2

main()

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

using namespace std;

typedef pair<int, int> pii;
const int INF = numeric_limits<int>::max() / 2;

int sx, sy, n, t;
int field[200][200]; //0:can't 1:can
int d[200][200];
int dx[6] = {1, 0, 1, -1, 0, -1}, dy[6] = {1, 1, 0, -1, -1, 0};

void solve()
{
    queue<pii> que;
    for (int i = 0; i < 200; i++)
        for (int j = 0; j < 200; j++)
            d[i][j] = INF;
    que.push(pii(sx + 100, sy + 100));
    d[sx + 100][sy + 100] = 0;

    while (que.size())
    {
        pii p = que.front();
        que.pop();
        for (int i = 0; i < 6; i++)
        {
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if (0 <= nx && nx < 200 && 0 <= ny && ny < 200 && field[nx][ny] && d[nx][ny] == INF)
            {
                que.push(pii(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
}

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

    while (true)
    {
        cin >> t >> n;
        if (n == 0 && t == 0)
            break;
        for (int i = 0; i < 200; i++)
            for (int j = 0; j < 200; j++)
                field[i][j] = 1;
        for (int i = 0; i < n; i++)
        {
            int x, y;
            cin >> x >> y;
            field[x + 100][y + 100] = 0;
        }
        cin >> sx >> sy;
        solve();
        int res = 0;
        for (int i = 0; i < 200; i++)
            for (int j = 0; j < 200; j++)
                if (d[i][j] <= t)
                    res++;
        cout << res << endl;
    }
}


Measured memory_bytes: 3448
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, K, A;

  std::cin >> N >> M;

  std::vector<int> a(M);

  for (int i = 0; i < N; i ++) {
    std::cin >> K;

    for (int j = 0; j < K; j ++) {
      std::cin >> A;

      A --;

      a[A] ++;
    }
  }

  std::cout << std::count(ALL(a), N) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int d, pos, res, neg;
vector< int > c( 30 ), t( 400 ), last( 30, 0 );
vector< vector< int > > arr( 400, vector< int >( 30, 0 ) );

int disSatisfaction( int i, int j )
{
	vector< int > lst = last;
	lst[ j ] = i;
	int delta = 0;
	for( int k = 1; k <= 26; ++k )
	{
		delta += c[ k ] * ( i - lst[ k ] );
	}
	return delta;
}

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

	cin >> d;
	for( int i = 1; i <= 26; ++i )
	{
		cin >> c[ i ];
	}
	for( int i = 1; i <= d; ++i )
	{
		for( int j = 1; j <= 26; ++j )
		{
			cin >> arr[ i ][ j ];
		}
	}
	for( int i = 1; i <= d; ++i )
	{
		res = -1e9;
		for( int j = 1; j <= 26; ++j )
		{
			neg = disSatisfaction( i, j );
			if( arr[ i ][ j ] - neg > res )
			{
				res = arr[ i ][ j ] - neg;
				pos = j;
			}
		}
		last[ pos ] = i;
		t[ i ] = pos;
	}
	for( int i = 1; i <= d; ++i )
	{
		cout << t[ i ] << "\n";		
	}
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  long long N; cin >> N;
  long long K; cin >> K;
  vector<int> A(N); rep(i, N) cin >> A.at(i);
  vector<int> been(N, -1);
  been.at(0) = 0;
  bool nonloop = true;
  long long loopN = 0;
  long long now = 1;
  long long kaisu = 0;
  long long a = 0;
  while(nonloop){
    now = A.at(now-1);
    kaisu++;
    if(been.at(now-1) != -1){
      nonloop = false;
      a = been.at(now-1);
    }
    been.at(now-1) = kaisu;
    loopN++;
  }
  loopN -= a;
  if(a+loopN <= K) {
  long long num = (K-a) % loopN;
  rep(i, num){
    now = A.at(now-1);
  }
  } else {
    now = 1;
    rep(i, K){
      now = A.at(now-1);
    }
  }
  cout << now << endl;
  return 0;
}

Measured memory_bytes: 4844
#include<iostream>

int main(){
  int N;
  std::cin >> N;
  
  int A[100];
  for(int i=0;i<N;++i){
    std::cin >> A[i];
  }
  
  int not_sort = 1,change=0;
  while(not_sort){
    not_sort = 0;
    for(int i=0;i<N-1;++i){
      if(A[i]>A[i+1]){
        int tmp;
        tmp = A[i];
        A[i] = A[i+1];
        A[i+1] =tmp;
        not_sort = 1;
        change++;
      }
    }
    
  }
  
  for(int i=0;i<N;++i){
    std::cout << A[i];
    if(i!=N-1){
      std::cout << " ";
    }else{
      std::cout << std::endl;
    }
    
  }
  
  std::cout << change << std::endl;
  
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#define tri(x) (x * x * x)
typedef long long  ll;

using namespace std;

ll N, K;

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

    ll modk = N / K, modk_2 = 0;

    for(int i = K / 2; i <= N; i += K)
        modk_2++;

    ll ans = tri(modk); 
    if(K % 2 == 0)
        ans += tri(modk_2);
    
    cout << ans << '\n';

    return 0;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

int main() {
  int N,sum1,sum2,ave = 0;
  cin >> N;
  std::vector<int> v(N);
  rep(i,N){
   cin >> v[i];
   ave += v[i];
  }
  ave /= N;
  rep(i,N){
    sum1 += (v[i]-ave) * (v[i] - ave);
    sum2 += (v[i]-ave-1) * (v[i] - ave-1);
  }
  cout << min(sum1,sum2) << endl;
}


Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
data = list(map(int,input().split()))

count =data[0]
data.remove(data[0])

if 0 in data:
    print(0)

else:

    for _ in data:

        if count ==0:
            break
        elif count <= 10**18:
            count *= _

    if count ==0:
        print(0)
    elif count <= 10**18:
        print(count)
    else:
        print(-1)

Measured memory_bytes: 21648
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	int now = -1;
	int las = 1234567891;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		if (las >= A)++now;
		else now = 0;
		las = A;
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new aoj0195().doIt();
	}
	class aoj0195 {	
		String ctr[] = {"A","B","C","D","E"};
		String str(int a[],int b[]){
			int max = 0;
			String word = "";
			for(int i = 0;i < 5;i++){
				if(max < a[i] + b[i]){
					max = a[i] + b[i];
					word = ctr[i]+" "+max;
				}
			}
			return word;
		}
		void doIt() {
			while(true){
				int a[] = new int [5];
				int b[] = new int [5];
				int c[] = new int [5]; 
				a[0] = sc.nextInt();
				b[0] = sc.nextInt();
				if(a[0] + b[0] == 0)break;
				for(int i = 1;i < 5;i++){
					a[i] = sc.nextInt();
					b[i] = sc.nextInt();
				}
				System.out.println(str(a,b));
			}
		}
	}
}

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

int main()
{
	string s;
	int sum=0;
	getline(cin,s);
	
	for(int i=0;i<s.size();i++)
	{
		sum+=s[i]-'0';
		if(sum==9) sum=0;
	}
	
	if(sum%9==0) cout<<"Yes"<<endl;
	 else cout<<"No"<<endl;
	 return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}

void go(ll n , ll k){
    ll mi = INF;
    REP(i,3){
        mi = min(mi, abs(n-k));
        n = abs(n-k);
    }

    cout << mi <<endl;
    
    return  ;


}
int main(){
    int64_t n,k;
    cin  >> n >>k;
    int64_t num,ans;

    num = n/k;
    ans= n -num*k;

    ans = min(abs(ans-k),ans);

    cout << ans <<endl;
    
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

//#define PI 3.14159265358979323846

int main()
{
    double r, s, R;
    double PI = 3.141592653589;
    cin >> r;
    s = r * r * PI;
    R = 2 * r * PI;

    printf("%.6f %.6f\n", s, R);

    return 0;
}


Measured memory_bytes: 3292
import java.util.Scanner;

import static java.lang.Math.min;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextInt();
        long r = sc.nextInt();
        long minValue = 2018;
        long v;
        long i,j;

//        System.out.println(l + " : " + r);

        r = min(r, l+4038);
        i=0;j=0;
        for(i=l;i<r;i++) {
            for(j=i+1;j<=r;j++) {
                v = (i*j)%2019;
//                v = floorMod(((long)l*(long)j), 2019);

//                System.out.println("[" + i + ", " + j + "] " + v);
                minValue = min(minValue, v);
                if (minValue == 0) { break; }
            }
            if (minValue == 0) { break; }
        }
//        System.out.println("[" + i + ", " + j + "]");
        // 出力
        System.out.println((int)minValue);
    }
}

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

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

typedef vector<vector<int>> graph;

constexpr int INF = (1 << 29);
constexpr int MAX_N = 50;

enum {A, B, NUM};
int dp[MAX_N][MAX_N][NUM];

inline string solve() {
	int n;
	cin >> n;

	graph G(n);
	for(int v = 0; v < n; ++v) {
		G[v].emplace_back(v);
		for(int u = 0; u < n; ++u) {
			int exist;
			cin >> exist;
			if(exist) G[v].emplace_back(u);
		}
	}

	fill_n((int *)dp, sizeof(dp) / sizeof(int), INF);
	for(int v = 0; v < n; ++v) {
		dp[v][v][A] = dp[v][v][B] = 0;
	}

	for(int iter = 0; iter < 2 * n; ++iter) {
		for(int v = 0; v < n; ++v) {
			for(int u = 0; u < n; ++u) {
				if(v == u) continue;

				// Aaron turn
				dp[v][u][A] = 0;
				for(const auto &to : G[v]) {
					chmax(dp[v][u][A], dp[to][u][B]);
				}

				// Bruce turn
				for(const auto &to : G[u]) {
					chmin(dp[v][u][B], dp[v][to][A] + 1);
				}
			}
		}
	}

	int a, b;
	cin >> a >> b;

	return dp[a][b][A] >= n ? "infinity" : to_string(dp[a][b][A]);
}

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

	int T;
	cin >> T;
	while(T--) cout << solve() << endl;

	return EXIT_SUCCESS;
}

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

#pragma region  // {{{

#define all(x) std::begin(x), std::end(x)
#define rall(x) std::rbegin(x), std::rend(x)
#define rep(i, begin, end) for (int64_t i{begin}, i##_end{end}; i < i##_end; ++i)
#define repc(i, begin, last) for (int64_t i{begin}, i##_last{last}; i <= i##_last; ++i)
#define repr(i, begin, last) for (int64_t i{begin}, i##_last{last}; i >= i##_last; --i)
#define let const auto
using i64 = std::int64_t;
using u64 = std::uint64_t;

constexpr int32_t INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

void ioSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(11);
    std::cerr << std::fixed << std::setprecision(11);
    std::clog << std::fixed << std::setprecision(11);
}

template <class T>
std::istream& operator,(std::istream& is, T& rhs) {
    return is >> rhs;
}

#define var(type, ...) \
    type __VA_ARGS__;  \
    std::cin >> __VA_ARGS__

inline void println() {
    std::cout << '\n';
}
template <class Head, class... Tail>
inline void println(Head&& head, Tail&&... tail) {
    std::cout << head << " " + (!sizeof...(tail));
    println(std::forward<Tail>(tail)...);
}

template <class T, class U>
inline bool chmin(T& a, const U& b) {
    return b < a && (a = b, true);
}

template <class T, class U>
inline bool chmax(T& a, const U& b) {
    return b > a && (a = b, true);
}

#pragma endregion  // }}}

constexpr int MOD = int(1e9) + 7;

i64 memo[1000010][2][2];
i64 N;

i64 dp(int i, bool zero, bool nine) {
    if (i >= N) return zero && nine;

    auto& ret = memo[i][zero][nine];
    if (~ret) return ret;

    ret = 0;
    ret += dp(i + 1, zero, nine) * 8;
    ret %= MOD;

    ret += dp(i + 1, true, nine);
    ret %= MOD;

    ret += dp(i + 1, zero, true);
    ret %= MOD;

    return ret;
}

signed main() {
    ioSetup();

    cin >> N;
    if (N == 1) {
        println(0);
        return 0;
    }

    memset(memo, -1, sizeof(memo));
    println(dp(0, false, false));

    return 0;
}


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

int main (void) {

    int N, K, X, Y;
    int sum = 0;

     cin >> N >> K >> X >> Y;

     for (int i = 1; i <= N; i++ ){
        if (K >= i) {
            sum += X;
        }else if (K < i){
            sum += Y;
         } 
     }
    cout << sum;


    return 0;
}



Measured memory_bytes: 3632
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int b=0;
    int r=0;
    String s=sc.next();
    for(int i=0;i<n;i++){
      if(s.charAt(i)=='B'){
        b++;
      }else{
        r++;
      }
    }
    System.out.println((r>b)?"Yes":"No");
  }
}

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

const long long MOD = 1000000007;

void solve(long long S){
    // S = 10;
    long long ans[S+1] = {};
    for (int i = 3; i <= S; i++) {
        ans[i] = 1;
        for (int j = 3; j + 3 <= i; j++) {
            ans[i] += ans[j];
            ans[i] %= MOD;
        }
        // printf("%d: %lld\n", i, ans[i]);
    }
    cout << ans[S] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 3736
DIV_NUM = 10**9+7

def main
  s = ARGF.gets.chomp.reverse

  c_ary = Array.new(s.length, 0)
  b_ary = Array.new(s.length, 0)
  a_ary = Array.new(s.length, 0)

  q_num = 1
  0.upto(s.length) do |i|
    case s[i]
    when 'A','B'
      c_ary[i] = c_ary[i-1]
    when 'C'
      c_ary[i] = (c_ary[i-1] + q_num) % DIV_NUM
    when '?'
      c_ary[i] = (c_ary[i-1] * 3 + q_num) % DIV_NUM
      q_num = (q_num * 3) % DIV_NUM
    end
  end
  # pp c_ary

  1.upto(s.length) do |i|
    case s[i]
    when 'A','C'
      b_ary[i] = b_ary[i-1]
    when 'B'
      b_ary[i] = (b_ary[i-1] + c_ary[i-1]) % DIV_NUM
    when '?'
      b_ary[i] = (b_ary[i-1] * 3 + c_ary[i-1]) % DIV_NUM
    end
  end
  # puts "B ==="
  # pp b_ary

  2.upto(s.length) do |i|
    case s[i]
    when 'B','C'
      a_ary[i] = a_ary[i-1]
    when 'A'
      a_ary[i] = (a_ary[i-1] + b_ary[i-1]) % DIV_NUM
    when '?'
      a_ary[i] = (a_ary[i-1] * 3 + b_ary[i-1]) % DIV_NUM
    end
  end
  # puts "A ==="
  # pp a_ary

  puts a_ary[-1] % DIV_NUM
end

if __FILE__ == $0
  main
end


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

template<typename T>
struct BellmanFord {
	struct Edge {
		const int from;
		const int to;
		const T cost;
		Edge(const int from, const int to, const T cost) :
			from(from),
			to(to),
			cost(cost)
			{}
	};
	const int V;
	vector<vector<Edge>> G;
	int start;
	const T INF = numeric_limits<T>::max();
	vector<T> dist;
	bool hasNegativeCycle = false;
	vector<bool> negative;
	vector<int> rec;
	BellmanFord(const int V) :
		V(V),
		G(vector<vector<Edge>>(V, vector<Edge>())),
		negative(vector<bool>(V))
		{}
	void addEdge(const int from, const int to, const T cost) {
		G[from].emplace_back(from, to, cost);
	}
	bool negativeCycle() {
		return hasNegativeCycle;
	}
	void build(const int start) {
		(*this).start = start;
		dist = vector<T>(V, INF);
		rec = vector<int>(V, -1);
		dist[start] = 0;
		for(int i = 0; i < V; ++i) {
			bool update = false;
			for(int from = 0; from < V; ++from) {
				if(dist[from] == INF) continue;
				for(Edge e : G[from]) {
					if(dist[e.from] + e.cost < dist[e.to]) {
						dist[e.to] = dist[e.from] + e.cost;
						rec[e.to] = e.from;
						update = true;
					}
				}
			}
			if(not update) break;
			if(i == V - 1) hasNegativeCycle = true;
		}
		for(int i = 0; i < V; ++i) {
			bool update = false;
			for(int from = 0; from < V; ++from) {
				if(dist[from] == INF) continue;
				for(Edge e : G[from]) {
					if(dist[e.from] + e.cost < dist[e.to]) {
						dist[e.to] = dist[e.from] + e.cost;
						negative[e.to] = true;
						update = true;
					}
					if(negative[e.from]) {
						negative[e.to] = true;
					}
				}
			}
			if(not update) break;
		}
	}
	T distance(const int to) {
		if(negative[to]) throw "INVALID";
		if(dist[to] == INF) throw "INVALID";
		return dist[to];
	}
	vector<int> route(int to) {
		distance(to);
		vector<int> ret;
		while(to != start) {
			ret.push_back(to);
			to = rec[to];
		}
		ret.push_back(start);
		reverse(ret.begin(), ret.end());
		return ret;
	}
};

int main() {
	int n, m, p; cin >> n >> m >> p;
	BellmanFord<int64_t> bf(n);
	for(int i = 0; i < m; ++i) {
		int a, b, c; cin >> a >> b >> c;
		bf.addEdge(--a, --b, -(c - p));
	}
	bf.build(0);
	try {
		cout << max<int64_t>(0, -bf.distance(n - 1)) << '\n';
	}
	catch(...) {
		cout << -1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[100010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	sortup(a,n);
	rep(i,1,n)a[i]+=a[i-1];
	ll index=0;
	rep(i,1,n)if(a[i-1]*3<a[i])index=i;
	printf("%lld\n",n-index);
	return 0;
}

Measured memory_bytes: 1788
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func comb(n int) {
	arr := make([]int, n)
	rec(arr, 0)
}

func rec(arr []int, i int) {
	if i == len(arr) {
		fmt.Println(arr)
		return
	}
	rec(arr, i+1)
	arr[i] = 1
	rec(arr, i+1)
	arr[i] = 0
}

func main() {
	sc := NewScanner()
	n := sc.nextInt()
	A := sc.nextIntSlice(n)
	q := sc.nextInt()
	M := sc.nextIntSlice(q)
	var solve func(i, v int) bool
	solve = func(i, v int) bool {
		if v == 0 {
			return true
		} else if v < 0 || i >= len(A) {
			return false
		}
		return solve(i+1, v) || solve(i+1, v-A[i])
	}
	for _, v := range M {
		if solve(0, v) {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}



Measured memory_bytes: 1108
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int solve(string s) {
    bool flag;
    int ans = 0;
    int position[s.size()];
    for (int i = 0; i < s.size(); i++) {
        switch (s[i]) {
            case 'y':
            case 'u':
            case 'i':
            case 'o':
            case 'p':
            case 'h':
            case 'j':
            case 'k':
            case 'l':
            case 'n':
            case 'm':
                if (i == 0) flag = true;
                position[i] = 1;
                break;

            default:
                if (i == 0) flag = false;
                position[i] = 2;
                break;
        }
    }
    for (int i = 0; i < s.size(); i++) {
        if (flag) {
            if (position[i] == 2) {
                ans++;
                flag = false;
            }
        } else {
            if (position[i] == 1) {
                ans++;
                flag = true;
            }
        }
    }
    return ans;
}

int main(int argc, char const *argv[]) {
    string nyuuryoku;
    vector<int> ans;
    while (1) {
        cin >> nyuuryoku;
        if (nyuuryoku == "#") break;
        ans.push_back(solve(nyuuryoku));
    }
    for (int i : ans) {
        cout << i << endl;
    }
    return 0;
}
/*
1.文字列を読み込む
2.先頭の文字が右にあるのか左にあるのか判断
3.右ならtrue左ならfalseをフラッグに入れる
4.フラッグを使い左右が変わったか判断
5.カウントを返す
*/


Measured memory_bytes: 3136
from collections import defaultdict
from collections import Counter

H, W, N = map(int, input().split())

# 3*3マスの処理用リスト
dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1],
       [-1, 0], [-1, -1], [0, -1], [1, -1]]

# そのマスを中心とする3*3グリッドに含まれる黒マスの数
dict = defaultdict(int)

for i in range(N):
    a, b = map(int, input().split())
    for dy, dx in dir:
        # 3*3グリッドは、H*Wの中に完全に含まれていなければならないことに注意
        if 2 <= a + dy <= H - 1 and 2 <= b + dx <= W - 1:
            dict[(a + dy, b + dx)] += 1

c = Counter(dict.values())
ans = [0 for _ in range(10)]

# ans[1], ans[2], ..., ans[9]を確定させる（ans[0]は後述）
for k, v in c.items():
    if v > 0:
        ans[k] = v

# 全体で作れる3*3グリッドは(H-2)*(W-2)個
# ans[1],...,ans[9]の総和を引くとans[0]になる
ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for i in range(10):
    print(ans[i])


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

ll cnt[110];

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

	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		ll now=0,num=1;
		while (1) {
			if(num>a)break;
			if(num&a)cnt[now]++;
			now++;
			num*=2;
		}
	}
	ll mod=1e9+7;
	ll ans=0;
	for(int i=0;i<61;i++){
		ll x=(1ll)<<i;
		x%=mod;
		x*=cnt[i];
		x%=mod;
		x*=n-cnt[i];
		x%=mod;
		ans+=x;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll<<60)

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int MOD = 1e9 + 7;

int n, k;
VI a(200010);
VI cycle;
vector<bool> seen(200010);


signed main()
{
	cin >> n >> k;
	a.resize(n);
	seen.resize(n);
	REP(i, n){
		cin >> a[i];
		a[i]--;
	}

	int now = 0;
	seen[now] = true;
	cycle.push_back(now);
	while(seen[a[now]] == false){
		int next = a[now];
		seen[next] = true;
		cycle.push_back(next);
		now = next;
	}

	int next = a[now];
	auto loop_begin_index = (int)(find(ALL(cycle),next) - cycle.begin());

	int loop_size = cycle.size() - loop_begin_index;

	// ループは高々1つ
	// ループにないものを探すのが大変？
	DEBUG(loop_begin_index);
	DEBUG(loop_size);
	DEBUG(k%loop_size);
	DEBUG(cycle[1]);
	DEBUG(cycle[2]);
	DEBUG(cycle[3]);

	if (k < loop_begin_index) {
		cout << cycle[k] + 1 << endl;
	} else {
		cout << cycle[(k-loop_begin_index)%(loop_size)+loop_begin_index]  + 1<< endl;
	}

	return 0;
}


Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n, max, blank;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if ((i + 1) * i / 2 >= n)
        {
            max = i;
            blank = (i + 1) * i / 2 - n;
            break;
        }
    }
    for (int i = 1; i <= max; i++)
    {
        if (i != blank)
            cout << i << endl;
    }
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, q;
string s;

int acc[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &q);

  cin >> s;

  acc[0] = 0;

  int cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A' && s[i + 1] == 'C') cnt += 1;
    acc[i + 1] = cnt;
  }

  for (int i = 0; i < q; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);

    printf("%d\n", acc[r - 1] - acc[l - 1]);
  }

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	int ans1 = a / k;
	int ans2 = b / k;
	if (ans1 != ans2 || a%k==0 || b%k==0) {
		cout << "OK" << endl;
	}
	else cout << "NG" << endl;
	return 0;
}

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

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

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

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

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

  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def counting_sort(A, B, k):
    C = {i: 0 for i in range(k+1)}

    for j in A:
        C[j] += 1

    for i in range(1, k+1):
        C[i] += C[i-1]

    for j in A[::-1]:
        B[C[j]-1] = j
        C[j] -= 1

def print_list(B):
    for i, j in enumerate(B):
        if i == n - 1:
            print(j)
        else:
            print(j, end=" ")

n = int(input())
A = [int(e) for e in input().split()]
B = [0 for i in range(n)]
counting_sort(A, B, max(A))
print_list(B)



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

#define N 10

pair<double, double> point[N];

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		double x,y;
		cin>>x>>y;
		point[i] = make_pair(x,y);
	}

	double answer = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			double x1 = point[i].first, y1 = point[i].second, x2 = point[j].first, y2 = point[j].second;
			answer += sqrt( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
		}
	}
	answer = answer/n;
	answer = answer * 2;

	cout<<setprecision(15)<<answer;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> s(100100,0);

    rep(i,n){
        ll a, b; cin >> a >> b; a--;
        s[a] += b;
    }

    ll cnt = 0;
    ll ans = 0;

    rep(i,100100){
        cnt += s[i];
        if(cnt >= k){
            ans = i+1;
            break;
        }
    }

    cout << ans << endl;
}

    

Measured memory_bytes: 1024
#include <stdio.h>

long long factorial(int n)
{
	if(n>0)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}
int main(void)
{
	int n;
	scanf("%d",&n);
	printf("%lld\n",factorial(n));
	return 0;
}

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

int INF=1e9;

int main(void){
    int h, w, k;
    cin>>h>>w>>k;
    /*二次元vectorの初期化*/
    vector<string> v(h);
    rep(i, h){
        cin>>v[i];
    }
    int res=INF;
    for(int div=0;div<(1<<(h-1));div++){
        vector<int> id(h);
        int g=0;
        for(int j=0;j<h;j++){
            id[j]=g;
            if((div>>j)&1) g++;
        }
        ++g;
        int ans=g-1;
        vector<vector<int> > c(g+1, vector<int>(w));
        rep(i, h)rep(j, w) c[id[i]][j]+=(v[i][j]-'0');
        vector<int> now(g);
        /*ラムダ関数の書き方, ラムダ式の書き方*/
        auto add = [&](int j){
            rep(i, g) now[i]+=c[i][j];
            rep(i, g) if(now[i]>k) return false;
            return true;
        };
        rep(j, w){
            if(!add(j)){
                ans++;
                now=vector<int>(g);
                if(!add(j)) {
                    ans=INF;
                    break;
                }
            }
        }  
        res=min(ans, res);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256