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

int f[45];

int main()
{
	int n;
	f[0] = 1, f[1] = 1;
	for (int i = 2; i < 45; i++)
		f[i] = f[i - 1] + f[i - 2];
	scanf("%d", &n);
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 2728
def main():
    n, k = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    u = [0]
    v = []
    w = []
    for i in range(n):
        u.append(u[i]+p[i])
    for i in range(n-k+1):
        w.append(u[k+i]-u[i])
    x = w.index(max(w))
    for i in range(k):
        v.append(p[x+i])
    a=0
    for i in range(k):
        a += 1+0.5*(v[i]-1)
    print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 31996
import java.io.*;
import java.util.*;

    public class Main extends PrintWriter {
        Main() { super(System.out, true); }
        Scanner sc = new Scanner(System.in);
        public static void main(String[] $) {
            Main o = new Main(); o.main(); o.flush();
        }

        void main(){
            long A = sc.nextLong();
            long B = sc.nextLong();
            long K = sc.nextLong();
            if(A < K){
                K = K - A;
                A = 0;
            }
            else{
                A = A - K;
                K = 0;
            }
            if(B > K){
                B = B - K;
            }
            else{
                B = 0;
            }
            print(A + " "  + B);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

struct Edge{
	int v;
	long long d;
};

struct Data{
	long long time;
	int u, v;
	int from;
};

bool operator>(const Data& a, const Data& b){
	return a.time > b.time;
}


const long long mod = 1E9+7;
const long long inf = 1E15;

int n, m;
int s, t;


vector<Edge> edges[100000];
long long dist[100000][2];
long long pattern[100000][2] = {0};


int main(){
	Edge e;

	cin>>n>>m;
	cin>>s>>t;
	s--;
	t--;

	for(int i=0;i<m;i++){
		int a,b,d;
		cin>>a>>b>>d;
		e.d = d;
		e.v = b-1;
		edges[a-1].push_back(e);
		e.v = a-1;
		edges[b-1].push_back(e);
	}

	for(int i=0; i<n; i++){
		dist[i][0] = dist[i][1] = inf;
	}

	priority_queue<Data,vector<Data>,greater<Data> > pq;
	Data data;

	dist[s][0] = 0;
	dist[t][1] = 0;
	pattern[s][0] = 1;
	pattern[t][1] = 1;
	for(int i=0; i<edges[s].size(); i++){
		data.time = edges[s][i].d;
		data.u = s;
		data.v = edges[s][i].v;
		data.from = 0;
		pq.push(data);
	}
	for(int i=0; i<edges[t].size(); i++){
		data.time = edges[t][i].d;
		data.u = t;
		data.v = edges[t][i].v;
		data.from = 1;
		pq.push(data);
	}


	while(!pq.empty()){
		data = pq.top();
		pq.pop();
		int from = data.from;
		int u = data.u;
		int v = data.v;
		long long t = data.time;

		if(t == dist[v][from]){
			pattern[v][from] += pattern[u][from];
			pattern[v][from] %= mod;
		}
		else if(t < dist[v][from]){
			pattern[v][from] = pattern[u][from];
			dist[v][from] = t;

			auto es = edges[v];
			for(int i=0; i<es.size(); i++){
				if(pattern[es[i].v][from] == 0){
					data.time = dist[v][from] + es[i].d;
					data.u = v;
					data.v = es[i].v;
					data.from = from;
					pq.push(data);
				}
			}
		}
	}

	long long min_time = dist[s][1];
	long long res = 0;
	long long routes = 0;
	//cout <<"min_time"<<min_time<<endl;

	for(int u=0; u<n; u++){
		//cout<<u<<" "<<dist[u][0]<<" "<<pattern[u][0]<<" "<<dist[u][1]<<" "<<pattern[u][1]<<endl;
		if(dist[u][0] == dist[u][1] && dist[u][0]*2 == min_time){
			long long buf = pattern[u][0] * pattern[u][1] % mod;
			res += routes * buf;
			res %= mod;
			routes += buf;
			routes %= mod;
			//cout <<"node"<<u<<":"<< res <<" "<<routes<<endl;
		}
		for(int i=0; i<edges[u].size(); i++){
			int v = edges[u][i].v;
			int d = edges[u][i].d;

			if(dist[u][0] + dist[v][1] + d == min_time &&
					dist[u][0] * 2 < min_time &&
					dist[v][1] * 2 < min_time){

				long long buf = pattern[u][0] * pattern[v][1] % mod;
				res += routes * buf;
				res %= mod;
				routes += buf;
				routes %= mod;
				//cout <<"edge"<<u<<" "<<v<<":"<< res <<" "<<routes<<endl;
			}
		
		}

	}


	cout << res * 2 % mod << endl;

	return 0;
}



Measured memory_bytes: 24684
n=int(input())
p=[3,5,7,11,13]
x=[]
for i in range(5):
	for j in range(i):
		for k in range(j):
			if n >= p[i]*p[j]*p[k]:
				x.append(i*j*k)
cnt=len(x)
if 135 <= n < 189:
	cnt += 1
elif 189 <= n:
	cnt += 2
else:
	pass
print(cnt)
	

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
template<class T> inline void YES(T condition) { 
    if(condition) cout << "YES" << endl;
    else cout << "NO" << endl;
}
template<class T> inline void Yes(T condition) {
    if(condition) cout << "Yes" << endl;
    else cout << "No" << endl;
}
template<class T> T gcd(T a, T b) {
    if(a && b) { return gcd(min(a, b), max(a, b) % min(a, b)); }
    else { return a; }
}
template<class T> T lcm(T a, T b){
    return a / gcd(a, b) * b;
}
long long qpow(long long a, long long b, int MOD) {
    if (b == 0) return 1;
    long long res = 1;
    while (b) {
        if (b & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

const int MOD = 1e9 + 7;
const int maxn = 2e6;
int fac[maxn + 5];
int invfac[maxn + 5];
void init() {
    fac[0] = 1;
    for (int i = 1; i <= maxn; i++) fac[i] = 1LL * fac[i - 1] * i % MOD;
    invfac[maxn] = (int)(qpow(fac[maxn], MOD - 2, MOD));
    for (int i = maxn - 1; i >= 0; i--) invfac[i] = 1LL * invfac[i + 1] * (i + 1) % MOD;
}
int C(int n, int k) {
    assert(0 <= k && n >= k);
    int tmp = (int)(1LL * invfac[k] * invfac[n - k] % MOD);
    return (int)(1LL * fac[n] * tmp % MOD);
}

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

    LL a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a + b) {
        cout << min(a, k) << '\n';
        return 0;
    } else {
        cout << (1LL * a - (k - a - b)) << '\n';
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    int c[h][w],counth=0,countw=0;
    for (int i=0; i<n; i++){
        int a;
        scanf("%d",&a);
        for (int j=0; j<a; j++){
            if (counth%2==0){
                c[counth][countw]=i+1;
                countw++;
            } else {
                c[counth][w-countw-1]=i+1;
                countw++;
            }
            if (countw==w){
                countw=0;
                counth++;
            }

        }
    }
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if (j==w-1){
                printf("%d\n",c[i][j]);
            } else {
                printf("%d ",c[i][j]);
            }
        }
    }
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[100000];
long long sum;
int x;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i+1<n;i++){
        sum+=a[i];
        if(sum*2<a[i+1])x=i+1;
    }
    cout<<n-x<<endl;
    return 0;
}

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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

int power(int x, int n) {
	if (n < 0) return 0;
	int res = 1;
	while (n) {
		if (n % 2 == 0) res = (res % MOD * res % MOD) % MOD, n /= 2;
		else res = (res % MOD * x % MOD) % MOD, n--;
	}
	return res % MOD;
}

int d, x, y;

void extendedEuclid(int A, int B) {
	if (B == 0) {
		d = A;
		x = 1;
		y = 0;
	}
	else {
		extendedEuclid(B, A % B);
		int temp = x;
		x = y;
		y = temp - (A / B) * y;
	}
}


int modInv(int a, int m) {
	extendedEuclid(a, m);
	return (x % m + m) % m;
}

void solve() {
	int n;
	cin >> n;

	int ans = 0;
	int summ[n], diff[n];

	F0R(i, n) {
		int x, y;
		cin >> x >> y;

		summ[i] = (x + y);
		diff[i] = (x - y);
	}

	sort(ALLn(summ, n));
	sort(ALLn(diff, n));

	ans = max(summ[n - 1] - summ[0], diff[n - 1] - diff[0]);
	cout << ans;
}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

Measured memory_bytes: 6896
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace DailyCP
{
    class cc
    {
        public static void Main()
        {
            //int t =  Convert.ToInt32(Console.ReadLine());
            //for (int T = 0; T < t; T++)
            //{
            //int n = Convert.ToInt32(Console.ReadLine());
            int[] nm = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            int n = nm[0];
            int m = nm[1];
            long A = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).Sum();
            if(A > n)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(n - A);
            }            
        }
        
    }
}

Measured memory_bytes: 29024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	s <- getLine
	let
		odds = map fst $ filter snd $ zip s $ cycle [ True, False ]
		evens = map fst $ filter snd $ zip s $ cycle [ False, True ]
	putStrLn $ which "Yes" "No" $ all ( `elem` "RUD" ) odds && all ( `elem` "LUD" ) evens

Measured memory_bytes: 508
# import sys
import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    x = int(input())
    if x<30:
        print("No")
    else:
        print("Yes")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9160
n, W = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]

base = a[0][0]
s = [[] for _ in range(4)]
for w, v in a:
    s[w-base].append(v)
for i in range(4):
    s[i].sort(reverse=True)

length = [len(s[i]) for i in range(4)]
cum = [[] for _ in range(4)]
for i in range(4):
    cum[i] = [0 for _ in range(length[i]+1)]
    for j in range(length[i]):
        cum[i][j+1] = cum[i][j] + s[i][j]

ans = 0
for i in range(length[0]+1):
    for j in range(length[1]+1):
        for k in range(length[2]+1):
            for l in range(length[3]+1):
                weight = (i+j+k+l) * base + j + 2*k + 3*l
                if weight <= W:
                    ans = max(ans, cum[0][i] + cum[1][j] + cum[2][k] + cum[3][l])
print(ans)

Measured memory_bytes: 3064
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1] - 1;
    }


    DList!(Tuple!(int, int)) que;
    int bestv = 101010;
    int[] ansans;

    foreach (i; 0..N) {
        que.clear;
        que.insertBack(tuple(i, -1));

        bool[int] used;
        auto prev = new int[](N);
        prev[] = -1;

        while (!que.empty) {
            auto n = que.front[0];
            auto p = que.front[1];
            que.removeFront;
            if (n in used && n != i) continue;
            prev[n] = p;
            if (n in used && n == i) {
                int[] ans;
                for (int v = n, flag = 0; v != n || flag == 0; flag = 1) {
                    ans ~= v;
                    v = prev[v];
                }
                if (ans.length < bestv) {
                    bestv = ans.length.to!int;
                    ansans = ans.dup;
                }
                break;
            }
            used[n] = true;
            foreach (m; G[n]) {
                que.insertBack(tuple(m, n));
            }
        }
    }

    if (bestv == 101010)
        writeln(-1);
    else {
        ansans.length.writeln;
        ansans.each!(a => writeln(a + 1));
    }
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

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

const int N = 4e5 + 9, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;



int main(){
    init();

    int n, m;   cin >> n >> m;

    int sum = 0;
    for(int i = 0;i < m;i++){
        int x;  cin >> x;
        sum += x;
    }

    cout << max(n - sum, -1);

}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

template<class T>
double closest_pair(vector<pair<T, T>> a, double inf = 1e15) {
	using P = pair<T, T>;
	using Iterator = typename vector<P>::iterator;
	function<double(Iterator, ll)> recur = [&](Iterator it, ll len) {
		if (len <= 1) return inf;
		ll half = len / 2;
		T x = (it + half)->first;
		double min_d = min(recur(it, half), recur(it + half, len - half));
		inplace_merge(
			it, it + half, it + len,
			[](P lhs, P rhs) { return lhs.second < rhs.second; }
		);

		vector<P> b;
		REP(i, len) {
			if (fabs((it + i)->first - x) >= min_d) continue;
			REP(j, b.size()) {
				double dx = (it + i)->first - b[b.size() - j - 1].first;
				double dy = (it + i)->second - b[b.size() - j - 1].second;
				if (dy >= min_d) break;
				min_d = min(min_d, sqrt(dx * dx + dy * dy));
			}
			b.push_back(*(it + i));
		}

		return min_d;
	};
	sort(a.begin(), a.end());
	return recur(a.begin(), a.size());
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n; cin >> n;
	vector<pair<double, double>> a(n);
	REP(i, n) cin >> a[i].first >> a[i].second;
	cout << closest_pair(a) << endl;

	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define cut(n, Min, Max) max(min(n,Max),Min)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vi b(m);
    cin>>b;
    int ans=0;
    REP(i,n){
        int val=c;
        REP(j,m){
            int a;
            cin>>a;
            val+=a*b[j];
        }
        if(val>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  cout << 180 * (N - 2) << endl;
  return 0;
}


Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
const ll INF = 4e18;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

    vector<ll> x(N), y(N);
    REP(i, N)
    {
        cin >> x[i] >> y[i];
    }

    ll area_min = INF;

    REP(ix, N)
    {
        REP(jx, N)
        {
            if (x[ix] >= x[jx]) {
                continue;
            }

            REP(iy, N)
            {
                REP(jy, N)
                {
                    if (y[iy] >= y[jy]) {
                        continue;
                    }


                    int cnt = 0;

                    REP(k, N)
                    {
                        if (x[ix] <= x[k] && x[jx] >= x[k] && y[iy] <= y[k] && y[jy] >= y[k])
                            cnt++;
                    }

                    if (cnt >= K) {
                        ll area = (x[jx] - x[ix]) * (y[jy] - y[iy]);
                        if (area_min > area) {
                            area_min = area;
                            // cout << x[ix] << " " << x[jx] << " " << y[iy] << " " << y[jy] << endl;
                        }
                    }
                }
            }
        }
    }

    cout << area_min << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn err() {
    println!("No");
    std::process::exit(0);
}

fn main() {
    input!(s: proconio::marker::Chars, x: i32, y: i32);
    let mut seq = Vec::new();
    let mut now = 0;
    for c in s.iter().copied().chain(std::iter::once('T')) {
        match c {
            'F' => {
                now += 1;
            }
            'T' => {
                seq.push(now);
                now = 0;
            }
            _ => panic!(),
        }
    }
    let xmax = seq.chunks(2).map(|v| v[0]).sum::<i32>();
    let ymax = seq.chunks_exact(2).map(|v| v[1]).sum::<i32>();
    if xmax < x.abs() || ymax < y.abs() || (xmax - x) % 2 == 1 || (ymax - y) % 2 == 1 {
        err();
    }
    let mut sub_x = vec![false; xmax as usize + 1];
    let mut sub_y = vec![false; ymax as usize + 1];
    sub_x[0] = true;
    sub_y[0] = true;
    for d in seq.chunks(2).skip(1).map(|v| v[0] as usize) {
        for i in (0..=xmax as usize - d).rev() {
            sub_x[i + d] |= sub_x[i];
        }
    }
    for d in seq.chunks_exact(2).map(|v| v[1] as usize) {
        for i in (0..=ymax as usize - d).rev() {
            sub_y[i + d] |= sub_y[i];
        }
    }
    let dx = (xmax - x) as usize / 2;
    let dy = (ymax - y) as usize / 2;
    if !sub_x[dx] || !sub_y[dy] {
        err();
    }
    println!("Yes");
}


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

int main(){
  int n;
  cin >> n;
  pair<pair<string,int>,int> p[n];
  for(int i=0;i<n;i++){
    int tmpint;
    string tmpstr;
    cin >> tmpstr >> tmpint;
    p[i] = make_pair(make_pair(tmpstr,tmpint*-1),i); 
  }
  sort(p,p+n);
  for(int i=0;i<n;i++) cout << p[i].second+1 << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

a=ord('a')
S=list(map(lambda x:ord(x)-a,input()))
K=int(input())
ans=[]
for x in S:
    if x==0:
        ans.append('a')
    elif 26-x<=K:
        ans.append('a')
        K-=26-x
    else:
        ans.append(chr(x+a))
if K>0:
    ans[-1]=chr((ord(ans[-1])-a+K)%26+a)
print(''.join(ans))

Measured memory_bytes: 88028
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    string s,t;
    cin >> s >> t;
    cout << t << s ;
    
	return 0;
    
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
    std::fill((T *)array, (T *)(array + N), val);
}

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans = min(k, a);
    k -= min(k, a);
    k = max(k - b, 0LL);

    if (k > 0)
    {
        ans -= k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    string N;
    cin >> N;
    
    if(N[0]==N[1] && N[1]==N[2]){
        cout << "Yes" << endl;
    }else if(N[1]==N[2] && N[2]==N[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a,b,c,d; cin >> a >> b >> c >> d;
	cout << (min(b,d) - max(a,c) > 0? min (b, d) - max (a, c) : 0) << endl;
	return 0;
}

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

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

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int a=0,i,sum=0;
  char en[11];
  
  scanf("%s",en);
  
  for(i=0;i<10;i++){
    if(en[i]=='A'||en[i]=='T'||en[i]=='G'||en[i]=='C')
      a++;
    else
       a=0;
    if(sum<a)
      sum=a;
  }
 
  printf("%d\n",sum);
  return 0;
}

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

const int N = 200010;
vector<int> G[N];
vector<int> Count(N);
int n;

void dfs(int now, int pre){
    for(int i = 0; i < G[now].size(); i++){
        int to = G[now][i];
        if(to == pre) continue;
        Count[to] += Count[now];
        dfs(to, now);
    }
}

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

    int q;
    cin >> n >> q;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    while(q--){
        int p, x;
        cin >> p >> x;
        Count[p - 1] += x;
    }

    dfs(0, -1);

    for(int i = 0; i < n; i++){
        cout << Count[i] << ' ';
    }
    cout << endl;

    return 0;
}

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

int main(){

  int n;
  string s,t;

  cin >> n;
  for(;n>0;n--){
    cin >> s >> t;

    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());

    int ns = s.size(), nt = t.size();
    int nn = max(ns,nt);

    for(int i=ns;i<nn;i++) s += '0';
    for(int i=nt;i<nn;i++) t += '0';

    int c = 0;
    string ss = "";
    
    for(int i=0;i<nn;i++){
      int k = c + s[i] + t[i] - '0';

      if(k <= '9') ss += k, c = 0;
      if(k > '9') ss += k - 10, c = 1;

    }

    if(c == 1) ss += '1';

    reverse(ss.begin(),ss.end());
    if(ss.size() > 80) cout << "overflow" << endl;
    else cout << ss << endl;

  }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	int N = S.size(); 
	long long dp[4010][4010] = {}; 
	dp[0][0] = 1; 
	int A[2010] = {}, B[2010] = {};
	for(int i = 1; i <= N; i++){
		A[i] = A[i-1] + S.at(i-1) - '0'; 
		B[i] = i * 2 - A[i]; 
		if(A[i] <= B[i]){
			for(int j = A[i] + 1; j <= i; j++) dp[j][i-j] = -1; 
		}
		else if(A[i] > B[i]){
			for(int j = B[i] + 1; j <= i; j++) dp[i-j][j] = -1;
		}
	}
	for(int i = 0; i <= A[N]; i++){
		for(int j = 0; j <= B[N]; j++){
			if(dp[i][j] == -1) continue; 
			if(i > 0 && dp[i-1][j] >= 0) dp[i][j] += dp[i-1][j]; 
			if(j > 0 && dp[i][j-1] >= 0) dp[i][j] += dp[i][j-1]; 
			if(dp[i][j] >= 998244353) dp[i][j] -= 998244353; 	
		}
	}
	cout << dp[A[N]][B[N]] << endl; 
}

Measured memory_bytes: 125952
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int n,W;
    cin >> n >> W;
    vector<int> v(n);
    vector<int> w(n);
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    vector<vector<int>> ans(n+100,vector<int> (W+100));
    for(int i = 0;i < n;++i){
        for(int j = 0;j <= W;++j){
            if(j >= w[i]){
                ans[i+1][j] = max(ans[i][j-w[i]]+v[i],ans[i][j]);
            }else{
                ans[i+1][j] = ans[i][j];
            }
        }
    }
    cout << ans[n][W] << endl;

    return 0;
}



Measured memory_bytes: 10788
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}


// Main Code
void solve() {
    int h, w, n;
    cin >> h >> w >> n;
    cout << (n + max(h, w) - 1) / max(h, w) << "\n";
    return;
}


Measured memory_bytes: 3612
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));
ll arr[1000000];
int main(){
	ll n;
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	ll aaa=0;
	ll mini=1000000000000000000;
	for(int i=0;i<n-1;i++){	
		aaa+=arr[i];
		mini=min(mini,abs(sum-2*aaa));
	}
	cout<<mini<<endl;
}

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;


//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;

//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}



vi dx = {1, -1, 0,  0};
vi dy = {0, 0,  1, -1};

//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 



int main(){

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

int t,tt;
t=1;
i1(t);
if(google_contest)tt=1;

while(t--){

int n;
i1(n);

vll a(n);
f(i,0,n)i1(a[i]);

string s;
i1(s);

int size = 62;
vll basis(size,0);

bool ok = true;
for(int i=n-1;i>=0;i--){
    ll curr = a[i];

    f(j,0,size){
        if(basis[j]){
            if((curr>>j)&1ll)curr^=basis[j];
        }
    }

    if(curr){
        if(s[i]=='1'){
            ok = false;
            break;
        }else{
            f(j,0,size){
                if((curr>>j)&1ll){
                    basis[j] = curr;
                    break;
                }
            }
        }
    }
}

if(ok){
    o1(0);
}else{
    o1(1);
}

if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


Measured memory_bytes: 3596
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var s = input.ReadLine();

        var c = 0;
        for(int i=2; i<n; i++) {
            if (s[i] != 'C') continue;
            if (s[i-1] != 'B') continue;
            if (s[i-2] != 'A') continue;
            c++;
        }

        return c;
    }
}

Measured memory_bytes: 11092
local mod = 1000000007

local function bmul(x, y)
  return (x * y) % mod
end

local n = io.read("*n", "*l")
local s = io.read()
local depth = 0
local f = true
local ret = 1
for i = 1, 2 * n do
  if s:sub(i, i) == "B" then
    if depth % 2 == 0 then
      depth = depth + 1
    else
      ret = bmul(ret, depth)
      depth = depth - 1
    end
  else
    if depth % 2 == 0 then
      if depth == 0 then
        f = false
        break
      else
        ret = bmul(ret, depth)
        depth = depth - 1
      end
    else
      depth = depth + 1
    end
  end
end
if 0 ~= depth then f = false end
if f then
  for i = 1, n do
    ret = bmul(ret, i)
  end
else
  ret = 0
end
print(ret)


Measured memory_bytes: 760
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL s[25],n;

LL dp(LL l,LL r,LL sl,LL sr){
	LL ret = INF;
	if(l > r) return 0;
	for(LL i = l;i <= r;i ++){
		ret = min(ret,dp(l,i - 1,sl,sl + sr) + dp(i + 1,r,sl + sr,sr) + s[i] * (sl + sr));
	}
	return ret;
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> s[i];
	cout << dp(2,n - 1,1,1) + s[1] + s[n] << '\n';
	return 0;
}
//

Measured memory_bytes: 384
import math
h=int(input())
h_now=h
num_now=1
ans=0
for i in range(50):
    if h_now==1:
        break
    else:
        h_now=math.floor(h_now/2)
        ans+=num_now
        num_now=num_now*2

ans+=num_now
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

void post_proc(int** a, int N)
{
	if (a != NULL) {
		for (int i=0; i<N; i++) {
			if (a[i] != NULL) delete[] a[i];
		}
		delete[] a;
	}
}

int main()
{
	int W, N;
	int v[1000], w[1000];
	char dummy;
	
	for (int test_num = 1; ; test_num++) {
		cin >> W >> N;
		if (W==0) break;
		for (int i=0; i<N; i++) { cin >> v[i] >> dummy >> w[i]; }
		
		int **dp;
		try {
			dp = new int*[N];
		} catch (bad_alloc) {
			//cout << "bad_alloc : dp" << endl;
			post_proc(dp, N); return 1;
		}
		
		for (int i=0; i<N; i++) {
			try {
				dp[i] = new int[W+1];
			} catch (bad_alloc) {
				//cout << "bad_alloc : dp[" << i << "]" << endl;
				post_proc(dp, N); return 1;
			}
		}
		
		for (int j=0; j<=W; j++) dp[0][j] = -1;
		dp[0][0] = 0;
		dp[0][w[0]] = v[0];
		
		int max_val = v[0];
		int weight_of_max_val = w[0];
		
		for (int i=1; i<N; i++) {
			for (int j=W; j>=0; j--) {
				dp[i][j] = dp[i-1][j];
				if (max_val <= dp[i][j]) {
					max_val = dp[i][j]; weight_of_max_val = j;
				}
				if ( j-w[i] >= 0 && dp[i-1][j-w[i]] >= 0 ) {
					if ( dp[i][j] < dp[i-1][j-w[i]] + v[i] ) {
						dp[i][j] = dp[i-1][j-w[i]] + v[i];
						if (max_val <= dp[i][j]) {
							max_val = dp[i][j]; weight_of_max_val = j;
						}
					}
				}
			}
		}
		
		cout << "Case " << test_num << ":" << endl;
		cout << max_val << endl << weight_of_max_val << endl;
		
		post_proc(dp, N);
	}
	
	return 0;
}

Measured memory_bytes: 6712
import java.io.*;
import java.util.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A >= 10 || B >= 10) {
			System.out.println(-1);
		} else {
			System.out.println(A * B);
		}

	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 23892
#include <iostream>

int main(void)
{
	int a,b;
	std::cin >> a >> b ;
	
	if ( a < b ){
		std::cout  << "a < b" << std::endl;
	}
	else if( a > b ){
		std::cout << "a > b" << std::endl;
	}
	else if( a == b ){
		std::cout << "a == b" << std::endl;
	}
	else{
		//??????????????\?????? 
	}

	return 0;
}

Measured memory_bytes: 1160
s = input()
n = len(s) - 1
ans = 0

for i in range(2**n):
    num = []
    bi = format(i, '0'+str(n)+'b')
    for j in range(n):
        num.append(s[j])
        if bi[j] == '1':
            num.append('+')
    num.append(s[-1])
    j_num = ''.join(num)
    ans += eval(j_num)

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int n;
    char s1[60], s2[60];
    cin >> n;
    cin >> s1;
    cin >> s2;
    int f = 0;
    long long ans = 1;
    imfor(i, n) {
        if (f == 0) {
            if (s1[i] == s2[i]) {
                f = 1;
                ans = ans * 3;
            }
            else {
                f = 2;
                ans = ans * 6;
                i++;
            }
        }
        else if (f == 1) {
            if (s1[i] == s2[i]) {
                f = 1;
                ans = (ans * 2) % 1000000007;
            }
            else {
                f = 2;
                ans = (ans * 2) % 1000000007;
                i++;
            }
        }
        else {
            if (s1[i] == s2[i]) {
                f = 1;
                ans = (ans * 1) % 1000000007;
            }
            else {
                f = 2;
                ans = (ans * 3) % 1000000007;
                i++;
            }
        }
    }
    cout << ans << endl;
}

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

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

int main() {
	map<string, int> mp;
	string s, t;
	cin >> s >> t;
	cin >> mp[s] >> mp[t];
	string u;
	cin >> u;
	--mp[u];
	cout << mp[s] << " " << mp[t] << endl;
	return 0;
}



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

using namespace std;

int main() {
	vector<pair<int, char>> *vx = new vector<pair<int, char>>[200001];
	vector<pair<int, char>> *vx_puls_y = new vector<pair<int,char>>[400001];
	int n;
	cin >> n;
	int* x = new int[n];
	int* y = new int[n];
	int min_collision_time = 1e9;
	char* muki = new char[n];
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i] >> muki[i];	
	}
	for (int rot = 0;rot < 4;rot++) {
		vx = new vector<pair<int, char>>[200001];
		vx_puls_y = new vector<pair<int, char>>[400001];
		for (int i = 0;i < n;i++) {
			int nx = 200000 - y[i];
			int ny = x[i];
			switch (muki[i])
			{
			case 'U':
				muki[i] = 'L';
				break;
			case 'R':
				muki[i] = 'U';
				break;
			case 'D':
				muki[i] = 'R';
				break;
			case 'L':
				muki[i] = 'D';
				break;
			default:
				break;
			}
			x[i] = nx;
			y[i] = ny;
			if (muki[i] == 'U' || muki[i] == 'D') {
				vx[x[i]].push_back(make_pair(y[i], muki[i]));
			}
			if (muki[i] == 'U' || muki[i] == 'R') {
				vx_puls_y[x[i] + y[i]].push_back(make_pair(y[i], muki[i]));
			}
			
		}
		for (int i = 0;i < 200001;i++) {
			sort(vx[i].begin(), vx[i].end());
			for (int j = 0;j < (signed)vx[i].size() - 1;j++) {
				if (vx[i][j].second == 'U' && vx[i][j + 1].second == 'D') {
					min_collision_time = min(min_collision_time, (vx[i][j + 1].first - vx[i][j].first) * 5);
				}
			}
		}
		for (int i = 0;i < 400001;i++) {
			sort(vx_puls_y[i].begin(), vx_puls_y[i].end());
			for (int j = 0;j < (signed)vx_puls_y[i].size() - 1;j++) {
				if (vx_puls_y[i][j].second == 'U' && vx_puls_y[i][j + 1].second == 'R') {
					min_collision_time = min(min_collision_time, (vx_puls_y[i][j + 1].first - vx_puls_y[i][j].first) * 10);
				}
			}
		}
	}
	if (min_collision_time == 1e9) {
		cout << "SAFE\n";
	}
	else {
		cout << min_collision_time << endl;
	}
}

Measured memory_bytes: 85696
#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 pair<ll, ll> P;

int main() {
  ll N;
  string ans;

  cin >> N;

  int parity = 0;
  do {
    if (abs(N) % 2 == 1) {
      ans = '1' + ans;
      if (parity == 0)
        N--;
      else
        N++;
    } else {
      ans = '0' + ans;
    }
    N /= 2;
    parity = 1 - parity;
  } while (N != 0);

  cout << ans << 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 = Integer.parseInt(sc.next());
        ArrayList<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            data.add(sc.nextInt());
        }
        sc.close();
        
        int min = data.get(0);
        int max = data.get(0);
        int ans = Integer.MIN_VALUE;
        int min_profit = Integer.MIN_VALUE;
        int count = 0;
        for (int num : data) {
            if (min > num) {
                min = num;

                if (min_profit <  min - max) {
                    min_profit = min - max;
                    max = min;
                } else {
                    max = Integer.MIN_VALUE;
                }
            } else if (count > 0 && max <= num) {
                max = num;
                if (ans < max - min)
                    ans = max - min;
            }
            count++;
       }
        System.out.println(ans > min_profit ? ans : min_profit);
    }
}


Measured memory_bytes: 105180