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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), M = input();
    string S = input< string >();
    whole(reverse, S);
    
    int idx = 0;
    vector< int > ans;
    while (idx != N) {
        if (idx + M >= N) {
            ans.push_back(N - idx);
            break;
        }

        bool f = true;
        rrange(d, 1, M + 1) {
            if (S[idx + d] == '1') continue;
            idx += d;
            ans.push_back(d);
            f = false;
            break;
        }
        
        if (f) {
            cout << -1 << endl;
            return;
        }
    }
    
    whole(reverse, ans);
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1096
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	stack<int> s;
	vi d(n);
	rep(i, n) cin >> d[i];
	rep(i, n) {
		if(d[i] >= a) s.push(d[i]);
		else break;
	}
	if(n - s.size() >= m) {
		cout << s.size() << endl;
		return 0;
	}
	while(1) {
		if(s.size() == 0) break;
		if(s.top() <= b) s.pop();
		else break;
	}	
	cout << s.size() << endl;
}

Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		Deque<Integer> q=new ArrayDeque<>();
		boolean front=true;
		for(int i=1;i<=n;i++)
		{
			if(front)
			{
				q.addFirst(nextInt());
				front=false;
			}
			else
			{
				q.addLast(nextInt());
				front=true;
			}
		}
		if(front)
		{
			while(!q.isEmpty())
				out.print(q.removeLast()+" ");
		}
		else
		{
			while(!q.isEmpty())
				out.print(q.removeFirst()+" ");
		}
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 71300
import sys
import itertools

import numpy as np

first, second, k = tuple(map(int, sys.stdin.readline().split()))

array = np.full(shape=(first, second), fill_value=0, dtype=np.int32)

for i, line in enumerate(sys.stdin):
  for j, c in enumerate(line.strip()):
    array[i, j] = 1 if c == '#' else 0

#v_counts = np.sum(array, axis=0)
#h_counts = np.sum(array, axis=1)
#array = array[np.argsort(-h_counts)][:, np.argsort(-v_counts)]

#indexes = list(range(h))

count = 0
def index_iter(size):
  indexes = list(range(size))
  for L in range(1, len(indexes)+1):
      for subset in itertools.combinations(indexes, L):
        yield list(subset)

for v_index in index_iter(first):
  for h_index in index_iter(second):
    #print(v_index, h_index)
    #print(array.shape)
    #print(np.sum(array[v_index][:, h_index]))

    if np.sum(array[v_index][:, h_index]) == k:
      count += 1

print(count)

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

int main()
{
    int A,B,sum=0;
    string s,s2;
    cin >> A >> B;
    for(int i=A; i<=B; i++){
        s = to_string(i);
        s2 = s;
        reverse( s.begin(), s.end() );
        if(s == s2){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

black_idx = []
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            black_idx.append([h,w])

distance = [[float("inf")]*W for _ in range(H)]
for b in black_idx:
    distance[b[0]][b[1]] = 0

d = deque(black_idx)
ans = 0

while d:
    y, x = d.popleft()
    for new_y, new_x in ([int(y)+1, int(x)], [int(y), int(x)+1], [int(y)-1, int(x)], [int(y), int(x)-1]):
        if 0 <= new_y <= H-1 and 0 <= new_x <= W-1 and distance[y][x] + 1 < distance[new_y][new_x]:
            distance[new_y][new_x] = distance[y][x] + 1
            ans = max(ans, distance[y][x] + 1)
            d.append([new_y, new_x])

print(ans)

Measured memory_bytes: 184192
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
vll di;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;

    rep(ni,N){
        cin >> ltmp;
        di.push_back(ltmp);
    }
    ll total = 0;
    for( ll ni = 0 ; ni <=N-2 ; ni++ ){
        for( ll mi = ni+1 ; mi <=N-1 ; mi++ ){
            total+=di[ni]*di[mi];
        }
    }
    cout << total << endl;
    

}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, s = 0;
    cin >> n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &v[i]);
    }
    for(int i = 0; i < n; i++){
        scanf("%d", &c[i]);
    }
    for(int i = 0; i < n; i++){
        if(v[i] - c[i] > 0) s += v[i] - c[i];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
ll r=1000000000+7;

ll fact(ll a){
    if(a==1)return 1;
    return a*fact(a-1) % r;
}

int main() {
    ll N, M;
    cin>>N>>M;
    if(llabs(N-M)>1){
        cout<<0<<endl;
        return 0;
    }
    ans=fact(N)*fact(M);
    if(N==M)ans*=2;
    cout<<ans%r<<endl;
    return 0;
}

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

#define min(a,b) ((a)<(b)?(a):(b))
#define INF 2000000000

int main(){
	int n,h[100001],i,j,k;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&h[i]);
	int dp[100001]={0};
	dp[1]=0;
//	dp[2]=abs(h[2]-h[1]);
//	dp[3]=abs(h[3]-h[1]);
	for(i=2;i<=n;i++){
//		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		if(i-1<k){
			int tmp,tmp2=INF;
			tmp=i-1;
			for(j=1;j<=tmp;j++){
				tmp2=min(tmp2,dp[i-j]+abs(h[i]-h[i-j]));
			}
			dp[i]=tmp2;
		}else {
			int tmp2=INF;
			for(j=1;j<=k;j++){
				tmp2=min(tmp2,dp[i-j]+abs(h[i]-h[i-j]));
			}
			dp[i]=tmp2;

		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

int main(){
  int num_students;
  scanf("%d", &num_students);
  
  int *order_students;
  order_students = (int *)malloc(num_students*sizeof(int));
  
  int i;
  int num_attendees;
  for(i = 1; i <= num_students; i++){
    scanf("%d", &num_attendees);
    order_students[num_attendees-1] = i;
  }
  
  i = 0;
  while(1){
    printf("%d", order_students[i]);
    i++;
    
    if(i == num_students){
      break;
    }
    
    printf(" ");
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll calc(Vll &a, ll &m)
{
  sort(ALL(a), greater<ll>());
  ll res = 0;
  ll len = a.size();
  REP(i, min(m, len)) res += a[i];
  return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  VVll cake(N, Vll(3));
  REP(i, N) cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
  ll ans = 0;
  bit_search(bit, 3)
  {
    Vll Sum(N, 0);
    REP(i, N)
    {
      Vll xyz = {cake[i][0], cake[i][1], cake[i][2]};
      REP(j, 3)
      {
        if (bit_check(bit, j)) Sum[i] += xyz[j];
        else Sum[i] -= xyz[j];
      }
    }
    ans = max(ans, calc(Sum, M));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int a, b, n, ma=-1, x1, x2, y1, y2, z, cns=100000, zer=0;

	cin>> a >> b >> n;

	x1 = max(zer, a - cns);
	x2 = min(a + cns, n);
	y1 = max(zer, b - cns);
	y2 = min(b + cns, n);
	z = max(zer, n - cns);

	if (n <= 1000000) {
		for (long long int i = 0;i <= n;i++) {
			//cout << i << " " << (a*i) / b - a * (i / b) << endl;
			ma = max(ma, (a*i) / b - a * (i / b));
		}
	}

	for (long long int i = x1;i <= x2;i++) {
		//cout << i << " " << (a*i) / b - a * (i / b) << endl;
		ma = max(ma, (a*i) / b - a * (i / b));
	}

	for (long long int i = y1;i <= y2;i++) {
		//cout << i << " " << (a*i) / b - a * (i / b) << endl;
		ma = max(ma, (a*i) / b - a * (i / b));
	}

	for (long long int i = z;i <= n;i++) {
		//cout << i << " " << (a*i) / b - a * (i / b) << endl;
		ma = max(ma, (a*i) / b - a * (i / b));
	}

	cout << ma << endl;

}


Measured memory_bytes: 3592
n = int(input())
edge = [list(map(int,input().split())) for _ in range(n-1)]
q, k = map(int,input().split())
querry = [list(map(int,input().split())) for _ in range(q)]
INF = float('inf')
from heapq import heappush,heappop
def dijkstra(n,edge,start):
    ed_list = [[] for _ in range(n)]
    for a,b,c in edge:
        ed_list[a-1].append([b-1,c])
        ed_list[b-1].append([a-1,c])
    cost = [INF]*n
    cost[start] = 0
    stack =[[0,start]]
    while stack:
        c, x = heappop(stack)
        for i,j in ed_list[x]:
            if cost[i] > c + j:
                cost[i] = c + j
                heappush(stack,[c + j, i])
    return cost
arr_cost = dijkstra(n,edge,k-1)
for i,j in querry:
    print(arr_cost[i-1] + arr_cost[j-1])

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m,k;
    cin >> n >> m >> k;
    
    bool flag = false;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(n * j + m * i - (i * j * 2) == k){
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using D = double;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main(int argc, char const *argv[]) {
  L n;
  VVL vv;
  VVL count(3, VL(100, 0));
  cin >> n;
  rep(j, 0, n - 1) {
    VL v;
    rep(i, 0, 2) {
      L num;
      cin >> num;
      v.pb(num);
      ++count[i][num];
    }
    vv.pb(v);
  }
  rep(j, 0, n - 1) {
    L score = 0;
    rep(i, 0, 2) {
      assert(count[i][vv[j][i]] >= 1);
      if (count[i][vv[j][i]] == 1) {
        score += vv[j][i];
      }
    }
    cout << score << endl;
  }

  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <string>

using namespace std;


int main(){
    long long int w, h, x, y;
    cin >> w;
    cin >> h;
    cin >> x;
    cin >> y;

    printf("%.6Lf ", (long double)(w*h*1.0/2));
    if(x*2==w && y*2==h){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
k = int(input())
data = input().split()
a = int(data[0])
b = int(data[1])
 
ans = False
 
if abs(a - b) > k:
  ans = True
else:
  for i in range(a, b + 1):
    if i % k == 0:
      ans = True
      break
print("OK" if ans else "NG")


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

int main() {
  long long n;
   cin>>n;
  vector<long long>a(n);
 
  for(long long i=0;i<n;i++){
    cin>>a.at(i);
  }
  long long test=0;
  for(long long i=0;i<n;i++){
    if(a.at(i)==test+1){
      test++;
    }
  }
  if(test==0){
    cout<<"-1"<< endl;
    return 0;
  }
  cout<<n-test<< endl;
}

Measured memory_bytes: 1920
from math import *
from collections import *
import sys
sys.setrecursionlimit(10**9)
n = int(input())
a = list(map(int,input().split()))
pre = [0 for i in range(n)]
pre[0] = a[0]
for i in range(1,n):
	pre[i] = pre[i-1] + a[i]
minn = abs(pre[-1]-2*pre[0])
for i in range(1,n):
	minn = min(minn,abs(pre[-1]-2*pre[i]))
print(minn)

Measured memory_bytes: 99532
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(s: str):
    print(s[0]+str(len(s)-2)+s[-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int N, stock=1;
    bool flag = true;
    cin >> N;

    int H[N];

    for (int i=0; i < N; i++) {
        cin >> H[i];
    }
    if (N == 1) {
        cout << "Yes" << endl;
        return 0;        
    }

    H[0]--;
    rep(i, N-1) {
        if (H[i] < H[i+1]) {
            H[i+1]--;
        } else if (H[i] > H[i+1]) {
            flag = false;
        }
    }

    cout << ((flag) ? "Yes" : "No") << endl;

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 3e3+23;

int a[N][N];
long long dp[N][N][4];

int r, c, k;

long long rek(int x, int y, int z) {
  if (x >= r || y >= c) return 0;
  long long &ret = dp[x][y][z];
  if (ret != -1) return ret;
  if (z) {
    ret = max({rek(x, y+1, z),
	       rek(x, y+1, z-!!a[x][y])+a[x][y],
	       rek(x+1, y, 3)+a[x][y]});
  }
  ret = max(ret, rek(x+1, y, 3));
  return ret;
}

void solve() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d%d", &r, &c, &k);
  for (int r, c, v, i = 0; i < k; ++i) {
    scanf("%d%d%d", &r, &c, &v);
    a[--r][--c] = v;
  }
  printf("%lld", rek(0, 0, 3));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main(){	
    int n;
    int i, j, k;
    int build[4][3][10] = { {{}} };

    cin >> n;

    int b, f, r, v;

    for (i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        build[b - 1][f - 1][r - 1] += v;
    }

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


Measured memory_bytes: 3088
using System;

class Program
{
	static void Main()
	{
		var input = int.Parse(Console.ReadLine());
		int t;
		int h, m, s;

		h = input / 3600;
		t = input % 3600;

		m = t / 60;
		t = t % 60;

		s = t;

		string result = string.Format("{0}:{1}:{2}", h, m, s);
		Console.WriteLine(result);
	}
}

Measured memory_bytes: 9212
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	String op = sc.next();
        int b = sc.nextInt();
      	
      	if(op.charAt(0) == '+'){
        	System.out.println(a+b);
        }else{
        	System.out.println(a-b);
        }
    }
}

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

using namespace std;

int
main(void){
	int x, y; cin >> x >> y;
	for(int i = 0; i <= x; i++){
		int num = i * 2 + (x - i)*4;
		if(num == y){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

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

int main() {
	int a, b;
	while (cin >> a >> b, a, b) {
		int m[100] = {};

		for (int i = 0;i < a;i++) {
			int c;
			cin >> c;
			for (int j = 0;j < c;j++) {
				int d;
				cin >> d;
				m[d]++;
			}
		}
		int ans = -1;
		int num;
		for (int i = 0;i < 100;i++) {
			if (m[i] > ans) {
				ans = m[i];
				num = i;
			}
		}
		if (ans < b)cout << 0 << endl;
		else cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
import collections
def main():
    N,X,Y = map(int, input().split())
    # 扱いやすいようにX,Yはインデックス表記にしておく
    X -= 1
    Y -= 1
    # i<jを満たす(i,j)について6通りの場合分けして全最短距離を求められる
    shortest = [[-1]*N for _ in range(N)]
    coll = collections.Counter()
    for i in range(N):
        k1 = abs(X-i)
        for j in range(i+1,N):
            k2 = abs(j-Y)
            shortest[i][j] = min(j-i, k1+1+k2)
        coll += collections.Counter(shortest[i])

    for i in range(1,N):
        print(coll.get(i,0))
        
main()


Measured memory_bytes: 83692
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
using namespace std;
int n,i,a[200005],b[100005][2];
long long ans,tmp,sx,sy,sum;
set<int> s;
/*bool cmp(_ x,_ y){
	return x.x>y.x;
}*/
int main(){
	cin>>n;
	rep(i,n){
		cin>>b[i][0]>>b[i][1];
		sx+=b[i][0];sy+=b[i][1];
		a[i*2]=b[i][0];
		a[i*2-1]=b[i][1];
	}
	sum=sx+sy;
	ans=max(sx,sy);
	sort(a+1,a+n+n+1,greater<int>());
	rep(i,n) tmp+=a[i];
	rep(i,n){
		if(max(b[i][0],b[i][1])<a[n]){
			ans=max(ans,tmp);
			break;
		}
		if(min(b[i][0],b[i][1])>a[n]){
			ans=max(ans,tmp);
			break;
		}
		long long tmp2=tmp;
		tmp2-=a[n]-min(b[i][0],b[i][1]);
		tmp2-=max(0,a[n-1]-max(b[i][0],b[i][1]));
		ans=max(ans,tmp2);
	}
	cout<<sum-ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

using namespace std;
using ll = long long;
using ii = pair<int, int>;

int pd[3010][3010];
ii nxt[3010][3010];
string s, t;
int n, m;

string ans;
void trace(int i, int j)
{
	if (i >= n or j >= m)
		return;
	
	if (nxt[i][j] == mp(i+1, j+1))
	{
		ans.pb(s[i]);
		trace(i+1, j+1);
		return;
	}

	trace(nxt[i][j].fi, nxt[i][j].se);
}

int main()
{
	cin >> s >> t;

	n = (int)s.size();
	m = (int)t.size();
	for (int i = n-1; i >= 0; i--)
	{
		for (int j = m-1; j >= 0; j--)
		{
			pd[i][j] = max(pd[i+1][j], pd[i][j+1]);
			if (s[i] == t[j])
				pd[i][j] = max(pd[i][j], 1 + pd[i+1][j+1]);

			if (pd[i][j] == pd[i+1][j])
				nxt[i][j] = {i+1, j};
			else if (pd[i][j] == pd[i][j+1])
				nxt[i][j] = {i, j+1};
			else
				nxt[i][j] = {i+1, j+1};
		}
	}
	trace(0, 0);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 106368
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef vector<int> Node;
typedef vector<Node> Graph;
typedef pair<int, int> P;

void bfs(int s, int MAX, const Graph& G, vector<int>& res){
    vector<int> dist(G.size(), -1);
    queue<int> que;
    que.push(s);
    dist[s] = 0;
    while(!que.empty()){
        int u = que.front(); que.pop();
        if(dist[u] + 1 > MAX) break;
        for(int v : G[u]){
            if(dist[v] == -1){
                dist[v] = dist[u] + 1;
                que.push(v);
                res.push_back(v);
            }
        }
    }
}

int main(){
    int N, K;
    while(cin >> N >> K){
        vector<int> C(N), R(N);
        REP(i, N) cin >> C[i] >> R[i];
        Graph G(N);
        REP(i, K){
            int a, b;
            cin >> a >> b;
            G[a - 1].push_back(b - 1);
            G[b - 1].push_back(a - 1);
        }
        vector<int> dist(N, INT_MAX);
        priority_queue<P, vector<P>, greater<P>> que;
        que.push(P(C[0], 0));
        dist[0] = 0;
        while(!que.empty()){
            int u = que.top().second;
            int c = que.top().first;
            que.pop();
            if(u == N - 1) break;
            if(dist[u] < c - C[u]) continue;

            vector<int> next;
            bfs(u, R[u], G, next);
            for(int v : next){
                if(dist[v] > c){
                    dist[v] = c;
                    que.push(P(c + C[v], v));
                }
            }
        }
        cout << dist[N - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1724
n, m = map(int, input().split())
image = []
template = ''
for i in range(n):
    image.append(input().rstrip())
for i in range(m):
    template += input().rstrip()

for x in range(n - m + 1):
    for y in range(n - m + 1):
        target = ''
        for i in range(m):
            target += ''.join(image[y+i][x:x + m])
        if target == template:
            print('Yes')
            exit()
print('No')



Measured memory_bytes: 3064
import java.util.Scanner;

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

        char[] split = s.toCharArray();

        if (split[0] != split[1] && split[1] != split[2] && split[2] != split[0]) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
import java.util.*;

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

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long x = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        int[][] min = new int[n][n];
        for (int i = 0; i < n; i++) {
            min[i][0] = a[i];
            for (int j = 1; j < n; j++) {
                min[i][j] = Math.min(min[i][j - 1], a[(i + n - j) % n]);
            }
        }
        long ans = Long.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            long time = i * x;
            for (int j = 0; j < n; j++) {
                time += min[j][i];
            }
            ans = Math.min(ans, time);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 55524
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let mut xys: Vec<Vec<(usize, usize)>> = Vec::new();

    for i in 0..n {
        let a = get!(usize);
        let xy = get!(usize, usize; a);

        xys.push(xy);
    }

    let mut ans = 0;

    for bit in 0..1<<n {
        let mut fl: bool = true;

        for i in 0..n {
            if bit>>i&1 != 0 {
                for xy in xys[i].iter() {
                    if xy.1 == 1 && (bit>>(xy.0-1)&1) == 0 {
                        fl = false;
                    }
                    if xy.1 == 0 && (bit>>(xy.0-1)&1) == 1 {
                        fl = false;
                    }
                }
            }
        }

        if !fl {
            continue;
        }

        let pop_count = (bit as u64).count_ones();

        if ans < pop_count {
            ans = pop_count;
        }
    }

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


Measured memory_bytes: 2172
#include<stdio.h>

int irekae(int);

int main(void){
	int a,b,c;
	int n;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		n=a;
		a=b;
		b=n;
	}
	if(b>c){
		n=c;
		c=b;
		b=n;
	}
	if(a>c){
		n=a;
		a=c;
		c=n;
	}
	if(a>b){
		n=a;
		a=b;
		b=n;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}




Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
const ll mod=1000000000+7;
ll i,j;
ll kong=0;
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    ll n;
    cin>>n;
    ll a[n+1];
    ll sum=0;
    rep(i,n){
    	cin>>a[i];
    	sum=(sum+a[i])%mod;
	}
	ll ans=0;
    for(i=0;i<n;i++){
    	sum-=a[i];
    	if(sum<0) sum+=mod;
		ll x=a[i]*sum;
		x%=mod;
		ans+=x;
		ans%=mod;
	}
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5212
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = firstLine[0];
            var B = firstLine[1];
            if ((A * B) % 2 == 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ios()                \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)


bool canBeMonth(char c1,char c2){
	int num = (c1 - '0') * 10 + (c2 - '0') ;
	return num >= 1 && num <= 12;
}

signed main()
{
	ios();
	string S;
	cin >> S;
	bool first2isM = canBeMonth(S[0],S[1]);
	bool second2isM = canBeMonth(S[2],S[3]);
	if(first2isM && second2isM) {
		cout << "AMBIGUOUS" << endl;
	} else if(!first2isM && second2isM ){
		cout << "YYMM" << endl;
	} else if(first2isM && !second2isM ){
		cout << "MMYY" << endl;
	} else if(!first2isM && !second2isM) {
		cout << "NA" << endl;
	}
}


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

using namespace std;
int main()
{
    int x , y , z , a;
    cin >> x >> y >> z;
    if ( y >= z ){
        cout << y+z;
    }
    else if( y == z-1 ){
        cout << y+z;
    }
    else if ( x+y == z-1 || x+y == z ){
        cout << y+z;
    }
    else if( x+y < z-1 ){
        cout <<x + 2*y + 1;
    }
    else if( x + y >= z ){
        cout << y + z;
    }
}

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

int main() {
    ll N,AC,WA,TLE,RE;
    cin>>N;
    AC=0;
    WA=0;
    TLE=0;
    RE=0;
    for(int i=0;i<N;i++){
      string str;
      cin>>str;
      if(str=="AC")AC++;
      else if(str=="WA")WA++;
      else if(str=="TLE")TLE++;
      else if(str=="RE")RE++;
      
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
    return 0;
}

Measured memory_bytes: 3632
a,b = list(map(int,input().split()))

if a<=0 and 0 <= b:
    print('Zero')
elif a >0 and b > 0:
    print('Positive')
else:
    n = abs(a-b)
    if n%2 == 0:
        print('Negative')
    else:
        print('Positive')

Measured memory_bytes: 3060
cnt = 1
while(cnt <= 50):
    d_set = input()
    d_set = d_set.split()
    m,f,r = d_set
    m,f,r = int(m),int(f),int(r)

    if m == -1 and f == -1 and r == -1:
        break

    if (m == -1 or f == -1) or (m+f < 30):
        print('F')
    elif (m+f >= 80):
        print('A')
    elif (m+f >= 65):
        print('B')
    elif (m+f >= 50):
        print('C')
    elif (m+f >= 30):
        if (r >= 50):
            print('C')
        else:
            print('D')

    
    cnt += 1



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

string s;

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

Measured memory_bytes: 768
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int m=scanner.nextInt();
        int[] ps=new int[m],ch=new int[m];
        HashMap<Integer,Integer> hashMap=new HashMap<>();
        int ffs=0;
        for(int i=0;i<m;i++){
            ps[i]=scanner.nextInt();
            ch[i]=scanner.nextInt();
            if(hashMap.get(ps[i])!=null && hashMap.get(ps[i])!=ch[i]){
                ffs=1;
            }
            hashMap.put(ps[i],ch[i]);

        }
        if(m==0){
            StringBuilder  stringBuilder=new StringBuilder();
//        for(int j=0;j<n;j++){
//                if(j==0){
//                    stringBuilder.append(1);
//                }
//                else{
//                    stringBuilder.append(0);
//                }
//            }
//            stringBuilder.append(-1);
            if(n==1){
                System.out.println(0);
            }
            else{
                for(int j=0;j<n;j++){
                if(j==0){
                    stringBuilder.append(1);
                }
                else{
                    stringBuilder.append(0);
                }
            }
                System.out.println(stringBuilder.toString());
               // System.out.println(-1);
            }
//            System.out.println(-1);

        }
        else if(ffs==1){
            System.out.println(-1);
        }
        else{
            if(n>1 && hashMap.get(1)!=null &&  hashMap.get(1)==0){
                System.out.println(-1);
            }
            else{
                int[] str=new int[n];
                for(int j=0;j<n;j++){
                    for(int i=0;i<m;i++){
                        if(ps[i]-1==j){
                            str[j]=ch[i];
                           // System.out.println(j+ " "+ch[i]);
                            break;
                        }
                    }
                }
                StringBuilder stringBuilder=new StringBuilder();
                for(int j=0;j<n;j++){
                    if(j==0 && str[j]==0 && n>1){
//                      ffs=1;
                        stringBuilder.append(1);
                        continue;
                    }
                    stringBuilder.append(str[j]);
                }
//                if(ffs==1){
//                    System.out.println(-1);
//                }
//                else
                    {
                    System.out.println(stringBuilder.toString());
                }}
        }
    }
}


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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    vector<unsigned long> t(D);
    for(auto&& i : t){
        cin >> i;
        --i;
    }

    long satisfy{0};
    vector last(C, vector<unsigned long>{0});
    for(unsigned long i{0}; i < D; ++i){
        satisfy += v[i][t[i]];
        last[t[i]].push_back(i + 1);
        for(unsigned long j{0}; j < C; ++j)satisfy -= c[j] * static_cast<long>(i + 1 - last[j].back());
    }
    for(auto&& i : last)i.push_back(D + 1);

    unsigned long M;
    cin >> M;
    for(unsigned long i{0}, d, q; i < M; ++i){
        cin >> d >> q;
        --q;
        auto f = t[d - 1];
        satisfy -= c[f] * (*upper_bound(begin(last[f]), end(last[f]), d) - d) * (d - *prev(lower_bound(begin(last[f]), end(last[f]), d)));
        last[f].erase(lower_bound(begin(last[f]), end(last[f]), d));
        last[q].insert(upper_bound(begin(last[q]), end(last[q]), d), d);
        satisfy += c[q] * (*upper_bound(begin(last[q]), end(last[q]), d) - d) * (d - *prev(lower_bound(begin(last[q]), end(last[q]), d)));
        satisfy -= v[d - 1][f];
        satisfy += v[d - 1][q];
        t[d - 1] = q;
        cout << satisfy << endl;
    }

    return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

map<tuple<string, string, string>, ll> mp;

ll dfs(string c, string a, string b){

  if(mp.find(make_tuple(c, a, b)) != mp.end()){
    return mp[make_tuple(c, a, b)];
  }

  ll ret = 0;
  if(c.length()==1 && a.length()==1 && c[0]==a[0]){
    return 1;
  }
  if(c.length()==1 && b.length()==1 && c[0]==b[0]){
    return 1;
  }

  if(a.length()>0 && c[0] == a[0]){
    ret += dfs(c.substr(1, c.length()-1), a.substr(1, a.length()-1), b);
  }
  if(b.length()>0 && c[0] == b[0]){
    ret += dfs(c.substr(1, c.length()-1), a, b.substr(1, b.length()-1));
  }

  return mp[make_tuple(c, a, b)] = ret;

}

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

  int N;
  cin >> N;
  string s;
  cin >> s;
  string c = s.substr(N, s.length()-N);
  reverse(c.begin(), c.end());

  ll ans = 0;
  for(int bit = 0; bit < (1<<N); bit++){
    string a = "";
    string b = "";

    rep(i, N){
      if(bit & (1<<i)){
        a += s[i];
      }else{
        b += s[i];
      }
    }

    ans += dfs(c, a, b);

  }

  cout << ans << endl;

  return 0;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pr(ll x){//因数の個数を返す
  vector<ll> v;
  ll y = x;
  for(ll i = 2LL;i*i<=x;i++) {
    if(y%i==0LL){
      ll z = 0LL;
      while(y%i==0LL){
        y/=i;
        z++;
      }
      v.push_back(z);
    }
  }
  if(y!=1LL) v.push_back(1LL);
  ll cnt = 1LL;
  for(auto t:v){
    cnt*=(t+1);
  }
  return cnt;
}

int main() {
  ll N;
  cin>>N;
  ll ans = 0LL;
  for(ll i = 1LL; i <= N; i=i+2LL){
    if(pr(i)==8)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#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++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
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 ll inf = 1e18;
const ll mod = 1e9+7;
const int MAX = 1e7;

// nCr
vll fac(MAX), finv(MAX), inv(MAX);
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= MAX; i++) {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

ll com(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main() {
    int x, y;
    cin >> x >> y;
    if ((2*x-y) % 3 != 0 || (2*y-x) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int a = (2*x-y)/3;
    int b = (2*y-x)/3;
    COMinit();
    cout << com(a+b,a) << endl;
}

Measured memory_bytes: 234752
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  ll l,r;
  cin>>l>>r;

  int  ans=2019;
  if((int)(l/2019) != (int)(r/2019)) ans=0;
  else{
    l=l%2019,r=r%2019;
    for(int i=l;i<r;i++)
    for(int j=i+1;j<=r;j++) ans=min(ans,(i*j)%2019);

  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
s=k=0
T=[]
for i=1:N
	s+=i%2==0?2A[i]:-2A[i]
	push!(T,s)
end
for t=T
	println(abs(s>>1-k))
	k=t
end


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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin>>x;
    pair<int,int> ans;
    for(int i=0;i<=1000;i++)
    {
        for(int j=0;j<=1000;j++)
        {
            if(pow(i,5)-pow(j,5)==x)
            {
                
                ans = make_pair(i,j);
                break;
            }
            if(pow(i,5)-pow(-j,5)==x)
            {
                ans = make_pair(i,-j);
                break;
            }

            if(pow(-i,5)-pow(j,5)==x)
            {
                ans = make_pair(-i,j);
                break;
            }
            if(pow(-i,5)-pow(-j,5)==x)
            {
                ans = make_pair(-i,-j);
                break;
            }
        }
    }
    cout<<ans.first<<" "<<ans.second;
    return 0;
}

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

int main(){
  int N, A, O, E, Q;
  cin >> N;
  vector<int> C(4);
  
  for (int i = 0; i < N; i++){
    cin >> A;
    C.at(A%4)++;
  }
  if (C.at(1)+C.at(3) <= C.at(0) || (C.at(1) + C.at(3) == C.at(0) + 1 && C.at(2) == 0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++) {
        cin >> v[i];
    }
    sort(v.begin() , v.end());
    int r = v[n-1];
    int cnt=0;
    for(int i=1;i<=r;i++){
    int x = lower_bound(v.begin(),v.end(),i)-v.begin();
     int rs = n-x;
     int ls = n-rs;
     if(rs == ls){
         cnt++;
     }
    }
     cout << cnt << '\n';
    
}

Measured memory_bytes: 640
# 入力値の取得
s = gets.chomp

# 計算
loop do
  if s.index("dreameraser") == 0
    s.sub!("dreameraser", "")
  elsif s.index("dreamerase") == 0
    s.sub!("dreamerase", "")
  elsif s.index("dreamer") == 0
    s.sub!("dreamer", "")
  elsif s.index("dream") == 0
    s.sub!("dream", "")
  elsif s.index("eraser") == 0
    s.sub!("eraser", "")
  elsif s.index("erase") == 0
    s.sub!("erase", "")
  else
    puts s.empty? ? "YES" : "NO"
    break    
  end
end


Measured memory_bytes: 67184
N = int(input())
a = N%26
next = int(N/26)
b = N%26
next = int(N/26)
a=[]
answer=[]
for i in range(20):
  if (N > 26) and (N%26)!=0:
    a.append(N%26)
    N = int(N/26)
  elif (N > 26) and (N%26)==0:
    a.append(26)
    N = int((N-1)/26)
  else:
    a.append(N)
    break
for i in range(len(a)):
  answer.append(chr(ord('a')+a[i]-1))
mojiretu = ' '
for x in reversed(answer):
    mojiretu += x
print(mojiretu)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        cout<<3;
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
        cout<<2;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
        cout<<1;
    else
        cout<<0;
    return 0;
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int,input().split()))
b = list(set(a))
import collections
c = collections.Counter(a)
g = []
for i in range(len(b)):
    if c[b[i]] >= 4:
        g.append(b[i])
        g.append(b[i])
    
    elif c[b[i]] >= 2:
        g.append(b[i])
if len(g) <= 1:
    print(0)
else:
    g = sorted(g,reverse = True)
    print(g[0]*g[1])

Measured memory_bytes: 20492
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] L = new int[N];
        int max = 0;
        int sum = 0;
        for(int i=0; i<N; i++) {
            L[i] = Integer.parseInt(sc.next());
            if(max < L[i]) {
                max = L[i];
            }
            sum += L[i];
        }
        if(sum - max > max) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
    }
}

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

int main() {
    int ans=0;
    string S;
    char A = 'A',C='C',G='G',T='T';
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == A || S[i] == C || S[i] == G || S[i] == T) {
            int alt_ans = 1;
            for (int j = i+1; j < S.size(); j++) {
                if (S[j] == A || S[j] == C || S[j] == G || S[j] == T) {
                    alt_ans++;
                }
                else {
                    break;
                }
            }
            ans = max(ans, alt_ans);
        }
    }
    cout << ans << endl;
}

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

int main() {
  char s;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    cin >> s;
    if (s == '1') {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
     
      int n = sc.nextInt();
      int count = 0;
      
      for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
          if(i*j == n){
            count = 200;
          }else{
            count++;
          }
        }
      }
      
      if(count >= 200){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      
      sc.close();
    }
}

Measured memory_bytes: 23764