akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

output:
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
"""

import sys


class Node(object):
    def __init__(self):
        # init node as a single leaf node.
        self.parent = -1
        self.children = []
        self.index = -1


def pre_parse(v):
    print(' ' + str(v.index), end='')
    if not v.children:
        return None
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        pre_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        pre_parse(node_list[right_child_idx])

    return None


def in_parse(v):
    if not v.children:
        return None
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        in_parse(node_list[left_child_idx])

    print(' ' + str(v.index), end='')

    if right_child_idx != -1:
        in_parse(node_list[right_child_idx])

    return None


def post_parse(v):
    if not v.children:
        return None
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        post_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        post_parse(node_list[right_child_idx])

    print(' ' + str(v.index), end='')

    return None


def generate_tree(_array):
    # add info of each node of a ordered tree
    for each in _array:
        idx, *children = [int(x) for x in each]
        assert len(children) == 2 and idx >= 0
        node_list[idx].index = idx
        node_list[idx].children = children

        for child_idx in children:
            # non-existent node: no parent
            if child_idx == -1:
                continue
            node_list[child_idx].parent = idx

    # find root node
    root_idx = [i for i, x in enumerate(node_list) if x.parent == -1][0]

    # tree walk in 3 ways
    print('Preorder')
    pre_parse(node_list[root_idx])
    print('\n' + 'Inorder')
    in_parse(node_list[root_idx])
    print('\n' + 'Postorder')
    post_parse(node_list[root_idx])
    print('')

    return node_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.split(), _input[1:]))
    assert len(array) == array_length

    node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array)

Measured memory_bytes: 7884
#include <stdio.h>
#define P 1000000007

main(){
	int a[202]={};
	int b[202]={};
	int nn;
	scanf("%d ",&nn);
	int n=0;
	int c[202];
	for(int i=0;i<nn;i++){
		char buf[10];
		scanf("%s",buf);
		if(buf[0]!='-')c[n++]=buf[0];
	}
	int k=0,l=0;
	for(int i=0;i<n;i++){
		if(c[i]=='U'){
			for(int j=i+1;j<n;j++)a[j]++;
			k++;
		}else{
			for(int j=0;j<i;j++)b[j]++;
			l++;
		}
	}
	long long dp[202][202];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int p=0;p<=i;p++){
			dp[i][p]=(p>0?dp[i-1][p-1]*(a[i-1]-p+1):0)+(p<i?dp[i-1][p]*(b[i-1]-l+(i-p)):0);
			dp[i][p]%=P;
		}
	}
	printf("%lld\n",dp[n][k]);
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    ll ans=1000*(x/500);
    x=x%500;
    ans=ans+(5*(x/5));
    cout<<ans;
}

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

#define d(x) cerr<<#x<<":"<<x<<endl;

int main(void){
    int N,temp,max=-10000000,min=10000000,maxitr,minitr;
    cin>>N;
    int a[N];
    rep(i,N){cin>>temp;a[i]=temp;}
    rep(i,N){
        if(a[i+1]<a[i])break;
        if(i==N-1){
            cout<<0<<endl; 
            return 0;
        }
    }
    rep(i,N){
        if(a[i]>0)break;
        if(i==N-1){
            //すべて負
            cout<<N-1<<endl;
            rep(j,N-1){
                a[N-2-j]-=a[N-1-j];
                cout<<N-1-j+1<<" "<<N-2-j+1<<endl;
            }
            return 0;
        }
    }
    rep(i,N){
        if(a[i]<0)break;
        if(i==N-1){
            //すべて正
            cout<<N-1<<endl;
            rep(j,N-1){
                a[j+1]+=a[j];
                cout<<j+1<<" "<<j+1+1<<endl;
            }
            return 0;
        }
    }
    //正の要素も負の要素もある
    rep(i,N){
        if(min>a[i]){min=a[i];minitr=i;}
        if(max<a[i]){max=a[i];maxitr=i;}
    }
    if(-1*min<max){
        //maxをすべての要素に加算
        cout<<2*N-1<<endl;
        rep(j,N){
            a[j]+=max;
            cout<<maxitr+1<<" "<<j+1<<endl;
        }
        rep(j,N-1){
            a[j+1]+=a[j];
            cout<<j+1<<" "<<j+1+1<<endl;
        }
        return 0;
    }
    else{
        cout<<2*N-1<<endl;
        rep(j,N){
            a[j]+=min;
            cout<<minitr+1<<" "<<j+1<<endl;
        }
        rep(j,N-1){
            a[j+1]+=a[j];
            cout<<N-1-j+1<<" "<<N-2-j+1<<endl;
        }
        return 0;    
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long res, ara[10];
    for(int i=0; i<7; i++)scanf("%lld", &ara[i]);
    if((ara[0]&1ll) && (ara[3]&1ll) && (ara[4]&1ll))
    res= ara[0]+ara[3]+ara[4];
    else if(ara[0] && (ara[3]&1ll) && (ara[4]&1ll))
    res= ara[0]+ara[3]+ara[4]-1;
    else if(ara[3] && (ara[0]&1ll) && (ara[4]&1ll))
    res= ara[0]+ara[3]+ara[4]-1;
    else if(ara[4] && (ara[3]&1ll) && (ara[0]&1ll))
    res= ara[0]+ara[3]+ara[4]-1;
    else res= (ara[0]/2ll)*2ll + (ara[3]/2ll)*2ll + (ara[4]/2ll)*2ll;
    printf("%lld\n", res+ara[1]);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
    using namespace std;
     
    int main(){
    	int n,a,b,c,d;
    	scanf("%d",&n);
        a=n/1000;
        b=n/100-a*10;
        c=n/10-a*100-b*10;
        d=n-a*1000-b*100-c*10;
        if((a==b&&b==c)||(b==c&&c==d))
        	printf("Yes\n");
        else printf("No\n");
        return 0;
    }

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll N;
vector<ll> x;

void func(ll n, ll d, ll e) {
	if (n == N) {
		x.push_back(d);
	}
	else {
		rep(i, N) {
			if (((e >> i) & 1)== 0) {
				func(n + 1, d + (i + 1) * (ll)pow(10, N - n - 1), e | (1 << i));
			}
		}
	}
}

void solve_abc150_c() {
	ll a, b, ans;
	cin >> N;

	vector<ll> P(N), Q(N);
	ll p = 0;
	ll q = 0;
	rep(i, N) {
		cin >> P[i];
		p += P[i] * pow(10, N - i - 1);
	}
	rep(i, N) {
		cin >> Q[i];
		q += Q[i] * pow(10, N - i - 1);
	}

	func(0, 0, 0);

	sort(ALL(x));

	a = b = 0;
	rep(i, x.size()) {
		if (p == x[i]) {
			a = i + 1;
		}
		if (q == x[i]) {
			b = i + 1;
		}
	}

	ans = abs(a - b);

	cout << ans << "\n";
}

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

	solve_abc150_c();

	return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>

int main(void)
{
	int i,j,tmp,num[3];
	for(i=0;i<3;i++)
		scanf("%d",&num[i]);
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(num[i]>num[j]){
				tmp=num[i];
				num[i]=num[j];
				num[j]=tmp;
			}
		}
	}
	printf("%d %d %d\n",num[0],num[1],num[2]);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> count(100);
  for(int i = 0;i < 100;i++)count[i] = 0;
  for(int i = 2;i <= n;i++){
    int now = i;
    for(int j = 2;j <= n;j++){
      while(now % j == 0){
        count[j]++;
        now /= j;
      }
    }
  }
  //for(int i = 0;i < 11;i++)cout << i << " " << count[i] << endl;
  int res = 0;
  for(int i = 0;i < 99;i++){
    if(count[i] < 4)continue;
    for(int j = i + 1;j < 100;j++){
      if(count[j] < 4 || i == j)continue;
      for(int k = 0;k < 100;k++){
        if(i != k && j != k && count[k] >= 2)res++;
      }
    }
  }
  for(int i = 0;i < 100;i++){
    if(count[i] < 24)continue;
    for(int j = 0;j < 100;j++){
      if(i != j && count[j] >= 2)res++;
    }
    //cout  << "!" << i << endl;
  }
  for(int i = 0;i < 100;i++){
    if(count[i] < 14)continue;
    for(int j = 0;j < 100;j++){
      if(i != j && count[j] >= 4)res++;
    }
  }
  for(int i = 0;i < 100;i++){
    if(count[i] >= 74)res++;
  }
  cout << res << endl;;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main() {
    string S;
    cin >> S;
    long long ans = 0;
    for(int mask = 0; mask < (1 << (S.size() - 1)); mask++) {
        long long result = 0;
        long long add = S[0] - '0';
        for(int i = 0; i < S.size() - 1; i++) {
            if(mask & (1 << i)) {
                result += add;
                add = 0;
            }
            add = add * 10 + S[i + 1] - '0';
        }
        result += add;
        ans += result;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */
 
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007
 
const long double PI = 3.141592653589793236L;
 
typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n, x, t;
    cin >> n >> x >> t;

    int ans = n / x;
    if(n % x) 
    {
        ans++;
    }

    ans *= t;

    cout << ans << "\n";

}

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	double n; 
	scanf("%lf",&n);
    printf("%.0lf\n",pow(floor(sqrt(n)),2.0));
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    string s;

    int Solve(char c)
    {
        var t = s.ToArray();

        for (var round = 1; ; round++)
        {
            var isUnique = true;

            var u = new char[t.Length - 1];
            for (var i = 0; i + 1 < t.Length; i++)
            {
                if (t[i] == c || t[i + 1] == c)
                {
                    u[i] = c;
                }
                else
                {
                    u[i] = t[i];
                    isUnique = false;
                }
            }

            if (isUnique) return round;

            t = u;
        }
    }

    int Solve()
    {
        if (s.All(c => c == s[0])) return 0;
        return s.Distinct().Select(Solve).Min();
    }

    public void Run()
    {
        s = input.ReadLine();
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 13408
from sys import stdin
input = stdin.readline
import copy as cp
from collections import deque

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

W, H, N = map(int, input().rstrip().split())

grid = VVI(H, W)
for _ in range(N):
  x, y, a = map(int, input().rstrip().split())
  if a == 1:
    for xx in range(x):
      for yy in range(H):
        grid[yy][xx] = 1
  elif a == 2:
    for xx in range(x, W):
      for yy in range(H):
        grid[yy][xx] = 1
  elif a == 3:
    for xx in range(W):
      for yy in range(y):
        grid[yy][xx] = 1
  elif a == 4:
    for xx in range(W):
      for yy in range(y, H):
        grid[yy][xx] = 1

ans = 0
for xx in range(W):
  for yy in range(H):
    ans += grid[yy][xx]

ans = H*W-ans

print(ans)


Measured memory_bytes: 41584
N = int(input())
A = [int(input()) for i in range(N)]
 
A.sort()
As_ = A[:N//2]
Ab_ = A[N//2:]
A.reverse()
Ab = A[:N//2]
As = A[N//2:]
if N%2 == 0:
    if N == 2:
        ans = abs(A[0] - A[1])
    else:
        ans = sum(Ab[:-1])*2 + Ab[-1] - As[0] - sum(As[1:])*2
else:
    if N == 3:
        ans = max([A[0]*2-A[1]-A[2], A[0]+A[1]-A[2]*2])
    else:
        ans1 = sum(Ab)*2 - sum(As[2:])*2 - As[0] - As[1]
        ans2 = sum(Ab_[2:])*2 + Ab_[0] + Ab_[1] - sum(As_)*2
        ans = max([ans1, ans2])
print(ans)

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

int main(){
  long long n,m;
  scanf("%lld%lld",&n,&m);
  n-=2,m-=2;
  if(n<0)n=-n;
  if(m<0)m=-m;
  printf("%lld\n",n*m);
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

int N, M;
int a[MAX];
bool c[MAX];

void solve() {
	cin >> N >> M;
	rep(i, M) {
		cin >> a[i];
		c[a[i]] = true;
	}

	int b = 1;
	int cnt = 0;
	rep(loop, 20) {
		if (b >= N) break;
		for (int i = 0; i + b < N; i += 2*b) {
			if (c[i]) c[i] = c[i + b];
			else if (c[i + b]) c[i] = c[i];
			else cnt++;
		}
		b *= 2;
	}
	cout << cnt << endl;
}

signed main() {
	srand(time(NULL));
	int T = (int)1e15;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

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

using namespace std;

using LL = long long;
template<typename T> using V = vector<T>; 
template<typename T, typename S> using P = pair<T, S>; 
template<class T> using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
using LD = long double;

#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i, n) for(int i = 0; i < (int)n ;i++)
#define REPN(i, n) for(int i = 1; i <= (int)n ; i++)
#define her 	cerr << "here\n" 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())

template<typename T, typename S> void check(T & a, S & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }

int32_t main(){
	SYNC;
	int n, k; 
	cin >> n >> k;

	V<int> a(n); 
	REP(i, n) cin >> a[i];

	sort(ALL(a)); 

	int d = 0;

	REP(i, n){
		d = gcd(d, a[i]); 
	}

	if(k >= d && k <= a[n - 1] && k % d == 0){
		cout << "POSSIBLE\n"; 
		return 0; 
	}

	cout << "IMPOSSIBLE\n";
	
	cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
	return 0; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
using namespace std;
int main(){
	int n;
	cin>>n;
	int res=1;
	while(res<=n){
		res*=2;
	}
	res/=2;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
   //  String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu);

StringBuffer sb = new StringBuffer(nyu);
		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);


if(nyu.equals(dst)){
//double res=Math.ceil((AB)/2);

System.out.println("Yes");
//}else if((int)c[0]>(int)c[2]){
//System.out.println(">");

}else{
System.out.println("No");

}




	}
}

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

static const ll MOD = 1000000007;

ll dp[55][55][2505];

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

  dp[0][0][0] = 1;
  rep(i,N){
    rep(j,N){
      rep(k,2505){
        if(k+2*j<2505){
          dp[i+1][j][k+2*j] += dp[i][j][k];
          dp[i+1][j][k+2*j] %= MOD;
        }
        if(k+2*j<2505){
          dp[i+1][j][k+2*j] += (j * dp[i][j][k])%MOD;
          dp[i+1][j][k+2*j] %= MOD;
        }
        if(k+2*j<2505){
          dp[i+1][j][k+2*j] += (j * dp[i][j][k])%MOD;
          dp[i+1][j][k+2*j] %= MOD;
        }
        if(k+2*(j+1)<2505){
          dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k];
          dp[i+1][j+1][k+2*(j+1)] %= MOD;
        }
        if(j>0 && k+2*(j-1)<2505){
          dp[i+1][j-1][k+2*(j-1)] += (((j*j)%MOD) * dp[i][j][k])%MOD;
          dp[i+1][j-1][k+2*(j-1)] %= MOD;
        }        
      }
    }
  }

  cout << dp[N][0][K] << endl;
  
  return 0;
}



Measured memory_bytes: 54528
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>


int mpow(int a, int b){
	int res = 1;
	while(b > 0){
		if(b & 1) res = (res * a);
		b = b >> 1;
		a = (a * a);
	}
	return res;
}




int main()
{
	int sum1, sum2, num, i, tmp;
	scanf("%d", &num);
	sum1 = mpow(3, num);
	sum2 = 1;
	for(i = 0; i < num; i++){
		scanf("%d", &tmp);
		
		if((tmp & 1) == 0){
			sum2 *= 2;
		}
	}

	printf("%d\n", sum1 - sum2);

	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a[1005],b[1005],dp[100005];
    ll h,n;
    for(int i=0;i<100005;i++){
        dp[i]=123456789;
    }
    scanf("%lld %lld",&h,&n);
    for(int i=0;i<n;i++){
        scanf("%lld %lld",&a[i],&b[i]);
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=h;j++){
            if(j-a[i]<=0){
                dp[j]=min(dp[j],b[i]);
            }
            else{
                dp[j]=min(dp[j-a[i]]+b[i],dp[j]);
            }
        }
    }
    printf("%lld\n",dp[h]);

}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	long Q = sc.nextLong();
    	long H = sc.nextLong();
    	long S = sc.nextLong();
    	long D = sc.nextLong();
    	long N = sc.nextLong();
    	long Litre = Math.min(S, Math.min(4*Q, 2*H));
    	if (2*Litre < D) {
    		System.out.println(N*Litre);
    	} else {
    		System.out.println(N/2 * D + N%2 * Litre);
    	}
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << array[k-1] << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

N, M = map(int, input().split())

card = [0]*N
for _ in range(M):
    l, r = map(lambda x: int(x)-1, input().split())
    card[l] += 1
    if r < N-1:
        card[r+1] -= 1
card = accumulate(card)
# c = list(card)
ans = 0
for ci in card:
    if ci == M:
        ans += 1
print(ans)


Measured memory_bytes: 3956
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	cout << A[N / 2] - A[N / 2 - 1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int n;
  cin >> n;
  while (1) {
    string s = to_string(n);
    for (int i = 0; i < s.size() - 1; i++) {
      if (s.at(i) != s.at(i + 1)) break;
      if (i == s.size() - 2) {
        cout << s << endl;
        return 0;
      }
    }
    n++;
  }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<ll, int> P;

vector<int> g[100];
int v,e;
int visited[100];
bool flg=false;

void judge(int s) {
	visited[s]=1;
	REP(i,g[s].size()) {
		if(!visited[g[s][i]]) judge(g[s][i]);
		else if(visited[g[s][i]]==1) {
			flg=true;
			return;
		}
	}
	visited[s]=2;
	return;
}

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

	cin>>v>>e;
	REP(i,e) {
		int s,t; cin>>s>>t;
		g[s].push_back(t);
	}
	REP(i,v) {
		if(!visited[i]) judge(i);
	}
	cout<<flg<<endl;

	return 0;
}

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

const ll P = 1E9+7;

char t[2][60];

int main()
{
  int n;
  scanf("%d",&n);
  scanf("%s",t[0]);
  scanf("%s",t[1]);
  int prec=-1;
  int i=0;
  ll res=1;
  while(i<n)
    {
      if(t[0][i]==t[1][i])
	{
	  //vertical
	  if(prec==-1)res=3;
	  else if(prec==1)res=(res*2)%P;
	  prec=1;
	  i++;
	}
      else
	{
	  //horizontal
	  if(prec==-1)res=6;
	  else if(prec==1)res=(res*2)%P;
	  else if(prec==2)res=(res*3)%P;
	  prec=2;
	  i+=2;
	}
    }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << min(A, B) + min(C, D) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int H = sc.nextInt();
    int W = sc.nextInt();
    int ans = 0;
    for (int i = 0; i < N; i++){
      int A = sc.nextInt();
      int B = sc.nextInt();
      if (A >= H && B >= W) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25316
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<(h2-h1)*60+m2-m1-k<<endl;  
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;

void solve()
{
	int n,i,x=0,a;
	cin >> n ;
	for(i=0;i<n;i++){
	    cin >> a;
	    if(i%2==0 && a%2==1)x++;
	}
	cout << x<< endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	rep(i, n)cin >> a[i];
	int cnt = 0;
	rep(i, n - 2) {
		if (a[i] < a[i + 1] && a[i + 1] < a[i + 2]) {
			cnt++;
		}
		else if (a[i] > a[i + 1] && a[i + 1] > a[i + 2]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

int main()
{
	long long int n,x,y;
	
	cin>>n>>x>>y;
	
	vector<long long int  >v(n);
	
	for(long long int i=1;i<=n;i++)
	{
		for(long long int j=i+1;j<=n;j++)
		{
			if(i<x && j<=x)
			{
				v[j-i]++;
			//	cout<<"1"<<j<<" "<<i<<endl;
			}
			else if(i<x && j<=y)
			{
				if((j-i) <= (y-j+x-i+1) )
				{
			//		cout<<"2"<<j<<" "<<i<<endl;
					v[j-i]++;
				}
				else{
			//		cout<<"3"<<j<<" "<<i<<endl;
					v[(y-j+x-i+1)]++;
				}
			}
			else if(i<y && j<=y)
			{
				if((j-i) <= (y-j+i-x+1))
				{
			//		cout<<"5"<<j<<" "<<i<<endl;
					v[j-i]++;
				}
				else{
			//		cout<<"6"<<j<<" "<<i<<endl;
					v[(y-j+i-x+1)]++;
				}
			}
			else if(i<=x && j>=y)
			{
			//	cout<<"4"<<j<<" "<<i<<endl;
				v[j-y+x-i+1]++;
			}
			else if(i<y){
				if((j-i) <= (i-x + j-y+1))
				{
			//		cout<<"7"<<j<<" "<<i<<endl;
					v[j-i]++;
				}
				else{
			//		cout<<"8"<<j<<" "<<i<<endl;
					v[(i-x + j-y+1)]++;
				}
			}
			else{
			//	cout<<"9"<<j<<" "<<i<<endl;
				v[j-i]++;
			}
			
		}
	}
	
	for(long long int i=1;i<n;i++)
	{
		cout<<v[i]<<endl;
	}
}

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

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int tc;


void solve(){

    char ch;
    cin>>ch;
    if(isupper(ch))cout<<"A"<<endl;
    else cout<<"a"<<endl;

}

int main()
{

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		String[] inputData = str.split(" ");

		int data[] = new int[inputData.length];

		//String??????inputData???int???????????£????????????
		for(int i=0;i < data.length;i++){
			data[i] = Integer.parseInt(inputData[i]);
		}

		//W,H,x,y,r data[0,1,2,3,4]
		//x-r<0 or x+r>W ??? NO
		//y-r<0 or y+r>H ??? Yes

		if(data[2]-data[4] < 0 | data[2]+data[4] > data[0] | data[3]-data[4] < 0 | data[3]+data[4] > data[1]){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}

	}
}

Measured memory_bytes: 24468
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
   vector<string> c(a);
  for(int i=0;i<a;i++){
    cin>>c.at(i);
  }
   sort(c.begin(), c.end());
    for(int i=0;i<a;i++){
      cout<<c.at(i);
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long ll;

const ll mod = 1e9+7;
const int MAX = 100005;
const int N = 2;

ll dp[N][MAX];

int a[105];

ll sum(ll a ,ll b){
    return (a+b)%mod;
}

ll sub(ll a, ll b){
    return (a-b+mod)%mod;
}

int main(){
    int n, k;
    cin>>n>>k;
    for(int i = 1; i<=n; ++i){
        cin>>a[i];
    }

    int acum = 0;
    for(int i = 0; i<N; ++i){
        dp[i][0] = 1;
    }

    int ii;
    for(int i = 1; i<=n; ++i){
        ii = i&1;
        acum+=a[i];
        for(int j = 1; j<= acum && j<= k; ++j){
            dp[ii][j] = sum(dp[ii^1][j], dp[ii][j-1]);
            if(j>a[i]){
                dp[ii][j] = sub(dp[ii][j], dp[ii^1][j-a[i]-1]);
            }
        }
    }
    cout<<dp[n&1][k]<<"\n";
}


Measured memory_bytes: 1792
import           Data.List
main = getLine >>= putStrLn . f . (\(a, b) -> (read a, read b)) . splitAt 2
  where
    f :: (Int, Int) -> String
    f (a, b)
      | inMonth a && inMonth b =  "AMBIGUOUS"
      | not (inMonth a) && inMonth b =  "YYMM"
      | inMonth a && not (inMonth b) =  "MMYY"
      | otherwise = "NA"
    inMonth x = 1 <= x && x <= 12

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

// s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T'

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

  string s;
  cin >> s;

  vector<int> sum(n+1);
  sum[0] = 0;


  for (int i = 1; i < n; ++i) {
    if (s[i-1] == 'A' and s[i] == 'C') {
      sum[i+1] += sum[i] + 1;
    } else {
      sum[i+1] = sum[i];
    }
  }
  /*
  for (auto itr : sum) cout << itr << " ";
  END;*/

  for (int i = 0; i < q; ++i) {
    int l,r; 
    cin >> l >> r;
    cout << sum[r] - sum[l] << endl;
  }
}


Measured memory_bytes: 1408
import sys

def solve():
    romans = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000, '\n': 0}
    for line in sys.stdin:
        cur, sum = 0, 0
        while cur + 1 < len(line):
            next_v = romans[line[cur + 1]]
            cur_v = romans[line[cur]]
            if next_v <= cur_v:
                sum += cur_v
            else:
                sum += next_v - cur_v
                cur += 1
            cur += 1
        print(sum)
    

if __name__ == "__main__":
    solve()



Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  vector<ll> A(3);
  for (ll i = 0; i < 3; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end(), greater<ll>());

  cout << A.at(0) * 10 + A.at(1) + A.at(2) << endl;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long a, b, c, d;
    scan(a, b, c, d);
    long lcm = c * d / gcd(c, d);
    // writeln(lcm);
    long c_cnt = b / c - (a - 1) / c;
    long d_cnt = b / d - (a - 1) / d;
    long lcm_cnt = b / lcm - (a - 1) / lcm;
    // writeln(c_cnt);
    // writeln(d_cnt);
    // writeln(lcm_cnt);
    writeln((b - a + 1) - (c_cnt + d_cnt - lcm_cnt));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3660
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int64_t A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int64_t ans = 1001001001;
  rep(i, max(X, Y)+1){
    if(i == max(X, Y)){
      chmin(ans, 2 * i * C);
    }
    else if(min(X, Y) <= i){
      if(X <= Y){
        chmin(ans, 2 * i * C + (Y - i) * B);
      }
      else{
        chmin(ans, 2 * i * C + (X - i) * A);
      }
    }
    else{
      chmin(ans, 2 * i * C + (X - i) * A + (Y - i) * B);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

res = 0
former = 0
s = 0

#はじめが正のとき
for i in range(N):
    if i == 0:
        if A[0] <= 0:
            res += (-A[0]+1)
            s = 1
        else:
            s = A[0]
    else:
        former = s
        s += A[i]
        if former*s >= 0:
            if s == 0:
                if former > 0:
                    res += 1
                    s = -1
                else:
                    res += 1
                    s = 1
            elif s > 0:
                res += s+1
                s = -1
            elif s < 0:
                res += (-s+1)
                s = 1
        else:
            pass
    #print(i,res)

#はじめが負の数
t = 0
for i in range(N):
    if i == 0:
        if A[0] >= 0:
            t += (A[0]+1)
            s = -1
        else:
            s = A[0]
    else:
        former = s
        s += A[i]
        if former*s >= 0:
            if s == 0:
                if former > 0:
                    t += 1
                    s = -1
                else:
                    t += 1
                    s = 1
            elif s > 0:
                t += s+1
                s = -1
            elif s < 0:
                t += (-s+1)
                s = 1
        else:
            pass
    #print(i,t)
if res > t:
    res = t
print(res)

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

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void main(String[] args) {

        int n;
        Main.Boll[] bollArray = null;
        HashMap<String, Integer> hash = new HashMap<>(100);
        try (Scanner sc = new Scanner(System.in)) {
            n = sc.nextInt();
            bollArray = new Boll[n];
            Main main = new Main();
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                int y = sc.nextInt();
                Main.Boll boll = main.new Boll(x, y);
                bollArray[i] = boll;
            }
        }

        for(Main.Boll boll :bollArray){
            for(Main.Boll target:bollArray){
                if(boll ==  target|| target.cheaked ==true){
                    continue;
                }
                Main.Boll temp1;
                Main.Boll temp2;
                if(target.x > boll.x) {
                    temp1 = target;
                    temp2 = boll;
                }else if(target.x < boll.x){
                    temp1 = boll;
                    temp2 = target;
                }else{
                    if(target.y > boll.y){
                        temp1 = target;
                        temp2 = boll;
                    }else{
                        temp1 = boll;
                        temp2 = target;
                    }

                }
                long deltaX = temp1.x - temp2.x;
                long deltaY = temp1.y - temp2.y;
                String temp = deltaX +":" + deltaY;
                debug(temp);
                Integer sum = hash.get(temp);
                if(sum != null){
                    debug(temp +"★"+(sum +1) );
                    hash.put(temp,sum +1);
                }else{
                    hash.put(temp,1);
                }
            }
            boll.cheaked = true;
        }
        int max = 0;
        for(Integer t : hash.values()){
            debug(t.toString());
            if(max < t.intValue()){
                max = t.intValue();
            }
        }
        debug("答え");
        System.out.println( n - max);

    }

    public static long delta(long x1,long x2){
        if(x1 > x2){
            return x1 - x2;
        }
        return x2 -x1;

    }
    class Boll {
        long x;
        long y;
        boolean cheaked = false;
        Boll(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public void isChecked(){
            this.cheaked = true;
        }
    }
}


Measured memory_bytes: 23636
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num; ++i)
		{
			std::getline(sstr, buf, delim);
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;

	//int num = GetValue<1>(stream)[0];
	std::stack<int> result;

	for(std::string buf; std::getline(stream, buf, ' ');)
	{
		int left = 0, right = 0;
		if (buf[0] == '+' || buf[0] == '-' || buf[0] == '*')
		{
			right = result.top();
			result.pop();
			left = result.top();
			result.pop();
		}

		switch (buf[0])
		{
		case '+':
			result.push(left + right);
			break;
		case '-':
			result.push(left - right);
			break;
		case '*':
			result.push(left * right);
			break;
		default:
			result.push(std::stoi(buf));
			break;
		}
	}

	std::cout << result.top() << std::endl;
}



Measured memory_bytes: 3212
while True:
    n,k=map(int,input().split())
    if n==0 and k==0: break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))    


Measured memory_bytes: 11704
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}



int main(){
	int n, m, x, tp;
	cin >> n >> m >> x;
	pair<int, vector<int> > books[n];
	FOR0(i, n){
		cin >> books[i].ff;
		FOR0(j, m){
			cin >> tp;
			books[i].ss.pb(tp);
		}
	}
	int fans = INT_MAX, ans = INT_MAX;
	int val[m];
	for (int i = 0; i < (1<<n); i++){
		ans = 0;
		mst0(val);
		for (int j = 0; j < n; j++){
			if (i&(1<<j)){
				ans += books[j].ff;
				FOR0(k, m){
					val[k] += books[j].ss[k];
				}
			}
		}
		bool chk = true;
		FOR0(k, m) {
			if (val[k]<x) chk = false;
		}
		if (chk){
			// cout << ans << endl;
			fans = min(ans, fans);
		}
		
	}
	if (fans == INT_MAX) cout << -1;
	else cout << fans;

}



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

using namespace std;

int main(int argc, const char *argv[])
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int n;
ll x, y;
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);

    bool flag = false;
    ll ans = LLONG_MAX, sum = 0;
    for(int i = 0; i < n; ++i) {
        read(x), read(y);

        if(x != y) flag = true;
        if(x > y) chkmin(ans, y);

        sum += y;
    }
    printf("%lld\n", flag ? sum - ans : 0); 

    return 0;
}


Measured memory_bytes: 256