akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    vll a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;
    for(ll i=n-1;i>=0;i--){
        ll atk = min(a[i+1], b[i]);
        ans += atk;
        b[i] -= atk;
        a[i+1] -= atk;

        if(b[i]){
            atk = min(a[i], b[i]);
            ans += atk;
            b[i] -= atk;
            a[i] -= atk;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4800
#include<iostream>

using namespace std;

int main(){
    int n,index=1;
    cin >> n;
    while(!(n==4||n==2||n==1)){
        if(n%2==0){
            n/=2;
        }else{
            n = 3*n+1;
        }
        index++;
    }
    cout << index+3;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

class UnionFind {
public:
  UnionFind(int n) : par(n, -1), rnk(n, 0), cnt(n, 1), _size(n) {}

  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;

    --_size;

    if (rnk[x] < rnk[y]) { swap(x, y); }
    par[y] = x;
    cnt[x] += cnt[y];
    if (rnk[x] == rnk[y]) { ++rnk[x]; }
  }
  int root(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
  int count(int x) {
    return cnt[root(x)];
  }
  int size() {
    return _size;
  }

private:
  vector<int> par;
  vector<int> rnk;
  vector<int> cnt; // The number of vertices in each connected components.
  int _size; // The number of connected components. Decreases by unite.
};

int main(int argc, char** argv) {
  ll N, M;
  cin >> N >> M;
  vector<P> pairs;
  rep(i, M) {
    ll A, B;
    cin >> A >> B;
    --A; --B;
    pairs.emplace_back(A, B);
  }
  reverse(all(pairs));
  vector<ll> ans;
  UnionFind tree(N);
  ll cost = N * (N-1) / 2; // The initial cost. This is the final state.
  ans.push_back(cost);

  rep(i, M-1) {
    P p = pairs[i];

    // For Debug
    // cout << p.first << ", " << p.second << ": " << tree.same(p.first, p.second) << endl;

    // Now, we unite p.first and p.second.
    // We want to calculate the diff.
    if (tree.same(p.first, p.second)) { // if already united, the cost does not change.
      ans.push_back(cost);
    } else {
      ll x = tree.root(p.first);
      ll y = tree.root(p.second);
      ll c1 = tree.count(x);
      ll c2 = tree.count(y);

      // For Debug
      // cout << x << ": " << c1 << ", " << y << ": " << c2 << endl;

      ll c = c1 + c2; // new size
      ll diff = c*(c-1)/2 - c1*(c1-1)/2 - c2*(c2-1)/2; // cost changes by diff.
      cost -= diff;
      ans.push_back(cost);

      tree.unite(p.first, p.second);
    }
  }

  reverse(all(ans));
  rep(i, M) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 5872
# import numpy as np
import sys
input = sys.stdin.readline

A,B = map(int,input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

res = lcm(A,B)

print(res)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
    }

    vector<int> c(N);
    for (int i = 0; i < N; ++i) {
        cin >> c[i];
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += max(0, v[i]-c[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
L = [int(x) for x in input().split()]

L = sorted(L)

ans = 0

for mid in range(N - 1, -1, -1):
    for low in range(mid - 1, -1, -1):
        itr = bisect_left(L, L[low] + L[mid])
        ng = len(L) - itr
        ans += (N - 1 - mid) - ng

print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int X,Y,Z;
    cin >> X >> Y >> Z;

    cout << (X - Z) / (Y + Z) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string A, B, C;
char R, W;

int main(void){
	//IO("test.in", "test.out");
	getline(cin, A), getline(cin, B), getline(cin, C);
	R = 'a';
	while(true)
		if(R == 'a' && A != "") R = A[0], A.erase(A.begin());
		else if(R == 'b' && B != "") R = B[0], B.erase(B.begin());
		else if(R == 'c' && C != "") R = C[0], C.erase(C.begin());
		else if(R == 'a'){
			W = 'A';
			break;
		}
		else if(R == 'b'){
			W = 'B';
			break;
		}
		else if(R == 'c'){
			W = 'C';
			break;
		}

	printf("%c\n", W);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
ll const N = 2e6;
ll dp[N],f[N],inv[N]; // f = factorial, inv[i] = 1/f[i] 
ll len,n,ans=0;
ll bp(ll x,ll y,ll MOD){
    ll ans = 1;
    while (y) {
        if (y & 1) ans = ans * x % MOD;
        x = x * x % MOD, y >>= 1;
    }
    return ans;
}
ll calc(ll n,ll r){
    return (f[n]*inv[n-r]%mod)*inv[r]%mod;
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        string s; 
        cin>>len>>s;
        n = s.size();
        len+=n;
        // ans = summation of (C(len,i)*pow(25,len-i))
        // previous one got TLE
        // So we have to precompute
        f[0] = inv[0] = 1;
        FOR(i,1,len+1){
            f[i] = f[i-1]*i%mod;
            inv[i] = bp(f[i],mod-2,mod);
        }
        dp[len]=1;
        for(ll i=len-1;i>=1;i--){
            dp[i] = calc(len,i)*bp(25,len-i,mod)%mod;
            dp[i] += mod;
            dp[i] %= mod;
        }

        FOR(i,n,len+1){
            ans = (ans+dp[i])%mod;
        }
        cout<<ans;
    }   
}

Measured memory_bytes: 51184
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  int M = cin.nextInt();
	  int K = cin.nextInt();
	  if( K == 0 ) {
		  for( int i = 0; i < (1 << M); ++i ) {
			  if( i > 0 ) { System.out.print(" "); }
			  System.out.print(i + " " + i);
		  }
		  System.out.println();
		  return;
	  }
	  int total = 0;
	  for( int i = 0; i < (1 << M); ++i ) {
		  if( i == K ) { continue; }
		  total ^= i;
	  }
	  if( total == K ) {
		  for( int i = 0; i < (1 << M); ++i ) {
			  if( i == K ) { continue; }
			  System.out.print(i + " ");
		  }
		  System.out.print(K + " ");
		  for( int i = (1 << M) - 1; i >= 0; --i ) {
			  if( i == K ) { continue; }
			  System.out.print(i + " ");
		  }
		  System.out.println(K);
		  return;
	  }
	  System.out.println(-1);
  }

}


Measured memory_bytes: 50376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n),B(n),C(n);
  
  rep(i,n){
    cin >> A[i];
  }
  rep(i,n){
    cin >> B[i];
  }
  rep(i,n){
    cin >> C[i];
  }
  int ans=0;
  
  rep(i,n){
    ans += B[A[i]-1];
    if(A[i]!=1){
      if(A[i]==(A[i-1]+1)){
        ans += C[A[i-1]-1];
      }
    }
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = "";
		int v;
		int cards[][] = new int[4][13];
		for (int i = 0; i < n; i++) {
			s = sc.next();
			v = sc.nextInt();
			if (s.equals("S"))
				cards[0][v - 1] = 1;
			else if (s.equals("H"))
				cards[1][v - 1] = 1;
			else if (s.equals("C"))
				cards[2][v - 1] = 1;
			else if (s.equals("D"))
				cards[3][v - 1] = 1;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (i == 0 && cards[i][j] != 1)
					System.out.println("S " + (j + 1));
				if (i == 1 && cards[i][j] != 1)
					System.out.println("H " + (j + 1));
				if (i == 2 && cards[i][j] != 1)
					System.out.println("C " + (j + 1));
				if (i == 3 && cards[i][j] != 1)
					System.out.println("D " + (j + 1));
			}
		}
	}
}


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

int main() {
  int x, y, z, a, b;

  cin >> x >> y >> z >> a >> b;

  if (x == 0) {
    cout << "1" << endl;
  }

  else if (y == 0) {
    cout << "2" << endl;
  }

  else if (z == 0) {
    cout << "3" << endl;
  }

  else if (a == 0) {
    cout << "4" << endl;
  }

  else if (b == 0) {
    cout << "5" << endl;
  }
}

Measured memory_bytes: 3588
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let ans: Vec<char> = "keyence".chars().collect();
    let mut ok = true;
    for i in 0..ans.len() {
        ok = true;
        for j in 0..i {
            if s[j] != ans[j] {
                ok = false;
            }
        }
        for j in i..ans.len() {
            if s[s.len() - ans.len() + j] != ans[j] {
                ok = false;
            }
        }
        if ok {
            break;
        }
    }
    println!("{}", if ok {"YES"} else {"NO"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
      return a.second > b.second;
    }else{
      return a.first > a.first;
    }
}

int main(){
  int n;
  cin>>n;
  vector<Pii> v;
  REP(i,n){
    Pii x;
    cin>>x.first>>x.second;
    v.push_back(x);
  }
  //sort(ALL(v),compare_by_a);
  sort(ALL(v),compare_by_b);
  int sum=v[0].second;
  REP(i,n){
    //cout<<v[i].first<<" "<<v[i].second<<endl;
    if(v[i].second<sum){
      sum=v[i].second;
    }
    sum-=v[i].first;
    if(sum<0){
      cout<<"No"<<endl;
      return 0;
    }

  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
//ll a[40001000];
//ll number[20],used[20];
int main()
{
    ll a[100000],n,i,count=0,k;
    cin>> n >> k;
    for(i=0;i<n;i++)
        cin>> a[i];
    sort(a,a+n);
    for(i=n-1;i>=0;i--)
    {
        if(a[i]>=k)
            count++;
        else
            break;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4308
from collections import defaultdict

class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)

N, K = map(int, input().split())
E = defaultdict(list)
MOD = 10**9 + 7
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
com = Combinatorics(K, MOD)
ans = K
parent = [None]*N
seen = [False]*N
parent[0] = -1
seen[0] = True
stack = [0]
while stack:
    v = stack.pop()
    n_children = len(E[v]) - (0 if v == 0 else 1)
    if n_children == 0: continue
    ans = (ans * com.perm(K - (1 if v == 0 else 2), n_children)) % MOD
    for u in E[v]:
        if seen[u]: continue
        parent[u] = v
        seen[u] = True
        stack.append(u)
print(ans)

Measured memory_bytes: 74672
package main

import "fmt"

type deque struct {
	front, back []byte
}

func (deq *deque) isEmptyFront() bool {
	return len(deq.front) == 0
}
func (deq *deque) isEmptyBack() bool {
	return len(deq.back) == 0
}

func (deq *deque) pushBack(v byte) {
	deq.back = append(deq.back, v)
}
func (deq *deque) pushFront(v byte) {
	deq.front = append(deq.front, v)
}
func (deq *deque) popBack(v *byte) bool {
	r := true
	if !deq.isEmptyBack() {
		*v = deq.back[len(deq.back)-1]
		deq.back = deq.back[:len(deq.back)-1]
	} else if !deq.isEmptyFront() {
		*v = deq.front[0]
		deq.front = deq.front[1:]
	} else {
		r = false
	}
	return r
}
func (deq *deque) popFront(v *byte) bool {
	r := true
	if !deq.isEmptyFront() {
		*v = deq.front[len(deq.front)-1]
		deq.front = deq.front[:len(deq.front)-1]
	} else if !deq.isEmptyBack() {
		*v = deq.back[0]
		deq.back = deq.back[1:]
	} else {
		r = false
	}
	return r
}

func (deq *deque) get(idx int) byte {
	tot := len(deq.front) + len(deq.back)
	var v byte
	if idx < tot {
		if idx < len(deq.front) {
			v = deq.front[len(deq.front)-1-idx]
		} else {
			v = deq.back[idx-len(deq.front)]
		}
	}
	return v
}

type op struct {
	rev, front bool
	c          byte
}

func rev(s string) string {
	r := make([]byte, len(s))
	i, j := len(s)-1, 0
	for i >= 0 {
		r[j] = s[i]
		j++
		i--
	}
	return string(r)
}

func main() {
	var S string
	fmt.Scan(&S)
	var Q int
	fmt.Scan(&Q)
	ops := make([]op, Q)
	for i := 0; i < Q; i++ {
		var q int
		fmt.Scan(&q)
		if q == 1 {
			ops[i].rev = true
		} else {
			var f int
			fmt.Scanf("%d %c", &f, &ops[i].c)
			if f == 1 {
				ops[i].front = true
			}
		}
	}
	sum := make([]int, Q+1)
	for i := Q - 1; i >= 1; i-- {
		if ops[i].rev {
			sum[i-1] = sum[i] + 1
		} else {
			sum[i-1] = sum[i]
		}
	}
	// fmt.Println("S", S, "Q", Q, "ops", ops, "sum", sum)
	if sum[0]%2 == 1 {
		S = rev(S)
	}
	var deq deque
	for i := 0; i < Q; i++ {
		if !ops[i].rev { // 反転ではない(文字列追加)
			if ops[i].front {
				if sum[i]%2 == 1 {
					deq.pushBack(ops[i].c)
				} else {
					deq.pushFront(ops[i].c)
				}
			} else {
				if sum[i]%2 == 1 {
					deq.pushFront(ops[i].c)
				} else {
					deq.pushBack(ops[i].c)
				}
			}
		}
	}
	// fmt.Printf("%q %q %q\n", string(deq.front), S, string(deq.back))
	for i := len(deq.front) - 1; i >= 0; i-- {
		fmt.Print(string(deq.front[i]))
	}
	for i := 0; i < len(S); i++ {
		fmt.Print(string(S[i]))
	}
	for i := 0; i < len(deq.back); i++ {
		fmt.Print(string(deq.back[i]))
	}
	fmt.Println()
}


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

using namespace std;
using ll = long long;
using ii = pair < int , int >;
using vi3 = pair < int , ii >;
using vi = vector < int >;
using vii = vector < ii >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

main(){

    scanf("%d %d" , &n , &m);

    int ans = 1;
    int d = 0;
    for(int i = 0 ; i < n ; i ++){
        int l;
        scanf("%d" , &l);
        if(l + d <= m)ans ++;
        d = l + d;
    }
    printf("%d\n" , ans);

    return 0;
}




Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);
$dll = new \SplDoublyLinkedList();
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    if ($line[0] === 'i') {
        $dll->unshift(substr($line, 7));
    } elseif ($line[6] === 'F') {
        $dll->shift();
    } elseif ($line[6] === 'L') {
        $dll->pop();
    } else {
        $check = substr($line, 7);
        foreach ($dll as $key => $val) {
            if ($val === $check) {
                $dll->offsetUnset($key);
                break;
            }
        }
    }
}

$str = array();
while (true) {
    try {
        $val = $dll->shift();
        $str[] = $val;
    } catch (Exception $e) {
        echo implode(' ', $str), PHP_EOL;
        break;
    }
}



Measured memory_bytes: 136132
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var length = IO.ReadDouble() / 3;
			IO.Write(Math.Pow(length , 3));
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
		public static long CombinationNum(int iLeftNumber , int iRightNumber)
		{
			if(iRightNumber == 0) { return 1; }
			if(iLeftNumber == 0)  { return 0; }
			return iLeftNumber * CombinationNum(iLeftNumber - 1 , iRightNumber - 1) / iRightNumber;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

using ll =long long;

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

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

int main()
{
int A,B,C;
  cin>>A>>B>>C;
  
  cout<<A*B/2<<endl;
  

}



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

using namespace std;

int main()
{
	char buf[11];
	int len, pos;
	int count = 0;

	cin >> buf;

	if (buf[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	
	len = strlen(buf);
	for (int i = 2; i < len - 1; i++) {
		if (buf[i] == 'C') {
			count++;
			pos = i;
		}
	}
	if (count != 1) {
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 1; i < len; i++) {
		if (buf[i] >= 'A' && buf[i] <= 'Z' && i != pos) {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}
vector<vector<int> > u(3001, vector<int> (3001));

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char dz[] = {'U', 'D', 'R', 'L'};
string bfs(int x, int y, int px, int py){
	vector<vector<pii> > path(3001, vector<pii> (3001));
	vector<vector<int> > curu = u;
	queue<pii> q;
	q.push({x, y});
	curu[x][y] = 1;
	curu[px][py] = 0;
	while(!q.empty()){
		pii u = q.front();
		q.pop();
		rep(i, 4){
			int qx = u.F + dx[i], qy = u.S + dy[i];
			if(qx >= 0 && qx <= 3000 && qy >= 0 && qy <= 3000 && !curu[qx][qy]) {
				curu[qx][qy] = 1;
				q.push({qx, qy});
				path[qx][qy] = {u.F, u.S};
			}
		}
	}
	// return "1";
	string ans = "";
	while(mp(px, py) != mp(x, y)){
		u[px][py] = 1;
		int cx = px - path[px][py].F;
		int cy = py - path[px][py].S;
		rep(i, 4) if(cx == dx[i] && cy == dy[i]) ans += dz[i];
		tie(px, py) = path[px][py];
	}
	reverse(all(ans));
	return ans;
}
void solve()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1 += 1500, y1 += 1500, x2 += 1500, y2 += 1500;
	string ans1 = bfs(x1, y1, x2, y2);
	string ans2 = bfs(x2, y2, x1, y1); 
	string ans3 = bfs(x1, y1, x2, y2);
	string ans4 = bfs(x2, y2, x1, y1);
	cout << ans1 << ans2 << ans3 << ans4;
}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


Measured memory_bytes: 144680
a, b = map(int,input().split())
if b == 1:
    print(0)
elif a >= b:
    print(1)
elif a < b:
    i = 2
    while(True):
        s = a * i - (i - 1)
        if s >= b:
            print(i)
            break
        i = i + 1

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int MOD=1e9+7;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    int cnt=0;
    vector<pair<P,P>> ret;
    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            if(a[i][j]%2==1){
                a[i][j]--;
                a[i][j+1]++;
                ret.push_back(make_pair(P(i,j),P(i,j+1)));
                cnt++;
            }
        }
    }
    for(int i=0;i<h-1;i++){
        if(a[i][w-1]%2==1){
            a[i][w-1]--;
            a[i+1][w-1]++;
            ret.push_back(make_pair(P(i,w-1),P(i+1,w-1)));
            cnt++;
        }
    }
    cout<<cnt<<endl;
    for(int i=0;i<cnt;i++){
        cout<<ret[i].first.first+1<<" "<<ret[i].first.second+1<<" "<<ret[i].second.first+1<<" "<<ret[i].second.second+1<<endl;
    }
}

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

#define ll long long
#define ull unsigned long long
#define met(a, x) memset(a,x,sizeof(a));
#define inf 0x3f3f3f3f
#define mp make_pair;

using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const int M = 4e4 + 10;
char a[110];
int s[30];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a;
    int n = strlen(a);
    for (int i = 0; i < n; i++) {
        s[a[i] - 'a' + 1]++;
    }
    int ans = inf;
    char c;
    for (int i = 1; i <= 26; i++) {
        if (s[i]) {
            int cnt = 0;
            int num = 0;
            c = i - 1 + 'a';
            for (int j = 0; j < n; j++) {
                if (a[j] != c) {
                    cnt++;
                } else if (a[j] == c) {
                    num = max(num, cnt);
                    cnt = 0;
                }
            }
            num=max(num,cnt);
            ans = min(ans, num);
        }
    }
    cout << ans << endl;
    return 0;
}



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

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

  	int R, G, B, N;

	cin >> R >> G >> B >> N;

	int remain,remainB,ret = 0;
	for (int r = 0; r <= N / R; ++r)
	{
		remain = N - (r * R);
		for (int g = 0; g <= remain / G; ++g)
		{
			remainB = remain - (g * G);
			if (remainB % B == 0)
			{
				++ret;
			}
		}
	}

	cout << ret << endl;

	return 0;
}

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

void solve()
{
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][W+1];
    for(int i=0; i<=n; i++){
        for(int j=0; j<=W; j++){
            if(i==0 || j==0){
                dp[i][j]=0;
                continue;
            }
            ll in=INT_MIN,ex=INT_MIN;
            if(j-w[i-1]>=0){
                in=v[i-1]+dp[i-1][j-w[i-1]];
            }
            ex=dp[i-1][j];
            dp[i][j]=max(in,ex);
        }
    }
    cout<<dp[n][W];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 82312
S = gets.chomp
u = S.split('').uniq
if u.length != 2 then
    puts "No"
    exit
end
h = {u[0] => 0, u[1]=> 0}
S.split('').each do |s|
    h[s] += 1
end
puts h[u[0]] == 2 ? "Yes" : "No"

Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int n,i,j,c[500],s[500],f[500],ans;
	cin>>n;
  for(i=0;i<n-1;i++){
    cin>>c[i]>>s[i]>>f[i];
  }

  for(i=0;i<n-1;i++){
    ans=0;
    for(j=i;j<n-1;j++){
      if(ans<s[j])ans=s[j];
      else if(ans%f[j]==0);
      else ans+=(f[j]-ans%f[j]);

      ans+=c[j];
    }
    cout<<ans<<endl;
  }
  cout<<0<<endl;
  
  return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

cnt = 0
i = 0
j = N-1
while i < j:
  if S[i] == 'x':
    if S[j] == 'x':
      i += 1
      j -= 1
    else:
      i += 1
      cnt += 1
  else:
    if S[i] == S[j]:
      i += 1
      j -= 1
    elif S[j] == 'x':
      cnt += 1
      j -= 1
    else:
      print(-1)
      exit()
print(cnt)

Measured memory_bytes: 9192
ss=input().rstrip()

x=1
y=0
mod=[0]*3000
ans=0
mod[0]=1
for i in range(len(ss)):
  s=ss[i*(-1)-1]
  n=int(s)
  y=(y+x*n)%2019
  ans+=mod[y]
  mod[y]+=1
  x=(x*10)%2019
print(ans)

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

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var a = new int[n];
		var map1 = new HashMap<Integer, Integer>();
		var map2 = new HashMap<Integer, Integer>();
		for (var i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			var v1 = i + a[i];
			if (!map1.containsKey(v1)) {
				map1.put(v1, 1);
			} else {
				map1.put(v1, map1.get(v1) + 1);
			}
			var v2 = i - a[i];
			if (!map2.containsKey(v2)) {
				map2.put(v2, 1);
			} else {
				map2.put(v2, map2.get(v2) + 1);
			}
		}
		sc.close();

		var count = 0L;
		for (var v1 : map1.keySet()) {
			if (map2.containsKey(v1)) {
				count += (long)map1.get(v1) * map2.get(v1);
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 82184
import java.util.Arrays;
import java.util.Scanner;

//Greedy, Greedy.
public class Main{

	int n, INF = 1<<29;
	int[] c;

	int f(int x){
		int res = 0, k = n-1;
		while(x>0&&k>=0){
			res += x/c[k];
			x%=c[k--];
		}
		return x==0?res:INF;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(int T=1;;T++){
			n = sc.nextInt();
			if(n==0)break;
			c = new int[n];
			int s = 0;
			for(int i=0;i<n;i++){
				c[i]=sc.nextInt(); s+=c[i];
			}
			int[] dp = new int[s+1];
			Arrays.fill(dp, INF);
			dp[0] = 0;
			boolean f1 = true, f2 = true;
			for(int x=1;x<=s&&f1;x++){
				for(int i=0;i<n;i++){
					if(x-c[i]>=0)dp[x] = Math.min(dp[x], dp[x-c[i]]+1);
				}
				if(dp[x]==INF)f1 = false;
				if(dp[x]<f(x))f2 = false;
			}
			System.out.println("Case #"+T+": "+(!f1?"Cannot pay some amount":!f2?"Cannot use greedy algorithm":"OK"));
		}
	}

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

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

const ll INF = 1e18;
int N;
vector<ll> scores, dp;
vector<int> rem;

void recursion(int r, int mask, ll score, int grp)
{
	if (r == (int)rem.size())
	{
		dp[mask] = max(dp[mask], score + scores[grp]);
		return;
	}
	recursion(r + 1, mask, score, grp);
	recursion(r + 1, mask ^ (1 << rem[r]), score, grp ^ (1 << rem[r]));
}

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> N;
	vector<vector<int>> a(N, vector<int> (N));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> a[i][j];
		}
	}
	dp.resize(1 << N, -INF);
	scores.resize(1 << N, 0);
	for (int mask = 0; mask < (1 << N); mask++)
	{
		for (int i = 0; i < N; i++)
		{
			if (mask & (1 << i))
			{
				for (int j = i + 1; j < N; j++)
				{
					if (mask & (1 << j))
						scores[mask] += a[i][j];
				}
			}
		}
	}
	dp[0] = 0;
	for (int mask = 0; mask < (1 << N); mask++)
	{
		rem.clear();
		for (int i = 0; i < N; i++)
		{
			if (!(mask & (1 << i)))
				rem.push_back(i);
		}
		recursion(0, mask, dp[mask], 0);
	}
	cout << dp[(1 << N) - 1];

	return 0;
}

Measured memory_bytes: 4312
import math
x = int(input())
tol = 1e-6
ans = 1
cur = [0,1]
unit = x/180*math.pi
while cur[0]**2 + cur[1]**2 > tol:
    cur[0] += math.sin(ans*unit)
    cur[1] += math.cos(ans*unit)
    ans += 1
print(ans)

Measured memory_bytes: 9504
//package AtCoder_163;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        StringTokenizer st=new StringTokenizer(br.readLine());
        ArrayList<Info> infants=new ArrayList<>();
        for(int i=1;i<=n;i++){
            infants.add(new Info(i,Long.parseLong(st.nextToken())));
        }
        Collections.sort(infants,Collections.reverseOrder());
        long dp[][]=new long[n+1][n+1];
        for(int i=0;i<n;i++){
            Info curr=infants.get(i);
            for(int l=0;l<=i+1;l++){
                long op1=0,op2=0;
                int r=i+1-l;
                if(l!=0){
                    op1=dp[l-1][r]+curr.val*(Math.abs(l-curr.index));
                }
                if(r!=0){
                    op2=dp[l][r-1]+curr.val*(Math.abs(n-r+1-curr.index));
                }
                dp[l][r]=Math.max(op1,op2);
            }
        }
        long ans=0;
        for(int i=0;i<=n;i++){
            ans=Math.max(ans,dp[i][n-i]);
        }
        System.out.println(ans);
    }
}

class Info implements Comparable<Info>{
    long val;int index;
    public Info(int index,long val){
        this.val=val;
        this.index=index;
    }

    @Override
    public int compareTo(Info o) {
        return Long.compare(this.val,o.val);
    }
}

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


void solve(long long N, long long K){
    cout << N - K + 1 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
import math

while True:
    line = int(input())
    if line == 0:
        break
    l = [float(s) for s in input().split()]
    avg = sum(l) / len(l)
    a2 = 0
    for i in l:
        a2 += (avg - i) ** 2

    print(math.sqrt(a2 / len(l)))

Measured memory_bytes: 7876
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

#define vec vector
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define int long long
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define rall(x) x.rbegin(), x.rend()
#define itn long long
using namespace std;
typedef pair<long long, long long> PII;
typedef long double ld;
int f(vec < vec < bool > > q, queue < PII > t){
        queue < PII > t1;
        bool fl = false;
        while(!t.empty()){
                PII w = t.front();
                t.pop();
                if(w.fi > 0 && q[w.fi-1][w.se] == false)
                        t1.push({w.fi-1, w.se}), q[w.fi-1][w.se] = true, fl = true;
                if(w.se > 0 && q[w.fi][w.se-1] == false)
                        t1.push({w.fi, w.se-1}), q[w.fi][w.se-1] = true, fl = true;
                if(w.fi+1 < q.size() && q[w.fi+1][w.se] == false)
                        t1.push({w.fi+1, w.se}), q[w.fi+1][w.se] = true, fl = true;
                if(w.se+1 < q[0].size()  && q[w.fi][w.se+1] == false)
                        t1.push({w.fi, w.se+1}), q[w.fi][w.se+1] = true, fl = true;
        }
        if(fl)
                return f(q, t1)+1LL;
        return 0LL;
}
signed main(){
      int n, m;
      cin >> n >> m;
      vec < vec < bool > > q(n, vec < bool > (m));
      char a;
      queue < PII > t;
      for(int i = 0; i < n; ++i){
              for(int j = 0; j < m; ++j){
                      cin >> a;
                      if(a == '#')
                        q[i][j] = true, t.push({i, j});
                        else
                        q[i][j] = false;
              }
      }
      cout << f(q, t);
return 0;
}

Measured memory_bytes: 378880
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

ll n, m, k;
ll res[3001][3001][4];
ll res1[3001][3001];

ll dfs(ll i,ll j,ll cur)
{
    if(i == n || j == m || cur == 3)
        return 0;
    if(res[i][j][cur] != -1)
        return res[i][j][cur];
    ll &ans = res[i][j][cur];
    ans = 0;
    if(res1[i][j] == 0)
        ans = max({ans,dfs(i+1,j,0), dfs(i,j+1,cur)});
    else
        ans = max({ans,res1[i][j] + dfs(i+1,j,0),res1[i][j] + dfs(i,j+1,cur+1),dfs(i,j+1,cur),dfs(i+1,j,0)});
    return ans;
}
void test_case()
{
	cin >> n >> m >> k;
    memset(res,-1,sizeof(res));
    for(int i = 0; i < k; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        res1[x-1][y-1] = z;
    }
    cout << dfs(0,0,0);

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 355968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, min;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  
  while (A.size() != 1) {
    sort(A.begin(), A.end());
    min = A.at(0);
  	for (int i=1; i<A.size(); i++) {
      A.at(i) = A.at(i) % min;
      if (A.at(i) == 0) {
        A.erase(A.begin() + i);
      }
    }
  }
  cout << A.at(0) << endl;
}


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

long long a, b, c;

int main() {
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    cout << 0 << endl;
  else
    cout << min({a * b, b * c, c * a}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EPS 1e-9
#define PI acos(-1)
using namespace std;
typedef long long ll;
const int maxn = 1e5+100;
ll a[maxn];
ll n,A,B;

bool check(ll res)
{
    ll num = 0;
    for(int i = 1; i <= n; i++)
    {
        ll tmp = a[i]-res*B;
        if(tmp>0)
        {
            num += (tmp-1)/(A-B)+1;
        }
    }
    if(num>res) return false;
    else return true;
}

int main()
{
    ios::sync_with_stdio(false);

    cin>>n>>A>>B;
    ll l = 1;
    ll r = 0;
    for(int i = 1; i <=n ;i++ )
    {
        cin>>a[i];
        r += a[i]/B+1;
    }

    ll ans;
    while(l<r)
    {
        ll mid = l+r>>1;
        if(check(mid))
        {
            r = mid;
            ans = mid;
        }
        else
        {
            l = mid+1;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	double W, H, x, y;
	cin >> W >> H >> x >> y;
	
	if (x == W / 2 && y == H / 2) {
		cout << (W * H) / 2 << ' ' << 1 << endl;
	}
	else {
		cout << (W * H) / 2 << ' ' << 0 << endl;
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n) {
	return 0;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));
}


int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans_area =(double(w) * double(h))/ 2;


	if (2 * x == w && 2 * y == h){
		cout <<fixed <<setprecision(8)<< ans_area << " " << 1 << endl;
	}
	else {
		cout << fixed << setprecision(8) << ans_area << " " << 0 << endl;
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 1008
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let s=readStr().ToCharArray() |> Array.toList

let rec shrink c = function
  | [_] -> []
  | _::b::s when b=c -> b::(shrink c (b::s))
  | a::s -> a::(shrink c s)
  | [] -> []

let check c = List.forall ((=) c)

let rec count c s = if check c s then 0 else 1+(count c (shrink c s))

['a'..'z']
|> List.fold (fun st c -> min st (count c s)) 1000
|> printfn "%d"


Measured memory_bytes: 19148
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        x: usize,
        y: usize,
    }

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", x + y / 2).unwrap();
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
inline double sq(double a) { return a*a; }

int n, ox[200], oy[200];

int main() {
    for(;;) {
        scanf("%d", &n);
        if(n==0) return 0;
        rep(i, n) scanf("%d%d", ox+i, oy+i);
        vector<int> ys;
        rep(i, n) ys.push_back(oy[i]);
        sort(ys.begin(), ys.end());
        ys.erase(unique(ys.begin(), ys.end()), ys.end());
        vector<double> x;
        vector<int> y;
        rep(i, n) {
            x.push_back(ox[i]);
            y.push_back(oy[i]);
            if(i==n-1) break;
            if(oy[i]<oy[i+1]) {
                rep(j, ys.size()) if(oy[i]<ys[j] && ys[j]<oy[i+1]) {
                    const double dx = ox[i+1]-ox[i], dy = oy[i+1]-oy[i];
                    x.push_back(ox[i]+dx/dy*(ys[j]-oy[i]));
                    y.push_back(ys[j]);
                }
            }
            else if(oy[i]>oy[i+1]) {
                const int m = ys.size();
                for(int j=m-1; j>=0; j--) if(oy[i+1]<ys[j] && ys[j]<oy[i]) {
                    const double dx = ox[i+1]-ox[i], dy = oy[i+1]-oy[i];
                    x.push_back(ox[i]+dx/dy*(ys[j]-oy[i]));
                    y.push_back(ys[j]);
                }
            }
        }
        typedef pair<int, int> node;
        set<node> vis;
        priority_queue<pair<double, node> > q;
        q.push(mp(0, mp(0, x.size()-1)));
        while(!q.empty()) {
            pair<double, node> vv(q.top());
            q.pop();
            const double c = -vv.first;
            const int l = vv.second.first;
            const int r = vv.second.second;
            if(vis.find(mp(l, r))!=vis.end()) continue;
            vis.insert(mp(l, r));
            if(l==r) {
                printf("%.9f\n", c);
                break;
            }
            for(int i=-1; i<=1; i++) if(0<=l+i && l+i<(int)x.size()) {
                for(int j=-1; j<=1; j++) if(0<=r+j && r+j<(int)x.size()) {
                    if(y[l+i]==y[r+j]) {
                        const double d1 = sqrt(sq(x[l]-x[l+i])+sq(y[l]-y[l+i]));
                        const double d2 = sqrt(sq(x[r]-x[r+j])+sq(y[r]-y[r+j]));
                        q.push(mp(-c-d1-d2, mp(l+i, r+j)));
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 1832