akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <utility>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define pb push_back
#define NIL -1
#define MAX 100001

using namespace std;

struct Node{
  int id;
  int parent;
  vector<int> child;
  int depth;
  
  void addChild(int c){
    child.pb(c);
  }
    
 void print(){
    cout << "node " << id << ": ";
    cout << "parent = " << parent << ", ";
    cout << "depth = " << depth << ", ";
    cout << (parent == -1?"root":child.size()==0?"leaf":"internal node") << ", ";
    cout << "[";
    if(child.size() != 0){
      rep(i, child.size()-1){
    cout << child[i] << ", ";
      }
      cout << child[child.size()-1];
    }
      cout << "]" << endl;
 }
};

Node node[MAX];

void init(int n){
  rep(i, n){
    node[i].depth = NIL;
    node[i].parent = NIL;
    node[i].child.clear();    
  }
}

signed main(){
  int n;
  int id, k, c, root;
  cin >> n;
  init(n);
  
  root = NIL;

  rep(i, n){
    cin >> id >> k;
    node[id].id = id;
    rep(j, k){
      cin >> c;
      node[id].addChild(c);
      node[c].parent = id;
      node[c].depth = node[id].depth + 1;
    }
  }

  rep(i, n){
    if(node[i].parent == NIL){
      root = i;
      break;
    }
  }
  
  queue<pair<Node, int> > q;
  q.push(make_pair(node[root], -1));
  while(!(q.empty())){
    pair<Node, int> p = q.front(); q.pop();
    node[p.first.id].depth = p.second + 1;
    rep(i, p.first.child.size()){
      q.push(make_pair(node[p.first.child[i]], p.second + 1));
    }
  }
  
  rep(i, n){
    node[i].print();
  }
}


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

char search(int i, int j, vector<string> f, int h, int w) {
    int ret = 0;
    for (int dx = -1; dx < 2; dx++) {
        for (int dy = -1; dy < 2; dy++) {
            int ny = i + dy;
            int nx = j + dx;
            if (0 <= ny && ny <= h-1 && 0 <= nx && nx <= w-1 && f[ny][nx] == '#') {
                ret++;
            }
        }
    }
    return ret + '0';
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i,h) {
        cin >> field[i];
    }
    rep(i,h) {
        rep(j,w) {
            char bomb;
            if (field[i][j] == '.') {
                bomb = search(i,j,field,h,w);
                field[i][j] = bomb;
            }
            
        }
    }
    rep(i,h) {
        cout << field[i] << endl;
    }
}

Measured memory_bytes: 256
a,b,c = gets.to_i,gets.to_i,gets.to_i
z = gets.to_i
cnt = 0

for i in 0..a do
    for j in 0..b do
        for k in 0..c do
            if 500*i + 100*j + 50*k == z
                cnt += 1
            end
        end
    end
end

puts cnt

Measured memory_bytes: 1788
#include<iostream>

using namespace std;
typedef long long ll;

int main()
{

    ll N, K;
    cin >> N >> K;

    ll result = 0;
    for (int i = K + 1; i <= N; ++i)
    {
        result += (N / i) * (i - K);
        if (N % i >= K) result += N % i - K + 1;
    }
    if (K == 0)
    {
        result = N * N;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 60012
S_ = input()
T = input()

for i in range(len(S_)-len(T), -1, -1):
    for j in range(len(T)):
        if S_[i+j] not in (T[j], '?'):
            break
    else:
        print(S_[:i].replace('?', 'a')+T+S_[i+len(T):].replace('?', 'a'))
        exit()
print('UNRESTORABLE')


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int m, k;
  cin >> m >> k;
  if (k == 0) {
    for (int i = 0; i < (1 << m); i++) {
      if (i > 0) cout << " ";
      cout << i << " " << i;
    }
    cout << endl;
    return 0;
  }
  if ((k >= (1 << m)) || (m == 1 && k == 1)) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < (1 << m); i++) {
    if (i == k) continue;
    if (i > 0) cout << " ";
    cout << i;
  }
  cout << " " << k;
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (i == k) continue;
    cout << " " << i;
  }
  cout << " " <<  k << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.StringTokenizer;
import java.util.Optional;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            String S = in.next();

            List<TreeSet<Integer>> ls = new ArrayList<>();
            for (int i = 0; i < 10; i++) {
                ls.add(new TreeSet<>());
            }
            for (int i = 0; i < N; i++) {
                int c = S.charAt(i) - '0';
                ls.get(c).add(i);
            }

            AtomicInteger ans = new AtomicInteger();
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    for (int k = 0; k < 10; k++) {
                        int finalJ = j;
                        int finalK = k;
                        Optional.ofNullable(ls.get(i).ceiling(0))
                                .flatMap(a -> Optional.ofNullable(ls.get(finalJ).ceiling(a + 1)))
                                .ifPresent(b -> {
                                    if (ls.get(finalK).ceiling(b + 1) != null) {
                                        ans.getAndIncrement();
                                    }
                                });
                    }
                }
            }
            out.println(ans.get());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 29324
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

bool cmp(const pair<long long, long long> &q, const pair<long long, long long> &w) {
    if (q == w)
        return false;
    if (q == make_pair(0ll, 0ll))
        return true;
    if (w == make_pair(0ll, 0ll))
        return false;
    bool side1 = (q.second > 0 || q.second == 0 && q.first < 0);
    bool side2 = (w.second > 0 || w.second == 0 && w.first < 0);
 
    if (side1 != side2) {
        return side1 < side2;
    }
 
    long vp = q.first * w.second - q.second * w.first;
    return vp > 0;
}

int main() {
  long long n;
  cin >> n;
  vector<pair<long double, long double> > a(2 * n);
  for(int i = 0; i < n; ++i){
    cin >> a[i].first >> a[i].second;
    a[i + n].first = -a[i].first;
    a[i + n].second = -a[i].second;
  } 

  long double x1 = 0, y1 = 0;
  for(int i = 0; i < n; ++i){
    if(a[i].second > 0 || (!a[i].second && a[i].first < 0)){
      x1 += a[i].first;
      y1 += a[i].second;
    }
  }
  sort(a.begin(), a.end(), cmp);
  long double mx = 0;
  for(int i = 0; i < 2 * n; ++i){
    x1 += a[i].first;
    y1 += a[i].second;
    mx = max(mx, sqrt(x1 * x1 + y1 * y1));
  } 
  cout << fixed << setprecision(20) << mx;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin >>n){
		int f = 0;
		for(int a=0; a<10; a++){
			for(int b=0; b<10; b++){
				for(int c=0; c<10; c++){
					if(n-a-b-c>=0 && n-a-b-c<=9){f++;}
				}
			}
		}
		cout <<f<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
from collections import Counter, defaultdict

read = sys.stdin.read


# 最小素因数を求める（エラトステネスの篩の亜種？）
def min_factor(n):
    sieve = list(range(n + 1))
    sieve[2::2] = [2] * (n // 2)
    for i in range(3, int(n ** 0.5) + 2, 2):
        if sieve[i] == i:
            sieve[i * i::2 * i] = [i] * ((n - i * i - 1) // (2 * i) + 1)
    return sieve


# 素因数分解
def prime_factorize(n):
    a = [1]
    while n != 1:
        b = table[n]
        a.append(b)
        n //= b
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

table = min_factor(10 ** 6)
dic = defaultdict(int)

for i in A:
    for key, value in Counter(prime_factorize(i)).items():
        dic[key] = max(dic[key], value)


lcm = 1
for i, j in dic.items():
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = sum(lcm * pow(i, mod - 2, mod) for i in A) % mod
print(answer)


Measured memory_bytes: 51692
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	a=II()
	print(a+a**2+a**3)





if __name__ == "__main__":
	main()


Measured memory_bytes: 9192
N=io.read("n")
A={}
for i=1,2 do
  A[i]={}
  for j=1,N do
    A[i][j]=io.read("n")
  end
end
local total={}
for i=1,N do
  local a1=0
  local a2=0
  for j=1,i do
    a1=a1+A[1][j]
  end
  for k=i,N do
    a2=a2+A[2][k]
  end
  total[i]=a1+a2
end
table.sort(total)
print(total[N])

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long N, vector<long long> a){
	ll ans = 0;

	REP(i,N) {
		if (a[a[i]] == i) ans++;
	}

	cout << ans/2 << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long N;
	cin >> N;
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> a[i]; a[i]--;
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 1920
package main

import "fmt"

func main() {
	// Code for A - AtCoder *** Contest
	var s1, s2, s3 string
	fmt.Scanf("%s %s %s", &s1, &s2, &s3)

	fmt.Println(string(s1[0]) + string(s2[0]) + string(s3[0]))
}


Measured memory_bytes: 1836
n = int(input())
dict = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j"}
dict2 = {"a":1, "b":2, "c":3, "d":4, "e":5, "f":6, "g":7, "h":8, "i":9, "j":10}
#ans = [["a", 1]]
#for i in range(n-1):
#    newans = []
#    for lis in ans:
#        now = lis[0]
#        count = lis[1]
#        for j in range(1, count + 2):
#            newans.append([now + dict[j], max(j, count)])
#    ans = newans
#for lis in ans:
#    print(lis[0])
def dfs(s):
    if len(s) == n:
        print(s)
        return
    m = max(s)
    count = dict2[m]
    for i in range(1, count+2):
        dfs(s+dict[i])
dfs("a")

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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;

  int maxX = x;
  int in;
  for(int i = 0; i < n; i++){
    cin >> in;
    if(maxX < in) maxX = in;
  }

  int minY = y;
  for(int i = 0; i < m; i++){
    cin >> in;
    if(minY > in) minY = in;
  }

  if(maxX < minY) cout << "No ";

  cout << "War" << endl;

  return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <map>
#include <iostream>
#include <iterator>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>
// #include <bits/stdc++.h>
using namespace std;

// #define ls now << 1
// #define rs now << 1 | 1
#define PB push_back
// #define MP make_pair
// #define double long double
#define int long long
// #define us unsigned
// #define LL long long
const int N = 1000000;
// const int M = 125000;
// #define re register
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
// const double inf_double = 1e4;
// const double eps = 1e-4;
// inline char nc()
// {
//     static char buf[1000000], *p1 = buf, *p2 = buf;
//     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
// }
// #define getchar nc
inline int read()
{
    register int s = 0;
    register bool neg = 0;
    register char c = getchar();
    for (; c < '0' || c > '9'; c = getchar())
        neg |= (c == '-');
    for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
        ;
    return (neg ? -s : s);
}

int a, s[N + 10], prime[N + 10], mu[N + 10], top, f[N + 10], mx, ans;
bool vis[N + 10];

inline void init()
{
    mu[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        if (!vis[i])
        {
            prime[++top] = i;
            mu[i] = -1;
        }
        for (int j = 1; j <= top && i * prime[j] <= N; j++)
        {
            vis[i * prime[j]] = 1;
            if (i % prime[j] == 0)
                break;
            mu[i * prime[j]] = -mu[i];
        }
    }
    for (int i = 1; i <= N; i++)
        for (int j = i; j <= N; j += i)
            f[j] = (f[j] + i * mu[i] + mod) % mod;
}

signed main()
{
    init();
    a = read();
    int x;
    for (int i = 1; i <= a; i++)
    {
        x = read();
        ans = (ans - x + mod) % mod;
        s[x]++;
        mx = max(mx, x);
    }
    for (int i = 1; i <= mx; i++)
    {
        int sum = 0;
        for (int j = 1; j <= mx / i; j++)
            sum = (sum + 1ll * j * s[i * j]) % mod;
        sum = sum * sum % mod * i % mod * f[i] % mod;
        ans = (ans + sum) % mod;
    }
    printf("%lld", ans * 499122177 % mod);
    return 0;
}

Measured memory_bytes: 28712
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
ilelec = lambda: map(int1,input().split())
alelec = lambda: list(map(int1, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
    
def primeFactors(n): 
	A =set()
	while n % 2 == 0: 
		A.add(2) 
		n = n // 2
	for i in range(3,int(math.sqrt(n))+1,2): 
		while n % i== 0: 
			A.add(i) 
			n = n // i 
	if n > 2: 
		A.add(n) 
	return list(A)


N= int(input())
A = alele()
mark = {}
f1 = 1
f2 = 0
x = None
for i in A:
    if f2 == 0:
        if x == None:
            x=i
        x = math.gcd(x,i)
        if x == 1:
            f2 =1
    if f1 == 1:
        c = primeFactors(i)
        for j in c:
            if mark.get(j,-1) !=-1:
                f1 = 0
                break
            mark[j] = 1
if f1 == 1:
    print("pairwise coprime")
elif f2 == 1:
    print("setwise coprime")
else:
    print("not coprime")

    
    
    

Measured memory_bytes: 175680
#include<stdio.h>
#include<math.h>

int main(void){
	double x1,y1,x2,y2,xkyo,ykyo,alkyo=0;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	xkyo=pow(x2-x1,2);
	ykyo=pow(y2-y1,2);
	alkyo=sqrt(xkyo+ykyo);
	printf("%lf\n",alkyo);
	
	return 0;
}


Measured memory_bytes: 2124
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;

const int mod = 1000000007;

long long qpow(long long base,int tms)
{
	long long tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * base % mod;
		base = base * base % mod;
		tms >>= 1;
	}
	return tmp;
}

long long inv2 = qpow(2,mod - 2);
long long dp[3050][3050];
int N,Q;
int seq[3050];

int main()
{
	scanf("%d%d",&N,&Q);
	for(int i = 1;i <= N; ++ i)
		scanf("%d",&seq[i]);
	for(int i = 1;i <= N; ++ i)
		for(int j = 1;j <= N; ++ j)
			dp[i][j] = seq[i] > seq[j];
	long long make_me_burn = qpow(2,Q);
	while(Q --)
	{
		int x,y; scanf("%d%d",&x,&y);
		dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) * inv2 % mod;
		for(int i = 1;i <= N; ++ i)
			if(i != x && i != y)
				dp[i][x] = dp[i][y] = (dp[i][x] + dp[i][y]) * inv2 % mod,
				dp[x][i] = dp[y][i] = (dp[x][i] + dp[y][i]) * inv2 % mod;
	}
	long long ans = 0;
	for(int i = 1;i <= N; ++ i)
		for(int j = i + 1;j <= N; ++ j)
			ans = ans + dp[i][j] * make_me_burn % mod,ans %= mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 71936
#include <iostream>
using namespace std;
int a[200005],b[200005];
int main()
{
    int n,m,x,y,s,i,j;
    cin >> n >> m;
    for(i=0; i<m; ++i)
    {
        cin >> x >> y;
        if(x == 1)
            b[y] = 1;
        if(y == n)
            a[s++] = x;
    }
    int flag = 0;
    for(i=0; i<s; ++i)
        if(b[a[i]] == 1)
            break;
if(i == s)
    cout << "IMPOSSIBLE" << endl;
else
    cout << "POSSIBLE" << endl;
return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n, k;
	cin >> n >> k;
	double num = 1.0 / n, ans = 0;
	rep(i, 1, n + 1) {
		int a = i, cnt = 0;
		while (a < k) { a *= 2; cnt++; }
		ans += num * pow(0.50, cnt);
	}
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    long long  H, W, dp[60][60];
    char inp[55][55];
    rep(i,55) rep(j,55) dp[i][j] = 200000000;

    cin >> H >> W;
    rep(i,H){
        cin >> inp[i];
    }
    rep(i,H){
        rep(j,W){
            dp[i + 1][j + 1] = inp[i][j] - '0';
        }
    }

    range(i,1,H + 1){
        range(j,1,W + 1){
            if(i == j && i == 1) continue;
            dp[i][j] += min(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    cout << dp[H][W] << endl;
}

Measured memory_bytes: 1192
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S=sc.next();
    String splits[]=S.split("");
    if(splits[2].equals(splits[3])&&splits[4].equals(splits[5])){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

        }
      }


Measured memory_bytes: 23508
n_ = 2 * 10**6 + 5
mod = 10**9 + 7
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod


def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod


def modinv(x, mod):
    a, b = x, mod
    u, v = 1, 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    return u % mod


inv26 = modinv(26, mod)

K = int(input())
S = input()
M = len(S)

ans = 0
po = 1
poo = pow(26, K, mod)
for i in range(K+1):
    ans = (ans + po * poo % mod * nCr(i+M-1, i)) % mod
    po = po * 25 % mod
    poo = poo * inv26 % mod
print(ans)


Measured memory_bytes: 104224
#include <stdio.h>
int main(){
	int a,b,c,d,f,g;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	f=a*b;
	g=c*d;
	if (f<g){
		printf("%d",g);
	}else if (g<f){
		printf("%d",f);
	}else{
		printf("%d",f);
	}
	return 0;
}

Measured memory_bytes: 128
#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 fi first
#define se second
#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 int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}, dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		if (s[i] == '?') s[i] = 'D';
	}
	cout << s << endl;
	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    stack<int> ans;
    while (n != 0) {
        ll q = n % 2;
        if (q < 0) q += 2;
        ans.push(q);
        n = (n - q) / -2;
    }
    while (!ans.empty()) {
        cout << ans.top();
        ans.pop();
    }
}


Measured memory_bytes: 256
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    let m = input.parse();
    let k = input.parse();
    let a = (0..n).map(|_| input.parse::<u64>()).collect::<Vec<_>>();
    let b = (0..m).map(|_| input.parse::<u64>()).collect::<Vec<_>>();

    let mut va = vec![0u64; n + 1];
    let mut vb = vec![0u64; m + 1];

    for i in 0..n {
        va[i + 1] = va[i] + a[i];
    }
    for i in 0..m {
        vb[i + 1] = vb[i] + b[i];
    }

    let mut cnt = 0;
    for i in 0..=n {
        let sum = va[i];
        if sum > k {
            continue;
        }
        let mut l = 0;
        let mut r = m;
        while l < r {
            let mid = l + (r - l) / 2;
            if vb[mid] + sum > k {
                r = mid - 1;
            } else if vb[mid] + sum < k {
                l = mid + 1;
            } else {
                l = mid;
                break;
            }
        }
        if sum + vb[l] > k {
            l -= 1;
        }
        cnt = cnt.max(i + l);
    }
    println!("{}", cnt);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


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

int main() {
int N; int X; 
  cin>>N>>X;
  vector<int> L(N);
  int B=1;  //num of bound
  int C=0; // place of ball
  for(int i=0; i<N; i++){
    cin>>L.at(i);
  }
  for(int i=0; i<N; i++){
    C+=L.at(i);
    if(C<=X) B++;
    else break;
  }
  cout<<B<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		double L = stdIn.nextInt();
		double ans = 0;

		ans = L / 3.0;

		System.out.println(Math.pow(ans, 3));
		stdIn.close();
	}
}


Measured memory_bytes: 36048
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;


int main(){
  int a,b;
  cin >> a >> b;
  if(a < b) print("a < b");
  else if(a > b) print("a > b");
  else print("a == b");

  return 0;
}





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

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> m(n);
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            m[i].push_back(make_pair(x, y));
        }
    }

    int mh = 0;
    rep(bit, (1<<n)) {
        vector<int> N(n);
        rep(i, n) {
            if ((1<<i) & bit) {
                N[i] = 1;
            }
        }

        bool flag = true;
        rep(i, n) {
            if (N[i] == 1) {
                rep(j, m[i].size()) {
                    if (m[i][j].second != N[m[i][j].first-1]) {
                        flag = false;
                    }
                }
            }
        }
        if (flag) {
            int count = 0;
            rep(i, n) {
                if (N[i]) count++;
            }
            mh = max(mh, count);
        }
    }
    cout << mh << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x,y,asi;
        x=scan.nextInt();
        y=scan.nextInt();
        
       for(int c=0; c<=x; c++){
           if(c*2+(x-c)*4==y){
               System.out.println("Yes");
               System.exit(0);
           }
       }
        System.out.println("No");
    }
}


Measured memory_bytes: 35824
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int n, r;
    cin >> n >> r;

    if(n >= 10){
        cout << r << endl;
    }else{
        cout << r + 100*(10-n) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec  1 14:07:23 2018
//
package main

import (
	"fmt"
)

var n int

type pos struct {
	x, y, h int
}

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

	return x
}

func max(x, y int) int {
	if x < y {
		return y
	}
	return x
}

func calcHeight(x, y, h int, p pos) int {
	return max(h-abs(p.x-x)-abs(p.y-y), 0)
}

func main() {
	fmt.Scan(&n)

	poss := make([]pos, n)
	for i := range poss {
		fmt.Scan(&poss[i].x, &poss[i].y, &poss[i].h)
	}

	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			var h int
			for _, p := range poss {
				if p.h > 0 {
					h = abs(p.x-x) + abs(p.y-y) + p.h
					break
				}
			}

			valid := true
			for _, p := range poss {
				if calcHeight(x, y, h, p) != p.h {
					valid = false
				}
			}

			if valid {
				fmt.Println(x, y, h)
				return
			}
		}
	}
}


Measured memory_bytes: 512
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'


using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

const double PI = acos((double)-1);
const double eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	int n; cin >> n;
	vector<vector<int>> g(n);
	int m; cin >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y; x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		bool fl = true;
		for (int u : g[i]) {
			if (a[u] >= a[i])	
				fl = false;
		}
		if (fl) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return;
}

Measured memory_bytes: 8728
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll n,i,j,cc=0;
    cin>>n;
    ll rem=n%500;
    j=n/500;
    cc=j*1000;
    j=rem/5;
    cc+=j*5;
    cout<<cc<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
int main(void)
{
	int n, x, i, j, k, count;
	while(1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)
			break;
    		count = 0;
    		for (i = 1; i <= n; i++) {
    			for (j = i + 1; j <= n; j++) {
    				for (k = j + 1; k <= n; k++) {
    					if (i + j + k == x) {
    						count++;
    					}
    				}
    			}
    		}
    		printf("%d\n", count);
	}
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long, long long> P;
#define X_MAX 1000000000

int main(){
  ull n;
  cin >> n;
  vector<ll> x(n), l(n);
  vector<P> xl(n);
  for (ull i = 0; i < n; i++) {
  	cin >> x.at(i) >> l.at(i);
    xl.at(i).second = x.at(i) - l.at(i);
    xl.at(i).first = x.at(i) + l.at(i);
  }
  sort(xl.begin(), xl.end());
  
  ull ans = 0;
  ll t = -1000000000;
  for (ull i = 0; i < n; i++) {
    if (t <= xl.at(i).second) {
      ans++;
      t = xl.at(i).first;
    }
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 3328
N = int(input())
S = input()

S1,S2 = S[:N],S[N:][::-1]

dic = {}
Ans = 0
keys = []

for i in range(2**N):
    red,blue = "",""
    red2,blue2 = "",""
    bits = bin(2**N+i)[3:]
    for j in range(N):
        if bits[j]=="0":
            red   += S1[j]
            red2 += S2[j]
        else:
            blue += S1[j]
            blue2 += S2[j]
    keys.append(red2+"-"+blue2)
    key = red+"-"+blue
    if key not in dic.keys():
        dic[key] = 1
    else:
        dic[key] += 1

for k in keys:
    Ans += dic.get(k,0)

print(Ans)

Measured memory_bytes: 56584
program replacing
  implicit none
  integer :: n, a(100000) = 0, q, b, c, i
  integer(8) :: s = 0, x(100000) = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    s = s + a(i)
    x(a(i)) = x(a(i)) + 1
  end do
  read(*,*) q
  do i = 1, q
    read(*,*) b, c
    s = s + x(b) * (c - b)
    x(c) = x(c) + x(b)
    x(b) = 0
    write(*,'(i0)') s
  end do
end program replacing

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

using namespace std;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  
  return 0;
}



Measured memory_bytes: 3612
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 32796
#include <bits/stdc++.h>
using namespace std;
int mp[9][9],flg[9][9],visited[9][9];


void mark(int x,int y, int num){
  for(int i=y;i<y+3;i++)
    for(int j=x;j<x+3;j++)
      if(mp[i][j]==num) flg[i][j]=1;
}

void  check(int y,int x){
  int used[10]={};
  for(int i=y;i<y+3;i++)
    for(int j=x;j<x+3;j++){
      if(used[mp[i][j]]) mark(x,y,mp[i][j]);
      used[mp[i][j]]=visited[i][j]=1;
    }
}

int main(){
  int q;
  cin>>q;
  int cnt=0;
  while(q--){
    if(cnt)cout <<endl;
    cnt=1;

    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)cin>>mp[i][j];
    memset(flg,0,sizeof(flg));

    for(int i=0;i<9;i++){
      int used[10]={};
      for(int j=0;j<9;j++){
	for(int k=0;k<9&&used[mp[i][j]];k++) 
	  if(mp[i][k]==mp[i][j])flg[i][k]=1;	 
	used[mp[i][j]]=1;
      }
    }
    for(int i=0;i<9;i++){
      int used[10]={};
      for(int j=0;j<9;j++) {
	if(used[mp[j][i]])
	  for(int k=0;k<9;k++) if(mp[j][i]==mp[k][i])flg[k][i]=1;
	used[mp[j][i]]=1;
      }
    }

    memset(visited,0,sizeof(visited));
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)
	if(visited[i][j]==0) check(i,j);

    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++)cout <<(flg[i][j]?"*":" ")<<mp[i][j];
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void){
    char S[3];
    int sum = 700;
    for(int i = 0; i < 3; i++){
        scanf("%c",&S[i]);
        if(S[i] == 'o') sum += 100;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums=new int[3];
        for(int i=0;i<3;i++){
            nums[i]=sc.nextInt();
        }
        Arrays.sort(nums);
        System.out.println(nums[0]+nums[1]==nums[2]?"Yes":"No");
    }
    
 
}

Measured memory_bytes: 23124
use proconio::{input, fastout};
use proconio::marker::Usize1;
use std::cmp::max;


#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcd: [(Usize1, Usize1, u64, u64); q],
    }
    let mut ans = 0u64;
    let mut v = vec![0u64; n + 1];
    let lim = (m - 1) as u64;
    loop {
        for i in 0..n {
            if v[i] > lim {
                v[i + 1] += 1;
                for k in (0..=i).rev() {
                    v[k] = v[i + 1]
                }
            }
        }
        if v[n] > 0 { break; }
        // println!("{:?}", v);
        let tmp: u64 = abcd.iter().map(|(a, b, c, d)| {
            if v[n - *b] - v[n - *a] == *c { d } else { &0 }
        }).sum::<u64>();
        ans = max(ans, tmp);
        v[0] += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2144
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N;
    cin >> N;
    vector<ll> p(N), inv_p(N+1);
    REP(i, N) {
        cin >> p[i];
        inv_p[p[i]-1] = i+1;
    }

    ll delta = 3e4;
    vector<ll> a(N), b(N);
    REP(i, N) {
        a[i] = delta*(ll(i+1));
        b[i] = delta*ll(N-(i+1)) + inv_p[i];
    }

    for(ll x: a) cout << x << " ";
    cout << endl;

    for(ll x: b) cout << x << " ";
    cout << endl;

    return 0;
}

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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  long long s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] * 4ll * m >= s) {
      ++cnt;
    }
  }
  cout << (cnt >= m ? "Yes" : "No");

  return 0;
}


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

#ifdef LOCAL

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, class C<A...> c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;
#else
#define debug(...) {}
#endif

const int N = 1e6;
long long infLL = 1e18;
int inf = 1e9;

vector<pair<int,int>> G[N];

int odl[N];
bool vis[N];

bool zle = false;

void dfs(int x, int y) {
	if (vis[x]) {
		if (y != odl[x]) zle = true;
		return;
	}
	vis[x] = true;
	odl[x] = y;
	for (auto p : G[x]) {
		int v = p.first;
		int e = p.second;
		dfs(v, y + e);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i ++) {
		int a, b, c;
		cin >> a >> b >> c;
		G[a].push_back({b, c});
		G[b].push_back({a, -c});
	}
	for (int i = 1; i <= n; i ++) {
		if (not vis[i]) {
			odl[i] = 0;
			dfs(i, 0);
		}
	}
	cout << (zle ? "No" : "Yes");
}


Measured memory_bytes: 33024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int cnt = sc.nextInt();
        sc.nextLine();
        String[] numArry = sc.nextLine().split(" ");
            for(int m=0;m<cnt;m++){
                System.out.print(numArry[m]);
                if(m == cnt -1){
                    System.out.println("");
                } else {
                    System.out.print(" ");
                }
            }

        for(int i=1;i<cnt;i++){
            int v = Integer.parseInt(numArry[i]);
            int j = i - 1;
            while(j>=0 && Integer.parseInt(numArry[j]) > v){
                numArry[j+1] = numArry[j];
                j--;
            }
            numArry[j+1] = Integer.toString(v);
            for(int m=0;m<cnt;m++){
                System.out.print(numArry[m]);
                if(m == cnt -1){
                    System.out.println("");
                } else {
                    System.out.print(" ");
                }
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 30820
#include <stdio.h>

int main(void){
        int count[4][3][10]={0}, n, i, j, k, b, f, r, v;
        scanf("%d", &n);
        for(i=0;i<n;i++){
                scanf("%d %d %d %d", &b, &f, &r, &v);
                count[b-1][f-1][r-1]+=v;
        }
        for(i=0;i<4;i++){
                for(j=0;j<3;j++){
                        for(k=0;k<10;k++){
                                printf("%2d", count[i][j][k]);
                        }
                        putchar('\n');
                }
                if(i!=3)
                        printf("####################\n");
        }
        return 0;
}




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

bool notPrime[1123456] = {};

void init(){
	notPrime[0] = notPrime[1] = 1;
	FOR(i, 2, 1123456){
		if(!notPrime[i]){
			for(int32 j = 2;i*j < 1123456;j++){
				notPrime[i*j] = 1;
			}
		}
	}
}

int main(void){
	int64 a, d, n;
	init();
	while(cin >> a >> d >> n && a && d && n){
		int32 cnt = 0;
		a -= d;
		while(cnt < n){
			a += d;
			if(!notPrime[a]) cnt++;
		}
		cout << a << endl;
	}
}



Measured memory_bytes: 4172
#include<stdio.h>
int main(){
  int a[4];
  int b[4];
  scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
  scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
  int S = a[0] + a[1] + a[2] + a[3];
  int T = b[0] + b[1] + b[2] + b[3];
  if(S > T || S == T){
    printf("%d\n",S);
  }
  else if(T > S){
    printf("%d\n",T);
  }
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int count = 0;
    for(int i=0; i<3; i++){
        if(s[i]==t[i]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int a, b, c, buf;
	cin >> a >> b >> c;

		if(a > b){
			buf = b;
			b = a;
			a = buf;
		}
		if (b > c) {
			buf = c;
			c = b;
			b = buf;
		}

		if (a > b) {
			buf = a;
			a = b;
			b = buf;
		}


		cout << a << ' ' << b << ' ' << c << endl;
		return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <string>

using namespace std;

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

  int len = s.length();

  // Aの探索
  for (int i = 0; i < len; i++) {
    if (s[i] == 'A') {
      for (int j = len - 1; j >= 0; j--) {
        if (s[j] == 'Z') {
          ans = (j - i) + 1;
          break;
        }
      }
      // 答えが出たらfor文を抜ける
      if (ans != 0) break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 832
#include<bits/stdc++.h>
#define ll long long
#define w cout 
#define e '\n'

using namespace std;

const int N = 1e6 + 5;
ll dd[N] ;

int main(){
	ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
	ll n , we ; 
	cin >> n >> we;
	for(int i = 0 ; i < N ; i++) {
		dd[i] = 1e18;
	}
	dd[0] = 0;
	for(int i = 0 ; i < n ;i ++) {
		ll ww , vv; cin >> ww >> vv;
		for(int j = N - 1  ; j - vv >= 0 ; j --) {
			if(dd[j - vv] != 1e18)
				dd[j] = min(dd[j] , dd[j - vv] + ww);
 		}
	}

	ll ans = 0;
	for(int i = 0 ; i < N ; i ++) {
		if(dd[i] <= we) {
			ans = i;
		}
	}

	w << ans;
}


/*3 8
3 30
4 50
5 60*/


Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(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);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll dp[100010][15];
char s[100010];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	dp[0][0]=1;
	rep(i,0,n){
		if(s[i]=='?'){
			rep(x,0,13)rep(y,0,10)dp[i+1][(x*10+y)%13]=(dp[i+1][(x*10+y)%13]+dp[i][x])%MOD;
		}else{
			int y=s[i]-'0';
			rep(x,0,13)dp[i+1][(x*10+y)%13]=(dp[i+1][(x*10+y)%13]+dp[i][x])%MOD;
		}
	}
	printf("%lld",dp[n][5]);
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
 string str;
 string match="ABC";
 int n;
 sl(n);
 cin>>str;
 int cnt=0;
 for(int i=0;i<n-2;i++){
	 if(str.substr(i,3)==match)cnt++;
 }
 cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
char c[1010][1010];
int main(){
		ll h,w;
		cin>>h>>w;
		queue<pair<P,ll>>que;
		ll cnt=0;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				cnt++;
				que.push({{i,j},1});
			}
		}
		if(cnt==h*w){
			cout<<0<<endl;
			return 0;
		}
		ll dy[4]={0,1,0,-1},dx[4]={1,0,-1,0};
		while(!que.empty()){
			pair<P,ll>p=que.front();
			que.pop();
			ll y=p.first.first,x=p.first.second;
			for(int i=0;i<4;i++){
				if(!(1<=y+dy[i]&&y+dy[i]<=h&&1<=x+dx[i]&&x+dx[i]<=w))continue;
				if(c[y+dy[i]][x+dx[i]]=='#')continue;
				c[y+dy[i]][x+dx[i]]='#';
				cnt++;
				if(cnt==h*w){
					cout<<p.second<<endl;
					return 0;
				}
				que.push({{y+dy[i],x+dx[i]},p.second+1});
			}
		}

	return 0;
}


Measured memory_bytes: 28200