akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn parent(i: usize) -> usize {
    i / 2
}

fn left(i: usize) -> usize {
    2 * i
}

fn right(i: usize) -> usize {
    2 * i + 1
}

fn main() {
    let h = read_line().unwrap().parse().unwrap();

    let input: Vec<i32> = read_line()
        .unwrap()
        .split_whitespace()
        .map(|n| n.parse::<i32>().unwrap())
        .collect();

    let a = [vec![0], input].concat();

    for i in 1..(h + 1) {
        print!("node {}: key = {}, ", i, a[i]);
        if parent(i) >= 1 {
            print!("parent key = {}, ", a[parent(i)])
        }
        if left(i) <= h {
            print!("left key = {}, ", a[left(i)]);
        }
        if right(i) <= h {
            print!("right key = {}, ", a[right(i)]);
        }
        println!();
    }
}

// Utilities
fn read_line() -> io::Result<String> {
    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    Ok(input.trim().to_string())
}



Measured memory_bytes: 5040
X, N = map(int,input().split())
p = set(list(map(int,input().split())))
if N == 0:
    print(X)
    exit(0)

L = []
for k in range(0,200):
    if k not in p:
        L.append(k)

temp = 100000
ans = -1
for e in L:
    if temp > abs(e-X):
        temp = abs(e-X)
        ans = e
print(ans)


Measured memory_bytes: 9196
import sys
S = input()
N = int(input())
for i in range(N):
  a = sys.stdin.readline().split()
  if a[0] == "replace":
    S = S[:int(a[1])] + a[3] + S[int(a[2])+1:]
  elif a[0] == "reverse":
    X =  S[int(a[1]):int(a[2])+1]
    X = X[::-1]
    S = S[:int(a[1])] + X +S[int(a[2])+1:]
  elif a[0] == "print":
    print(S[int(a[1]):int(a[2])+1])


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

#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
ll n,t,a[222222],ans=0;

int main()
{
	//freopen("input.txt", "r", stdin);
	cin >> n >> t;
	for(int i=1;i<=n;++i)
	{
		cin >> a[i];
	}
	ans+=t;
	for(int i=1;i<n;++i)
	{
		ans+=min(a[i+1]-a[i],t);
	}
	cout << ans << "\n";
	return 0;
}

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

using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tc = 1;
    // cin >> tc;
    while(tc--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0; i<n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        ll res = 0;
        for(int i=0; i<k; i++) {
            res += a[i];
        }
        cout << res << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int solve (std::vector<int> k) {
  int kmin = *std::min_element(k.begin(), k.end());

  std::vector< std::vector<int> > L;
  std::vector<int> s;
  for(int i=0; i<k.size(); i++) {
    if ( k[i] - kmin > 0 ) s.push_back(k[i]-kmin);
    else if ( s.size() != 0 ) {
      L.push_back(s);
      s.clear();
    }
  }
  if ( s.size() != 0 ) L.push_back(s);

  int rtn = kmin;
  for(int i=0; i<L.size(); i++) rtn += solve(L[i]);
  return rtn;
}

int main (void) {

  int N; std::cin >> N;
  std::vector<int> h(N);
  for(int i=0; i<N; i++) std::cin >> h[i];

  std::cout << solve(h) << std::endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int m; cin >> m;
    vector<pll> v;
    REP(i,m) {
        ll d,c;
        cin >> d >> c;
        v.push_back({d,c});
    }

    ll ans = 0;
    REP(i,m) {
        vector<pll> v2{v[i]};
        while(v2.back().second != 1) {
            if (v2.back().second % 2 != 0) {
                pll tmp = v2.back();
                //cerr << tmp.first << endl;
                v2.back().second = 1;
                v2.push_back({tmp.first,tmp.second-1});
            }
            if (v2.back().first < 5 ) {
                ans += v2.back().second / 2;
                v2.back().first *= 2;
                v2.back().second /= 2;
            } else {
                ans += v2.back().second;
                v2.back().first = 1 + (v2.back().first - 5) * 2;
                v2.back().second /= 2;
            }
            //cerr << ans << endl;
        }
        REP(j,v2.size()-1) {
            ll s2 = v2[j].first + v2[j+1].first;
            //cerr << s2 << endl;
            if (s2 > 9) { 
                ans += 2;
                v2[j+1].first = s2 - 9;
            } else {
                ans++;
                v2[j+1].first = s2;
            }
            //cerr << ans << endl;
        }
        v[i] = v2.back();
    }
    REP(i,v.size() -1) {
        ll s2 = v[i].first + v[i+1].first;
        //cerr << v[i].first << endl;
        if (s2 > 9) { 
            ans += 2;
            v[i+1].first = s2 - 9;
        } else {
            ans++;
            v[i+1].first = s2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6128
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        a: usize,
        b: usize,
        n: usize,
    }
    if n >= b - 1 {
        println!("{}", (a as f64 - a as f64 / b as f64).floor() as usize);
    } else {
        println!("{}", (a as f64 * n as f64 / b as f64).floor() as usize);
    }
}


Measured memory_bytes: 2592
#include<iostream>
using namespace std;
 
int main(){
	int N;
  	cin >> N;
  
  	int maxPrice = 0;
  	int totalPrice = 0;
  
    for(int i=0; i<N; i++){
      int price;
      cin >> price;
      if(price > maxPrice){
        maxPrice = price;
      }
      totalPrice += price;
    }
  
    int result = totalPrice - maxPrice / 2;
  
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n, large_t = map(int, input().split())
    cost = 10000
    count = 0

    for i in range(n):
        ci, ti = map(int, input().split())

        if ti <= large_t:
            cost = min(cost, ci)
        else:
            count += 1

    if count != n:
        print(cost)
    else:
        print('TLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(void)
{
    int ant[5],k;
    for(int i=0;i<5;i++)
    {
        cin>>ant[i];
    }
    cin>>k;
    int jud=0;
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<5;j++)
        {
            if(abs(ant[i]-ant[j])>k)
            {
                jud++;
            }
        }
    }
if(jud==0)
{
    cout<<"Yay!";
}
else
{
    cout<<":(";
}

return 0;
}

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

int main() {
  int h, n;
  cin >> h >> n;
  
  int a, sum = 0;
  while (cin >> a) {
    sum += a;
    if (sum >= h) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int maxn;
    long[] frac,inv;
    long mod = 1000000000+7;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve() throws IOException {
        int n = sc.nextInt(), k = sc.nextInt();
        maxn = 2*n;
        ini();
        long ans = comb(2*n-1,n-1);
        if(k>=n-1) return ans;
        // otherwise, the k is relatively small
        long sub = 0;
        for(int zero = k+1;zero <= n-1; zero++){
            sub += comb(n,zero)*comb(n-1,n-zero-1)%mod;
            sub %= mod;
        }
        ans = (ans+mod-sub)%mod;
        return ans;

    }
    long comb(int n, int m){
        if(n<m) return 0;
        return frac[n]*inv[m]%mod*inv[n-m]%mod;
    }
    void ini(){
        frac = new long[maxn+1]; inv = new long[maxn+1];
        frac[0]= 1;
        for(int i=1;i<=maxn;i++) frac[i] = i*frac[i-1]%mod;
        inv[0]=1;
        inv[maxn] = power(frac[maxn],mod-2);
        for(int i=maxn-1;i>0;i--){
            inv[i] = inv[i+1]*(i+1)%mod;
        }
    }
    long power(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
             p/= 2;
        }
        return ans;
    }

}



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

using lint = long;
const int MAXN = 20009;
struct edg{int pos, cap, rev;};
vector<edg> gph[MAXN];
void clear(){for(int i=0; i<MAXN; i++) gph[i].clear();}
void add_edge(int s, int e, int x){
	gph[s].push_back({e, x, (int)gph[e].size()});
	gph[e].push_back({s, 0, (int)gph[s].size()-1});
}
int dis[MAXN], pnt[MAXN];
bool bfs(int src, int sink){
	memset(dis, 0, sizeof(dis));
	memset(pnt, 0, sizeof(pnt));
	queue<int> que;
	que.push(src);
	dis[src] = 1;
	while(!que.empty()){
		int x = que.front();
		que.pop();
		for(auto &e : gph[x]){
			if(e.cap > 0 && !dis[e.pos]){
				dis[e.pos] = dis[x] + 1;
				que.push(e.pos);
			}
		}
	}
	return dis[sink] > 0;
}
int dfs(int x, int sink, int f){
	if(x == sink) return f;
	for(; pnt[x] < gph[x].size(); pnt[x]++){
		edg e = gph[x][pnt[x]];
		if(e.cap > 0 && dis[e.pos] == dis[x] + 1){
			int w = dfs(e.pos, sink, min(f, e.cap));
			if(w){
				gph[x][pnt[x]].cap -= w;
				gph[e.pos][e.rev].cap += w;
				return w;
			}
		}
	}
	return 0;
}
lint match(int src, int sink){
	lint ret = 0;
	while(bfs(src, sink)){
		int r;
		while((r = dfs(src, sink, 2e9))) ret += r;
	}
	return ret;
}

int H, W;
char a[202][202];
int M[202][202];

int main()
{
    scanf("%d%d", &H, &W);
    for(int i=0; i<H; ++i) scanf("%s", a[i]);
    int tp = 3;
    add_edge(1, 2, 1000);
    add_edge(2, 1, 1000);
    add_edge(3, 4, 1000);
    add_edge(4, 3, 1000);
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            if(a[i][j] == 'S')
                M[i][j] = 1;
            if(a[i][j] == 'T')
                M[i][j] = 3;
            if(a[i][j] == 'o')
            {
                tp += 2;
                M[i][j] = tp;          
                add_edge(tp, tp+1, 1); 
                add_edge(tp+1, tp, 1);
            }
        }
    }
    for(int i=0; i<H; ++i)
        for(int j=0; j<W; ++j)
            for(int k=0; k<j; ++k)
            {
                if(M[i][j] != 0 && M[i][k] != 0)
                {
                    add_edge(M[i][j]+1,M[i][k], 1000);
                    add_edge(M[i][k]+1,M[i][j], 1000);
                }
            }
    for(int i=0; i<W; ++i)
        for(int j=0; j<H; ++j)
            for(int k=0; k<j; ++k)
            {
                if(M[j][i] != 0 && M[k][i] != 0)
                {    
                    add_edge(M[j][i]+1,M[k][i], 1000);
                    add_edge(M[k][i]+1,M[j][i], 1000);
                }
            }
    long ans = match(1, 3);
    if(ans > 999) puts("-1");
    else printf("%ld\n", ans);
}




Measured memory_bytes: 61696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    S = S +  "###";
    ll ans = 0;
    ll nowa = 0;
    for(ll i = 0; i < S.size(); i++) {
        if(S[i] == 'A') {
            nowa++;
            continue;
        }
        if(S[i] == 'B' && S.substr(i, 2) == "BC") {
            ans += nowa;
            i++;
            continue;
        }
        nowa = 0;
    }
    cout << ans << endl;
    return 0;
}

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

const int mod = 1e9 + 7;

void upd(int &x, int y) {
    if ((x += y) >= mod) {
        x -= mod;
    }
}

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

    static int dp[62][3]; // borrow
    dp[0][0] = 1;

    for (int i = 0; i < 61; i++) {
        for (int j = 0; j < 3; j++) {
            for (int x = 0; x < 2; x++) {
                for (int y = x; y < 2; y++) {
                    int s = ((n >> i & 1) - x - y - j);
                    if (s < 0) {
                        upd(dp[i + 1][(1 - s) / 2], dp[i][j]);
                    } else {
                        upd(dp[i + 1][0], dp[i][j]);
                    }
                }
            }
        }
    }

    cout << dp[61][0] << endl;
}


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

string S;
int l;
set<string> seen;
int dp[200000][3/*和 mod 3*/][4/*
  0/1/2: まだ連続する2数字が出現しておらず、0/1/2で終わる
  3: すでに連続する2数字が出現している*/];
#define MOD 998244353

void see(const string& s) {
  if(seen.count(s)) return;
  seen.insert(s);
  for(int i = 0; i < l - 1; ++i) {
    if(s[i] != s[i + 1]) {
      string t = s; t[i] = t[i + 1] = 3 - s[i] - s[i + 1];
      see(t);
    }
  }
}

int main() {
  cin >> S; l = S.size();
  for(int i = 0; i < l; ++i) S[i] -= 'a';
  bool good = false;
  for(int i = 0; i < l - 1; ++i) if(S[i] != S[i + 1]) good = true;
  if(!good) {
    cout << 1 << endl;
  } else if(l <= 3) {
    see(S);
    cout << seen.size() << endl;
  } else {
    dp[0][0][0] = dp[0][1][1] = dp[0][2][2] = 1;
    for(int i = 1; i < l; ++i) {
      int prev = i - 1, cur = i;
      for(int mod = 0; mod < 3; ++mod) for(int last = 0; last < 3; ++last) {
        int new_mod = (mod + last) % 3;
        (dp[cur][new_mod][3] += dp[prev][mod][last]) %= MOD;
        (dp[cur][new_mod][3] += dp[prev][mod][3]) %= MOD;
        for(int prelast = 0; prelast < 3; ++prelast) {
          if(last == prelast) continue;
          (dp[cur][new_mod][last] += dp[prev][mod][prelast]) %= MOD;
        }
      }
    }
    int mod = 0;
    for(int i = 0; i < l; ++i) (mod += S[i]) %= 3;
    bool strange = true;
    for(int i = 0; i < l - 1; ++i) if(S[i] == S[i + 1]) strange = false;
    cout << (dp[l - 1][mod][3] + strange) % MOD << endl;
  }
  return 0;
}


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

class Dice
{
public:
    Dice()
    {
        number = new int[6];
        work = new int[6];
    }
    ~Dice()
    {
        delete number;
        delete work;
    }

    void setNum(int a, int b, int c, int d, int e, int f)
    {
        number[0] = a;
        number[1] = b;
        number[2] = c;
        number[3] = d;
        number[4] = e;
        number[5] = f;
    }

    void roll(char ch)
    {
        for (int i = 0; i < 6; i++)
        {
            work[i] = number[i];
        }
        switch(ch)
        {
        case 'E':
            setNum(work[3], work[1], work[0], work[5], work[4], work[2]);
            break;
        case 'W':
            setNum(work[2], work[1], work[5], work[0], work[4], work[3]);
            break;
        case 'N':
            setNum(work[1], work[5], work[2], work[3], work[0], work[4]);
            break;
        case'S':
            setNum(work[4], work[0], work[2], work[3], work[5], work[1]);
            break;
        }
    }

    void initNum(int i, int num)
    {
        number[i] = num;
    }

    int getTop()
    {
        return number[0];
    }

private:
    int *number;
    int *work;
};

int main(int argc, char *argv[])
{
    Dice dice;
    int num;
    for (int i = 0; i < 6; i++)
    {
        scanf("%d", &num);
        dice.initNum(i, num);
    }

    char ch = getchar();
    //char ch;
    while ((ch = getchar()) != '\n')
    {
        dice.roll(ch);
    }
    printf("%d\n", dice.getTop());
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int rest = 0;
    for (auto p: mp) {
        if (p.second >= 2) {
            rest += p.second-1;
        }
    }
    if (rest%2==0) cout << mp.size() << endl;
    else cout << mp.size()-1 << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    string s;
    cin >> s;
    ll n = s.length() + 1;
    vector < ll > a(n, 0);
    for(int i = 0; i < n - 1; i++){
        if(s[i] == '<'){
            if(a[i] >= a[i + 1]) a[i + 1] = a[i] + 1;
        }
    }
    for(int i = n - 2; i >= 0; i--){
        if(s[i] == '>'){
            if(a[i] <= a[i + 1]) a[i] = a[i + 1] + 1;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 4764
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		long[][] a = new long[n + 1][m + 1];
		long[][] b = new long[m + 1][l + 1];
		long[][] c = new long[n + 1][l + 1];
		int i,j,k;
		for(i = 1; i <= n; ++i){
			for(k = 1; k <= m; ++k){
				a[i][k] = scan.nextInt();
			}
		}
		for(k = 1; k <= m; ++k){
			for(j = 1; j <= l; ++j){
				b[k][j] = scan.nextInt();
			}
		}
		for(i = 1; i <= n; ++i){
			for(j = 1; j <= l; ++j){
				for(k = 1; k <= m; ++k){
					c[i][j] += a[i][k] * b[k][j] ;
				}
			}
				
			}
		for(i = 1; i <= n; ++i){
			for(j = 1; j <= l; ++j){
				if(j == l)
					System.out.println(c[i][j]);
				else 
					System.out.print(c[i][j]+" ");
			}
		}
		}
}
		
		
		


	

Measured memory_bytes: 55080
#include<stdio.h>
#include<math.h>
int main(void){
	int a,b,C;
	double S,L,h;
	scanf("%d %d %d",&a,&b,&C);
	S=(double)(a*b*sin(C*atan(1.0)*4.0/180.0))*0.5;
	L=(double)(a+b+sqrt(a*a+b*b-2.0*a*b*cos(C*atan(1.0)*4.0/180.0)));
	h=(double)(S/a*2.0);
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
    int n; cin >> n;
    map<string,int> mp;
    for(int i = 0; i < n; ++i){
        string s,t; cin >> s >> t;
        if(s == "insert") mp[t]++;
        if(s == "find"){
            if(mp[t] == 0) puts("no");
            else puts("yes");
        }
    }
    return 0;
}


Measured memory_bytes: 52456
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

const int MOD = 1e9 + 7;

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}

int mul(int x, int y) {
    return (1LL * x * y) % MOD;
}

int bin_pow(int a, int p) {
    if (!p)
        return 1;
    if (p % 2)
        return (1LL * bin_pow(a, p - 1) * a) % MOD;
    int t = bin_pow(a, p / 2);
    return (1LL * t * t) % MOD;
}

int inv(int x) {
    return bin_pow(x, MOD - 2);
}

vector <int> get_pref(vector <int>& a) {
    vector <int> ans(sz(a) + 1);
    forn (i, 0, sz(a))
        ans[i + 1] = add(ans[i], a[i]);
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> dp(k + 1);
    dp[k] = 1;
    auto pref = get_pref(dp);
    forn (i, 0, n) {
        int x;
        cin >> x;
        vector <int> new_dp(k + 1);
        forn (j, 0, k + 1)
            new_dp[j] = sub(pref[min(k + 1, j + x + 1)], pref[j]);
        swap(dp, new_dp);
        pref = get_pref(dp);
    }
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 1884
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    LL x;
    cin >> x;
    if(x<600){
        cout << 8 << endl;
    }else if(x<800){
        cout << 7 << endl;
    }else if(x<1000){
        cout << 6 << endl;
    }else if(x<1200){
        cout << 5 << endl;
    }else if(x<1400){
        cout << 4 << endl;
    }else if(x<1600){
        cout << 3 << endl;
    }else if(x<1800){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
N = int(input())
A, B = list(map(int, input().split()))
P = list(map(int, input().split()))

num = [0, 0, 0]

for p in P:
    if p <= A:
        num[0] += 1
    elif p <= B:
        num[1] += 1
    else:
        num[2] += 1

print(min(num))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;


#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}



// substr(start, len)

int main(){
  int N, K, n, ans = 0;
  cin >> N >> K;

  n = N;

  while(true){
    if(n < K){
      ans++;
      break;
    }else{
      n /= K; 
      ans++;
    }
  }
  cout << ans << endl;

// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
n = gets.to_i
f = n.times.map{gets.chomp.split(" ").map(&:to_i)}
p = n.times.map{gets.chomp.split(" ").map(&:to_i)}
ans = -(10**9)
for i in 1..1023
  combi = []
  10.times do |j|
    combi[j] = i%2
    i /= 2
  end
  same = Array.new(n,0)
  temp = 0
  for j in 0..n-1
    10.times do |k|
      if combi[k] == 1 && f[j][k] == 1
        same[j] += 1
      end
    end
    temp += p[j][same[j]]
  end
  if ans < temp
    ans = temp
  end
end
puts ans

Measured memory_bytes: 2812
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MOD = (int)1e9 + 7;

class modint {
  int v;
public:
  modint (): v(0) { }
  modint (ll v): v((v + MOD) % MOD) { }

  bool operator== (modint x) { return v == x.v; }
  bool operator!= (modint x) { return v != x.v; }

  modint operator+ (modint x) { return v + x.v; }
  modint operator- (modint x) { return v - x.v; }
  modint operator* (modint x) { return (ll)v * x.v; }

  modint& operator+= (const modint x) { return *this = (*this + x); }
  modint& operator-= (const modint x) { return *this = (*this - x); }
  modint& operator*= (const modint x) { return *this = (*this * x); }

  int operator* () { return v; }
};

#define debug(format, ...) printf(format, __VA_ARGS__);

int main() {
  long long a, b, c; scanf("%lld%lld%lld", &a, &b, &c);
  int ans = 0;
  while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0 && ans < 1000) {
    tie(a, b, c) = tuple<ll, ll, ll>(b/2 + c/2, a/2 + c/2, a/2 + b/2);
    ans += 1;
  }
  if(ans == 1000) ans = -1;
  printf("%d\n", ans);
  // (a, b, c)
  // (b/2 + c/2, a/2 + c/2, a/2 + b/2)
  // [0 1/2 1/2]^k [a]
  // [1/2 0 1/2]   [b]
  // [1/2 1/2 0]   [c]

  // [0 1 1]^k (1/2)^k [a b c]'
  // [1 0 1]
  // [1 1 0]

  // (0,1) (2,1) (2,3) (6,5) (10,11)
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if (500 * i + 100 * j + 50 * k) == x:
                ans += 1
print(ans)


Measured memory_bytes: 67492
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n;
void solve()
{
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n){cout<<"Yes"<<endl;return;}
        }
    }
    cout<<"No"<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


allcnb=0
for i in num:
  if i>=2:
    allcnb+=int(i*(i-1)/2)

for i in ball:
  cnb=0

  if num[i]>=2:
    cnb=num[i]-1

  print(allcnb-cnb)


Measured memory_bytes: 83664
#include<stdio.h>
int main(void){
	int N,a,t;
	int i,j;
	long long dp[100][21]={0};
	scanf("%d",&N);
	scanf("%d",&a);
	dp[0][a]++;
	for(i=1;i<N-1;i++){
		scanf("%d",&a);
		for(j=0;j<21;j++){
			if(dp[i-1][j]!=0){
				t=a+j;
				if(t>=0&&t<21){
					dp[i][t]=dp[i][t]+dp[i-1][j];
				}
				t=j-a;
				if(t>=0&&t<21){
					dp[i][t]=dp[i][t]+dp[i-1][j];
				}
			}
		}
	}
	scanf("%d",&a);
	printf("%lld\n",dp[N-2][a]);
	return 0;
}

Measured memory_bytes: 624
#include<iostream>
using namespace std;
int main(){
  long long int  N,A,B;
  cin >> N >> A >> B;
  long long int ans = N/(A+B)*A;
  if(N%(A+B)<=A) ans += N%(A+B);
  else ans += A;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        String s = sc.next();
        String t = sc.next();
        int count=0;
        for(int i=0;i <3; i++){
            if(s.charAt(i)==t.charAt(i))
                count++;
        }
        out.println(count);
    }
    private static boolean helper(long x){
        double ans = Math.sqrt(x);
        return ans%1!=0;
    }

    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair  {
    int x;
    int y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

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

using namespace std;

const vector<int64_t> divisor = {2, 3, 5};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int64_t N;
    vector<int64_t> X(4);
    cin >> N;
    for (int i = 0; i < 4; i++) {
      cin >> X[i];
    }
    int64_t res = INT64_C(1) << 58;
    priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>,
                   greater<pair<int64_t, int64_t>>>
        que;
    que.push(make_pair(0, N));
    set<int64_t> st;
    while (!que.empty()) {
      auto q = que.top();
      que.pop();
      int64_t c = q.first, n = q.second;
      if (n == 0) res = min(res, c);
      if (st.find(n) != st.end()) continue;
      st.insert(n);
      for (int i = 0; i < 3; i++) {
        int64_t d = divisor[i];
        if (n % d == 0) {
          int64_t m = n / d, nc = c + X[i];
          if (n - m < (INT64_C(1) << 32)) nc = min(nc, c + (n - m) * X[3]);
          que.push(make_pair(nc, m));
        } else {
          int64_t m = (n / d) * d;
          que.push(make_pair(c + (n - m) * X[3], m));
          if (m + d < N + 100)
            que.push(make_pair(c + (m + d - n) * X[3], m + d));
        }
      }
    }
    cout << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 11232
/*
 * Contents   : AOJ DPL 1 F
 * Author     : KitauraHiromi
 * LastUpdate : 20180618
 * Since      : 20180618
 */
#define INF 1000000001
#include <iostream>
#include <algorithm>
using namespace std;
int N, W;
int dp[101][101*101]; // dp[i][v]: i個目までの荷物を価値vまで入れたときの最小重さ
int value[101], weight[101];
int main(void){
    cin >> N >> W;
    fill((int*)dp, (int*)(dp+101), INF);
    dp[0][0] = 0;
    for(int i=0; i<N; ++i) cin >> value[i] >> weight[i];
    for(int i=0; i<N; ++i){
        for(int v=0; v<101*101; ++v){
            (v >= value[i]) ? dp[i+1][v] = min(dp[i][v], dp[i][v-value[i]] + weight[i]) : dp[i+1][v] = dp[i][v];
        }
    }
    // dp[N][i]がWを超えない最大のiが答え
    int res = 0;
    for(int i=0; i<101*101; ++i) if(dp[N][i] <= W) res = i;
    cout << res << endl;
}


Measured memory_bytes: 7140
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pb push_back
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    sort(s + 1,s + 1 + n);
    const int mod = 1e9 + 7;
    map < int , int > M;
    for (int i = 1;i <= n;++i)
        ++M[s[i]];
    if (n & 1)
    {
        int ok = 1;
        ok &= M[0] == 1;
        for (int i = 2;i <= n;i += 2)
            ok &= M[i] == 2;
        if (!ok) return puts("0") * 0;
    }
    else
    {
        int ok = 1;
        for (int i = 1;i <= n;i += 2)
            ok &= M[i] == 2;
        if (!ok) return puts("0") * 0;
    }
    int ans = 1;
    for (int i = 1;i + i <= n;++i)
        ans = (ans + ans) % mod;
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 4480
using System;

class Program
{
    static void Main(string[] args)
    {
        var nmx = Console.ReadLine().Split(' ');
        var n = int.Parse(nmx[0]);
        var m = int.Parse(nmx[1]);
        var x = int.Parse(nmx[2]);

        var left = 0;
        var right = 0;

        var s = Console.ReadLine().Split(' ');
        for (int i = 0; i < m; i++)
        {
            if (x < int.Parse(s[i]))
            {
                right++;
            }
            else
            {
                left++;
            }
        }

        Console.WriteLine(Math.Min(left, right));
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<long> AS;
    long A;

    for (int i = 0; i < N + 1; ++i) {
        cin >> A;
        AS.push_back(A);
    }
    long B;
    vector<long> BS;
    for (int j = 0; j < N; ++j) {
        cin >> B;
        BS.push_back(B);
    }

    long r = 0;
    for (int i = 0; i < N; ++i) {
        if (AS[i] <= BS[i]) {
            long rem = BS[i] - AS[i];
            r = r + AS[i] + min(AS[i + 1], rem);
            AS[i + 1] = AS[i + 1] - min(AS[i + 1], rem);
        } else {
            r += BS[i];
        }
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

vi a,memo;
bool f(int k){//石がk個のときにゲームをはじめて勝てるか
    if(memo[k] != -1)return memo[k];
    bool ret = false;
    rep(i,a.size())if(k - a[i] >= 0){
        if(!f(k-a[i]))ret = true;
    }
    memo[k] = ret;
    return ret;
}

signed main(void) {
    int n,k;
    cin >> n >> k;
    a = vi(n);
    rep(i,n) cin >> a[i];
    memo = vi(k+1,-1);
    if(f(k)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}


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

using namespace std;

int main(){

	int l, r, sz, tmp, mi=99999;
	vector<int> v;

	cin>> l >> r;

	for(int i=l;i<=r;i++){
		v.emplace_back(i%2019);
		if(i%2019==0){
			cout<< "0" <<endl;
			return 0;
		}

		sz=v.size();
		if(sz>2020) break;
	}

	/*sort(v.begin(), v.end());
	for(int i=sz-1;i>0;i--){
		if(v[i]==v[i-1]) v.pop_back();
	}*/

	//sz=v.size();

	for(int i=0;i<sz;i++){
		for(int j=i+1;j<sz;j++){
			tmp=(v[i]*v[j])%2019;
			mi=min(mi, tmp);
		}
	}

	cout<< mi << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what
 
using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;
 
int n;
int root;
int a[N];
vector<int> v[N];
 
ll calc(int x, int p = -1) {
  ll mx = 0, leaf = 1;
  ll sum = 0;
  for (auto it : v[x]) {
    if (it == p)
      continue;
    ll rem = calc(it, x);
    sum += rem;
    mx = max(mx, rem);
    leaf = 0;
  }
  if (leaf) 
    return a[x];
  ll z = sum - a[x];
  if (z < 0) {
    cout << "NO";
    exit(0);
  }
  ll max_matching;
  if (mx > sum / 2) {
    max_matching = sum - mx;
  } else {
    max_matching = sum / 2;
  }
  if (max_matching >= z) {
    return a[x] - z;
  } else {
    cout << "NO";
    exit(0);
  }
}
 
int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1, x, y; i < n; i++) {
      cin >> x >> y;
      v[x].pb(y);
      v[y].pb(x);
    }
    root = 1;
    for (int i = 1; i <= n; i++) {
      if (sz(v[i]) > 1) {
        root = i;
      }
    }
    if (n == 2) {
      if (a[1] == a[2]) 
        cout << "YES";
      else 
        cout << "NO";
      return 0;
    }
    cout << (calc(root) == 0 ? "YES" : "NO");
    return 0;
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 3e3 + 5;
int n , a[maxn];
ll dp[maxn][maxn];
const ll inf = 1e18;
ll Cal(int i , int j)
{
    if(i > j)return 0;
    ll & res = dp[i][j];
    if(res != inf)return res;
    int len = j - i + 1;
    if((n - len) % 2 == 0)
    {
        res = -inf;
        res = max(res , Cal(i + 1,j) + a[i]);
        res = max(res , Cal(i , j - 1) + a[j]);
    }
    else
    {
        res = inf;
        res = min(res , Cal(i + 1 , j) - a[i]);
        res = min(res , Cal(i , j - 1) - a[j]);
    }
    return res;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    fill_n(&dp[0][0],maxn*maxn,inf);
    cout << Cal(1,n);
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);  
    vector<pair<int, int>> E_in; 
    for (int i = 1; i < N; i++) {
        int a, b;cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        pair<int, int> p = make_pair(a, b);
        E_in.push_back(p);
    } 
    queue<int> que;
    vector<int> used(N, 0);
    vector<int> parent(N, 0);
    int max_color = 0;
    map<pair<int, int>, int> E_num; 
    que.emplace(0); 
    used[0] = 1;
    while (que.size() != 0) {
        int state = que.front();  
        que.pop();
        int color_num = 0;
        for (auto next : G[state]) {
            if (used[next] != 1) {
                color_num++;
                used[next] = 1;
                if (color_num == parent[state]) {
                    color_num++;
                }
                pair<int, int> p = make_pair(state, next);
                E_num[p] = color_num; 
                parent[next] = color_num;
                que.push(next); 
            }
        }
        max_color = max(max_color, color_num);
    }
 
    cout << max_color << "\n";
    for (auto i : E_in) {
        cout << E_num[i] << "\n";
    }
 
    return 0;
}

Measured memory_bytes: 13812
//
//  main.cpp
//  ITP1_6-C
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, const char * argv[])
{

    int n;
    cin >> n;
    
    int b,f,r,v;
    
    int buildingData[4][3][10] = {};
    
    
    for (int i = 0; i < n; i++) {
        
        cin >> b >> f >> r >> v;
        
        buildingData[b-1][f-1][r-1] += v;

    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {

                printf(" %d", buildingData[i][j][k]);
                
            }
            printf("\n");
        }
        
        if (i == 3){
            break;
        }
        printf("####################\n");
    }
    
    return 0;
}

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

int main()
{
	int time,a;
	string str;
	while(1){
		cin>>str;
	if(str == "-")break;
	cin>>time;
	for(int i=0;i<time;i++){
		cin>>a;
		string left = str.substr(0,a);
		string right = str.substr(a) + left;
		str = right;
	}
	cout<<str<<endl;
}
	return 0;
}

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

int main() {
  for(int N; cin >> N; ) {
    int ans = 0;
    for(int a = 0; a < 10; a++)
      for(int b = 0; b < 10; b++)
        for(int c = 0; c < 10; c++)
          for(int d = 0; d < 10; d++)
            if(a+b+c+d == N) ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<ll,ll>
	#define PB push_back
	inline void chmax(ll &x,ll y) {x=x>y?x:y;}
	inline void chmin(ll &x,ll y) {x=x<y?x:y;}

	const int MOD=1e9+7;
	void add(ll &x,ll y) {x+=y;if(x>=MOD) x-=MOD;if(x<=-MOD) x+=MOD;}
	const int MAX_N=1e5+10;
	char s[MAX_N];
	int f[30];
	int bin[30];
	int tt[1<<27];
	void main()
	{
		bin[0]=1;for(int i=1;i<30;i++) bin[i]=bin[i-1]<<1;

		int n;scanf("%d",&n);
		scanf("%s",s+1);
		for(int i=1;i<=n;i++) f[s[i]-'a']++;

		ll ans=0;
		tt[0]=1;for(int i=0;i<26;i++) tt[bin[i]]=f[i],add(ans,f[i]);
		for(int s=1;s<bin[26];s++) if(s!=(s&-s))
		{
			int b=s&-s;
			tt[s]=(ll)tt[s^b]*tt[b]%MOD;
			add(ans,tt[s]);
			//if(s<bin[3]) printf("tt[%d]=%d\n",s,tt[s]);
		}
		printf("%lld",(ans+MOD)%MOD);
 	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 264576
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();


		for(int i = 0 ; i < a ; i++) {


		}

		sc.close();
			System.out.println(a * b);


	}

}


Measured memory_bytes: 35780
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
using namespace std;
struct d
{
	ll int c;
	vector<ll  int> v;
};
int main()
{
	ll int n,m,x;
	cin>>n>>m>>x;
	ll int i,j;
	struct d d1[n];
	for(i=0;i<n;i++)
	{
			cin>>d1[i].c;
		for(j=0;j<m;j++)
		{
			ll int x;
		
			cin>>x;
			d1[i].v.pb(x);
		}
		
		
	}

	ll int k,sc=0,mi=1e10;
	for(i=1;i<pow(2,n);i++)
	{
		ll int a=i;
		j=0;
		ll int s[m]={0};
		sc=0;
		while(a>0)
		{
			ll int d=a&1;
			if (d==1)
			{
				for(k=0;k<m;k++)
				{
					s[k]+=d1[j].v[k];
				}
				sc+=d1[j].c;
			
			}
			
		
			j++;
			ll int flag=0;
			for (k=0;k<m;k++)
			{
				if (s[k]<x)
				{
					flag=1;
					break;
				}
			}
			if (flag==0)
			{
				if (sc<mi)
				mi=sc;
				
				
			}
			a=a>>1;
					
		}
		
	}
	if (mi==1e10)
	cout<<-1<<endl;
	else
	cout<<mi<<endl;
	
	
	
	
		
}
		


 







Measured memory_bytes: 4072