akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n,total=0,sum=0;
	cin >> n;
	int a[n+1];
	
	for(int i=1;i<=n;i++)
	   cin >> a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==0)
		{
			sum++;
			if(a[i]%3==0 || a[i]%5==0)
			   total++;
		}
	}
	
	if(total<sum)
	   cout << "DENIED";
	else 
	   cout << "APPROVED";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    long long input, term;
    cin >> input >> term;
    
    vector<long long> point(input);
    for(long long i = 0; i < input; i++){
        cin >> point.at(i);
        if(i - term >= 0){
            if(point.at(i) > point.at(i - term)){
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }



}


Measured memory_bytes: 4836
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


def gcd(h, l):
    if h % l:
        return gcd(l, h % l)
    else:
        return l


MOD = int(1e9 + 7)

import numpy
import scipy
from collections import deque
from math import sqrt
#https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b?lang=en
#B - Counting of Trees
"""
sort, and then check how many next levels we have against the previes level
keep a prevcount, and each level is prev level ** cur elvel
"""
A = gi()
B = gi()

div = gcd(max(A, B), min(A, B))

ans = 1
cur = div
for d in range(2, int(sqrt(div)) + 1):
    if (cur == 1):
        break
    if cur % d == 0:
        ans += 1
    while cur % d == 0:
        cur = cur // d

#    print(cur, d)

if cur > 1:
    ans += 1

print(ans)


Measured memory_bytes: 13292
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N, M;
  cin >> N >> M;
  if(N >= M) {
    cout << 0 << endl;
    return 0;
  }
  vi x;
  rep(i,M){
    int n;
    cin >> n;
    x.pb(n);
  }
  sort(rng(x));
  vi diff;
  int sum = 0;
  rep(i,M -1) {
    sum += abs(x[i + 1] - x[i]);
    diff.pb(abs(x[i + 1] - x[i]));
  }
  sort(rng(diff));
  int msum = 0;
  rep(i, N - 1) {
    msum += diff[M - 2 - i];
  }
  sum -= msum;
  cout << sum << endl;
  return 0;
}

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

int main(){
  int v[4][3][10]={0};
  int N;
  cin >> N;
  int r, f, b, a;
  for(int i=0;i<N;i++){
    cin >> r >> f >> b >> a;
    v[r-1][f-1][b-1] += a;
  }

  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        cout << " " << v[i][j][k];
      }
      cout << endl;
    }
    if(i < 3){
      cout << "####################" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])

inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
q = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1

while len(q) > 0:
    x, y = q.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] and (p[yy][xx] > p[y][x] + 1):
           p[yy][xx] = p[y][x] + 1
           q.insert(0, (xx, yy))
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if y%2 == 1 {
		fmt.Println("No")
		return
	}
	ansx := 2*x - (y / 2)
	ansy := y/2 - x
	if ansx < 0 || ansy < 0 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return
}


Measured memory_bytes: 1816
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main() {
  int A, B, a, b, ans;
  cin >> A >> B;
  a=max((4-A),0);
  b=max((4-B),0);
  ans=100000*(a+b);
  if (A+B==2) {
    ans=ans+400000;
  }
  cout << ans << endl;
}


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

using namespace std;

vector<int> a, b, c;
vector<vector<int> > dp;

void solve(int n) {
    if(n <= 0)
        return;
    if(dp[n-1][0] == -1)
        solve(n-1);
    dp[n][0] = a[n] + max(dp[n-1][1], dp[n-1][2]);
    dp[n][1] = b[n] + max(dp[n-1][0], dp[n-1][2]);
    dp[n][2] = c[n] + max(dp[n-1][0], dp[n-1][1]);
}

int main() {
    int n;
    cin >> n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    dp.resize(n, vector<int>(3, -1));
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    solve(n-1);
    if(dp[n-1][0] > dp[n-1][1]) {
        if(dp[n-1][0] > dp[n-1][2])
            cout << dp[n-1][0] << "\n";
        else cout << dp[n-1][2] << "\n";
    } else if(dp[n-1][1] > dp[n-1][2]) {
        cout << dp[n-1][1] << "\n";
    } else cout << dp[n-1][2] << "\n";
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, ans;
ll f[51];
int prime[1000010], mark[1000010], tot;
ll find(ll x) {
	ll l = 1, r = 1000000, ret = -1;
	while (l <= r) {
		ll mid = (l + r) >> 1;
		if (mid * (mid + 1) / 2 <= x) {
			ret = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	return ret;
}
void get_prime() {
	for (int i = 2; i <= 1000000; i++) {
		if (!mark[i]) prime[++tot] = i;
		for (int j = 1; j <= tot; j++) {
			if (prime[j] * i > 1000000) break;
			mark[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
}
int main() {
	get_prime();
	for (int i = 1; i <= 50; i++) {
		f[i] = find(i);
	}
	cin >> n;
	for (int i = 1; prime[i] * prime[i] <= n && i <= tot; i++) {
		if (n % prime[i] == 0) {
			ll cnt = 0;
			while (n % prime[i] == 0) {
				cnt++;
				n /= prime[i];
			}
			ans += f[cnt];
		}
	}
	if (n > 1) {
		ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 7848
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 998244353;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = INF;
    rep(i, s.size() - t.size() + 1) {
        int k = t.size();
        rep(j, t.size()) {
            if(s[i + j] == t[j]) --k;
        }
        ans = min(ans, k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
int n;
string s;

vector<ll> Val;
vector<vector<int>> G;

void init()
{
    Val.resize(n, 0);
    G.resize(n, vector<int> (0));
}

void dfs(int v, int par)
{
    for (auto u : G[v])
    {
        if (u == par)
        {
            continue;
        }

        Val[u] += Val[v];
        dfs(u, v);
    }
    return;
}


int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int q;
    cin >> n >> q;
    init();

    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;

        G[u].push_back(v);
        G[v].push_back(u);
    }

    for (int i = 0; i < q; i++)
    {
        int u, cost;
        cin >> u >> cost;;
        u--;
        Val[u] += cost;
    }

    dfs(0, -1);
    for (int i = 0; i < n; i++)
    {
        cout << Val[i] << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 24320
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <limits>
using namespace std;
#define int long long
#define REP(i, n) for (int i = -200; i < (int)(n); i++)
signed main(){
int x;
cin >> x;
REP(i,200){
    REP(j,200){
        if(pow(i,5)-pow(j,5)==x){
            cout << i << " " << j;
          return 0;
        }
    }   
 }
}

Measured memory_bytes: 4052
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
//global
int sosu[20000]={};

void get_sosu(int num){
   sosu[0] = 2;
   int i,j,k;
   int cnt = 1;
   for(i=3;i<=num;i+=2){
      k=0;
      for(j=3;j<=sqrt(i);j+=2){
        if(i%j==0)	{
	  k=1;
	  break;
	}
      }
      if(k==0) {
        sosu[cnt]= i;
        cnt++;
      }            
  }
}


int compare_int(const void *a, const void *b)
{
    return *(long long*)a - *(long long*)b;
}

int min_comp(int min, int a)
{

}
int max_comp(int max, int a)
{
  if(max>a)    return max;
  else    return a;
}

int double_num(int num, int time)
{
if(time>=1){
    time = time - 1;
    num = num * 2;
    num = double_num(num, time);
     return num;
  }
if(time<=0) return num;
 }

int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  long long min=0;
  int A, B, C, K;
//  int sosu[20000]={};
  int i,j,k;
  int flag=0;  
//    int k=0;

  scanf("%d", &A);
  //printf("%d\n", A);

  int cnt=1;

  get_sosu(55555);
  cnt=0;
  for(i=0;i<20000;i++){
        if(sosu[i] %5 ==1){
         printf("%d  ", sosu[i]);
         cnt++;
         if(cnt==A) break;
       }
   }
   printf("\n");

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int a[3];
int main() {
    IOS
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[0] + a[1] << endl;

    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int K;
string S;
cin>>K>>S;
int a=S.size();
if(a>K){
for(int i=0; i<K; i++){
cout<<S.at(i);
}
cout<<"..."<<endl;
}
else
cout<<S<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main(){
    string text;
    string ref;
    int counter = 0; 
    cin >> ref;
    cin >> text;
    while (text != "END_OF_TEXT") {
        //cout << text << endl;
        int l = text.length();
        for (int i = 0; i < l; i++){
            if ('A' <= text[i] && text[i] <= 'Z'){
                text[i] += 'a' -  'A';
            }
        }
        if (text == ref) {
            counter++;
        }
        cin >> text;
    }
    cout << counter << endl;
}


Measured memory_bytes: 3176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>
#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
    struct dsu {
    public:
        dsu() : _n(0) {}
        dsu(int n) : _n(n), parent_or_size(n, -1) {}

        int merge(int a, int b) {
            assert(0 <= a && a < _n);
            assert(0 <= b && b < _n);
            int x = leader(a), y = leader(b);
            if (x == y) return x;
            if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
            parent_or_size[x] += parent_or_size[y];
            parent_or_size[y] = x;
            return x;
        }

        bool same(int a, int b) {
            assert(0 <= a && a < _n);
            assert(0 <= b && b < _n);
            return leader(a) == leader(b);
        }

        int leader(int a) {
            assert(0 <= a && a < _n);
            if (parent_or_size[a] < 0) return a;
            return parent_or_size[a] = leader(parent_or_size[a]);
        }

        int size(int a) {
            assert(0 <= a && a < _n);
            return -parent_or_size[leader(a)];
        }

        std::vector<std::vector<int>> groups() {
            std::vector<int> leader_buf(_n), group_size(_n);
            for (int i = 0; i < _n; i++) {
                leader_buf[i] = leader(i);
                group_size[leader_buf[i]]++;
            }
            std::vector<std::vector<int>> result(_n);
            for (int i = 0; i < _n; i++) {
                result[i].reserve(group_size[i]);
            }
            for (int i = 0; i < _n; i++) {
                result[leader_buf[i]].push_back(i);
            }
            result.erase(
                    std::remove_if(result.begin(), result.end(),
                                   [&](const std::vector<int>& v) { return v.empty(); }),
                    result.end());
            return result;
        }

    private:
        int _n;
        // root node: -1 * component size
        // otherwise: parent
        std::vector<int> parent_or_size;
    };

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP


using namespace std;
using namespace atcoder;

class ADisjointSetUnion {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n, q;
        in >> n >> q;
        dsu ds(n);
        while (q--) {
            int t;
            in >> t;
            int u, v;
            in >> u >> v;
            if (t) out << ds.same(u, v) << '\n';
            else ds.merge(u, v);
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ADisjointSetUnion solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    ll x, y;
    cin >> x >> y;

    ll cnt = 1;
    while (x * 2 <= y)
    {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i=0;i<n;i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n);
	dp[0] = 0;
	for(int i=1;i<n;i++)
	{
		int t=0;
		dp[i] = INT_MAX;
		for(int j=i-1;j>=0 && t<k;j--, t++)
		{
			dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
N=int(input())
l=[int(x) for x in input().rstrip().split()]
ans=10000000000
now1=0
now2=0

for i in range(N+1):
    now1=sum(l[0:i+1])
    now2=sum(l[i+1:])
    ans=min(ans,abs(now1-now2))
print(ans)

    

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int in[10000], cou, i, min, max;
	long long int sum = 0;
	scanf("%d", &cou);
	for (i = 0; i < cou; i++) {
		scanf("%d", &in[i]);
		if (i == 0) {
			min = in[0];
			max = in[0];
		}
		if (min > in[i])min = in[i];
		if (max < in[i])max = in[i];
		sum += in[i];
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2104
a,b,c,x,y = map(int,input().split())
ans = 0
if x > y:
    a,b,x,y = b,a,y,x
if a + b >= 2 * c:
    ans1 = 2 * c * x + b * (y - x)
    ans2 = 2 * c * y
    print(min(ans1,ans2))
else:
    print(a*x + b*y)

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 205;

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int ans = 0;
    for(int i = 0;i<s1.length();i++){
        ans += s1[i] == s2[i];
    }
    cout <<ans;
}











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

int s[100010];
int A[100010];

int main(void) {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	long long int sum = 0;
	for (int i = 1; i <= N; i++) {
		s[i] = abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]) - abs(A[i - 1] - A[i + 1]);
		sum += abs(A[i - 1] - A[i]);
	}
	sum += abs(A[N] - 0);
	for (int i = 1; i <= N; i++) {
		cout << sum - s[i] << endl;
	}
	//system("pause");
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N; cin >> N;
    vector<ll> A(N+1,1);
    ll ans = 0;
    for(ll i = 1; i <= N; ++i) {
        ll c = N-N%i;
        ll n = (c-i)/i+1;
        ans += i*((n+1)*n)/2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81404
def f(x: int) -> int:
    s = 0
    while x > 0:
        s += x % 10
        x //= 10
    return s


def harshad_number(N: int) -> bool:
    return N % f(N) == 0


if __name__ == "__main__":
    N = int(input())
    yes = harshad_number(N)
    print('Yes' if yes else 'No')


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

int main()
{
	string s;
	int k,p,a = 0;
	

	cin >> s;
	k = s.length();
	p = 15 - k;

	for (int i = 0; i < k; i++)
	{
		if (s[i] == 'o')
		{
			a++;
		}
	}

	if ((p + a) >= 8)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

void solve();

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

void solve(){
    ll X;cin>>X; 
    cout<<(10-X/200)<<endl;
}

Measured memory_bytes: 3648
<?php
// Here your code !
$num = trim(fgets(STDIN));
for($i = 1; $i <= $num; $i++){
    if($i % 3 == 0 || has3($i)){
        echo " ".$i;
    }
}

function has3($x){
    while($x){
        if($x % 10 == 3) return true;
        $x /= 10;
    }
    return false;
}
?>

Measured memory_bytes: 15400
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        long N = r.l();
        int root = (int)Math.sqrt(N)+1;
        int factor = 1;
        for(int i = 2; i <= root; i++)
            if(N%i == 0)
                factor = i;
        println(Math.max(digit(factor), digit(N/factor)));
    }
    static int digit(long n){
        int d = 0;
        while(n > 0){
            d++;
            n /= 10;
        }
        return d;
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

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

int main() {
	
	int r, D, x;
	cin >>r >>D >>x;
	
	for(int i=0; i<10; i++){
		
		cout <<r*x-D <<endl;
		x=r*x-D;
		
	}
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] c = new int[10][10];
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				c[i][j] = sc.nextInt();
			}
		}

		int end=1;
		int[] d = new int[10];
		dijkstra(c,end,d);
//		for(int i=0;i<10;i++){
//			System.out.println(d[i]);
//		}
		int max=0;
		int[][] a = new int[H][W];
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				a[i][j] = sc.nextInt();
				if(a[i][j]==-1) continue;
				dijkstra(c,a[i][j],d);
				max=max+d[1];
			}
		}
		System.out.println(max);

	}
	 public static void dijkstra(int[][] map,int src,int[] distance) {
			int nTown = distance.length;
			boolean[] fixed = new boolean[nTown]; // 最短距離が確定したかどうか
			for (int i=0; i<nTown; i++) { // 各都市について初期化する
			    distance[i] = Integer.MAX_VALUE; // 最短距離の初期値は無限遠
			    fixed[i] = false;	// 最短距離はまだ確定していない
			}
			distance[src] = 0;	// 出発地点までの距離を0とする
			while (true) {
			    // 未確定の中で最も近い都市を求める
			    int marked = minIndex(distance,fixed);
			    if (marked < 0) return; // 全都市が確定した場合
			    if (distance[marked]==Integer.MAX_VALUE) return; // 非連結グラフ
			    fixed[marked] = true; // その都市までの最短距離は確定となる
			    for (int j=0; j<nTown; j++) { // 隣の都市(i)について
				if (map[marked][j]>0 && !fixed[j]) { // 未確定ならば
				    // 旗の都市を経由した距離を求める
				    int newDistance = distance[marked]+map[marked][j];
				    // 今までの距離よりも小さければ、それを覚える
				    if (newDistance < distance[j]) distance[j] = newDistance;
				}
			    }
			}
		    }
		    // まだ距離が確定していない都市の中で、もっとも近いものを探す
		    static int minIndex(int[] distance,boolean[] fixed) {
			int idx=0;
			for (; idx<fixed.length; idx++)	// 未確定の都市をどれか一つ探す
			    if (!fixed[idx]) break;
			if (idx == fixed.length) return -1; // 未確定の都市が存在しなければ-1
			for (int i=idx+1; i<fixed.length; i++) // 距離が小さいものを探す
			    if (!fixed[i] && distance[i]<distance[idx]) idx=i;
			return idx;
		    }








}


Measured memory_bytes: 47064
#include <atcoder/all>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++)
    {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0)
        {
            d.merge(u, v);
        }
        else
        {
            if (d.same(u, v))
            {
                printf("1\n");
            }
            else
            {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4008
#include<string>
#include<iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int d, n;
  cin >> d;
  n = 25 - d;
  cout << "Christmas";
  rep(i, n){
    cout << " " << "Eve";
  }
}

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

using ll = long long;

#define fi first
#define se second

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    map<pair<int, int>, ll> cnt;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        int a = s[0] - '0', b = s.back() - '0';
        cnt[{a, b}]++;
    }
    ll ans = 0;
    for (auto it: cnt) {
        if (it.fi.fi == it.fi.se) {ans += it.se * it.se; continue;}
        pair<int, int> p = {it.fi.se, it.fi.fi};
        ans += (cnt[p] * it.se);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
from collections import deque

s = deque(input())

q = int(input())
r = 0
for _ in range(q):
    A = list(input().split())
    if A[0] == '1':
        r = (r + 1)%2
    else:
        if (A[1] == '1' and r % 2 == 0) or (A[1] == '2' and r % 2 == 1):
            s.appendleft(A[2])
        else:
            s.append(A[2])

if r == 1:
    s.reverse()
print("".join(s))

Measured memory_bytes: 74072
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";
fn solve(S: String) {
    if S.len() == 3 && S.find('a') >= Some(0) && S.find('b') >= Some(0) && S.find('c') >= Some(0){
        println!("{}", YES);
    }else{
        println!("{}", NO);
    }
}

// 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)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut S: String;
    S = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string a,b;
    a=to_string(n);
    b=to_string(m);
    if(n<=m){
        for(int i=0;i<m;i++){
            cout<<a;
        }
    }
    else{
        for(int i=0;i<n;i++){
            cout<<b;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
//#define foreach_it(type,it,c) for(type::iterator it=c.begin(); it!=c.end(); ++it)
// fast?
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

int Yen(int x, int y, int h, int w){
	int ret = 0;
	int inSize = x + y + h;
	int inWeight = w;
	// C++11
	vector<pair<int, int> > size_weight_List
	{MP(60,2),MP(80,5),MP(100,10),MP(120,15),MP(140,20),MP(160,25)};
	VI feeList{ 600, 800, 1000, 1200, 1400, 1600 };

	FOR(i, 0, size_weight_List.size()){
		if (inSize <= size_weight_List[i].first && inWeight <= size_weight_List[i].second){
			ret = feeList[i];
			break;
		}
	}
	return ret;
}

int main(){
	int n;
	int x, y, h, w;
	long long ans = 0;
	fastIO;
	
	while (cin >> n,n){
		while (n--){
			cin >> x >> y >> h >> w;
			ans += Yen(x, y, h, w);
		}
		cout << ans << endl;
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 1192
S = input().split()
i = len(S) -1
def f1():
    global i
    s = S[i]
    i -= 1
    if s == "+":
        n1 = f1()
        n2 = f1()
        return n1 + n2
    elif s == "-":
        n1 = f1()
        n2 = f1()
        return n2 - n1
    elif s == "*":
        n1 = f1()
        n2 = f1()
        return n1 * n2
    else:
        return int(s)
print(f1())


Measured memory_bytes: 5612
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x = int(input())
    res = 8 - (x - 400) // 200
    print(res)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9164
n = int(input())
ss = input()
s = []
for i in ss:
    s.append(i)
res = ""
n = n % 26
#print(n)
for i in s:
    #print(i)
    if ord(i)+n > 90:
        res+=chr(ord(i)-26+n)
    else:
        res += chr(ord(i)+n)
    #print(res)
        
print(res)


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

using namespace std;

int main() {
    // Input
    int N, M;
    vector<int> s, c;

    cin >> N >> M;
    s = vector<int>(M);
    c = vector<int>(M);
    for (int i = 0; i < M; i++) cin >> s[i] >> c[i];

    // Process
    bool judge = true;
    vector<int> n = vector<int>(N, -1);
    for (int i = 0; judge && i < M; i++){
        if (n[s[i] - 1] == -1) n[s[i] - 1] = c[i];
        else judge = (n[s[i] - 1] == c[i]);
    }

    int ans = -1;
    if (judge && (n[0] != 0 || N == 1)){
        for (int i = 0; i < 3; i++){
            if (n[i] == -1){
                if (i == 0){
                    if (N == 1) n[i] = 0;
                    else n[i] = 1;
                } else {
                    n[i] = 0;
                }
            }
        }
        ans = 0;
        for (int i = 0; i < N; i++) ans += pow(10, N - i - 1) * n[i];
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
ll INF = 1e18;
using namespace std;

unordered_map<ll,vector<ll>> edge;
vector<ll> counter;
void dfs(ll current, ll parent){
  counter[current] += counter[parent];

  for(ll next: edge[current]){
    if(next == parent)continue;
    dfs(next, current);
  }
}

int main(){
  ll N,Q;
  cin >> N >> Q;
  counter.resize(N+1);


  rep(i,N-1){
    ll a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  
  rep(i,Q){
    ll p, x;
    cin >> p >> x;
    
    counter[p] += x;
  }
  
  dfs(1, 0);

  rep(i,N){
    cout << counter[i+1] << " ";
  }
  
  cout << endl;




  return 0;
}


Measured memory_bytes: 30920
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO

#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define ll long long

int main(){
    //freopen("input.txt","r",stdin);
    ll n,m,i,j,*data1,*data2,*tdata,ans,t1,t2,t3,md=1000000007ll;
    data1=new ll[100000];
    data2=new ll[100000];
    tdata=new ll[100000];
    scanf("%lld %lld",&n,&m);
    for(i=0;i<n;i++){
        scanf("%lld",&tdata[i]);
    }
    sort(tdata,tdata+n);
    for(i=1;i<n;i++){
        data1[i-1]=tdata[i]-tdata[i-1];
    }
    for(i=0;i<m;i++){
        scanf("%lld",&tdata[i]);
    }
    sort(tdata,tdata+m);
    for(i=1;i<m;i++){
        data2[i-1]=tdata[i]-tdata[i-1];
    }
    ans=0ll;
    n--;
    for(i=0;i<n;i++){
        t1=((i+1)*(n-i))%md;
        ans+=((t1*data1[i])%md);
        ans%=md;
    }
    m--;
    t2=0;
    for(i=0;i<m;i++){
        t1=((i+1)*(m-i))%md;
        t2+=((t1*data2[i])%md);
        t2%=md;
    }
    ans=(ans*t2)%md;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 2688
import java.util.*;
class Main{

    int min(int a,int b){
	if(a<b)return a;
	else return b;
    }

    int max(int a,int b){
	if(a>b)return a;
	else return b;
    }

    int calc(int b,int c,int d,int e){
	int res=b*d+c*e;
	if(d>=5&&e>=2)res=res*8/10;
	return res;
    }

    Main(){
	Scanner sc =new Scanner(System.in);
	int a=sc.nextInt();
	for(int i=0;i<a;i++){
	    int b=sc.nextInt();
	    int c=sc.nextInt();
	    int d=sc.nextInt();
	    int e=sc.nextInt();

	    int D=max(d,5);
	    int E=max(e,2);

	    int x=min( calc(b,c,d,e) , calc(b,c,D,E) );
	    System.out.println(x);
	}
    }
    public static void main (String[]arg){
	new Main();
    }
}

Measured memory_bytes: 23448
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s[3];
    rep(i, 0, 3) cin >> s[i];
    if(s[0][s[0].size() - 1] == s[1][0] && s[1][s[1].size() - 1] == s[2][0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){
  int A, B;
  cin >> A >> B;//A, B(代入)
  int sum = 0;
  for(int i = A; A <= i && i <= B; i++){
    int a = i / 10000;//i 5桁
    int b = i % 10000 / 1000;//i 4桁
    int c = i %100 / 10;//i 2桁
    int d = i % 10;//i 1桁
    if(a == d && b == c){
      sum++;
    }
  }
  cout << sum << endl;
}

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

using namespace std;

int main(){

  vector<string> v = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
  
  string S;
  cin >> S;


  for(int i=0; i<7; i++){
    if(S==v[i]){
      cout << i+1;
      break;
    }
    
  }
  
    
  return 0;


}

Measured memory_bytes: 256
#include <stdio.h>

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

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

int main(){
    int n;
    cin >> n;
    int a[2][n];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < 1; i++){
        for(int j = 1; j < n; j++){
            a[i][j] += a[i][j-1]; 
        }
    }
    a[1][0] += a[0][0];
    for(int i = 1; i < 2; i++){
        for(int j = 1; j < n; j++){
            a[i][j] += max(a[i][j-1],a[i-1][j]);
        }
    }
    cout << a[1][n-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> a(H);
  REP(i, H) cin >> a[i];

  vector<vector<int>> vec(H, vector<int>(W, 0));
  vector<int> ng(H, 0);
  int cnt = 1;
  REP(i, H){
    bool flag = false;
    REP(j, W){
      if(a[i][j] == '#') flag = true;
    }
    if(!flag){
      ng[i] = 1;
      continue;
    }

    REP(j, W){
      if(a[i][j] == '#'){
        if(flag) flag = false;
        else cnt++;
      }
      vec[i][j] = cnt;
    }
    cnt++;
  }

  REP(k, H){
    REP(i, H){
      if(ng[i] == 0) continue;
      if(i != 0 && !ng[i-1]){
        REP(j, W) vec[i][j] = vec[i-1][j];
        ng[i] = 0;
      }else if(i != H-1 && !ng[i+1]){
        REP(j, W) vec[i][j] = vec[i+1][j];
        ng[i] = 0;
      }
    }
  }

  REP(i, H) REP(j, W){
    cout << vec[i][j];
    SPBR(j, W);
  }

  return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#pragma warning(disable:4996)
#define MAX 101
#define INF 100000
#define FLAG 1
#define DEFLAG 0

int main() {
	int i, j, n, min, a[MAX][MAX], k, x[MAX], minNode, sum = 0, g[MAX];

	scanf("%d", &n);
	for (i = 0; i<n; i++) {
		for (j = 0; j<n; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	k = 1;
	x[0] = 0;
	g[0] = FLAG;
	for (i = 1; i<n; i++) {
		g[i] = DEFLAG;
	}
	while (1) {
		min = INF;
		for (i = 0; i<k; i++) {
			for (j = 0; j<n; j++) {
				if (min > a[x[i]][j] && a[x[i]][j] != -1 && g[j] != FLAG) {
					min = a[x[i]][j];
					minNode = j;
				}
			}
		}
		if (k != n) {
			x[k] = minNode;
			g[minNode] = FLAG;
			k++;
			sum += min;
		}
		else { break; }

	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 cin>>N;
 vector<string>S(N);
 for(int i=0;i<N;i++){
   cin>>S.at(i);
 }
 sort(S.begin(),S.end());
  
 int ans=1;
 for(int i=1;i<N;i++){
   if(S.at(i-1)!=S.at(i)){
     ans++;
   }
 }   
 cout<<ans<<endl;
}
  
   

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

int main() {
  int N,t,ansx,ansy;
  int x = 0,y = 0,i = 0,now = 0;
  bool judge = true;
  cin >> N;
  while(i != N){
    cin >> t >> ansx >> ansy;
    now = t - now;
    for(int j = 0; j < now; j++){
      if(ansx != x){
        x < ansx ? x++ : x--;
      } else {
        y <= ansy ? y++ : y--;
      }
    }

    if(x == ansx && y == ansy){
      now = t;
    } else {
      judge = false;
      break;
    }
    i++;
  }
    
  cout << (judge == true ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <cstdlib>
#include <set>
#include <map>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=20000;i++)
	{
		if(i==25)
		{
			int k;
		}
		if(i*0.08>=a && i*0.08<a+1 && i*0.1>=b && i*0.1<b+1)
		{
			printf("%d",i);
			return 0;
		}
	}
	printf("-1");
	return 0; 
}

Measured memory_bytes: 128
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

S = input()[:-1]
po = [0 for i in range(n)]

for i in range(n-1,-1,-1):
    if i == n-1:
        if S[i] == "R":
            po[i] += 1
    else:
        if S[i] == "R":
            po[i] += po[i+1]+1
        else:
            po[i] += po[i+1]
co = 0

for i in range(n):
    if po[i] - co > 0 and S[i] != "R":
        co += 1
print(co)


Measured memory_bytes: 87520
#include <stdio.h>

int main(void)
{
	char foo[200001];
	scanf("%s", foo);
	char *p = foo;
	for (; *p; ++p) {
		if (*p == 'A') {
			break;
		}
	}
	char *last;
	char *p2 = p;
	for (; *p2; ++p2) {
		if (*p2 == 'Z') {
			last = p2;
		}
	}
	printf("%d\n", last - p + 1);
}


Measured memory_bytes: 384