akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i, n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double a, b, x;
signed main() {
	cin >> a >> b >> x;
	x /= a;
	if (x < a * b / 2) {
		printf("%.12Lf\n", atan2(b, x / b * 2) * 180. / acos(-1));
	}
	else {
		printf("%.12Lf\n", atan2(b - x / a, a / 2) * 180. / acos(-1));
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  int N, l, r, t, b, x, y, d;
  map<int, vector<int> > M;
  while (cin >> N, N) {
    M[0] = {0,0};
    for (int i = 1; i < N; ++i) {
      cin >> t >> d;
      M[i] = {M[t][0], M[t][1]};
      if (d == 0) --M[i][0];
      else if (d == 1) --M[i][1];
      else if (d == 2) ++M[i][0];
      else if (d == 3) ++M[i][1];
    }
    t = -200;
    r = -200;
    l = 200;
    b = 200;
    for (map<int, vector<int> >::iterator itr = M.begin(); itr != M.end(); ++itr) {
      x = itr->second[0];
      y = itr->second[1];
      t = max(t, y);
      r = max(r, x);
      b = min(b, y);
      l = min(l, x);
    }
    cout << r - l + 1 << " " << t - b + 1 << endl;
    M.erase(M.begin(), M.end());
  }
  return 0;
}

Measured memory_bytes: 3020
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
bool akinai(int,int);
int main(){
	int n,i,ans;
	cin>>n;
	for(i=1;i<=n;i++){
		ans=akinai(n,i);
		if(ans==true){
			cout<<" "<<i;
		}
	}
	cout<<endl;
	return 0;
}

bool akinai(int n, int i){
	int count=0;
	int amari;
	while(1){
		if(count==0){
			amari=i%3;
		}
		if(amari==0 || i%10==3){
			return true;
		}
		if(amari!=0 && count==5){
			return false;
		}
		i/=10;
		count++;
	}
}

Measured memory_bytes: 3060
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
loop = min(41,K)
for _ in range(loop):
    B = [0]*N
    for n in range(N):
        l = max(0,n-A[n])
        r = min(N-1,n+A[n])
        #print(l,r)
        B[l]+=1
        if r+1<N:
            B[r+1] -= 1
    #print(B)
    for n in range(1,N):
        B[n] += B[n-1]
    A = B
print(*A)

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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main()
{
	int N, K;
	cin >> N >> K;
	
	Vi coinomote(N);
	for (int i = 1; i <= N; ++i) {
		int a = 0;
		int tmp_i = i;
		while (tmp_i < K) {
			tmp_i *= 2;
			++a;
		}
		coinomote[i - 1] = a;
	}
	
	double ans = 0;
	for (const auto& v : coinomote) {
		ans += 1 / pow(2, v);
	}
	ans /= N;
	printf("%.12f\n", ans);
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		WriteLine(N <= 999 ? "ABC" : "ABD");
	}
}


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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vint key(m);
    vint a(m);
    REP(i,m){
        int b;
        cin >> a[i] >> b;
        REP(j,b){
            int c;
            cin >> c;
            int t=1;
            c--;
            t <<= c;
            key[i]+=t;
        }
    }
    
    int num=1;
    num <<= n;
    vint dp(num,INF);
    dp[0]=0;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int now=q.front();
        q.pop();
        if(dp[now]!=INF){
            REP(i,m){
                int ad=key[i];
                int next = (ad|now);
                if(dp[next]>dp[now]+a[i]){
                    dp[next]=dp[now]+a[i];
                    q.push(next);
                }
            }
        }
        
    }
    if(dp[num-1]==INF){
        cout << "-1\n";
    }else{
        cout << dp[num-1] << endl;
    }
    return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    long a,b,c,x,y;
    long res,tmp;
    cin >> a >> b >> c >> x >> y;
    res = a*x + b*y;
    res = std::min(res,std::max(x,y)*c*2);
    if(x < y){
        res = std::min(res,c*x*2+b*(y-x));
    }else{
        res = std::min(res,c*y*2+a*(x-y));
    }
    cout << res;
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(){
	int count,counter;
	int y,m,d;
	int sum;
	
	scanf("%d",&count);
	counter=0;
	while(counter<count){
		scanf("%d %d %d",&y,&m,&d);
		sum=(y-1)*(20+19)*5+((y-1)/3)*5+d;
		if(y%3==0){
			sum+=(m-1)*20;
		}else{
			sum+=(m-1)*19+m/2;
		}
		printf("%d\n",196471-sum);
		counter++;
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int x;
	cin >> x;
	int ans = 1;
	FOR(i, 2, x + 1) {
		int p = i * i;
		while (p * i <= x) p *= i;
		if (p <= x) chmax(ans, p);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a,int b)
{
    while(a!=b)
    {
        if(a>b)
            a-=b;
        else
            b-=a;

    }

    return a;
}
int main()
{
    int a,b,c,k,sum=0;
    scanf("%d",&k);
    for(a=1;a<=k;a++)
    {
        for(b=1;b<=k;b++)
        {
            for(c=1;c<=k;c++)
                sum=sum+gcd(a,gcd(b,c));
        }
    }printf("%d",sum);
    return 0;
}


Measured memory_bytes: 1728
N, A, B = map(int, input().split())
S = list(input())

a, b = 0, 0
for s in S:
    if s == 'a':
        if (a + b) < (A + B):
            print('Yes')
            a += 1
        else:
            print('No')
    elif s == 'b':
        if (a + b) < (A + B) and b < B:
            print('Yes')
            b += 1
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 4712
n,h=map(int,input().split())
k=[]
thrown=[False]*n
for i in range(n):
    a,b=map(int,input().split())
    k.append((a,0,i))
    k.append((b,1,i))
k.sort(key=lambda x:x[0],reverse=True)
ans=0
for i in range(2*n):
    if thrown[k[i][2]]:continue
    else:
        if k[i][1]==1:
            h-=k[i][0]
            ans+=1
            thrown[k[i][2]]==True
        elif k[i][1]==0:
            ans+=h//k[i][0]
            h%=k[i][0]
            if h!=0:
                ans+=1
                h-=k[i][0]
        if h<=0:break
print(ans)


Measured memory_bytes: 82008
import math
n = int(input())
nn = 1
xl = []
yl = []
ll = 0
for i in range(n):
    x,y = map(int, input().split())
    xl.append(x)
    yl.append(y)

j = 0
while j < n-1:
    k = j+1
    while k <= n-1:
        ll += math.sqrt((xl[j]-xl[k])**2 + (yl[j] - yl[k])**2)
        k += 1
    j += 1

print(ll*2/n)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    int n, k;
    cin >> n >> k;
    double ans;
    vector<int>p(n);
    rep(i, n) cin >> p[i];
    int psum = 0;
    int pa;
    rep(i, k) psum += p[i] + 1;
    pa = psum;
    for (int i = 0; i + k < n; i++) {
        psum = psum - p[i] + p[i + k];
        if (pa < psum) {
            pa = psum;
        }
    }
    cout << fixed << setprecision(15) << (double)pa*0.5 << endl;
    
    return 0;
}


Measured memory_bytes: 4016
<?php
define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%d", $S);
$ans = 0;
for ($i = 1; $i <= intdiv($S, 3); $i++) {
    $amari = $S - $i * 3;
    $x = pascal($amari + $i - 1, $i - 1);
    $ans += $x;
    $ans %= MOD;
}
printf("%d", $ans);

function pascal($x, $y) {
    global $memo;
    $y = min($y, $x - $y);
    if (isset($memo[$x][$y])) {
        return $memo[$x][$y];
    }
    if($y === 0 || $y === $x) {
        $tmp = 1;
        $memo[$x][$y] = $tmp;
        return $tmp;    
    } else {
        $tmp = pascal($x - 1, $y - 1) + pascal($x - 1, $y);
        $tmp %= MOD;
        $memo[$x][$y] = $tmp;
        return $tmp;
    }
}


Measured memory_bytes: 49216
#include <iostream>
int main(void){
    int d;
    std::cin >> d;
    if (d==25){
        std::cout << "Christmas" << std::endl;
    }
    else if(d==24){
        std::cout << "Christmas Eve" << std::endl;
    }
    else if (d==23){
        std::cout << "Christmas Eve Eve" << std::endl;
    }
    else if (d==22){
        std::cout << "Christmas Eve Eve Eve" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val S = readLine()!!
    val K = readLine()!!.toLong()

    val init = check(S)
    val delta1 = check(S + S) - init
    val delta2 = check(S + S + S) - delta1 - init

    println(init + delta2 * (K / 2) + delta1 * ((K - 1) / 2))
}

fun check(s :String): Long{
    var now = s[0]
    var ans = 0L
    var counter = 1L
    for(i in 1 until s.length){
        if(s[i] == now){
            counter++
        }else{
            now = s[i]
            ans += counter / 2
            counter = 1L
        }
    }
    ans += counter / 2
    return ans
}

Measured memory_bytes: 31876
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		int[] r = new int[N];
		for(int i = 0;i < N;i++) {
			r[i] = scn.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 0;i <=N-K;i++ ) {
			if(r[i+K-1] <0) {
				ans = Math.min(ans, -r[i]);
			}else if(r[i] <0 ) {
				ans = Math.min(ans, Math.abs(r[i+K-1]-2*r[i]));
				ans = Math.min(ans, Math.abs(2*r[i+K-1]-r[i]));
			}else {
				ans = Math.min(ans, r[i+K-1]);
			}

		}
		System.out.println(ans);
		scn.close();
	}
}

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

int main(){
	string a = "keyence" ;
  	string s ;
  	cin >> s ;
  	int j = 0 ;
  	int k = 0 ;
  	bool ok = false ;
  	for(int b = 0 ; b <(int) s.size() ; b++){
    	if(s[b] == a[j])
          j++ ;
      	else
          break ;
    }
  	for(int b = 0 ; b < (int) s.size() ; b++){
    	if(s[s.size()-1 - b] == a[6-k])
          	k++ ;
        else
        	break ;
    }
  	if(j+k >= 7)
      cout << "YES\n" ;
  	else
      cout << "NO\n" ;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

MAX = 10**5*2+3

N,K = inpl()
aa = inpl()
cnts = defaultdict(int)
inds = defaultdict(list)
info = [[0,0] for _ in range(N)]
ed = set(aa)

for i,a in enumerate(aa):
    cnts[a] += 1
    inds[a].append(i)     # inds[a][i-1] : a の i番目の index
    info[i] = [a,cnts[a]] # aa[i] -> info[i][1] 番目の info[i][0]


nexts = [-1]*MAX
ed.add(0)
for e in ed:
    tmp = e
    if e == 0:
        i = 0
    else:
        i = inds[tmp][0] + 1

    while True:
        #print(tmp,i)
        if i == N:
            nexts[e] = 0
            break
        tmp,n = info[i]
        if cnts[tmp] == n:
            nexts[e] = tmp
            break
        else: #cnts[a] != n
            nextind = inds[tmp][n+1-1] # tmpの値の次のindex
            nextind += 1 # の一個次
            i = nextind


visited = [False]*MAX
kero = []
x = 0
L = 0
while True:
    if visited[x]:
        break
    else:
        kero.append(x)
        visited[x] = True
        x = nexts[x]
        L += 1

tmp = kero[K%L-1]
#print(kero)
#print(tmp)

ans = []
if tmp == 0:
    i = 0
else:
    i = inds[tmp][0] + 1

while i < N:
    tmp,n = info[i]
    if cnts[tmp] == n:
        ans.append(tmp)
        i += 1
    else:
        nextind = inds[tmp][n+1-1] # tmpの値の次のindex
        nextind += 1 # の一個次
        i = nextind

print(' '.join(map(str,ans)))


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

int main(){
  int n,q;
  cin >> n >> q;
  dsu tree(n);
  while(q--){
    
    int t,u,v;
    cin >> t >> u >> v;
    if(t==0) tree.merge(u,v);
    else{
      if(tree.same(u,v)){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4016
from numpy import*
M=10**9+7
m=lambda:map(int,raw_input().split())
n,k=m()
b=eye(n,n,0,'O')
a=matrix([m()for i in b],'O')
while k:b=[b,b*a][k&1];a=a*a%M;k>>=1
print sum(b)%M

Measured memory_bytes: 13048
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli n,i,sum=0,ans=0;
	cin>>n;
	lli a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n-1;i++)
	{
		sum=(sum+a[i])%mod;
		ans=(ans%mod+(a[i+1]*sum)%mod)%mod;
//		cout<<sum<<endl;
	}
	cout<<ans;
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
  
  return 0;
}

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

string FILENAME = "template";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define forll(V, S, E) for(int V = S; V < E; V++)
#define fore(V, N) for(auto &V:N)
#define print(X) cout << X
#define printsp(X) cout << X << " "
#define println(X) cout << X << endl
#define rem(X) X.top(); X.pop()
#define graph unordered_map<int, vector<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) println("bust");
    else println("win");
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    s=input()
    q=int(input())
    s=deque(s)
    inv=False
    for i in range(q):
        que=input()
        if que[0]=='1':
            inv=not(inv)
        else:
            f=que[2]
            if (f=='1' and not(inv)) or (f=='2' and inv):
                s.appendleft(que[4])
            else:
                s.append(que[4])
    if inv:s.reverse()
    print(*s,sep='')



if __name__=='__main__':
    main()

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

using namespace std;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll l = (ll)s.size();
    vector<mint> kai(2000001);
    kai[0]=mint(1);
    for(ll i=1;i<=2000000;++i){
        kai[i] = kai[i-1]*mint(i);
    }
    mint ans(0);
    for(ll x=0;x<=k;++x){
        mint t = mint(26).pow(x);
        t *= mint(25).pow(k-x);
        mint t2 = kai[k-x+l-1];
        t2 /= kai[k-x];
        t2 /= kai[l-1];
        t *= t2;
        ans += t;
    }
    cout << ans.x << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int M = 3;

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if(S == "Y"){
      M = 4;
    }
    else{
    }
  } 
  
  if(M == 3){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}



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

int main() {
  //----------変数置いたり代入したり----------
  
  int H, W, K; // それぞれの変数は問で与えられた通り
  cin >> H >> W >> K;
  
  vector<vector<char>> clist(H, vector<char>(W)); 
  // H×Wの配列に "." or "#"を代入
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      char c;
      cin >> c;
      clist.at(i).at(j) = c;
    }
  }
  
  //----------ここまでは問題なしと思われる----------

  //----------処理していく(ここから不安)----------
  
  int ans = 0; 
  // ansは答えとして出力したい値を表す変数, 
  // 条件に合致する行列の選び方をしたときに+1していく
 
  //----------ビット全探索で行列の選び方を決定していく----------
  for (int tmp1 = 0; tmp1 < (1 << H); tmp1++) {
    bitset<6> s(tmp1);
    for (int tmp2 = 0; tmp2 < (1 << W); tmp2++) {
      bitset<6> t(tmp2);

      int jud=0; // "#"の個数を数えるための変数, 見つけ次第+1していく
      for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
          
          //----------最も怪しいと思われる部分----------
          //自分の考えでは、clistの要素のうち、選ばれていない行と列に属し、
          //かつ、"#"であればカウントする
          if(!s.test(i) && !t.test(j) && clist.at(i).at(j)=='#') {
            jud++;
          }
          //------------------------------------------
          
        }
      }
      
      //judによりカウントされた"#"の数がKであれば、
      //その行列の選び方がOKということになるため、ansに+1する
      if (jud==K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<iomanip>

using namespace std;

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

	int inf = 1e9 + 1;	
	int h, n;
	cin >> h >> n;
	vector<pair<int, int>> spell(n);
	vector<int> cost(h + 1, inf);
	for (int i = 0; i < n; i++) {
		cin >> spell[i].first >> spell[i].second;
	}

	for (int i = 0; i < n; i++) {
		cost[spell[i].first] = spell[i].second;
	}


	for (int i = 1; i <= h; i++) {
		for (int j = 0; j < n; j++) {
			if (spell[j].first >= i) cost[i] = min(cost[i], spell[j].second);
			else cost[i] = min(cost[i], cost[i - spell[j].first] + spell[j].second);
		}
	}

	cout << cost[h];
}

Measured memory_bytes: 508
n = int(input())

d = dict()

for _ in range(n):
    k = input()
    if d.get(k):
        d[k] += 1
    else:
        d[k] = 1

for kk in ['AC', 'WA', 'TLE', 'RE']:
    if d.get(kk):
        print(kk + ' x ' + str(d.get(kk)))
    else:
        print(kk + ' x 0')


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

#define INF (1e9)

using namespace std;

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

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

    double sum = 0;
    for (int i = 1; i <= N; i++) {
        if(i < K){
            sum += pow(0.5, ceil(log2((double)K / i)));
        }else{
            sum++;
        }
    }

    printf("%1.10lf\n", sum / N);
}


Measured memory_bytes: 256
import Data.List

main = do
  n <- readLn
  as <- sort . map read . words <$> getLine
  print (liningUp n as)

liningUp n as
  | odd n && as == lodd = 2 ^ (div n 2) `mod` (10^9+7)
  | even n && as == leven = 2 ^ (div n 2) `mod` (10^9+7)
  | otherwise = 0
  where
    lodd  = take n $ concat $ transpose [[0,2..],[2,4..]]
    leven = take n $ concat $ transpose [[1,3..],[1,3..]]

Measured memory_bytes: 33916
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
a, b, c = map(int, input().split())

cnt = 0
for i in range(a, b+1, 1):
    if c % i ==0:
        cnt+=1

print(cnt)





Measured memory_bytes: 6880
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int train = Math.min(a, b);
		int bus = Math.min(c, d);
		System.out.println(train+bus);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
 
int main(){
    int dp[10001] = {};
    int n,k,m;
    while(cin>>n>>k>>m,n){
        dp[1] = 0;
        for(int i = 2; i <= n; i++){
            if(i == n){
                dp[i] = (dp[i-1] + m) % i;
            }else{
                dp[i] = (dp[i-1] + k) % i;
            }
        }
        cout<<dp[n]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3056
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(b >= a) {
			System.out.println(a);
		} else {
			System.out.println(a-1);
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <list>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ld eps = (ld)1 / 1e10;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ll a, b, c, d, s = 0;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0)
    {
        if (!s) c -= b;
        else a -= d;
        s = 1 - s;
    }
    cout << (s ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;
int main(){
    int N;
    cin >> N;
    int ans = 0;
    while(N > 1){
        //cout << N << endl;
        N = (N / 3) + (N % 3 == 0 ? 0 : 1);
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i=0; i<N; i++) {
        cin >> W.at(i);
    }
    for(int i=1; i<N; i++) {
        W.at(i) += W.at(i-1);
    }
    int ans = 1000000000;
    for(int T=0; T<N; T++) {
        int S1 = W.at(T);
        ans = min(ans, abs(W.at(N-1) - 2*S1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str, A: int, B: int, U: str):
    dictionary = {S: A, T: B}
    dictionary[U] = dictionary[U] - 1
    print("{0} {1}".format(dictionary[S], dictionary[T]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    solve(S, T, A, B, U)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n = read();
    string a, b;
    sf(a, b);
    int i = 0, j = 0;
    int cnt = 0;
    while (i < n || j < n) {
        if (cnt == 0) {
            cout << a[i++];
            cnt ^= 1;
        }else {
            cout << b[j++];
            cnt ^= 1;
        }
    }
    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b;
    int ans;
    cin >> a >> b;

    // 処理
    if (a >= 13) {
        ans = b;
    } else if (a >= 6 && a < 13) {
        ans = b / 2;
    } else if (a < 6) {
        ans = 0;
    }

    // 出力
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1) + m * (m - 1)) / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define takearr(a,n) long long a[n];for(int i=0;i<n;i++)cin>>a[i]
#define ll long long
int main()
{
  ll n,x;cin>>n>>x;
  takearr(a,n);
  sort(a,a+n);
  ll sum=0;int ans=0;int i;
  for(i=0;i<n;i++)
    {
      if(sum+a[i]>x)break;
      else {ans++;sum+=a[i];}
    }
  if((i==n)&&(sum<x))ans--;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	count := 1
	max := 0
	for i := 0; i < n-1; i++ {
		if max < h[i] {
			max = h[i]
		}
		if max <= h[i+1] {
			count++
		}
	}
	fmt.Println(count)
}


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

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
ll sum[200000];
int a[200000];
signed main(){
	sum[1]=1;
	for(int i=2;i<200000;i++){
		sum[i]=(sum[i-1]+ppow(i,MOD-2))%MOD;
	}
	int n;scanf("%d",&n);
	ll ans=0;
	rep(i,n){
		scanf("%d",&a[i]);
		(ans+=a[i]*sum[i+1]%MOD+a[i]*sum[n-i]%MOD+MOD-a[i])%=MOD;
	}
	for(int i=1;i<=n;i++)(ans*=i)%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 2176
n, q = map(int, input().split())
process = []
for i in range(n) :
    name, time = input().split()
    process.append([name, int(time)])

time = 0
while True :
    if len(process) == 0 :
        break
    if process[0][1] > q :
        process[0][1] -= q
        time += q
        process.append(process[0])
        process.pop(0)
    else :
        time += process[0][1]
        print(process[0][0], time)
        del process[0]



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

const int N = 120;

int q[N];

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

    for (int i = 0; i < n ; i ++ )
        cin >> q[i];

    int sum = 0;

    sort(q,q+n);

    for (int i = 0; i < n; i ++ )
        sum += q[i];

        if(sum % 10 == 0)
        {
            for (int j = 0; j < n; j ++ )
            {
                if(q[j] % 10 != 0)
                    {
                        sum -= q[j];
                        cout << sum << endl;
                        return 0;
                    }
            }
        }
        else  cout << sum << endl;
        if(sum % 10 == 0) cout << "0" << endl;
    return 0;
}


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

int main() {
    int n,i,j,a[20] = {},b[50],c[50];
    int satisfy = 0;
    
    scanf("%d",&n);
    for(i = 0; i < n; i++) {
        scanf("%d",&a[i]);
    }
    for(i = 0; i < n; i++) {
        scanf("%d",&b[i]);
    }
    for(i = 0; i < (n-1); i++) {
        scanf("%d",&c[i]);
    }
    
    for(i = 0; i < n; i++) {
        if(a[i] != 0) {
            j = a[i] - 1;
            satisfy += b[j];
            if(a[i] + 1 == a[i+1])
                satisfy += c[j];
        }
    }
    printf("%d",satisfy);
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] array = new int[N];

		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);

		int sum = 0;
		for (int i = N - 1, j = 0; j < K; i--, j++) {
			sum += array[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 25172
if __name__ == '__main__':
    h, w, k = map(int, input().split())
    field = [list(input()) for i in range(h)]
    cnt = 1
    for y in range(h):
        for x in range(w):
            if field[y][x] == "#":
                field[y][x] = cnt
                cnt += 1

    for y in range(h):
        for x in range(w):
            if field[y][x] == "." and x - 1 >= 0:
                field[y][x] = field[y][x - 1]

    for y in range(h):
        for x in list(reversed(range(w))):
            if field[y][x] == "." and x + 1 < w:
                field[y][x] = field[y][x + 1]

    for x in range(w):
        for y in range(h):
            if field[y][x] == "." and y - 1 >= 0:
                field[y][x] = field[y - 1][x]

    for x in range(w):
        for y in list(reversed(range(h))):
            if field[y][x] == "." and y + 1 < h:
                field[y][x] = field[y + 1][x]

    for y in range(h):
        for x in range(w):
            print("{} ".format(field[y][x]), end='')
        print()


Measured memory_bytes: 7504
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
    ll n;
    ll a,b;
    cin>>n>>a>>b;
    ll ans = fastexp(2,n);
    ans -= 1;
    ans += mod;
    ans %= mod;
    ll num = 1;
    rep(i,a){
    	num *= (n-i);
    	num %= mod;
    }
    ll den = 1;
    rep(i,a){
    	den *= (i+1);
    	den %= mod;
    }
    ll temp = num*inverse(den);
    temp %= mod;
    ans -= temp;
    ans += mod;
    ans %= mod;
    a = b;
    num = 1;
    rep(i,a){
    	num *= (n-i);
    	num %= mod;
    }
    den = 1;
    rep(i,a){
    	den *= (i+1);
    	den %= mod;
    }
    temp = num*inverse(den);
    temp %= mod;
    ans -= temp;
    ans += mod;
    ans %= mod;
    cout<<ans;
	return 0;	
}

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

int main(void)
{
    int n, m[4][3][10] = {0};
    
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        m[b-1][f-1][r-1] += v;
    }
    
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 10; ++k) {
                cout << " " << m[i][j][k];
            }
            cout << endl;
        }
        if (i != 3)
            cout << "####################" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
    #include <iostream>
    #include <unordered_map>
    #include <unordered_set>
    #define pb push_back
    #define mpr make_pair
    #define pii pair<int, int>
    #define pll pair<ll, ll>
    #define ll long long
    #define ld long double
    #define fi first
    #define se second
    #define all(arr) arr.begin(), arr.end()
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define fo(i, l, r) for (int i = l; i <= r; i++)
    #define INF 1000000001
    #define inf1 1000000000000000001
    #define MOD 1000000007
    #define mod 1000000007
    #define pie 3.14159265358979323846264338327950L
    #define N 200009
    #define M 1e6 + 9
    #define mid(l, r) l + (r - l) / 2
    #define vec vector<int>
    #define vecl vector<ll>
    #define umap unordered_map<ll, ll>
    #define yes cout << "Yes" << endl;
    #define no cout << "No" << endl;
    #define endl "\n"
    #define int long long
    using namespace std;

    int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
    int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
    ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
    ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



    const int MAX = 5100000;
    long long fac[MAX], finv[MAX], inv[MAX];
    
    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[k] * finv[n - k] % MOD) % MOD;
    }

    long long binpow(long long a, long long b, long long m) {
        a %= m;
        long long res = 1;
        while (b > 0) {
            if (b & 1)
                res = res * a % m;
            a = a * a % m;
            b >>= 1;
        }
        return res;
    }



    void test_case()
    {
        int n;
        cin>>n;

        int ans = 0;

        COMinit();

        for(int i=1; i<=n; i++) {
                int temp = (binpow(9,n-i,mod) - binpow(8,n-i,mod) + 100000000700 ) % mod;
                int val  = (COM(n,i)* (temp)) % mod ;
                ans = (ans % mod + val % mod)% MOD;
                // cout<<val<<endl;
            }
            ans = ans % MOD;
        
        cout<<ans<<endl;
        
    }

    signed main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout << fixed << setprecision(20);

        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);

        int t = 1;
        // cin >> t;
        while (t--)
        {
            test_case();
        }
    }

Measured memory_bytes: 123176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
 
  int main(){
  lint n;
  lint sum=0;
  cin >>n; vector<lint> a(n);
  rep(i,n){cin >> a[i];
        sum+=a[i];
  }
  sort(all(a));
  if(sum%10!=0)cout<<sum<<endl;
  else{
      rep(i,n){
          sum-=a[i];
          if(sum%10!=0){
              cout<<sum<<endl;
              return 0;
          }
          sum+=a[i];
      }
      cout<<0<<endl;
  }
  }
  
     


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

using namespace std;

int N, M;
vector<string> Dictionary, RDictionary;
map<string, int> Count;

int count(const vector<string> &dic, string word) {
	int left, right;

	left = lower_bound(dic.begin(), dic.end(), word) - dic.begin();
	word.push_back('z' + 1);
	right = lower_bound(dic.begin(), dic.end(), word) - dic.begin();

	//cout << "left=" << left << "  right=" << right << "  word=" << word << endl;
	return right - left;
}

int solve(const string& word) {
	int len;
	string tmp;

	len = word.size();
	if (word[0] == '*') {
		tmp = word.substr(1);
		reverse(tmp.begin(), tmp.end());
		return count(RDictionary, tmp);
	}
	
	if (word[len - 1] == '*') {
		tmp = word.substr(0, len - 1);
		return count(Dictionary, tmp);
	}

	return Count[word];
}

int main() {
	int pos, sum;
	string word;

	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cin >> word;
		Dictionary.push_back(word);
		Count[word] = 1;
		//cout << "1:" << word << endl;
		reverse(word.begin(), word.end());
		RDictionary.push_back(word);
		//cout << "2:" << word << endl;
	}

	sort(Dictionary.begin(), Dictionary.end());
	sort(RDictionary.begin(), RDictionary.end());
	for (int i = 0; i < M; ++i) {
		cin >> word;
		pos = word.find('?');
		if (pos == string::npos) {
			cout << solve(word) << endl;
			continue;
		}
		sum = 0;
		for (char ch = 'a'; ch <= 'z'; ++ch) {
			word[pos] = ch;
			//cout << "word=" << word << endl;
			sum += solve(word);
		}
		cout << sum << endl;
	}

	return 0;
}



Measured memory_bytes: 82656