akhauriyash/Code-Regression huggingface dataset:
class Node:
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right
        self.parent = -1
        self.sibling = -1
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.type = ""

    def __str__(self):
        if self.parent == -1:
            self.type = "root"
        elif self.degree == 0:
            self.type = "leaf"
        else:
            self.type = "internal node"
        return "node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(
            self.node, self.parent, self.sibling, self.degree, self.depth, self.height, self.type)


preOrder = None
inOrder = None
postOrder = None


def dfs(tree, v, p, d, s):
    global preOrder, inOrder, postOrder
    preOrder.append(v)
    tree[v].parent = p
    tree[v].depth = d
    tree[v].sibling = s
    maxheight = 0
    if tree[v].left != -1:
        tree[v].degree += 1
        maxheight = max(
            maxheight, dfs(
                tree, tree[v].left, v, d + 1, tree[v].right))
    inOrder.append(v)
    if tree[v].right != -1:
        tree[v].degree += 1
        maxheight = max(
            maxheight, dfs(
                tree, tree[v].right, v, d + 1, tree[v].left))
    postOrder.append(v)
    if tree[v].left == tree[v].right:
        tree[v].height = 0
        return 0
    tree[v].height = maxheight + 1
    return tree[v].height


def resolve():
    global preOrder, inOrder, postOrder
    preOrder, inOrder, postOrder = [], [], []
    n = int(input())
    tree = [None for i in range(n)]
    V = [list(map(int, input().split())) for _ in range(n)]
    hasChild = set()
    childrens = set()
    for a, left, right in V:
        tree[a] = Node(a, left, right)
        if left != right:
            hasChild.add(a)
            childrens.add(left)
            childrens.add(right)
    root = hasChild - childrens
    if len(root) > 0:
        root = root.pop()
    else:
        root = 0
    dfs(tree, root, -1, 0, -1)
    print("Preorder")
    print("", *preOrder)
    print("Inorder")
    print("", *inOrder)
    print("Postorder")
    print("", *postOrder)


resolve()



Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long
#define MAX_N 500001

using namespace std;

long long MOD = 1000000007;

long long fact[MAX_N];
void factorial(int N){
    fact[0]=1;
    for(int i=0; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv;
long long inverse(long long x){
    if (inv.count(x)){
        return inv[x];
    }else if(x==0){
        return 1;
    }

    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
        //cout << p << endl;
    }
    inv[x]=ret;
    return ret;
}

long long comb(int a, int b){
    long long ret=fact[a]*inverse(fact[a-b])%MOD;
    return ret*inverse(fact[b])%MOD;
}

int main(){
    ll N, M;
    cin >> N >> M;

    //cout << N << ' ' << M;
    factorial(M);
    ll ans=0;
    ll f=1;
    for(ll K=1; K<=N; K++){
        ll tmp=comb(N,K)*fact[M]%MOD;
        tmp=(tmp*inverse(fact[M-K]))%MOD;
        tmp=(tmp*fact[M-K])%MOD;
        tmp=(tmp*fact[M-K])%MOD;
        tmp=(tmp*inverse(fact[M-N]))%MOD;
        tmp=(tmp*inverse(fact[M-N]))%MOD;
        ans+=f*tmp;
        ans%=MOD;
        f*=-1;
    }

    ll tmp = fact[M]*inverse(fact[M-N])%MOD;
    tmp =(tmp*tmp)%MOD;
    //cout << tmp << endl;
    //cout << ans << endl;
    cout << ((tmp-ans)%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 38612
mod scanner {
    use std::io::Read;
    use std::io::StdinLock;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        cin: StdinLock<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(cin: StdinLock<'a>) -> Scanner<'a> {
            Scanner { cin: cin }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            let ok = |c| '!' <= c && c <= '~';
            let t = self.cin
                .by_ref()
                .bytes()
                .map(|c| c.unwrap() as char)
                .skip_while(|&c| !ok(c))
                .take_while(|&c| ok(c))
                .collect::<String>();
            t.parse::<T>().ok().unwrap()
        }
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());

    let mut res = 0;
    let n: usize = sc.next();
    let mut p = -1;
    for _ in 0..n {
        let x = sc.next();
        if p == x {
            res += 1;
            p = -2;
        } else {
            p = x;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
typedef long long ll;
int N;
char s[MAX_N];
ll J[MAX_N],JO,JOI,I,OI,ans;
int main(){
  scanf("%d %s",&N,s);
  for(int i=1;i<=N;i++){
    J[i]=J[i-1];
    if(s[i-1]=='J')J[i]++;
    if(s[i-1]=='O')JO+=J[i];
    if(s[i-1]=='I')JOI+=JO;
  }
  ans=JO;
  for(int i=N;i>=1;i--){
    if(s[i-1]=='I')I++;
    if(s[i-1]=='O')OI+=I;
    ans=max(ans,I*J[i]);
  }
  ans=max(ans,OI);
  printf("%lld\n",ans+JOI);
  return 0;
}

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

// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define sz(x) int((x).size())
#define fi first
#define se second

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))
#define mp(a,b) make_pair(a,b)

// useful bits
#define IN(i,l,r) (i >= l && i <= r);
#define relax(a,b) a = max(a,b);
#define relaxi(a,b) a = min(a,b);

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)

ll n ,a,b;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
//	freopen("output.txt", "w" , stdout);
	/* freopen("in.txt" , "r" , stdin); */
	/* clock_t start = clock(); */
	#endif
	cin >> n >> a >> b;
	/* cerr << a << " " << b<<endl; */
	if(a >b){cout << 0 << endl; return 0;}
	if((n == 1&& a!=b) ){cout<< 0 << endl; return 0;}

	ll diff = (n-1)*b+a - ((n-1)*a+b)+1;
	cout << diff<< endl;

	#ifndef ONLINE_JUDGE
	/* cout << setprecision(12) << ld(clock()-start) / CLOCKS_PER_SEC << endl; */
	#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        rep(i, 0, h) {
            rep(j, 0, w) {
                if (i == 0 || j == 0 || i == h - 1 || j == w - 1) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2 - x1, y = y2 - y1;
  printf("%d %d %d %d\n",x2 - y,y2 + x,x1 - y,y1 + x);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
#define N 100010
vector<int> p[N];
int a[N],vis[N];
int s;
void dfs(int x,int y)
{
    int i,j,k;
    k=p[x].size();
    for(i=0;i<k;i++)
    {
        j=p[x][i];
        if(vis[j]==0)
        {
            vis[j]=y;
            dfs(j,y);
        }
    }
}
int main()
{
    int i,j,k,n,m,x,y;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&x,&y);
        p[x].push_back(y);
        p[y].push_back(x);
    }
    j=1;
    s=0;
    for(i=1;i<=n;i++)
    if(vis[i]==0)
    {
        vis[i]=j;
        dfs(i,j);
        j++;
    }
    for(i=1;i<=n;i++)
    {
        if(vis[a[i]]==vis[i]||a[i]==i)
        s++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 9472
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, k; cin>>n>>k;
    int a[51];
    //vector<int> v;
    int ct[51]={};
    int s=0;
    int ind[51];
    for(int i=0; i<n; i++){
        cin>>a[i]; ind[i]=i;
        if(a[i]<=k){
            ct[i]+=(k+1-a[i]);
            s+=ct[i];
            //for(int j=0; j<k+1-a[i]; j++) v.push_back(i);
        }
    }
    if(s>k){
        cout<<-1<<endl;
        return 0;
    }
    int mxi=max_element(ct, ct+n)-ct;
    if(ct[mxi]>(k+1)/2){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0; i<n; i++){
        while(s<k && ct[i]<(k+1)/2){
            s++;
            ct[i]++;
        }
    }
    sort(ind, ind+n, [&](int i, int j){ return ct[i]>ct[j];});
    int ans[52];
    fill(ans, ans+k, -1);
    int l=0;
    for(int i=0; i<n; i++){
        while(ct[ind[i]]){
            ans[l]=ind[i]; ct[ind[i]]--;
            l++; l++;
            if(l>=k) l=1;
        }
    }
    ans[k]=ans[k-1];
    int q=(k+1)*n-k;
    cout<<q<<endl;
    vector<int> v;
    for(int i=0; i<n; i++){
        if(ans[0]!=i) v.push_back(i);
    }
    for(int j=0; j<k; j++){
        v.push_back(ans[j]);
        for(int i=0; i<n; i++){
            if(i!=ans[j] && i!=ans[j+1]) v.push_back(i);
        }
    }
    for(int i=0; i<q; i++){
        cout<<v[i]+1;
        if(i<q-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

char island[101][101];
int h, w;

void dfs(int i, int j, char c){
	int di, dj;
	
	island[i][j] = 'x';
		
	for (di = -1; di <= 1; di += 2){
		if (0 <= i + di && i + di < h && island[i + di][j] == c){
			dfs(i + di, j, c);
		}
	}
	for (dj = -1; dj <= 1; dj += 2){
		if (0 <= j + dj && j + dj < w && island[i][j + dj] == c){
			dfs(i, j + dj, c);
		}
	}
}

int main(void)
{
	int i, j;
	int num;
	
	while (1){
		scanf("%d%d", &h, &w);
		if (!(h + w)){
			break;
		}
		memset(island, 'x', sizeof(island));
		for (i = 0; i < h; i++){
			scanf("%s", island[i]);
			getchar();
		}
		
		num = 0;
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if (island[i][j] != 'x'){
					dfs(i, j, island[i][j]);
					num++;
				}
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(max({a, b, c}) == 7 && min({a, b, c}) == 5 && a + b + c == 17){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int n;
int from[100005], to[100005], step[100005], ans[100005];
char c[100005];

void init() {
	scanf("%s", c+1);
	n = strlen(c+1);
	int lastl, lastr;
	for(int i = n; i >= 1; i--) {
		if(c[i] == 'L') {
			lastl = i, lastr = 0;
		}
		if(c[i] == 'R') {
			if(lastr == 0) lastr = i;
			step[i] = lastl - i;
			from[i] = lastr;
			to[i]=  lastl;
		}
	}
	lastl = lastr = 0;
	for(int i = 1; i <= n; i++) {
		if(c[i] == 'L') {
			if(lastl == 0) lastl = i;
			step[i] = i - lastr;
			from[i] = lastl;
			to[i] = lastr;
		}
		if(c[i] == 'R') {
			lastr = i;
			lastl = 0;
		}
	}
//	for(int i = 1; i <= n; i++) printf("%d ", step[i]);
//	cout << endl;
}

void solve() {/*
	for(int i = 1; i <= n; i++) {
		int pos = i;
		while(1) {
			int use = pos;
			step[i]++;
			if(c[pos] == 'L') {
				use--;
			}
			else {
				use++;
				if(c[use] == 'L') {
					from[i] = use;
					to[i] = pos;
					break;
				}
			}
			pos = use;
		}
	}*/
	//from -> L, to -> R
	for(int i = 1; i <= n; i++) {
		if(step[i] % 2 == 1) {
			ans[from[i]]++;
		}
		else ans[to[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		printf("%d ", ans[i]);
	}
}

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


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


int main() {
  int h, w;
  cin >> h >> w;
  
  string s = "";
  string buf(w+2, '.');
  s += buf;
  for (int i = 0; i < h; i++) {
    string si;
    cin >> si;
    s += "." + si + ".";
  }
  s += buf;
  
  
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (s.at(i*(w+2)+j) == '#') {
        char sij_up = s.at((i-1)*(w+2)+j);
        char sij_down = s.at((i+1)*(w+2)+j);
        char sij_right = s.at(i*(w+2)+j+1);
        char sij_left = s.at(i*(w+2)+j-1);
        if (sij_up == '.' && sij_down == '.' && sij_right == '.' && sij_left == '.') {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  
  cout << "Yes" << endl;
}


Measured memory_bytes: 3596
# 余弦定理から、a**2 = b**2 + c**2 - 2bccosA
# ヨビノリの授業動画で三角関数の理解を深める

# import math
# a,b,h,m = map(int,input().split())
# q = abs((h+m/60)/12-m/60) * 360
# print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(q))))


import math

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


'''
時計の角度はいくつか？
長針は６０分で１回展（360度）回るので1分あたりに進む角度は、
360 / 60 = 6

よって、時間が6分だったら 6*6=36度回る

短針は12時間で1回展（360度）まわるので1分辺りに進む角度は
360 / (12*60) = 0.5 度回る
よって時間が6分だったら 6*0.5=3度回る
'''

longAngle  = M * 6
shortAngle = (H * 60 + M) * 0.5
Angle      = math.cos(math.radians(abs(longAngle - shortAngle)))


result = math.sqrt(A**2 + B**2 - 2*A*B*Angle)

print(result)


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

int main(int argc, char const *argv[]) {
  size_t n, ans = 0;
  cin >> n;

  // n = k * (m + 1)
  for (size_t k = 1; k * k < n; k++)
    if (n % k == 0 && k < n / k - 1) ans += n / k - 1;  // ans += m;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	
    ll n,ans;
    string s;
    char c;
    cin>>c;
    c++;
    
    puta(c);
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,a,b,c = map(int, input().split())
    l = [int(input()) for _ in range(n)]


    res = 10**20
    #各竹について0~3で場合分け
    for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 48860
#include<cstdio>
#include<algorithm>

#define INF 1e17
using namespace std;

typedef long long ll;

int n;
ll a[100001];
ll sum[100001];

bool cut(ll x,int f){
	int s=lower_bound(sum+f,sum+n,sum[f]+x)-sum;
	int t=lower_bound(sum+s,sum+n,sum[s]+x)-sum;
	//printf("%d %d %d %lld\n",f,s,t,x);
	//printf("%lld %lld %lld\n",sum[s]-sum[f],sum[t]-sum[s],sum[n]-sum[t]+sum[f]);
	if(sum[s]-sum[f]<x)return false;
	if(sum[t]-sum[s]<x)return false;
	if(sum[n]-sum[t]+sum[f]<x)return false;
	return true;
}



bool check(ll x){
	int cut_f=0;
	for(int i=0;i<n;i++){
		if(cut(x,i))return true;
	}
	return false;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i-1];
	ll left=0,right=INF;
	for(int i=0;i<100;i++){
		ll mid=(left+right)/2;
		if(check(mid))left=mid;
		else right=mid;
	}
	printf("%lld\n",left);
	return 0;
}

Measured memory_bytes: 2588
"use strict";

!function () {
  !function (input) {
    var S = input.split("\n")[0];
    var fst = parseInt(S.slice(0, 2), 10);
    var snd = parseInt(S.slice(2), 10);
    var isYYMM = 1 <= snd && snd <= 12;
    var isMMYY = 1 <= fst && fst <= 12;
    if (isYYMM && isMMYY) console.log("AMBIGUOUS");else if (isYYMM) console.log("YYMM");else if (isMMYY) console.log("MMYY");else console.log("NA");
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();


Measured memory_bytes: 22080
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
int main(){
	int n;
	cin>>n;
	ll a[200100];
	a[0]=0;
	rep(i,0,n){
		ll x;
		cin>>x;
		a[i+1]=a[i]+x;
	}
	map<ll,ll> mp;
	ll ans=0;
	rep(i,1,n+1){
		ans+=mp[a[i]];
		mp[a[i]]++;
	}
	ans+=mp[0];
	cout<<ans<<endl;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
#define currPoint(P, i) P[i]
#define nextPoint(P, i) P[(i+1)%P.size()]

int n;
double x, y;

int main()
{
  cin >> n;

  while(n--){
    cin >> x >> y;
    Point A(x, y);
    cin >> x >> y;
    Point B(x, y);
    cin >> x >> y;
    Point C(x, y);
    Point alpha = conj(A) * (B - C);
    Point beta  = conj(B) * (C - A);
    Point gamma = conj(C) * (A - B);
    Point O = (A * alpha + B * beta + C * gamma) / (alpha + beta + gamma);
    printf("%.3f %.3f %.3f\n", O.real(), O.imag(), abs(O - A));
  }

  return 0;
}

Measured memory_bytes: 1268
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

vi a;
int n;

int main()
{
    cin >> n;
    REP(i, n)
    {
        int c;
        cin >> c;
        a.push_back(c);
    }
    sort(ALL(a));
    reverse(ALL(a));
    int ans = 0;
    REP(i, n)
    {
        ans += a[i++];
        if (i != n)
            ans -= a[i];
    }
    cout << ans << endl;
}

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

int dp[1000006];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++){
        dp[i] = dp[i-1]+1;
        int coin = 6;
        while (i - coin >= 0){
            dp[i] = min(dp[i], dp[i-coin]+1);
            coin *= 6;
        }
        coin = 9;
        while (i - coin >= 0){
            dp[i] = min(dp[i], dp[i-coin]+1);
            coin *= 9;
        }
    }
    printf("%d", dp[N]);
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

typedef long long ll;



int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    // to vector
    vector<char> s(N);
    REP(i,N) s[i]=S[i];
    int W = count(ALL(S),'W');
    int E = count(ALL(S),'E');


    int change = E;
    int m=E;
    // counting
    REP(leader,N) {
        if (s[leader] == 'E') change--;
        if (leader>0) {
            if (s[leader-1]=='W') change++;
        }

        chmin(m,change);
    }
    cout << m << endl;



    return 0;
}


Measured memory_bytes: 1028
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    k = getN()
    a,b = getList()
    for i in range(a, b+1):
        if i % k == 0:
            print("OK")
            return

    print("NG")
    return
if __name__ == "__main__":
    main()

Measured memory_bytes: 65148
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    x = I()
    if x == 0:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

typedef pair<int, int> P;

signed main() {
  int n, m;
  cin >> n >> m;
  P a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + m);
  int count = 0;
  int mini = 0;
  for (int i = 0; i < m; i++) {
    if (a[i].first >= mini) {
      count++;
      mini = a[i].second;
    } else {
      mini = min(mini, a[i].second);
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int a[200005];
int cmp(int a,int b) {
	return a>b;
}
int main() {
	int n,k;
	ll ans=0;
	cin>>n>>k;
	FOR(i,0,n) cin>>a[i];
	sort(a,a+n,cmp);
	FORD(i,k-1,0) a[i]=0;
	FOR(i,0,n) ans+=a[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;


#define rep(i, n) for (int i = 0; i < (int)(n); i++)

/* vector<int> A(N); */
/* xの二乗
 pow(x, 2.0) */
 
int main() {
  
  int H,N;
  long long All =0;
  cin >> H >> N;
  vector<int> A(N);
  
  rep(i,N){
  	cin >> A.at(i);
  }
  
  rep(i,N){
  	All = All+A.at(i);
  }
  
  if(All >= H){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a - b == b - c)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int ans[n] = {0};
  
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    ans[a - 1]++;
    ans[b - 1]++;
  }
  
  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}
const int M=1e3;
const int N=14;
int n,m;
int a[M];
vi c[M];
vi abiertax[N];
int sol[(1<<15)];

void solve(int mask,int idx=0){
    if (sol[mask]==-1){
        sol[mask]=INF;
        for(int i=idx;i<n;++i){
            if ((mask &(1<<i) )==0){
                for(int j:abiertax[i]){
                    int mask2= mask;
                    for(int k:c[j]){
                        mask2 |= (1<<k);
                    }
                    solve(mask2,i+1);
                    sol[mask] = min(sol[mask],sol[mask2]+a[j]);
                }
                break;
            }
        }
    }
}

int main() {
    READ(0);
    cin>>n>>m;
    FOR(i,m){
        cin>>a[i];
        int b;cin>>b;
        c[i].resize(b);
        FOR(j,b) {
            cin>>c[i][j];
            abiertax[--c[i][j]].push_back(i);
        }
    }
    fill(sol,sol+(1<<n),-1);
    sol[(1<<n)-1]=0;
    solve(0);
    if (sol[0]==INF) cout << -1;
    else cout << sol[0];
    return 0;
}



Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>

#define ll long long
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<" "<<to_string(head);
    debug(tail...);
}

int main(){
    int N;
    cin>>N;
    vector<int> b(N);
    FOR(i,N)cin>>b[i];
    string res="";
    while(b.size()>0){
        bool flag=0;
        for(int j=b.size()-1;j>=0;--j){
            if(b[j]==j+1){
                res=to_string(j+1)+"\n"+res;
                b.erase(b.begin()+j);
                flag=1;
                break;
            }
        }
        if(flag==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main {
  case class Rotation(run: Dice => Dice){
    def apply(d: Dice): Dice = run(d)
    def compose(other: Rotation) = Rotation(run compose other.run)
  }

  object Rotation {
    def id = Rotation(d => d)
    def north = Rotation(d => Dice(List(1,5,2,3,0,4).map(d.pip)))
    def east = Rotation(d => Dice(List(3,1,0,5,4,2).map(d.pip)))
    def ccw = Rotation(d => Dice(List(0,3,1,4,2,5).map(d.pip)))

    final def axial(rot: Rotation): Seq[Rotation] =
      for(i <- 0 to 3) yield List.fill(i)(rot).fold(id)(_ compose _)

    def enumerateTop: Seq[Rotation] =
      for(i <- 1 to 6) yield ((0 to i).map(j => if(j % 2 == 0) north else east)).fold(id)(_ compose _)

    def enumerate: Seq[Rotation] = enumerateTop.flatMap(e => axial(ccw).map(e compose _))
  }

  case class Dice(pip: List[Int]){
    lazy val all: Seq[Dice] = Rotation.enumerate.map(_.run(this))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val Array(n,_*) = readLine.split(" ").map(_.toInt)
    val dices = for(i <- 1 to n) yield Dice(readLine.split(" ").map(_.toInt).toList)

    val res = for {
      i <- 0 until n
      j <- i+1 until n
    } yield dices(i) == dices(j)

    println( if(res.forall(_ == false)) "Yes" else "No")
  }
}

Measured memory_bytes: 56612
import sys
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

A, B, C = InMap()

if A == B:
    if B == C:
        print('No')
    else:
        print('Yes')
elif B == C:
    print('Yes')
elif A == C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){

  int n; cin >> n;
  vector<string> A(n); for (int i=0; i<n; i++) cin >> A[i];
  int swapCount = 0;
  vector<string> B=A;
  for (int i=0; i<n; i++) for (int j=n-1; j>i; j--) if ((int)B[j][1]<(int)B[j-1][1]) swap(B[j],B[j-1]);

  vector<string> S=A;
  for (int i=0; i<n; i++){
    int minj=i;
    for (int j=i; j<n; j++) if ((int)S[j][1]<(int)S[minj][1]) minj=j;
    swap(S[i],S[minj]);
  }

  cout << B[0];
  for (int k=1; k<n; k++) cout << " " << B[k];
  cout << endl << "Stable" << endl;

  cout << S[0];
  for (int k=1; k<n; k++) cout << " " << S[k];
  cout << endl;

  if (B==S) cout << "Stable"; else cout << "Not stable";
  cout << endl;


  return 0;
}



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

int main(){
	
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=0;i<10000;i++){
			if(i%10+i%100/10+i%1000/100+i/1000==n)ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

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

    bool ok=true;
    sort(all(a));
    rep(i,n){
        if(i!=0){
            if(a[i-1]==a[i]){ok=false; break;}
        }
    }
    cout<<(ok==true ? "YES" : "NO")<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace AtCoderContest
{
    class Program
    {
        static void Main()
        {
            var inputs = Console.ReadLine().Split(" ").Select(int.Parse).ToList();
            var (n, x, t) = (inputs[0], inputs[1], inputs[2]);

            if (n % x == 0)
            {
                Console.WriteLine((n / x) * t);
            }
            else
            {
                Console.WriteLine((n / x + 1) * t);
            }
        }
    }
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    double sum=v[0];
    for(int i=1;i<n;i++){
        sum=(sum+v[i])/2;
    }
    printf("%.12lf\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int h, w, map[20][20], ans;
int f(int i, int j, int k, int l) {
	int a = 9, b = 0;
	for (int p = i; p <= j; p++) {
		for (int q = k; q <= l; q++) {
			if (p == i || p == j || q == k || q == l)a = min(a, map[p][q]);
			else b = max(b, map[p][q]);
		}
	}
	if (b >= a)return 0;
	int r = 0;
	for (int p = i + 1; p < j; p++) {
		for (int q = k + 1; q < l; q++) {
			r += a - map[p][q];
		}
	}
	return r;
}
signed main() {
	while (cin >> h >> w, h) {
		for1(i, h)for1(j, w)cin >> map[i][j];
		ans = 0;
		for1(i, h)for (int j = i + 2; j <= h; j++) {
			for1(k, w)for (int l = k + 2; l <= w; l++) {
				ans = max(ans, f(i, j, k, l));
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3120
using System;
using System.Linq;
class Ho{
   static void Main(){
     var S = Console.ReadLine();
     var n = S.Length;
     var Sgya = new string(S.Reverse().ToArray());  
     var tuyoi = S.Substring(0,(n+3)/2-2);
     var tuyoi2 = Sgya.Substring((n+3)/2-1);
     if(S==Sgya && tuyoi == tuyoi2){
       Console.WriteLine("Yes");
     }
     else{
        Console.WriteLine("No");
     }
   }
    
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
#define M 1000000009
#define pi 3.14159265358979323846264338327950
typedef pair<int,int> pr;
#define N 1000002
signed main()
{
    SPEED;
    int n,i,f=0,mod=100000000000000;
    cin>>n;
    int a[n+1];
    for(int i=0;i<=n;++i)
        cin>>a[i];
    int dp[n+1];
    dp[0]=1;
    if((a[0]>=1 && n>0) || (n==0 && a[0]>1))
    {
        cout<<-1;
        return 0;
    }
    if(n==0 && a[0]==1)
    {
        cout<<1;
        return 0;
    }
    for(i=1;i<n;++i)
    {
        dp[i]=min(2*(dp[i-1]-a[i-1]),mod);
        if(dp[i]<=0)
        {
            f=1;
            break;
        }
    }
    if(f==1 || 2*(dp[n-1]-a[n-1])<a[n])
    {
        cout<<-1;
        return 0;
    }
    int mv[n+1]={0};
    mv[n]=a[n];
    int res=mv[n];
    for(i=n-1;i>=0;--i)
    {
        mv[i]=min(dp[i],mv[i+1]+a[i]);
        res+=mv[i];
    }
    cout<<res;
}

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

int main() { 
  int N;
  cin >> N;
  
  int a = 0;
  for(int i = 1;i <= 9; i++){
    for(int j = 1; j <= 9; j++){
     if(N == i*j){
       a++;
     }
    }
  }
  if(a >= 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

    int a[n];
    
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    int maxv = -1000000001;
    int minv = a[0];
    
    for(int i = 1; i < n; i++){
        maxv = max(maxv, a[i] - minv);
        minv = min(minv, a[i]);
    }

    cout << maxv << '\n';

    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define sim template < class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
    sim > typename enable_if< sizeof dud< c >(0) x 1, debug & >::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge< c > range(c i, c j) { return rge< c >{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef XOX
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair< b, c > d)
{
    ris << "" << d.first << " --> " << d.second << "";
}
sim dor(rge< c > d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) "" << #__VA_ARGS__ " = " << (__VA_ARGS__) << ", "

#define F first
#define S second
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define all(v) (v).begin(), (v).end()
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie();                    \
    cout.tie()
#define min3(x, y, z) (x < y ? (x < z ? x : z) : (y < z ? y : z))
#define max3(x, y, z) (x > y ? (x > z ? x : z) : (y > z ? y : z))
#define MAX_N int(1e6 + 7)
#define MAX_M int(1e6 + 7)
#define MAX_V int(1e6 + 7)
#define oo int(1e9 + 217)
#define MOD int(1e9 + 7)
using ll = long long;
using vi = vector< int >;
using vl = vector< ll >;
using vpii = vector< pair< int, int > >;
using pii = pair< int, int >;

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

void solve()
{
}

int main()
{
    fast;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b == 0 and b != a)
        b--;
    if (d == 0 and d != c)
        d--;
    cout << max({a * c, a * d, b * c, b * d});
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define FF(i,a,b) for (int i=a;i<=b;i++)
#define F(i,b,a)  for (int i=b;i>=a;i--)
#define mes(a,b)  memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
typedef long long ll;
const int N = 2e5+10;

ll n, m, s, ans;
int main()
{
    cin>>n>>m;
    if(n*2>=m) cout<<m/2<<endl;
    else cout<<n+(m-2*n)/4<<endl;

    return 0;
}


Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;



int main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int a, l, x;
    while (cin >> a >> l >> x) {
        double S = a * sqrt(l * l - a * a / 4.0) / 2.0;
        double S2 = l * sqrt(((l + x) * (l + x) - l * l) / 4.0);
        printf("%.10lf\n", S + S2);
    }
}

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

int st[100],top=0;

void push(int x){
  st[top]=x;
  top++;
}

int pop(void){
  top--;
  return st[top];
}

int main(){
  int x,r,t;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      r=pop();
      t=pop();
      push(r+t);
    } else if ( s[0] == '-' ){
      r=pop();
      t=pop();
      push(t-r);
    } else if ( s[0] == '*' ){
      r=pop();
      t=pop();
      push(t*r);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",st[0]);
  return 0;
}



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

int main()
{

string S;
cin >> S;
   
if (S=="Sunny") {
cout <<"Cloudy"<<endl; 
}
else if (S=="Cloudy") {
cout <<"Rainy"<<endl; 
}
else if (S=="Rainy"){
cout <<"Sunny"<<endl;
}
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string S; cin >> S;
    if(S[0]==S[1] and S[1]==S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int d = sc.nextInt();
        
        if(Math.abs(a-c)<=d)
        	System.out.println("Yes");
        else if(Math.abs(a-b) <= d&&Math.abs(b-c) <= d )
        	System.out.println("Yes");
        else 
        	System.out.println("No");
		
	}


}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int n, ans = 0 ;
int d[55], cnt[30] ;
bool vis[30] ;
vector<int> v ;
void dfs (int cur) {
    if (cur == n) {
        int res = 1e9 ;
        for (int i = 0; i < v.size(); i ++)
            for (int j = i + 1; j < v.size(); j ++)
                res = min (res, min (abs (v[i] - v[j]), 24 - abs (v[i] - v[j]))) ;
        ans = max (ans, res) ;
        return ;
    }
    dfs (cur + 1) ;
    if (!vis[v[cur]]) {
        v[cur] = 24 - v[cur] ;
        dfs (cur + 1) ;
        v[cur] = 24 - v[cur] ;
    }
}
int main() {
    cin >> n ;
    cnt[0] = 1 ;
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &d[i]) ;
        cnt[d[i]] ++ ;
    }
    for (int i = 0; i <= 12; i ++)
        if (cnt[i] >= 3) {
            printf("0\n"); return 0 ;
        }
    for (int i = 0; i <= 12; i ++) {
        if (cnt[i] == 1) v.push_back (i) ;
        if (cnt[i] == 2) {
            v.push_back (i), v.push_back (24 - i) ;
            vis[i] = 1; vis[24 - i] = 1 ;
        }
    }
    dfs (1) ;
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}


int main(){
	int n,m,a,b,c;
	string S;
	cin>>a>>b;
	cout<<b*2-a<<endl;
	return 0;
}



Measured memory_bytes: 256