akhauriyash/Code-Regression huggingface dataset:
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();

let [X, Y, A, B, C] = reader.readInts();

let p: number[] = reader.readInts()
let q: number[] = reader.readInts()
let r: number[] = reader.readInts()

let decreasingOrder = (a: number, b: number) => b-a;
let increasingOrder = (a: number, b: number) => a-b;

p.sort(decreasingOrder)
q.sort(decreasingOrder)
r.sort(increasingOrder)

while (p.length > X)
    p.pop();

while (q.length > Y)
    q.pop();

let pq: number[] = [];
let i = 0, j = 0;

// Merge arrays
for(; i < X; i++) {
    while (j < Y && q[j] >= p[i]) {
        pq.push(q[j++]);
    }
    pq.push(p[i]);
}

while (j < Y) {
    pq.push(q[j++]);
}

i = pq.length-1;

while (i >= 0 && r.length > 0) {
    if (pq[i] >= r[r.length-1]) {
        r.pop();
    } else {
        pq[i--] = r.pop();
    }
}

console.log(pq.reduce((prev, current) => prev+current, 0));


Measured memory_bytes: 61592
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl b(n-1);
    vl a(n);
    rep(i,n-1) cin >> b[i];
    for(ll i=n-2; i>=0; i--){
        if(i==n-2) a[i+1] = b[i];
        else a[i+1] = min(b[i+1],b[i]);
    }
    a[0] = b[0];
    ll sum = 0;
    rep(i,n) sum += a[i];
    cout << sum << endl;
    //rep(i,n) cout << a[i] << " ";
}

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

using namespace std;
#define ll long long

int main(){
    ll N;
    int a[4];
    int cnt=0;
    ll L[87];
    L[0] = 2;
    L[1] = 1;
    cin >> N;
    for(int i = 2; i <= N; i++){
        L[i]= L[i-1]+ L[i-2];
    }   
    cout << L[N] << endl;
} 

Measured memory_bytes: 256
n = int(input())
l = []
r = []
for _ in range(n):
  a, b = map(int, input().split())
  l.append(a)
  r.append(b)
before_sa = 0
for i in range(1, n+1):
  a, b = l[-i], r[-i]
  a += before_sa
  if a % b == 0:
    continue
  else:
    sa = (a//b + 1) * b - a
    before_sa += sa
print(before_sa)


Measured memory_bytes: 11060
#include<stdio.h>

int main()
{
    long long int n,k,i;
    scanf("%lld %lld",&k,&n);
    long long int house[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&house[i]);
    }
long long int max = 0;
    for(i=1;i<n;i++)
    {
        if((house[i]-house[i-1])>max)
        {
            max = house[i]-house[i-1];
        }
    }

    if(k+ house[0]-house[n-1]>max)
    {
        max = k + house[0] - house[n-1];
    }

    printf("%lld",k-max);
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define int long long
#define MOD 1e9
#define MAX LONG_MAX
#define MIN LONG_MIN
#define pb push_back

using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	int n,sum=0;
	cin>>n;

	std::vector<int> arr(n);
	unordered_map<int,int> map;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		map[arr[i]]++;
		sum+=arr[i];
	}

	int k;
	cin>>k;
	while(k--){
		int a,b;
		cin>>a>>b;
		int x=map[a];
		sum=sum-(x*a)+(x*b);
		map.erase(a);
		map[b]+=x;
		cout<<sum<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 7340
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,c,x,y,n,i;
	cin>>a>>b;
	c=b;
	n=1;
	for(i=0;i<3;i++){
		c=c/10;
		n=n*10;
		if(c==0) break;
	}
	a=a*n+b;
	y=0;
	while(1){
		y=y+1;
		x=y*y;
		if(x==a){
			cout<<"Yes"<<endl;
			break;
		}
		if(x>=100100){
			cout<<"No"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
const int INTINF = 2147483647;
using namespace std;


typedef pair<int, int> P;
struct Edge {
	int to;
	int cost;
	Edge(int t, int c) {
		to = t;
		cost = c;
	}
};

class Dijkstra {
private:
	vector<vector<Edge> > vec;
	priority_queue<P, vector<P>, greater<P> > que;
	vector<int> distances;

	void Solve() {
		while (!this->que.empty()) {
			P p = que.top(); que.pop();
			// 現在参照するノード
			int v = p.second;
			if (this->distances[v] < p.first) continue;
			for (int i = 0; i < this->vec[v].size(); ++i) {
				Edge e = this->vec[v][i];
				if (this->distances[e.to] > this->distances[v] + e.cost) {
					this->distances[e.to] = this->distances[v] + e.cost;
					que.push(P(this->distances[e.to], e.to));
				}
			}
		}
	}

public:
	Dijkstra(vector<vector<Edge> > &v, int start = 0) : vec(v), distances(v.size()) {
		for (int i = 0; i < this->distances.size(); ++i) this->distances[i] = INTINF;
		this->distances[start] = 0;
		this->que.push(P(0, start));
		this->Solve();
	}

	int GetDistances(int dst) {
		return this->distances[dst];
	}
};

int main() {
	int v, e, r;
	cin >> v >> e >> r;
	vector<vector<Edge> > vec(v, vector<Edge>());
	for (int i = 0; i < e; ++i) {
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);
		vec[s].push_back(Edge(t, d));
	}


	Dijkstra d(vec,r);
	for (int i = 0; i < v; ++i) {
		int ddd = d.GetDistances(i);
		if (ddd == INTINF) cout << "INF" << endl;
		else cout << ddd << endl;
	}
}


Measured memory_bytes: 20348
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BPostalCode {
public:
    void solve(istream& cin, ostream& cout) {
        ll a, b; string s;
        cin >> a >> b >> s;
        int n = s.length();
        bool flag = false;
        if(s[a] != '-') flag = true;
        for(int i=0; i<n; i++) {
            if(i == a) continue;
            if(s[i] < '0' || s[i] > '9') flag = true;
        }
        if(flag) cout << "No\n";
        else cout << "Yes\n";
    }
};


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


Measured memory_bytes: 256
while 1:
    n = input()
    if n==0: break
    k = map(int, raw_input().split())
    f = False
    for i in xrange(n):
        if k[i]>1:
            f = True; break;
    if f:
        print len(k)-k.count(0)+1
    else:
        print "NA"

Measured memory_bytes: 5524
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();

        int result = Math.min(a, k);
        k -= a + b;
        if (k > 0) {
            result -= k;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35520
N,M=map(int,input().split())
from collections import defaultdict,deque
OUT=defaultdict(set)
cnt=defaultdict(int)
for i in range(N+M-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    OUT[a]|={b}
    cnt[b]+=1
check=deque([i for i in range(N) if cnt[i]==0])
ans=[N]*N
ans[check[0]]=0
while len(check)>0:
    now=check.popleft()
    for nex in OUT[now]:
        cnt[nex]-=1
        if cnt[nex]==0:
            ans[nex]=now+1
            check.append(nex)
for i in range(N):
    print(ans[i])

Measured memory_bytes: 53164
# -*- coding: utf-8 -*-
import itertools
n = int(input())
i_list = list(map(int, input().split()))
answer = 0

for i in itertools.combinations(i_list, 3):
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[2] + i[0] > i[1] and i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        answer += 1
print(answer)

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

fn main() {
    let a = read();
    let b = read();
    let c = read();

	let mut ans = 0;
	if a == b {
		ans = c;
	} else if a == c {
		ans = b;
	} else {
		ans = a;
	}
    println!("{}", ans);
}

fn read() -> i32 {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int a[1000]={1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000};
int main()
{
	int x;
	cin >> x;
	for(int i=1;;i++)
	{
		if(x==1000)
		{
			printf("1000");
			break;
		}
		if(a[i]>x)
		{
			cout << a[i-1];
			break;
		}
	}
	
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
	out << '(' << a.fi << ", " << a.se << ')';
	return out;
}
}


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

void addWall(vector<string>& s, int& H, int& W, char wall = '#') {
	s.insert(s.begin(), string(W, wall));
	s.push_back(string(W, wall));
	for (auto& t : s) t = wall + t + wall;
	H = s.size();
	W = s[0].size();
}

int main() {
	int H, W;
	while (cin >> H >> W, H, W) {
		vector<string> s(H);
		rep(i, H) cin >> s[i];
		pii UL{1, 1}, UR{1, W}, DR{H, W}, DL{H, 1}; //(y, x)
		addWall(s, H, W);
		{
			// pre_calc
			vector<pii> path;
			set<pii> used;
			pii now = UL, nxt;
			path.pb(UL);
			used.insert(UL);
			int dir = 1;
			while (1) {
				nxt = make_pair(-1, -1);
				rep(i, 4) {
					int nx = now.se + dx[(dir + i + 3) % 4], ny = now.fi + dy[(dir + i + 3) % 4];
					if (s[ny][nx] == '#') continue;
					nxt = make_pair(ny, nx);
					(dir += i + 3) %= 4;
					break;
				}
				if(nxt == make_pair(-1, -1)) break;
				if (nxt == UL) break;
				if (used.count(nxt)) {
					while (path.back() != nxt) {
						pii p = path.back();
						s[p.fi][p.se] = '#';
						used.erase(p);
						path.pop_back();
					}
				}
				used.insert(nxt);
				path.pb(nxt);
				now = nxt;
			}
		}
		LINE;
		int dir = 1;
		set<pii> used;
		pii now = UL, nxt;
		used.insert(now);
		while (1) {
			nxt = now;
			rep(i, 4) {
				int nx = now.se + dx[(dir + i + 3) % 4], ny = now.fi + dy[(dir + i + 3) % 4];
				if (s[ny][nx] == '#') continue;
				nxt = make_pair(ny, nx);
				(dir += i + 3) %= 4;
				break;
			}
			if (nxt == now || used.count(nxt)) break;
			used.insert(nxt);
			now = nxt;
		}
		bool f = nxt == UL;
		f &= used.count(UL);
		f &= used.count(UR);
		f &= used.count(DR);
		f &= used.count(DL);
		rep(i, H) dump(s[i]);
		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC114A
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  if(n==3||n==5||n==7) printf("YES");
  else printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    ll sum = 0;
    REP(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    ll cnt = 0;
    REP(i,n){
        if(sum <= a[i] * 4 * m){
            cnt++;
        }
    }

    if(cnt >= m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from sys import exit

s = input().lower()
t = input().lower()
N = len(s)

d = {}
for i in range(ord('a'), ord('z')+1):
    d[chr(i)] = -1

for i in range(N):
    if d[s[i]]==-1:
        d[s[i]] = t[i]
    else:
        if t[i] == d[s[i]]:
            pass
        else:
            print('No')
            exit()


k  = []
for i in d:
    if d[i]==-1:
        pass
    else:
        if d[i] in k:
            print('No')
            exit()
        k.append(d[i])

print('Yes')


Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, q;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s >> q;
  vector<set<int>> vs(30);

  REP(i, s.length()) {
    vs[s[i] - 'a'].insert(i + 1);
  }

  REP(i, q) {
    int t;
    cin >> t;
    if(t == 1) {
      int p;
      char c;
      cin >> p >> c;
      int pp = s[p - 1] - 'a';
      s[p - 1] = c;

      vs[pp].erase(p);
      vs[c - 'a'].insert(p);
    } else {
      int l, r;
      cin >> l >> r;

      int c = 0;
      REP(j, 26) {
        auto lit = vs[j].lower_bound(l);
        auto rit = vs[j].upper_bound(r);

        if(lit != vs[j].end() && lit != rit) {
          c++;
        }
      }

      cout << c << endl;
    }
  }
}


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

int main() {
    int n;
    int count = 0;
    cin >> n;
    vector<int> l(n,0), r(n,0);
    for(int i = 0; i < n; i++){
        cin >> l[i] >> r[i];
        count = count + (r[i] - l[i] + 1);
    }
    cout << count << endl;
}

Measured memory_bytes: 256
a=[int(x) for x in input().split()]
#(a)
#b=[a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3]]
print(max(a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3]))

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

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

      
	  for(int i = 0 ; i <= n ; i +=7 )
	  {
           int rem = n - i ;
          // cout<<rem <<" "<<i<<endl;
           if(rem % 4  == 0 )
           {
           	cout<<"Yes"<<endl;
           	return 0 ;
           }
	  }

	  cout<<"No"<<endl;
}

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

using namespace std;


int main(){
    ios_base::sync_with_stdio(0);
    int n;cin>>n;
    int ma = 0;
    int inx = -1;
    for(int i = 1;i <= n;i++) {
        int x;cin>>x;
        if(abs(x) > abs(ma)) {
            ma = x;
            inx = i;
        }
    }
    if(inx == -1) cout<<0<<endl;
    else {
        cout<<2*n-1<<endl;
        for(int i = 1;i <= n;i++) {
            cout<<inx<<' '<<i<<endl;
        }
        if(ma > 0) {
            for(int i = 1;i < n;i++) {
                cout<<i<<' '<<i+1<<endl;
            }
        } else {
            for(int i = n;i > 1;i--) {
                cout<<i<<' '<<i-1<<endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int a1,a2;
    scanf("%d%d",&a1,&a2);
    printf("%d %d %f\n",a1/a2,a1%a2,(double)a1/a2);
    return 0;
}




Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[lim] = {};

int main()
{
	int i,j,n,W,w[lim],v[lim];
	cin>>n>>W;
	for(i=1; i<=n; i++) cin>>w[i]>>v[i];
	for(i=1; i<lim; i++) dp[i] = 1e18;
	for(i=1; i<=n; i++)
		for(j=lim-1; j>=v[i]; j--)
			dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
	
	for(i=lim-1; i; i--) if(dp[i] <= W) break;
	cout<<i;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define NIL -1

typedef struct{
  int l;
  int r;
  short put;
} Node;

Node *T;
short *P,*I;
int n;

void Postorder(int u,short a){  
  if(T[u].l!=NIL) Postorder(T[u].l,0);
  if(T[u].r!=NIL) Postorder(T[u].r,0);
  
  printf("%d",u);
  if(a!=NIL)printf(" ");
}

void reverse(int root,int p){
  int i,j,u; //i=P,j=I

  //printf("root=%d,p=%d,n=%d || ",root,p,n);
  //for(i=0;i<n;i++) printf("P[i]=%d,P[i].put=%hd ",P[i],T[P[i]].put);
  
    for(i=root;i<n;i++){
      T[ P[i] ].put=1;
      if(P[i]==I[p]) break;
      T[ P[i] ].l=P[i+1];
    }

    //printf(" i=%d\n",i);

  if(i!=n-1){
    for(j=p ;j<n; j++){
    
      if(T[ I[j] ].put == NIL){
	T[ I[j-1] ].r = P[i+1];
	reverse(i+1,j);
	return;	
      }
      
    }
  }
  
}
    

int main(){
  int i,j,a=0,u;  

  scanf("%d",&n);

  P=(short *)malloc(sizeof(short) * n);
  I=(short *)malloc(sizeof(short) * n);

  for(i=0;i<n;i++) scanf("%hd",&P[i]);
  for(i=0;i<n;i++){
    scanf("%hd",&I[i]);
    if(I[i]>a) a=I[i];
  }

  T=(Node *)malloc(sizeof(Node) * a);
  for(i=0;i<n;i++) T[ P[i] ].l = T[ P[i] ].r = T[ P[i] ].put = NIL;

  reverse(0,0);

  //for(i=0;i<n;i++) printf("i=%d,P[i]=%hd,T[ P[i] ].l=%d,T[ P[i] ].r=%d\n",i,P[i],T[P[i]].l,T[P[i]].r);

  Postorder(P[0],NIL);  
  printf("\n"); 

  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, w;
    cin >> n>> w;
    int weight[n+1];
    long int value[n+1];
    long int dp[n+1][w+1];
    weight[0] = 0;
    value[0]=0;
    for(int i=1; i<=n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    for(int i=0; i<=n ; i++)
    {
        for(int j=0; j<=w; j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(weight[i] > j)  //if weight is exceding maximum allowable weight
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], value[i] + dp[i-1][j-weight[i]]);
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = Math.max(a, Math.max(b, c));

		if ((max - a + max - b + max - c) % 2 == 0) {
			System.out.println((max - a + max - b + max - c) / 2);
		} else {
			System.out.println((max - a + max - b + max - c) / 2 + (max - a + max - b + max - c) % 2 + 1);
		}

		sc.close();

	}

}

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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N;
ll a[400], sum[401];
ll dp[401][401];

ll calcdp(ll l, ll r) {
    if(r - l < 1) return 0;
    ll &res = dp[l][r];
    if(res) return res;
    if(r - l == 1) return res = a[l] + a[l + 1];
    res = LINF;
    FOR(i, l, r) {
        res = min(res, calcdp(l, i) + calcdp(i + 1, r) + sum[r + 1] - sum[l]);
    }
    return res;
}

signed main() {
    cin >> N;
    REP(i, N) cin >> a[i];
    REP(i, N) sum[i + 1] += sum[i] + a[i];
    cout << calcdp(0, N - 1) << "\n";
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    if (N <= M / 2) {
        ans += N;
        M -= N * 2;
        ans += M / 4;
    }
    else {
        ans += M / 2;
    }

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

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        long N = sc.nextLong();
        long M = sc.nextLong();
 
        long ans1 = Math.min(N, M / 2);
 
        long ans2 = 0;
        if (M - 2 * ans1 > 0) {
            ans2 = (M - 2 * ans1) / 4;
        }
 
        _out.println(ans1 + ans2);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

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

	int K, T;
	cin >> K >> T;
	vector<int> A(T);
	for(int i = 0; i < T; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	int M = A.back();
	int rem = K - M;
	int ans = max(0, M - 1 - rem);

	cout << ans << endl;
}

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


#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

const int MAX=200;

int H,W;
int A[MAX][MAX];
int acc[MAX][MAX];
int dpV[MAX][MAX][MAX],dpH[MAX][MAX][MAX];

void calc(){
    rep(l,W)for(int r=l+1;r<=W;r++){
        for(int i=0;i<H;i++){
            dpV[l][r][i]=dpV[l][r][dpV[l][r][i]];
        }
    }

    rep(l,H)for(int r=l+1;r<=H;r++){
        for(int i=0;i<W;i++){
            dpH[l][r][i]=dpH[l][r][dpH[l][r][i]];
        }
    }

    rep(l,W)for(int r=l+1;r<=W;r++){
        int cur=H;
        for(int i=H-1;i>=0;i--){
            while(i<cur&&dpH[i][cur][l]<r)cur--;
            chmax(dpV[l][r][i],cur);
        }
    }

    rep(l,H)for(int r=l+1;r<=H;r++){
        int cur=W;
        for(int i=W-1;i>=0;i--){
            while(i<cur&&dpV[i][cur][l]<r)cur--;
            chmax(dpH[l][r][i],cur);
        }
    }
}

signed main(){
    cin>>H>>W;
    rep(i,H){
        string s;cin>>s;
        rep(j,W)A[i][j]=s[j]=='#';
    }

    rep(i,H)rep(j,W)acc[i][j+1]=acc[i][j]+A[i][j];
    rep(l,W)for(int r=l+1;r<=W;r++)for(int i=0;i<=H;i++)dpV[l][r][i]=i;
    rep(l,W)for(int r=l+1;r<=W;r++){
        for(int i=H-1;i>=0;i--){
            if(acc[i][r]-acc[i][l]==0||acc[i][r]-acc[i][l]==r-l){
                dpV[l][r][i]=i+1;
                if(i+1<H&&acc[i+1][r]-acc[i+1][l]==acc[i][r]-acc[i][l])dpV[l][r][i]=dpV[l][r][i+1];
            }
            else{
                dpV[l][r][i]=i;
            }
        }
    }

    rep(l,H)for(int r=l+1;r<=H;r++)for(int i=0;i<=W;i++)dpH[l][r][i]=i;
    memset(acc,0,sizeof(acc));
    rep(i,H)rep(j,W)acc[i+1][j]=acc[i][j]+A[i][j];
    rep(l,H)for(int r=l+1;r<=H;r++)dpH[l][r][W]=W;
    rep(l,H)for(int r=l+1;r<=H;r++){
        for(int i=W-1;i>=0;i--){
            if(acc[r][i]-acc[l][i]==0||acc[r][i]-acc[l][i]==r-l){
                dpH[l][r][i]=i+1;
                if(i+1<W&&acc[r][i+1]-acc[l][i+1]==acc[r][i]-acc[l][i])dpH[l][r][i]=dpH[l][r][i+1];
            }
            else{
                dpH[l][r][i]=i;
            }
        }
    }

    for(int t=0;t<20;t++){
        if(dpV[0][W][0]==H){
            cout<<t<<endl;
            return 0;
        }

        calc();
    }
    return 0;
}

Measured memory_bytes: 61824
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 3e3+7;
const ll inf = 1e18+7;
ld prob[MAX],ans=0;
ld dp[MAX][MAX];
int main() {
  fastio;
  ll n;
  cin>>n;
  f(i,1,n+1) cin>>prob[i];
  
  dp[1][0] = 1.0 - prob[1];

  f(i,2,n+1) dp[i][0] = dp[i-1][0]*(1.0-prob[i]);

  dp[1][1] = prob[1];

  f(i,2,n+1) dp[i][i] = dp[i-1][i-1]*prob[i];

  f(i,1,n+1){
    f(j,1,i) {
      dp[i][j] = dp[i-1][j]*(1.0 - prob[i]) + dp[i-1][j-1]*prob[i];
    }
  }

  f(i,n/2 + 1,n+1) ans += dp[n][i];
  cout<<fixed<<setprecision(10)<<ans;
  return 0; 
}

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

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> costs(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        int tmp;
        cin >> tmp;
        costs[tmp] = 1;
    }

    int forward = 0;
    for (int i = x; i <= n; ++i)
        forward += costs[i];

    int backward = 0;
    for (int i = x; i >= 0; --i)
        backward += costs[i];

    cout << min(forward, backward) << '\n';
}


Measured memory_bytes: 256
N = int(input())

nums = list(range(1, N+1))
factors = []
for i, n in enumerate(nums):
    if n > 1:
        count = 0
        for j in range(i, len(nums)):
            while nums[j] % n == 0:
                nums[j] //= n
                count += 1
        factors.append((n, count))

f74 = len([True for n, k in factors if k >= 74])
f24 = len([True for n, k in factors if k >= 24])
f14 = len([True for n, k in factors if k >= 14])
f4 = len([True for n, k in factors if k >= 4])
f2 = len([True for n, k in factors if k >= 2])
print(f74 + f24 * (f2 - 1) + f14 * (f4 - 1) + f4 * (f4 - 1) // 2 * (f2 - 2))


Measured memory_bytes: 3064
#include <iostream>
#include <complex>

using namespace std;

bool isPrime(int n) {
  if (n == 2) {
    return true;
  }
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

bool like2017(int n) {
  if (n == 2017) {
    return true;
  }
  if (n % 2 == 0) {
    return false;
  }
  if (!isPrime(n)) {
    return false;
  }
  if (!isPrime((n+1)/2)) {
    return false;
  }
  return true;
}

int main() {
  int Q;
  int l[100010], r[1000010], s[100010];
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
  }
  // 累積和s[i]を求める
  // s[i] = 0からiまでの間で、2017に似た奇数の個数
  s[0] = 0;
  for (int i = 2; i < 100005; i++) {
    s[i] = s[i-1];
    if (like2017(i)) {
      s[i]++;
    }
    // cout << "i:" << i << ", s[i]:" << s[i] << endl;
  }

  for (int i = 0; i < Q; i++) {
    // cout << "s[r[i]]:" << s[r[i]] << ", s[l[i]]:" << s[l[i]] << endl;
    cout << s[r[i]] - s[l[i]-1] << endl;
  }

}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(void) {
	int n; cin >> n;
	string str;
	unordered_map<string, ll> mp;
	rep(i, n) {
		cin >> str;
		sort(ALL(str));
		mp[str]++;
	}
	ll ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans += it->second * (it->second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10660
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	sum := make([]int, n)
	ans := 0
	for i := range sum {
		a, b := scanInt(), scanInt()
		sum[i] = a + b
		ans += -b
	}
	sort.Sort(sort.Reverse(sort.IntSlice(sum)))

	for i := 0; i < n; i += 2 {
		ans += sum[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4608
using System;

namespace ABC070_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = sss[0];
            var b = sss[1];
            var c = sss[2];
            var d = sss[3];
            var ans = 0;

            var rele = Math.Min(b, d);
            var push = Math.Max(a, c);

            Console.WriteLine(Math.Max(ans, rele - push));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    ll k;
    cin >> s >> k;
//    ll cnt = 0;
//    char ans;
//    for (int i = 0; cnt < k; i++) {
//        cnt += (s[i] - '0') * 5000000000000000;
//        ans = s[i];
//    }
//    cout << ans << endl;
    char ans = '1';
    for (int i = 0; i < s.length(); i++) {
        if (i + 1 == k) {
            ans = s[i];
            break;
        }
        if (s[i] != '1') {
            ans = s[i];
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import Counter

def main():
    N = int(input())
    D = list(map(int, input().split()))
    D.append(0)
    D = Counter(D)
    for i in range(13):
        if (i==0 or i==12) and D[i]==2:
            print(0)
            exit()
        elif D[i]>=3:
            print(0)
            exit()
    ret = 0
    for i in range(2**11):
        l = [0,24]
        if D[12]==1:
            l.append(12)
        for j in range(1,12):
            if D[j]==1:
                if i>>j & 1:
                    l.append(24 - j)
                else:
                    l.append(j)
            elif D[j]==2:
                l.append(24 - j)
                l.append(j)
        l.sort()
        mi = 24
        for i in range(1,len(l)):
            mi = min(mi, l[i]-l[i-1])
#        print(l,mi)
        ret = max(ret, mi)
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9464
import sys

p = [0] * 51
v = 0
for i in range(19):
    t = (i+3)*(i+2)*(i+1)//6
    v = v + 2 * (i-8) * (i-9) if i > 9 else 0
    p[i] = t - v
    p[36-i] = p[i]

for i in sys.stdin:
    print(p[int(i)])

Measured memory_bytes: 7604
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

N, K = [int(x) for x in stdin.readline().rstrip().split()]
V = list(map(int,stdin.readline().rstrip().split()))

getV_num = min(N, K)

ans = 0

for i in range(getV_num+1):
    toru = i
    sute = K-i

    #print(toru)
    #print(sute)
    
    for j in range(toru+1):
        leftn = j
        rightn = (toru - j)

        data = []


        for k in range(leftn):
            data.append(V[k])

        for k in range(rightn):
            data.append(V[N-1-k])

        data.sort()
        for _ in range(sute):
            if data:
                if data[0] < 0:
                    del data[0]
                else:
                    break
            else:
                break

        ans = max(ans, sum(data))

print(ans)


Measured memory_bytes: 67432
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; vl num(n);
  
  for(ll i=1; i*i <= n; i++){
    for(ll j=1; j*j <= n; j++){
      for(ll k=1; k*k <= n; k++){
        ll x = i*i+j*j+k*k+i*j+j*k+k*i-1;
        if(x < n) num[x]++;
      }
    }
  }
  
  for(ll x : num){
    cout << x << endl;
  }
  
  
}

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

int main ()
{
    int num1 , num2  , res = 0 ;

    cin >> num1 >> num2 ;

    if (num1 >= 10 || num2 >= 10)
    {
        res  = -1 ;
    }
    else
    {
        res = num1 * num2 ;
    }

    cout << res << endl ;

    return 0 ;
}


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

int main() {
	vector<vector<int>> c(3, vector<int> (3, 0));
	for (int i=0; i<3; i++)
		for (int j=0; j<3; j++)
			cin >>c.at(i).at(j);
	bool Ok=true;
	for (int i=0; i<2; i++)
		for (int j=0; j<2; j++) 
			if (c.at(i).at(j)+c.at(i+1).at(j+1)!=c.at(i+1).at(j)+c.at(i).at(j+1))
				Ok=false;
	if (Ok)
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y, long long int mod = 1000000007){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}
using namespace std;

int maxPath(vector<vector<int>>& graph, int* dp, int sv) {
    
    if(dp[sv] != -1)
        return dp[sv];
    
    
    int currMax = 0;
    for(int ei : graph[sv]) {
        //cout << " of " << ei << endl;
        currMax = max(currMax, 1 + maxPath(graph, dp, ei));
    }
    
    dp[sv] = currMax;
    // cout << sv << endl;    
    // for(int i = 1; i < graph.size(); i++) {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    return currMax;
}

int main() {
    fastio;
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n + 1);
    
    int dp[n + 1];
    vector<int> starts;
    memset(dp, -1, sizeof(dp));
    while(m--) {
        int x, y;
        cin >> x >> y;
        starts.pb(x);
        graph[x].pb(y);
    }
    // for(int i = 1; i <= n; i++) {
    //     for(int j : graph[i]) {
    //         cout << j << " ";
    //     }
    //     cout << endl;
    // }
    
    
    // for(int i = 1; i <= n; i++) {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    int ans = 0;
    for(int i : starts) {
        //cout << dp[i] << endl;
        ans = max(ans, maxPath(graph, dp, i));
    }
    
    cout << ans << endl;
    //cout << calls << endl;
}

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

typedef pair<int, pair<int, int> > cube;

int main() {
    int n, h;
    while (cin >> n >> h, n|h) {
        set<cube> cs;
        for (int i = 0; i < h; i++) {
            string p;
            int a, b;
            cin >> p >> a >> b;
            for (int i = 1; i <= n; i++) {
                cube c;
                if (p == "xy") {
                    c = make_pair(a, make_pair(b, i));
                } else if (p == "xz") {
                    c = make_pair(a, make_pair(i, b));
                } else if (p == "yz") {
                    c = make_pair(i, make_pair(a, b));
                }
                cs.insert(c);
            }
        }
        cout << n * n * n - cs.size() << endl;
    }
}

Measured memory_bytes: 4332
N = int(input())
T, A = list(map(int, input().split()))
tmp = list(map(int, input().split()))
H = {}
for i in range(len(tmp)):
    H[i] = tmp[i]

#print(sorted(H.items(), key=lambda x: x[1]))
minT = 1e10
ans = 0
for i,h in sorted(H.items(), key=lambda x: x[1]):
    t = T - h*0.006
    #print(i+1, t)
    if abs(t - A)<minT:
        minT = abs(t - A)
        ans = i+1
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
    int w,h,x,y,r;
	scanf("%d",&w);
	scanf("%d",&h);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);
	if(x>=r && x+r<=w && y>=r && y+r<=h){
	   printf("Yes\n");
	}
	else{
	   printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1016
import Control.Monad
import Control.Monad.ST
import Data.Array.Unboxed
import Data.Array.ST
import Data.Maybe

main = do
    (h:w:_)<-map read.words<$>getLine::IO [Int]
    m <- concat <$> replicateM h getLine :: IO String
    --
    let wn = length $ filter(=='.') m
    let bd = listArray ((1,1),(h,w)) $ map (\c->if c=='.' then 0 else (-1)) m::UArray (Int,Int) Int
    --
    let bd' = sol' h w bd

    print $ if bd' ! (h,w) == 0 then (-1) else wn - (bd' ! (h,w))
--
sol' :: Int -> Int -> UArray (Int,Int) Int -> UArray (Int,Int) Int
sol' h w bd = runST $ do
    m <- thaw bd :: ST s (STUArray s (Int,Int) Int)
    writeArray m (1,1) 1
    solve h w m 1 [(1,1)]
    freeze m

solve :: Int -> Int -> STUArray s (Int,Int) Int -> Int -> [(Int,Int)] -> ST s ()
solve _ _ _ _ [] = return ()
solve h w m s cd = do
    nn <- forM nt $ \(i,j) ->
        if i<1 || i>h || j<1 || j>w then return Nothing
        else do
            f <- readArray m (i,j)
            when (f==0) $ writeArray m (i,j) (s+1)
            return $ if f == 0 then Just (i,j) else Nothing
    solve h w m (s+1) $ catMaybes nn
    where
        nt = concatMap mv cd
        mv (i,j) = map (\(di,dj)->(i+di,j+dj)) [(-1,0),(1,0),(0,-1),(0,1)]


Measured memory_bytes: 1148
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll fexp(ll x, ll y) {
    ll ans = 1;
    while (y > 0) {
        if (y & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> f(k + 1);
    for (int i = k; i >= 1; --i) {
        f[i] = fexp(k / i, n);
        for (int j = i * 2; j <= k; j += i)
            f[i] -= f[j];
        f[i] = (f[i] % MOD + MOD) % MOD;
    }
    ll ans = 0;
    for (int i = 1; i <= k; ++i)
        ans = (ans + f[i] * i) % MOD;
    cout << ans;
}

Measured memory_bytes: 4052