akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
  int n, x, y, h, w, size, fee;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    fee = 0;
    while (n--) {
      scanf("%d %d %d %d", &x, &y, &h, &w);
      size = x + y + h;
      if (size <= 60 && w <= 2)
	fee += 600;
      else if (size <= 80 && w <= 5)
	fee += 800;
      else if (size <= 100 && w <= 10)
	fee += 1000;
      else if (size <= 120 && w <= 15)
	fee += 1200;
      else if (size <= 140 && w <= 20)
	fee += 1400;
      else if (size <= 160 && w <= 25)
	fee += 1600;
    }
    printf("%d\n", fee);
  }
  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int keta(int a) {
	return to_string(a).size();
}
signed main() {
	int n;
	cin>>n;
	Rep(i,n){
		if((i*27)/25==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

N,M = map(int,input().split())
P = list(map(int,input().split()))
XY = []
for i in range(M):
  XY.append(list(map(int,input().split())))
#print(XY)

E = [set() for _ in range(N+1)]
for x,y in XY:
  E[x].add(y)
  E[y].add(x)
#print(E)

def dfs(v,mark):
  visited[v] = mark
  for u in E[v]:
    if visited[u] == 0:
      dfs(u,mark)

visited = [0 for _ in range(N+1)]
mark = 1
for i in range(1,N+1):
  if visited[i] == 0:
    dfs(i,mark)
    mark += 1
#print(visited)

G = [set() for _ in range(max(visited))]
for i in range(1,N+1):
  G[visited[i]-1].add(i)
#print(G)

ans = 0
for g in G:
  Pset = set()
  for idx in g:
    Pset.add(P[idx-1])
  ans += len(Pset & g)
print(ans)

Measured memory_bytes: 113916
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strn = sc.next();
        sc.close();
        String  str[] = strn.split("");

        int sum = 0;
        for(int i = 0; i<strn.length(); i++){
            sum += Integer.parseInt(str[i]);
        }
        String ans = "No";
        if(sum%9==0){
            ans = "Yes";
        }
        System.out.println(ans);
    }
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, i; cin >> N >> i;
    cout << N - i + 1 << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 17;
const int MASK = 1<<16;

int n;
int a[N][N];
ll cost[MASK];
ll memo[MASK];
bool vis[MASK];

ll DP(int mask){
	if(mask == 0) return 0;
	if(vis[mask]) return memo[mask];
	ll ans = LLONG_MIN;
	for(int m = mask; m > 0; m = (m - 1) & mask){
		ans = max(ans, cost[m] + DP(mask ^ m));
	}
	vis[mask] = true;
	return memo[mask] = ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			ri(a[i][j]);
		}
	}
	for(int mask = 0; mask < 1<<n; mask++){
		for(int i=0; i<n; i++){
			if(!(mask & 1<<i)) continue;
			for(int j=i+1; j<n; j++){
				if(!(mask & 1<<j)) continue;
				cost[mask] += a[i][j];
			}
		}
	}
	printf("%lld\n",DP((1<<n)-1));
	return 0;
}

Measured memory_bytes: 1280
int main(void)
{
    int H=1, W=1, i, j;

    

    while ((H != 0) && (W != 0))
    {
        scanf("%d %d", &H, &W);

        if ((H == 0) && (W == 0))
        {
            return 0;
        }
        else
        {
            for (j = 0;j < H;j++)
            {
                for (i = 0;i < W;i++)
                {
                    if ((j%2 == 0) && (i%2== 0))
                    {
                        printf("#");
                    }
                    else
                    {
                        if ((j % 2 == 1) && (i % 2 == 1))
                        {
                            printf("#");
                        }
                        else
                        {
                            printf(".");
                        }
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }

    return 0;
}


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

#define int long long

signed main(){
    int a , b, ans = 1;
    cin >> a >> b;
    int tot = a;
    if(b==1){
        cout << "0\n"; return 0;
    }
    while(tot < b){
        tot--;
        tot+=a;
        ans++;
    }
    cout << ans << '\n';
}

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

#define bitGet(a, i) a & (1 << i)
#define bitOn(a, i) a != (1 << i)
#define bitOff(a, i) a &= ~(1 << i)
#define bitMake(a, i) a = (1 << N)
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define ull unsigned long long
#define ll long long
#define ld long double
#define pri(a) cout << a << " "
#define pril(a) cout << a << " "
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define pi pair<int, int>
#define oo INT_MAX
#define sz(a) (int)(a.size()-1)
#define maxN 200005

using namespace std;

int n;
ll a[maxN], sum[maxN], rs;

const int mod = 1000000007;

int main() {
    #ifndef ONLINE_JUDGE
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    #endif // !ONLINE_JUDGE

    cin >> n;

    fto(i, 1, n) {cin >> a[i]; sum[i] = (sum[i-1] + a[i]) % mod;}

    fto(i, 2, n) rs = (rs + (sum[i-1] * a[i]) % mod) % mod;

    cout << rs;
    
    return 0;
}


Measured memory_bytes: 6716
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
ll n, s;
//-------------------関数----------------------//

ll ketawa(ll b, ll nn) {
	if (nn < b) {
		return nn;
	}
	return ketawa(b, nn / b) + nn%b;
}
int main() {
	cin >> n >> s;
	ll hoge = n / 2 + 1;
	if (n  == s) { cout << n+1 << endl; return 0; }
	//if (s == 1) { cout << n << endl; return 0; }
	if (s > hoge) { cout << -1 << endl; return 0; }
	ll heihoukon = sqrt(n);
	REP(i, heihoukon + 1) {
		if (i <= 1) { continue; }
		if (ketawa(i, n) == s) {
			cout << i << endl; return 0;
		}
	}
	ll izryt = -1;
	ll kisuu = n & 1;
	REP(i, heihoukon + 1) {
		if (i) {
			if ((s - ketawa(n / i, n)) % i == 0&&ketawa(n/i,n)<=s&&s<=ketawa(n/(i+1)+1,n)) {
				izryt = (n / i) - (s - ketawa(n/i,n)) / i;
			}
		}
	}
	cout << izryt << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    [H,W] = raw_input().split()
    H = int(H)
    W = int(W)
    if H == 0 and W == 0:
        break

    for y in range(0,H):
        s = ''
        for x in range(0,W):
            c = '.'
            if x == 0 or x == W - 1:
                c = '#'
            if y == 0 or y == H - 1:
                c = '#'
            
            s = s + c
        
        print s
    print ''

Measured memory_bytes: 4220
a = []
N = int(input())
for i in range(N):
   s = input()
   a.append(s)

print("AC x {}".format(a.count("AC")))
print("WA x {}".format(a.count("WA")))
print("TLE x {}".format(a.count("TLE")))
print("RE x {}".format(a.count("RE")))

Measured memory_bytes: 16300
S = int(input())

A = int(S/100)
B = S%100

if 1<=A<= 12:
    if 1<=B<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=B<=12:
        print('YYMM')
    else:
        print('NA')

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

#define N 20
int solve(int,int);

int n;
int A[N];

int main()
{
  int q,i,j = 0;
  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  int M[q];
  for(i = 0;i < q;i++)
    {
      scanf("%d",&M[i]);
    }
  for(i = 0;i < q;i++)
    {
      if(solve(j,M[i]) == 1)
	{
	  printf("yes\n");
	}
      else
	{
	  printf("no\n");
	}
    }
}

int solve(int i,int m)
{
  int res;
  if(m == 0)
    {
      return 1;
    }
  if(i >= n)
    {
      return 0;
    }
  res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  string s;
  cin>>n>>s;
  for(i=0;i<n-1;i++){
    if(s[i]=='x'&&s[i]==s[i+1])break;
  }
  cout<<i+1<<endl;
  return 0;
}

Measured memory_bytes: 3340
n,x = map(int,input().split())

def get_result():
    if x == 1 or x == 2*n-1:
        return []
    
    if n == 2:
        return [1,2,3]
    
    if x == 2:
        center = [3,2,1,4]
        others = list(range(5,2*n))
    elif x == 2*n-2:
        center = [2*n-3,2*n-2,2*n-1,2*n-4]
        others = list(range(1,2*n-4))
    else:
        center = [x+1,x,x-1,x+2]
        others = list(range(1,x-1)) + list(range(x+3,2*n))
    split_idx = n-2
    result = others[:split_idx] + center + others[split_idx:]
    
    return result


res = get_result()
if len(res)==0:
    print("No")
else:
    print("Yes")
    for r in res:
        print(r)
        

Measured memory_bytes: 51500
def calc(n, a, init_sum, init_count)
  prev_sum = init_sum
  count = init_count
  for i in 1...n do
    sum = prev_sum + a[i]
    if prev_sum * sum >= 0
      count += sum.abs + 1
      sum = prev_sum > 0 ? -1 : 1
    end
#    puts [sum, count].join(" ")
    prev_sum = sum
  end
  return count
end

n = gets.to_i
a = gets.split.map(&:to_i)
count1 = count2 = 0
if a[0] != 0
  count1 = calc(n, a, a[0], 0)
  count2 = calc(n, a, (a[0] > 0 ? -1 : 1), a[0].abs + 1)
else
  count1 = calc(n, a, 1, 1)
  count2 = calc(n, a, -1, 1)
end
#puts [count1, count2].join(" ")
puts [count1, count2].min


Measured memory_bytes: 20756
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <stack>
#include <queue>
#include <memory>
#include <ctime>
#include <bitset>
#include <map>
#include <fstream>
using namespace std;
typedef long long ll;
#define MSG(a) cout << #a << " " << a << endl;
#define rep(i, n) for(unsigned int i = 0; i < n; i++)

const int MAX_N = 1000;

int compless(vector<int>& s, vector<int>& e, int w);

int main()
{
	int W, H, N;
	while( scanf("%d %d", &W, &H) != EOF && W )
	{
		scanf("%d", &N);

		vector<int> xs(N), xe(N), ys(N), ye(N);
		vector<bitset<MAX_N * 6> > field(MAX_N * 6);

		rep(i, N)	
			scanf("%d %d %d %d", &xs[i], &ys[i], &xe[i], &ye[i]);
	
		
		W = compless(xs, xe, W);
		H = compless(ys, ye, H);


		rep(i, N)
			for(int y = ys[i]; y < ye[i]; y++)
				for(int x = xs[i]; x < xe[i]; x++)
					field[y][x] = true;
	
		int ans = 0;

		rep(y, H) rep(x, W)
		{
			if(field[y][x]) continue;
			
			ans++;

			queue<pair<int, int> > que;

			for(que.push(make_pair(y, x)); !que.empty(); que.pop())
			{
				int tx = que.front().second, ty = que.front().first;
				int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};

				rep(i, 4)
				{
					int nx = tx + dx[i], ny = ty + dy[i];

					if(0 <= nx && nx < W && 0 <= ny && ny < H && !field[ny][nx])
					{
						que.push(make_pair(ny, nx));
						field[ny][nx] = true;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

int compless(vector<int>& s, vector<int>& e, int u)
{
	vector<int> result;

	rep(i, s.size())
	for(int d = -1; d <= 1; d++)
	{
		int ns = s[i] + d, ne = e[i] + d;
		if(0 <= ns && ns < u) result.push_back(ns);
		if(0 <= ne && ne < u) result.push_back(ne);
	}

	sort(result.begin(), result.end());
	result.erase(unique(result.begin(), result.end()), result.end());

	rep(i, s.size())
	{
		s[i] = find(result.begin(), result.end(), s[i]) - result.begin();
		e[i] = find(result.begin(), result.end(), e[i]) - result.begin();
	}

	return result.size();
}

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

int main(){
    int flag=1;
    int n,m,x;
    int a;
    int costleft=0,costright=0;
    int ans=0;

    cin >>n>>m>>x;

    for (int i = 0; i < m; i++){
        cin >>a;
        if(x>a)costleft++;
        else costright++;
    }
    
    ans = min(costright,costleft);
    cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int a, b;

	while(cin >> a >> b)
	{
		int l;
	    int g = 1;

		for (int i = 2; a > i && b > i; i++)
		{
			for (int j = 0; a % i == 0 && b % i == 0; j++)
			{
				a = a / i;
				b = b / i;
				g *= i;
			}
		}

		l = g * a * b;
		cout << g << " " << l << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
N = int(input())
dp = [0]*(N+1)
for i in range(N+1):
    dp[i] = i

for i in range(1,N+1):
    s = 1
    while i-6**s >= 0:
        dp[i] = min(dp[i],dp[i-6**s] + 1)
        s += 1
    n = 1
    while i-9**n >= 0:
        dp[i] = min(dp[i],dp[i-9**n] + 1)
        n += 1

print(dp[N])

Measured memory_bytes: 43116
import numpy as np

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

KA=[] # K,Aの行列
number = 0; # 食べ物の種類数
# 好きな食べ物カウント
like = np.zeros(M)

while True:
    try:
        KA.append(list(map(int,input().split())))
    except:
        break;

for i in KA:
    i.pop(0)

for i in range(M+1):
    if sum(x.count(i) for x in KA) == N:
        number+=1

print(number)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, Y;
	cin >> N >> Y;
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			if(i + j > N) continue;
			int sum = 1000 * i + 5000 * j + 10000 * (N - i - j);
			if(sum == Y){
				cout << N - i - j << " " << j << " " << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    while(1){
        int huda[51]={0};
        int tmp[51]={0};
        int n,r;
        scanf("%d%d",&n,&r);
        if(n+r==0) break;
        for(int i=1;i<=n;i++){
            huda[i]=n-i+1;
            //printf("%d\n",huda[i]);
        }
        for(int i=0;i<r;i++){
            int p,c;
            scanf("%d%d",&p,&c);
            for(int j=1;j<=c;j++){
                tmp[j]=huda[p+j-1];
            }
            for(int j=p-1;j>=1;j--){
                huda[p+c-1+j-(p-1)]=huda[j];
            }
            for(int j=1;j<=c;j++){
                huda[j]=tmp[j];
            }
        }
        printf("%d\n",huda[1]);
    }
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int Comb[5005][5005];

void add(int &a, int b) {
    a += b;
    while(a >= MOD)
        a -= MOD;
    while(a < 0)
        a += MOD;
}

int main() {
    int n, a, b, c; cin >> n >> a >> b >> c;
    
    if(b % 2) {
        cout << "0\n";
        return 0;

    }
    
    for(int i = 0; i <= n; ++i) {
        Comb[i][0] = 1;
        for(int j = 1; j <= i; ++j)
            Comb[i][j] = (Comb[i - 1][j - 1] + Comb[i - 1][j]) % MOD;
    }

    int block2 = b / 2;
    int ans = 0;

    for(int block1 = 0; block1 <= a; ++block1) {
        int block13 = (a - block1);
        for(int block3 = 0; 3 * block3 + block13 <= c; ++block3) {
            int remain3 = c - (3 * block3 + block13);
            if(remain3 && block2 == 0)
                continue;
            int stars = 1;
            if(block2 > 0)
                stars = Comb[block2 + remain3 - 1][block2 - 1];
            int temp = Comb[block1 + block2][block1];
            temp = 1LL * temp * Comb[block1 + block2 + block13][block13] % MOD;
            temp = 1LL * temp * Comb[block1 + block2 + block13 + block3][block3] % MOD;
            temp = 1LL * stars * temp % MOD;
            add(ans, temp);
        }
    }

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

Measured memory_bytes: 67072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<long long> L(n + 1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= n; ++i) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[n] << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    vint x(5);
    rep(i, 5) cin >> x[i];

    int ans = 0;
    rep(i, 5) if (x[i] == 0) ans = i+1;

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

Measured memory_bytes: 3488
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int s=sc.nextInt();
		int w=sc.nextInt();
		if(s>w)System.out.println("safe");
		else System.out.println("unsafe");
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}

	}
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var B = cin.ReadIntArray(N - 1);

            var A = new int[N];
            for (int i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    A[0] = B[0];
                }
                else if (i == N - 1)
                {
                    A[N - 1] = B[N - 2];
                }
                else
                {
                    A[i] = Math.Min(B[i - 1], B[i]);
                }
            }
            Console.WriteLine(A.Sum());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	string s;
	cin>>k>>s;
	if(s.size()<=k)cout<<s;
	else{
		for(int i=0;i<k;i++)cout<<s[i];
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		int h, w;
		Scanner scan = new Scanner(System.in);

		while(true){
			h = scan.nextInt();
			w = scan.nextInt();

			if(h == 0 && w ==0) break;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(i == 0 || i == h-1 || j == 0 || j == w-1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		scan.close();
	}
}



Measured memory_bytes: 32344
S = input()
li = ['dream','dreamer','erase','eraser']
li_len=[5,7,5,6]

while S:
    for i,moji in enumerate(li):
        if S[-li_len[i]:] == moji:
            S = S[:-li_len[i]]
            break
    else:
        print('NO')
        break
if not S:print('YES')


Measured memory_bytes: 9104
package main

import "fmt"

func sum(ar []int) int {
	s := 0
	for _, ar := range ar {
		s += ar
	}
	return s
}

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

	fmt.Println(sum(as) - N)
}


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

using namespace std;
int main(void) {
    int n; cin >> n;
    int k; cin >> k;

    vector<double> dice(n);

    for(int i = 0; i < n; ++i) {
        double men; cin >> men;
        dice[i] = 1 + (men-1) * 0.5;
    }

    double bef = 0.0;
    for(int i = 0; i < k; ++i) {
        bef += dice[i];  
    }

    double max = bef;

    for(int i = k; i < n; ++i) {
       bef += dice[i] - dice[i-k];
       if(max<bef) max = bef;
    }

    cout << fixed <<setprecision(10) << max << endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n)cin>>a[i];
  rep(i, n)cin>>b[i];
  rep(i, n)cin>>c[i];

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll result = 0;
  for(auto cb: b){
    auto a_it = lower_bound(a.begin(), a.end(), cb);
    ll ta = distance(a.begin(), a_it);
    if(ta==0)continue;

    auto c_it = upper_bound(c.begin(), c.end(), cb);
    ll tb = distance(c_it, c.end());
    result += ta*tb;
//cout<<ta<<' '<<tb<<endl;
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int k;
    cin>>k;
    deque<int>d;

    for(int i = 1;i<=9;i++) d.push_back(i);
    int cnt = 0;
    int t;
    while(true){
        t = d.front();
        d.pop_front();
        int t1 = t%10;
        if(t1 != 0){
            d.pb(10*t + t1 - 1);
            if(cnt==k) break;
        }
        d.pb(10*t + t1);
        cnt++;
        if(cnt==k) break;
        if(t1 != 9){
            d.pb(10*t+t1+1);
            //if(cnt==k) break;
        }
    }
    cout<<t;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

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


Measured memory_bytes: 4816
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    char c;
    cin>>c;
    if(c==(char)tolower(c)) cout<<'a'<<endl;
    else cout<<'A'<<endl;
    return 0;
}



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

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans =0;

        int n = (int)Math.ceil((double)N/(double)1000) *1000;


        System.out.println(n-N);
    }

}

Measured memory_bytes: 35436
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int Y = sc.nextInt();
        for (int x = 0; x <= N; x++) {
            for (int y = 0; y <= N-x; y++) {
                int z = N -(x+y);
                int amount = 10000*x + 5000*y + 1000*z;
                if (amount == Y) {
                    so.println(x + " " + y + " " + z);
                    return;
                }
            }
        }
        
        so.println("-1 -1 -1");
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

ll dp[55][55][2555];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
        for (int sum = 0; sum <= 2500; sum++) if (dp[i][j][sum]) {
            dp[i+1][j][sum] += dp[i][j][sum];
            dp[i+1][j+1][sum+X[i]] += dp[i][j][sum];
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) for (int sum = 0; sum <= 2500; sum++) {
        if (A*i == sum) ans += dp[N][i][sum];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<utility>
using namespace std;
typedef long long ll;
int main()
{
    string  s;  
	cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++){
    	cout<<"x";
	}
    cout<<endl;


    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

a, b = [int(item) for item in input().split()]
for i in range(20000):
    eight = int(i * 0.08)
    ten = int(i * 0.1)
    if eight == a and ten == b:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

import static java.lang.StrictMath.abs;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
//        自分のターンが終わった時点で、間のマスの数が偶数だったらよい
//        自分のターンが回ってきたときに間の数が奇数なら前に進み、偶数なら後ろに進むのが最適解
        if((b-a+1)%2 == 0 ){
            System.out.println("Borys");

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

    }
}


Measured memory_bytes: 23764
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader r = new BufferedReader (new InputStreamReader (System.in));
		String s1 = r.readLine();
		int index = Integer.valueOf(s1.split(" ")[1]) - 1;
		char[] s2 = r.readLine().toCharArray();
		char c = s2[index];
		s2[index] = Character.isUpperCase(c) ? Character.toLowerCase(c) : Character.toUpperCase(c);
		System.out.println(new String(s2));
	}
}

Measured memory_bytes: 20820
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n,m,x=map(int, input().split())
a = list(map(int, input().split()))

ans1 = 0
for i in range(x,n+2):
    if i in a:
        ans1 += 1
ans2 = 0
for i in range(x):
    if i in a:
        ans2 += 1


print(min(ans1, ans2))





Measured memory_bytes: 9064
#include <stdio.h>
#include <queue>
using namespace std;

priority_queue<int, vector<int>, greater<int> > pq;

int main(void)
{
    int n, p, ans = 0;

    scanf("%d" ,&n);
    pq.push(n + 1);
    while (n--)
    {
        scanf("%d" ,&p);

        if (pq.top() >= p)
            ++ans;

        pq.push(p);
    }

    printf("%d" ,ans);
    return 0;
}

Measured memory_bytes: 1400
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<62)-10e15;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
string S;
 
LL ans = 0;
 
void solve(){
	int N = S.size();
	//Sのi桁目をS[i-1]で取り出せるようにする
	reverse(S.begin(),S.end());
	//挿入する+の位置をbitが立っているかどうかで表す
	//例えば　125 を　1+25　にするとき
	//S   = 521
	//bit = 01
	for(int bit=0;bit<(1<<(N-1));bit++){
		//bitのi[bit]目について見ていく
		LL digit = 1LL;
		for(int i=0;i<N;i++){
			ans += ((LL)(S[i]-'0'))*digit;
			if((bit>>i)&1) digit = 1LL;
			else digit *= 10LL;
		}
	}
}
 
int main(){
    cin >> S;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
minus = Counter([i-a[i] for i in range(n)])
plus = Counter([i+a[i] for i in range(n)])

cnt = 0
for i in minus:
    if i in plus:
        cnt += minus[i] * plus[i]
print(cnt)


Measured memory_bytes: 61400
#define z 1000000
a[z],b[z],n,x,c;main(i){for(;i++<z;)a[i]=i;for(i=0;i++<z;)if(a[i])for(b[x++]=i,c=i;c<z;c+=i)a[c]=0;for(;~scanf("%d",&n);){c=0;while(b[c]<=n&&b[c++]);printf("%d\n",c);}exit(0);}

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

int main() {
  long int n, result=0;
  
  cin >> n;
  
  long int list[n];
  
  for(int i=0;i<n;i++) {
    cin >> list[i];
    
    if(i==0) {
      continue;
    }
    
    if(list[i] < list[i-1]) {
      result = result + (list[i-1] - list[i]);
      list[i] = list[i-1];
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;



int main() {
  string s;
  cin >> s;
  sort(All(s));
  if(s=="abc"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

dp = [[0]*(S+1) for i in range(N+1)]
dp[0][0] = 1
for i, a in  enumerate(A, 1):
  for s in range(S+1):
    dp[i][s] = 2*dp[i-1][s]
    if a <= s:
      dp[i][s] += dp[i-1][s-a]
    dp[i][s] %= MOD

print(dp[-1][-1])

Measured memory_bytes: 132772
#include<stdio.h>


void trace(int A[], int N){
    int i;
    for(i = 0; i < N; i++){
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
    int i, j, v;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i-1; 
        while(j >= 0 && A[j] > v){
             A[j + 1] = A[j];
                j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }



}

int main(){

     int N, i, j;
     int A[100];

     scanf("%d", &N);
     for(i = 0; i < N; i++)
       scanf("%d", &A[i]);

   trace(A, N);
   insertionSort(A, N);

return 0;

}

Measured memory_bytes: 604
#include <iostream>
#include <stdio.h>

using namespace std;
typedef pair<double, double> P;

void solve()
{
	P p[3];
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &p[0].first, &p[0].second, &p[1].first, &p[1].second, &p[2].first, &p[2].second) != EOF)
	{
		if(p[0].second == p[1].second)
		{
			cout << p[2].first << " " << p[0].second - (p[2].second - p[0].second) << endl;
		}
		else if(p[0].first == p[1].first)
		{
			cout << p[0].first + (p[0].first - p[2].first) << " " << p[2].second << endl; 
		}
		else
		{
			double a1 = (p[1].second - p[0].second) / (p[1].first - p[0].first);
			double b1 = p[0].second - a1 * p[0].first;
			double a2 = -1 / a1;
			double b2 = p[2].second - a2 * p[2].first;
			double x = (b1 - b2) / (a2 - a1);
			double y = a2 * x + b2;
			double dx = x - p[2].first;
			double dy = y - p[2].second;
			cout << x + dx << " " << y + dy << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long e[4];
    e[0]=a*c;
    e[1]=a*d;
    e[2]=b*c;
    e[3]=b*d;
    a=max(e[0],max(e[1],max(e[2],e[3])));
    cout<<a;

}

Measured memory_bytes: 3624
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
int a,b;
cin>>a>>b;
if(b>a)
cout<<string(b,'0'+a);
else
cout<<string(a,'0'+b);




    return 0;
  }


Measured memory_bytes: 256
n, m = map(int, input().split())
x = [int(i) for i in input().split()]
x.sort()
if n>=m:
    print(0)
else:
    L = list()
    for i in range(m-1):
        L.append(x[i+1]-x[i])
    a=0
    L.sort()
    for i in range(n-1):
        L.pop(-1)
    for i in L:
        a = a + i
    print(a)


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

int main()
{
	int n; cin>>n;
	vector<int> a(n);
	int s=0;
	for(int& e: a) { cin>>e; s+=e; }

	if (s%10) {
		cout<<s<<endl;
	}
	else {
		int res=0;
		for(int e: a) {
			res=max(res, (s-e)%10 ? s-e : 0);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 256
#include <ctime>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
int N, K, card[500][500], r[1000];
int main() {
	srand((unsigned)time(NULL));
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N / 2; j++) {
			scanf("%d", &card[i][j]);
		}
	}
	while (true) {
		for (int i = 0; i < N; i++) r[i] = rand() % 2;
		bool flag = true;
		for (int i = 0; i < K; i++) {
			int c = 0;
			for (int j = 0; j < N / 2; j++) {
				if (r[card[i][j] - 1]) c++;
			}
			if (c < N / 8 || 3 * N / 8 < c) { flag = false; break; }
		}
		if (flag) {
			for (int i = 0; i < N; i++) {
				printf("%d", r[i]);
			}
			printf("\n"); break;
		}
	}
	return 0;
}

Measured memory_bytes: 4204
#include<bits/stdc++.h>
using namespace std;
const int MAXN=505;
int C[MAXN],S[MAXN],F[MAXN];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        //cout<<n<<endl;
        for(int i=1;i<=n-1;i++)
        {
            scanf("%d%d%d",&C[i],&S[i],&F[i]);
            //cout<<C[i]<<" "<<S[i]<<" "<<F[i]<<endl;
        }
        for(int i=1;i<=n-1;i++)
        {
            int t=S[i],add;
            for(int j=i+1;j<=n-1;j++)
            {
                t+=C[j-1];
                if(t<=S[j])
                {
                    add=S[j]-t;
                    t+=add;
                }else if(((t-S[j])%F[j])!=0)
                {
                    add=S[j]+((t-S[j])/F[j]+1)*F[j]-t;
                    t+=add;
                }
            }
            t+=C[n-1];
            printf("%d\n",t);
        }
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair

using namespace std;


int main(){

    int n;
    cin >> n;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    sorta(a);

    int before_num = 0;
    int ans = 0;
    int starti = 0;

    rep(i,n){

        if(before_num != a[i]){

            int count = i - starti;

            if(count < before_num){
                ans = ans + count;
            }
            if(count > before_num){
                ans = ans + count - before_num;
            }

            before_num = a[i];
            starti = i;
        }
    }

    int count = n - starti;
    if(count < before_num){
            ans = ans + count;
    }
    if(count > before_num){
        ans = ans + count - before_num;
    }

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

Measured memory_bytes: 892
#include <stdio.h>

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

Measured memory_bytes: 600
n,y=map(int,input().split())

res=(-1,-1,-1)

for i in range(n+1):
    for j in range(n-i+1):
        k = 10000*i + 5000*j + 1000*(n-i-j)
        if k==y:
            res=(i,j,n-i-j)
            break
print(*res)

Measured memory_bytes: 40940