akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    //  cin >> str;
    int n;
    cin >> n;
    int arr[n];
    vector<int> vec;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (int i = n - 1; i >= 0; i -= 2)
    {
        vec.push_back(arr[i]);
        vis[i] = 1;
    }
    for (int i = 0; i < n; i++)
    {
        if (!vis[i])
            vec.push_back(arr[i]);
    }
    for (int i = 0; i < n; i++)
        cout << vec[i] << " ";
    return 0;
}


Measured memory_bytes: 9612
use proconio::input;

fn main() {
    input! {
        n: i64
    }

    let mut sum: i64 = 0;
    for a in 1..n + 1 {
        for b in 1..n + 1 {
            for c in 1..n + 1 {
                sum = sum + gcd_in3(a, b, c);
            }
        }
    }
    println!("{}", sum);
}

fn gcd_in3(a: i64, b: i64, c: i64) -> i64 {
    return gcd(gcd(a, b), c);
}

// 最大公約数を返す
fn gcd(p: i64, q: i64) -> i64 {
    if p % q == 0 {
        return q;
    } else {
        return gcd(q, p % q);
    }
}

Measured memory_bytes: 2128
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  map<ll,ll> ma;
  ll n;
  cin>>n;
  rep(i,0,n){
    ll a;
    cin>>a;
    ma[a]++;
  }
  ll ans = 0;
  map<ll,ll>::iterator itr = ma.begin();
  while(itr!=ma.end()){
    ll a = (*itr).fi;
    ll b = (*itr).se;
    if(a>b){
      ans += b;
    }
    else{
      ans += b-a;
    }
    itr++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
struct tests{
	long long cost; 
	long long L; 
	long long U; 
	long long B; 
}; 
bool cmp(const tests &a, const tests &b){
    return a.cost > b.cost;
}
int main(){
	int N; long long X; cin >> N >> X; 
	tests T[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> T[i].B >> T[i].L >> T[i].U; 
		T[i].cost = T[i].U * (X - T[i].B) + T[i].L * T[i].B; 
	}
	sort(T, T+N, cmp); 
	long long noben = 0; 
	long long time = 0; 
	int idx = 0; 
	for(int i = 0; i < N; i++) noben += T[i].L * T[i].B; 
	if(noben == 0){
		cout << 0 << endl; return 0; 
	}
	long long S[100010] = {}; 
	S[0] = T[0].cost; 
	for(int i = 1; i < N; i++) S[i] = S[i-1] + T[i].cost; 
	long long ans = 1e18;
	for(int i = 0; i < N; i++){
		long long time = 0; long long nobenben = noben; 
		int j = lower_bound(S, S+N, nobenben - T[i].cost) - S;
		if(i > j){
			time = X * (j+1); nobenben -= S[j]; 
		}else{
			int j = lower_bound(S, S+N, nobenben) - S;
			time = X * j; nobenben -= S[j] - T[i].cost; 
		}
		if(nobenben < 0 || nobenben > T[i].cost) continue; 
		if(T[i].L * T[i].B >= nobenben){
			time += (nobenben + T[i].L - 1) / T[i].L; 
		}
		else{
			nobenben -= T[i].L * T[i].B;
			time += T[i].B; 
			time += (nobenben + T[i].U - 1) / T[i].U; 
		}
		ans = min(ans, time);
	}
	cout << ans << endl; 
}

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

using namespace std;
using pii = pair<int, int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<pii>> PY(N + 1);
  vector<pii> res(M);
  for (int i = 0; i < M; i++) {
    int p, y;
    cin >> p >> y;
    PY[p].push_back(make_pair(y, i));
  }
  for (int i = 0; i <= N; i++) {
    if (PY[i].size() == 0)
      continue;
    sort(PY[i].begin(), PY[i].end());
    for (int j = 0; j < PY[i].size(); j++)
      res[PY[i][j].second] = make_pair(i, j + 1);
  }
  for (int i = 0; i < M; i++) {
    cout << setfill('0') << right << setw(6) << res[i].first;
    cout << setfill('0') << right << setw(6) << res[i].second << '\n';
  }
  return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	int x, y, z, n;
	cin >> x >> y >> z >> n;
	LL ans = 0;
	
	FOR(r, 0, n / x + 1)
		FOR(g, 0, n / y + 1)
		{
			int tut = r * x + g * y;
			if (tut > n)
				continue;
			tut = n - tut;
			if (tut % z)
				continue;
			++ans;
		}
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


Measured memory_bytes: 256
mod = 10**9+7
n,m = map(int,input().split())
a = set()
for i in range(m):
  a.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])

Measured memory_bytes: 51160
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    long long a, b, c; cin >> a >> b >> c;
    cout << ((c > a+b && a*b*4 < (c-a-b)*(c-a-b))? "Yes" : "No")<< endl;
    return 0;
}


Measured memory_bytes: 256
# coding:utf-8

# 要素数取得
a = int(raw_input())
#print a
# 要素を拾って配列に
i=0
l = [0]*a
for i in range(0, a):
    b = str(raw_input())
    l[i] = list(b)
#print l

cnt = 0

#print l
#print cnt

def is_unique(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)

if is_unique(l)== True:
    #先頭末尾
    if all(l[i][-1] == l[i+1][0] for i in range(a-1)):
        print "Yes"
    else:
        print "No"
else:
    print "No"


Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
string s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
# A  駅と B 駅を結ぶ鉄道があり、運賃は X 円です。
# また、B 駅と C 駅を結ぶバスがあり、運賃は Y 円です。
# joisinoお姉ちゃんは、A 駅から B 駅まで鉄道で移動し、
# B 駅から C 駅までバスで移動すると、バスの運賃が半額になる特別券を手に入れました。
# この特別券を用いたとき、A 駅から C 駅まで移動するのにいくらかかるか求めてください。

input = gets.chomp.split
x = input[0].to_i
y = input[1].to_i

puts x + (y / 2)


Measured memory_bytes: 1788
/*
 * 2019年  2月 25日 月曜日 12:20:59 JST
 */

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

int main(void){
  int N;
  cin >> N;
  double ans = 0.0;
  for(int i = 0; i < N; i++){
    double x; string u;
    cin >> x >> u;
    double c = (u == "JPY" ? 1.0 : 380000.0);
    ans += x * c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    char t = 'a';
    int acur = 0, bcur = 0, ccur = 0;
    while(1) {
        if(t == 'a') {
            if(acur == a.size()) {
                cout << 'A' << endl;
                return 0;
            }
            t = a[acur];
            acur++;
        }
        if(t == 'b') {
            if(bcur == b.size()) {
                cout << 'B' << endl;
                return 0;
            }
            t = b[bcur];
            bcur++;
        }
        if(t == 'c') {
            if(ccur == c.size()) {
                cout << 'C' << endl;
                return 0;
            }
            t = c[ccur];
            ccur++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int H,W;cin>>H>>W;
    int Ch,Cw;cin>>Ch>>Cw;Ch--;Cw--;
    int Dh,Dw;cin>>Dh>>Dw;Dh--;Dw--;
    vector<vector<bool>> S(H,vector<bool>(W));
    vector<vector<int>> dist(H,vector<int>(W));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) dist[i][j] = 1e9;
    dist[Ch][Cw] = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char c;cin>>c;
            if(c=='.') S[i][j] = true;
        }
    }
    const int di[] = {0,0,-1,1};
    const int dj[] = {-1,1,0,0};
    const int magic_di[] = {-2,-1,0,1,2};
    const int magic_dj[] = {-2,-1,0,1,2};
    deque<pair<int,int>> que;
    que.push_back({Ch,Cw});
    while(que.size()){
        auto p = que.front();que.pop_front();
        int i = p.first, j = p.second;
        for(int k=0;k<4;k++){
            int i2 = i + di[k],j2 = j + dj[k];
            if(i2<0||i2>=H||j2<0||j2>=W) continue;
            if(!S[i2][j2]) continue;
            if(dist[i2][j2]>dist[i][j]){
                dist[i2][j2] = dist[i][j];
                que.push_front({i2,j2});
            }
        }
        for(int k=0;k<5;k++){
            for(int l=0;l<5;l++){
                int i2 = i + magic_di[k],j2 = j + magic_dj[l];
                bool skip = 0; 
                //for(int m=0;m<4;m++) if(magic_di[k]==di[m]&&magic_dj[l]==dj[m]) skip = true;
                if(skip||i2<0||i2>=H||j2<0||j2>=W) continue;
                if(!S[i2][j2]) continue;
                int d2 = dist[i][j] + 1;
                if(dist[i2][j2]>d2){
                    dist[i2][j2] = d2;
                    que.push_back({i2,j2});
                }
            }
        }
    }
    if(dist[Dh][Dw]!=1e9) cout << dist[Dh][Dw] << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7768
/*最大公約数*/
#include <stdio.h>

int main(){
  int x, y, r, tmp;

  scanf("%d", &x);
  scanf("%d", &y);
 
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
  
  printf("%d\n", y);
 
  return 0;
}



Measured memory_bytes: 2140
w, a, b = map(int, input().split())
if a <= a + w <= b <= b + w:
    print(abs(b - a - w))
elif b <= b + w <= a <= a + w:
    print(abs(a - b - w))
elif a <= b <= a + w <= b + w:
    print(0)
elif b <= a <= b + w <= a + w:
    print(0)
elif b <= a <= b + w <= a + w:
    print(0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  map<char,ll> memo;
  rep(i,N){
    string S;
    cin >> S;
    memo[S[0]]++;
  }

  ll ret = 0;
  string march = "MARCH";
  for(ll S=0; S<(1<<5); S++){
    int cnt = 0;
    rep(i,5) if((S>>i)&1) cnt++;
    if(cnt == 3){
      ll tmp = 1;
      rep(i,5) if((S>>i)&1){
        tmp *= memo[march[i]];
      }
      ret += tmp;
    }
  }

  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int L = sc.nextInt();
    int R = sc.nextInt();
    int d = sc.nextInt();
    int count = 0;
    for(int i = L; i <= R; i++){
      if(i % d == 0){
      count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

bool palindrome(string s) {
    string tmp = s;
    reverse(all(tmp));
    return s == tmp;
}

int main() {
    string s; cin >> s;
    deque<char> q;
    rep(i,s.size()) q.push_back(s[i]);
    int ans = 0;
    while (!q.empty()) {
        char front = q.front();
        char back = q.back();
        if (front == back) {
            if (q.size() != 1) {
                q.pop_front(); 
                q.pop_back();
            } else {
                q.pop_front();
            }
        } else {
            if (front != 'x' && back != 'x') {
                cout << -1 << endl;
                return 0;
            } else if (front == 'x') {
                q.push_back('x');
                ans++;
            } else if (back == 'x') {
                q.push_front('x');
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3840
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    n,k=map(int,input().split())
    nk=[1]*(n+1)
    ng=[1]*(n+1)
    mod=10**9+7
    for i in range(2,n+1):
        nk[i]=(nk[i-1]*i)%mod
    ng[n]=pow(nk[n],mod-2,mod)
    for i in range(n,0,-1):
        ng[i-1]=(ng[i]*i)%mod
    ans=0
    for i in range(1,k+1):
        if n-k+1<i:
            ans=0
        else:
            ans=(nk[n-k+1]*ng[i]*ng[n-k+1-i])%mod
            ans=ans*(nk[k-1]*ng[i-1]*ng[k-i])%mod
        print(ans)
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main()
{
  int h,w,hh,ww;
  int black=0;
  int ans=0;
  char a[1000][1000];
  string str;
  queue<pair<int,int> >q;
  queue<pair<int,int> >q2;
  cin >> h >> w;

  for(int i=0;i<h;i++){
    cin >> str;
    for(int j=0;j<w;j++){
      a[i][j]=str[j];
      if(str[j]=='#')
        black++;
        q.push(pair<int,int>(i,j));
    }
  }
  while(black!=h*w){
    while(!q.empty()){
      pair<int,int>p=q.front();
      q.pop();
      hh=p.first;
      ww=p.second;
      if(a[hh][ww]=='#'){
      if(hh>=1 && a[hh-1][ww]=='.'){
        a[hh-1][ww]='!';
        q2.push(pair<int,int>(hh-1,ww));
      }
      if(hh+1<h && a[hh+1][ww]=='.'){
        a[hh+1][ww]='!';
        q2.push(pair<int,int>(hh+1,ww));
      }
      if(ww>=1 && a[hh][ww-1]=='.'){
        a[hh][ww-1]='!';
        q2.push(pair<int,int>(hh,ww-1));
      }
      if(ww+1<w && a[hh][ww+1]=='.'){
        a[hh][ww+1]='!';
        q2.push(pair<int,int>(hh,ww+1));
      }
      }

    }
    ans++;
    while(!q2.empty()){
      pair<int,int>p2=q2.front();
      q2.pop();
      hh=p2.first;
      ww=p2.second;
      q.push(p2);
      a[hh][ww]='#';
      black+=1;
    }
  }

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

Measured memory_bytes: 9360
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int n;
cin >> n;

int sum =0;

int d[n];
rep(i,n)cin >> d[i];

for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
    sum += d[i]*d[j];
        
    }
}



cout << sum << endl;
return 0;
}



Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
    _ <- getLine
    ns <- map read . words <$> getLine
    putStrLn $ show (solve ns)

solve :: [Int] -> Int
solve ns = sum (concat (comb2 ns)) 
            
comb2 :: [Int] -> [[Int]]
comb2 []     = []
comb2 (n:ns) = map (*n) ns : comb2 ns

Measured memory_bytes: 892
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  ll L_MIN, L_MAX, R_MIN, R_MAX;
  cin >> L_MIN >> R_MAX;
  L_MAX = L_MIN;
  R_MIN = R_MAX;
  ll l, r;
  bool fail_flag = false;
  for (int i = 1; i < M; i++) {
    cin >> l >> r;
    if (R_MAX < l || r < L_MIN) {
      fail_flag = true;
      break;
    }
    if (l < L_MIN) {
      L_MIN = l;
    }
    if (L_MAX < l) {
      L_MAX = l;
    }
    if (r < R_MIN) {
      R_MIN = r;
    }
    if (R_MAX < r) {
      R_MAX = r;
    }
  }
  ll ans = (fail_flag) ? 0 : R_MIN - L_MAX + 1;
  if (ans < 0) {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int i, j, c, n;
	char S[5];
	scanf("%s", S);
	n = 1;
	for (i = 0; i < 4; i++) {
		c = 0;
		for (j = 0; j < 4; j++) {
			if (S[i] == S[j]) {
				c = c + 1;
			}
		}
		if (c != 2) {
			n = 0;
			break;
		}
	}
	if (n == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
//おまじない
#include <stdio.h>

 
int main() {
  int n;
  scanf("%d",&n);
  int f=0;
  for(int i=1;i<=9;i++){
    if(n%i==0){
      if(1<=n/i&&n/i<=9){
        f++;
        break;
      }
    }
  }
  
  if(f==1){
    printf("Yes\n");
  }
  
  else{
    printf("No\n");
  }
}
     

      


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    string s;

    cin>>s;

    for(int i=0;i<s.length();i++) {
        cout<<'x';
    }
}




Measured memory_bytes: 3592
using System;
using System.Linq;

namespace _6_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,,] OfficialHouse = new int[4, 3, 10];
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                OfficialHouse[x[0] - 1, x[1] - 1, x[2] - 1] += x[3];
            }
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.Write(" " + OfficialHouse[0, i, j]);
                }
                Console.WriteLine();
            }
            for (int k = 1; k < 4; k++)
            {
                Console.WriteLine("####################");
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        Console.Write(" " + OfficialHouse[k, i, j]);
                    }
                    Console.WriteLine();
                }
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9584
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,t;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) t = t + s[i];
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 10000000
int dp[21][50001];
int main( void )
{
  int n,m;
  cin >> n >> m;
  dp[0][0] = 0;
  for( int i=1; i<=n; i++ ){
    dp[0][i] = INF;
  }
  for( int i=1; i<=m; i++ ){
    int d;
    cin >> d;
    for( int j=0; j<=n; j++ ){
      if( j-d < 0 ){
        dp[i][j] = dp[i-1][j];
      } else {
        dp[i][j] = min( dp[i-1][j], dp[i][j-d]+1 );
      }
    }
  }
  cout << dp[m][n] << endl;
  return 0;
}

Measured memory_bytes: 5260
dr = [0, 0, 1, -1, 1, -1, -1, 1]
dc = [1, -1, 0, 0, 1, 1, -1, -1]
n, m = map(int, input().split())
grid = []
for _ in range(n):
    grid.append(list(input()))
for i in range(n):
    for j in range(m):
        if grid[i][j] == '.':
            grid[i][j] = 0
for i in range(n):
    for j in range(m):
        if grid[i][j] == '#':
            for k in range(8):
                newx = i + dr[k]
                newy = j + dc[k]
                if newx < 0 or newx >= n or newy < 0 or newy >= m or grid[newx][newy] == '#':
                    continue
                grid[newx][newy] += 1
for i in range(n):
    for j in range(m):
        print(grid[i][j], end='')
    print()

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

using namespace std;

int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;

	if (x+r<=W&&x>=r&&y+r<=H&&y>=r) {

		cout << "Yes" << endl;

	}

	else {

		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3116
n, m=map(int, input().split())
grid = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    grid.append(array)


maxa,mina=grid[0]
for i in range(1,m):
    if maxa<grid[i][0]:
        maxa=grid[i][0]
    if mina>grid[i][1]:
        mina=grid[i][1]

v=mina-maxa+1
if v>0:
    print(v)
else:
    print(0)

Measured memory_bytes: 27344
# coding: utf-8
# Your code here!

N = int(input())
string = input().split()
string0 = string[0]
string1 = string[1]
new_string = ''

for i in range(len(string0)) : 
    new_string += string0[i]
    new_string += string1[i]
    
print(new_string)

Measured memory_bytes: 3316
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64;n]
    }
    let mut y = 1000;
    for i in 0..n-1 {
        if a[i] < a[i+1] {
            let k = y / a[i];
            y += (a[i+1] - a[i]) * k;
        }
    }
    println!("{}", y);
}


Measured memory_bytes: 2172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#define N 1000000
using namespace std;
 
int main(){
    int n,k,s=0,d=0;
    scanf(" %d %d", &n , &k);
    int a[N],h1,h2,h3,h4,h5,h6,h7,h8,h9,h10;
    int i=0;
    for(;n-i>11; i+=10){
        scanf(" %d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8,&h9,&h10);
        a[i]=h1; a[i+1]=h2; a[i+2]=h3; a[i+3]=h4; a[i+4]=h5;
        a[i+5]=h6;a[i+6]=h7; a[i+7]=h8; a[i+8]=h9; a[i+9]=h10;
        s +=(h1+h2+h3+h4+h5+h6+h7+h8+h9+h10)/k;
        d = max(max( max(h1, max(h2, h3)), max(h4, max(h5, d))),max( max(h6, max(h7, h8)), max(h9, h10)));
    }
    for(;i<n;i++){
        scanf(" %d", &h1);
        s += h1/k;
        d = max(d, h1);
        a[i] = h1;
    }
     
    int low=s-1,high,mid;
    high = min(1000000000,(d*n)/k);
    while(1){
        if(high-low <= 1) break;
        mid = (low+high)/2;
        int count=0, bef=0,bag,p;
        bool f = true;
        while(1){
            if(bef == n) break;
            if(count >= k){
                f = false;
                break;
            }
            bag = mid;
            for(p=bef;p<n;p++){
                if(bag >= a[p]) bag-=a[p];
                else break;
            }
            bef = p;
            count++;
        }
        if(f) high = mid;
        else low = mid;
    }
     
    printf("%d\n", high);   
    return 0;
}

Measured memory_bytes: 3592
import heapq

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()

ans = 0
candidates = []
now = 0
for i in range(M+1):
  for j in range(now, N):
    if AB[j][0] <= i:
      heapq.heappush(candidates, -AB[j][1])
      now = j + 1
      
    else:
      now = j
      break
  
  if candidates:
    ans -= heapq.heappop(candidates)

print(ans)

Measured memory_bytes: 31596
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int lcs(string a, string b) {
  int n = a.size(), m = b.size();
  int dp[2][m+1];
  for(int i = 0;i <= n;i++) {
    for(int j = 0;j <= m;j++) {
      if(i==0||j==0) dp[i%2][j] = 0;
      else {
        if(a[i-1] == b[j-1]) dp[i%2][j] = 1 + dp[1-i%2][j-1];
        else dp[i%2][j] = max(dp[i%2][j-1], dp[1-i%2][j]);
      }
    }
  }
  return dp[n%2][m];
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

ull f(ll a, ll x) {
  if(a < 0) return 0;
  return (a/x+1);
}

int main() {
  string s;
  cin>>s;
  stack<char> st;
  trav(x,s) {
    if(x == 'B') {if(!st.empty()) st.pop();}
    else st.push(x);
  }
  string ans;
  while(!st.empty()) {ans.push_back(st.top()); st.pop();}
  reverse(ans.begin(), ans.end());
  cout<<ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0);
    cout.tie(0);
    int r, g , b , k ;
    int cnt = 0 ;
    cin >> r >> g >> b >> k;
    while(g <= r)
    {
        g *= 2 ;
        cnt++ ;
        if(cnt > k) break ;
    }
    while(b <= g)
    {
        b *= 2 ;
        cnt++ ;
        if(cnt > k) break ;
    }
    if(cnt > k)
    {
        cout <<"No" << endl ;
    }
    else cout<<"Yes\n" ;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int nax = 2e5 + 100;

vector<int> g[nax];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
	#endif
	int n,k;
	cin>>n>>k;
	vector<int> a(n),f(n+1);
	for(int i=0;i<n;i++){
		cin>>a[i];
		f[a[i]]++;
	}
	int ans = 0;
	sort(f.begin(),f.end());
	for(int i=0;i<=n-k;i++)ans+=f[i];
	cout << ans << endl;
}

Measured memory_bytes: 6528
N, M = [int(_) for _ in input().split()]

mod = 10 ** 9 + 7
MAX_N = 10 ** 5 + 100

#階乗
def calc_factorial(max_i):
    factorial = [1] * max_i
    for i in range(1, max_i):
        factorial[i] = (i * factorial[i - 1]) % mod
    return factorial

#素因数分解
def calc_factorization(n):
    factorization = {}
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            factorization[i] = 1
            n = n // i
            while n % i == 0:
                factorization[i] += 1
                n = n // i
    if n > 1:
        factorization[n] = 1
    return factorization

#組み合わせ
def comb(factorial, n, k, mod):
    a = factorial[n] % mod
    b = (factorial[k] * factorial[n - k]) % mod
    b_ = pow(b, mod - 2, mod)
    return (a * b_) % mod

C = calc_factorization(M)
#階乗を計算しておく
factorial = calc_factorial(MAX_N)

res = 1
for c in C.items():
    res *= comb(factorial, (c[1] + N - 1), c[1], mod) #combinations_count(factorial, (c[1] + N - 1), c[1], mod)

print(res % mod)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  if (K >= 50) {
    for (int i = 0; i < N; i++) {
      cout << N << " ";
    }
  } else {
    for (int i = 0; i < K; i++) {
      vector<int> B(N);
      int start[300000];
      int end[300000];
      for (int j = 0; j < 300000; j++) {
        start[j] = 0;
        end[j] = 0;
      }
      for (int j = 0; j < N; j++) {  
        int s = max(0,j-A[j]);
        int e = min(N,j+A[j]+1);
        start[s]++;
        end[e]++; 
      }
      int num = 0;
      for (int j = 0; j < N; j++) {
        num += start[j];
        num -= end[j];
        B[j] = num;
      }
      A = B;
    }
    for (int i = 0; i < N; i++) {
      cout << A[i] << " ";
    }
  }
  
   return 0;
}

Measured memory_bytes: 7152
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

b = []

ans = [[0]*w]*h

for i in range(n):
	b += [i+1]*a[i]

for i in range(h):
	if i%2 == 0:
		ans[i] = b[i*w : (i+1)*w]
	else:
		ans[i] = reversed(b[i*w : (i+1)*w])

for i in range(h):
	print(*ans[i])

Measured memory_bytes: 9512
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int sum=0;
        int day=0;
        
        while(sum < c){
            day++;
            sum += a;
            if(day % 7 == 0) sum += b;
        }
        System.out.println(day);
    }

}



Measured memory_bytes: 26344
n, play = map(int, input().split())
card = list(map(int, input().split()))
card.sort()
# カードのリスト化を全操作済み
bc = [list(map(int, input().split())) for _ in range(play)]
bc.sort(key=lambda x:x[1], reverse=True)

arr = []
sum_b = 0
for b, c in bc:
  arr += [c]*b
  sum_b += b
  if sum_b >= n:
    break
# 最初のカードを連結
arr += card    
arr.sort(reverse=True)
# カード枚数分合計
print(sum(arr[:n]))

Measured memory_bytes: 34888
#!/usr/bin/env python3

stdin = open(0)
N = [int(x) for x in stdin.read().rstrip()]


def solve(N):
    L = len(N)
    # n円の場合、n+1円の場合
    dp = 0, 1
    for n in N:
        a = min(dp[0] + n, dp[1] + 10 - n)
        b = min(dp[0] + n + 1, dp[1] + 10 - (n + 1))
        dp = a, b
    return dp[0]


print(solve(N))


Measured memory_bytes: 13644
import numpy as np

N,K = map(int,input().split())
p = 10**9+7
Nlist = []
ReNlist =[]
Ans = 0
for i in range(N+1):
    Nlist.append(i)
    ReNlist.append(N-i)
Nlist = np.array(Nlist).cumsum()
ReNlist = np.array(ReNlist).cumsum()
for i in range(K,N+1):
    Ans += ReNlist[i-1]-Nlist[i-1] +1
    Ans = Ans % p
print(Ans+1)


Measured memory_bytes: 45708
#include <iostream>
using namespace std;
int main(){
    char s;
    int i,j,k=0,n,a,b;
    cin>>a>>b;
    for(i=1;i<=a+b+1;i++){
        cin>>s;
        if(k==0)
            if(i!=a+1){
                if(s<'0'||s>'9') k=1;
            }
            else
                if(s!='-')k=1;
    }
    if(k==1) cout<<"No"<<"\n";
    else cout<<"Yes"<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a;
	cin >> a;
	//cout << (a + b + 1) / 2 << endl;
	printf((a < 1200) ? "ABC\n" : "ARC\n");
}

Measured memory_bytes: 256
a, b, c, x, y = gets.chomp.split(" ").map(&:to_i)

c2 = c * 2

if c2 <= a && c2 <= b then
  puts [x, y].max * c2
  exit
end

if c2 > a && c2 > b then
  s = []
  s << c2 * y + (x - y).abs * a
  s << c2 * x + (y - x).abs * b
  s << x * a + y * b
  puts s.min
  exit
end

if c2 <= a && c2 >= b then
  if x >= y then
    puts c2 * x
    exit
  end

  if x < y then
    puts c2 * x + (y - x) * b
    exit
  end
end

if c2 > a && c2 < b then
  if y >= x then
    puts c2 * y
    exit
  end

  if y < x then
    puts c2 * y + (x - y) * a
    exit
  end
end

s = []
s << c2 * y + (x - y).abs * a
s << c2 * x + (y - x).abs * b
s << x * a + y * b
puts s.min


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1 << 18;
int case_no = 1;
#define w(x) int x; cin>>x; while(x--)
#define ANS #ifndef ONLINE_JUDGE freopen("answer.txt", "w", stdout); #endif
	/*
	#ifndef ONLINE_JUDGE 
   	freopen("input.txt", "r", stdin); 
   	freopen("error.txt", "w", stderr); 
   	freopen("answer.txt", "w", stdout); 
   	#endif 
   	*/
unsigned long long n = 7777777777777777777;

int solve(int k) {
	for(int i = 1; i <= 19; i++) {
		if((n % (long long)pow(10, i)) % k == 0) return i;
	}
	return -1;
}

int main() {
	FIO
	int k; cin >> k;
	int num = k, size = 0;
	if((k % 10 == 0) or (k % 10 == 2) or (k % 10 == 4) or (k % 10 == 5) or (k % 10 == 6) or (k % 10 == 8)) {
		cout << "-1" << endl;
	}
	else {
		while(num != 0)  {
			num /= 10;
			size++;
		}
		int n = size;
		while(size--) {
			num = (num * 10) + 7;
		}
		while(true) {
			if(num % k != 0) {
				num = (num % k) * 10 + 7;
				n++;
			}
			else break;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
#define N 100000
int count = 0;
void BinarySearch(int array[], int right, int left, int key) {
	while (left < right) {
		int mid = (left + right) / 2;
		if (array[mid] == key) {
			count++;
			break;
		} else if (array[mid] < key) {
			left = mid + 1;
		} else {
			right = mid;
		}
	}
}

int main() {
	int i, n, array[N];
	scanf("%d", &n);
	for (i = 0; i < n; i++) 
		scanf("%d", &array[i]);
	int m;
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		int l;
		scanf("%d", &l);
		BinarySearch(array, n, 0, l);
	}
	printf("%d\n", count);
}

Measured memory_bytes: 1420
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,k = I2()
    a = Intl()
    aa = list(set(a))
    b = {}
    for i in aa:
        b[i] = 0
    for i in a:
        b[i] += 1
    c = [x[1] for x in b.items()]
    c.sort(reverse=True)
    s = list(it.accumulate(c))
    print(n - s[k-1] if len(aa) >= k else 0)

Measured memory_bytes: 45088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

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

  int n;
  cin >> n;

  string tmp;
  set<string> s;
  for (int i = 0; i < n; i++)
  {
    cin >> tmp;
    s.insert(tmp);
  }

  if (s.size() == 3)
  {
    cout << "Three" << endl;
  }
  else
  {
    cout << "Four" << endl;
  }
}

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

using namespace std;

int n;
pair<int,int> ab[101];
pair<int,int> cd[101];
bool flag[101];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
        flag[i] = false;
    }
    for(int i = 0; i < n; i++){
        cin >> cd[i].first >> cd[i].second;
    }

    sort(cd,cd+n);

    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x = cd[i].first;
        int y = cd[i].second;

        int min_val = -1;
        int min_num = -1;
        for(int j = 0; j < n; j++){
            if(ab[j].first < x && ab[j].second < y && flag[j] == false){
                if(min_val < ab[j].second){
                    min_val = ab[j].second;
                    min_num = j;
                }
            }
        }
        if(min_num != -1){
            flag[min_num] = true;
            cnt++; 
        }
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin>>n;
	   	if(n == 1){ cout<<1; }
	   	else if(n>= 2 && n<=3){ cout<<2; }
	   	else if(n>=4 && n<=7){ cout<<4; }
	   	else if(n>=8 && n <=15){ cout<<8; }
	   	else if(n>=16 && n <=31){ cout<<16; }
	   	else if(n>=32 && n <=63){ cout<<32; }
	   	else if(n>=64 && n <=100){ cout<<64; }
	    return 0;
	  }


Measured memory_bytes: 3636
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] array1 = new int[n];
    int[] array2 = new int[n];
    int l = sc.nextInt();
    int sum = 0;
    for(int i=0; i<n; i++){
      array1[i] = l + i;
    }
    if(array1[0]>0){
      for(int i=1; i<n; i++){
        sum += array1[i];
      }
    }else if(array1[n-1]<0){
      for(int i=0; i<n-1; i++){
        sum += array1[i];
      }
    }else{
      for(int i=0; i<n; i++){
        sum += array1[i];
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define mp make_pair
#define ll long long
#define F first
#define S second
#define pi 6.28318530717958623200
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main()
{
     ll n,m;
     cin>>n>>m;
     vll a(m);
     ll sum=0;
     for(ll i=0;i<m;i++)
     {
         cin>>a[i];
         sum+=a[i];
     }

     if(sum>n)cout<<-1<<endl;
     else cout<<n-sum<<endl;
     return 0;
}


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

s_list = []
cnt = 0
for j in range(n):
    i,p = input().split()
    s_list.append([i,int(p),j])

s_list.sort(key=lambda x:(x[0],-x[1]))
 
for k in s_list:
  print(k[2]+1)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a[4][3][10]={0},b,f,r,v,n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d %d",&b,&f,&r,&v);
		a[b-1][f-1][r-1]=a[b-1][f-1][r-1]+v;
	}
	for(int x=0;x<4;x++)
	{
		for(int y=0;y<3;y++)
		{
			for(int z=0;z<10;z++)
			{
				printf(" %d",a[x][y][z]);
			}
			printf("\n");
		}
		if(x!=3) printf("####################\n");
	}
	return 0;
}

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

int main() {
  int n, d, x;
  cin >> n >> d >> x;

  vector<int> a(n), b(n, 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    int now = 1;
    while (now + a[i] <= d) {
      now += a[i];
      b[i]++;
    }
  }

  int ans = x;
  for (int i = 0; i < n; i++) {
    ans += b[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
int N, ans;
void Main(){
    N = read();
    vector<int> P(100, 0);
    int t;
    for (int i = 2; i <= N; i++) {
        t = i;
        for (int p = 2;t>1;p++) while (t%p == 0) {
            t /= p;
            P[p]++;
        }
    }
    for (int i = 2; i<100; i++) {
        if (P[i] >= 74) ans++;
        for (int j = i+1; j<100; j++) {
            if (min(P[i],P[j]) >= 2 && max(P[i],P[j]) >= 24) ans++;
            if (min(P[i],P[j]) >= 4 && max(P[i],P[j]) >= 14) ans++;
            if (min(P[i],P[j]) >= 14) ans++;
            if (min(P[i],P[j]) >= 24) ans++;
            for (int k = j+1; k<100; k++){
                if (min(P[i],P[j]) >= 4 && P[k] >= 2) ans++;
                if (min(P[i],P[k]) >= 4 && P[j] >= 2) ans++;
                if (min(P[j],P[k]) >= 4 && P[i] >= 2) ans++;
            }
        }
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 256
n = int(input())
dic = {}

for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

max_s = max(dic.values())
max_s_list = []


for k,v in dic.items():
    if v == max_s:
        max_s_list.append(k)

max_s_list = sorted(max_s_list)

for j in max_s_list:
    print(j)

Measured memory_bytes: 32984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lldd long double
int main()
{ll n, x, t;
 cin>>n>>x>>t;
 if(n<x)
 cout << t;
 else{
 if(n%x!=0)
  cout << (t + (t * (n/x)));
 else
  cout<<(t * n/x);}}

Measured memory_bytes: 3596
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		double n = double.Parse(Console.ReadLine());
    double min = n*(double)100/108;
    double max = (n+1)*(double)100/108;
    bool answerExist = false;

    for(int i = 0; i <= 50000; i++)
    {
      double ii = (double)i;
      if(min <= ii && ii < max)
      {
        Console.WriteLine(i);
        answerExist = true;
        break;
      }
    }

    if(!answerExist) Console.WriteLine(":(");
	}
}

Measured memory_bytes: 11220
#include <stdio.h>

//pake yen
//berarti nominal dikali yen
int main(){
int yen;

scanf("%d",&yen);

for(int i = 0; i >= 0; i++){
	if(i * 1000 >= yen){
		printf("%d", i * 1000 - yen);
		break;
	}
}
return 0;
}

Measured memory_bytes: 1728
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 800005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
lli n,m;
lli arr[S];
lli dp[S];
lli cal(lli a,lli b)
{
   return (a*b)/(__gcd(a,b));
}
void solve()
{

   lli sum=0,lcm=0,two=0;
   cin>>n>>m;
   for(lli i=1;i<=n;i++)
   {
        cin>>arr[i];
        lli num=arr[i];
        lli ct=0;
        while(num%2==0)
        {
            num=num/2;
            ct++;
        }
        if(i==1)
        {
            two=ct;
            lcm=num;
        }
        else if(ct!=two)
        {
            cout<<0;
            return;
        }
        else
        {
            lcm=cal(lcm,num);
        }
   }
   // print(two)
   
   lcm=lcm*(lli)(pow(2LL,two));
    
   lli ans=(2*m)/lcm;

   if(ans%2) ans=ans/2+1;

   else
    ans=ans/2;


    cout<<ans;


   


}



int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif
     // test
     {
        solve();
        nl
     }
    
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 4772
N, M = [int(x) for x in input().split(" ")]
s = []
for i in range(M):
    s.append([int(x) - 1 for x in input().split(" ")][1:])
p = [int(x) for x in input().split(" ")]

# sw_patterns = []
count = 0
for i in range(2 ** N):
    # sw_patterns.append(format(i, "0{}b".format(N)))
    sw_pattern = format(i, "0{}b".format(N))
    all_light = True
    for j in range(M):
        target = [sw_pattern[inx] for inx in s[j]]
        if sum([int(data) for data in target if int(data) == 1]) % 2 == p[j]:
            continue
        else:
            all_light = False
            break
    if all_light:
        count += 1

print(count)


Measured memory_bytes: 3188
N = int(raw_input())
ts = map(int, raw_input().split(" "))
vs = map(int, raw_input().split(" "))
tsa = [0]
for t in ts:
    tsa.append(tsa[-1]+t)

T = 0
X = 0
V = 0
def acc():
    ppp = False
    for j in range(N):
        if tsa[j] <= T:
            continue
        if vs[j] > V:
            continue
        c = tsa[j] - T - (V - vs[j])
        if c <= 0:
            return -1
        d = tsa[j] - (T+1) - (V+1 - vs[j])
        if d < 0:
            ppp = True
    if tsa[-1] - T - (V - 0)<=0:
        return -1
    if tsa[-1] - (T+1) - (V+1 - 0) < 0:
        ppp = True
    if ppp:
        return 0
    return 1

def tind():
    for i in range(len(ts)):
        if tsa[i] <= T and  T < tsa[i+1]:
            return i

for i in range(sum(ts)):
    a = acc()
    ti  = tind()
    if a == 1:
        if V == vs[ti]:
            X += V
        else:
            X += V + 0.5
            V += 1
    elif a == 0:
        if V == vs[ti]:
            X += V
        else:
            X += V + 0.25
    else:
        X += V - 0.5
        V -= 1
    T=i+1

print X

Measured memory_bytes: 3332
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{	string s1 = "Sunny", s2 = "Cloudy", s3 = "Rainy";
	string x;
	cin >> x;
	if (x == s1)
		cout << s2 << endl;
	if (x == s2)
		cout << s3 << endl;
	if (x == s3)
		cout << s1 << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
slen = len(S)
tlen = len(T)
ans = 0
for i in range(slen - tlen+1):
    count = 0
    for j in range(tlen):
        if S[i+j] == T[j]:
            count += 1
    ans = max(ans,count)
print(tlen-ans)

Measured memory_bytes: 9060