akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

#define MAX_NUM 100000
int parent[MAX_NUM + 10];

int init(int n) {
    rep(i, 0, n) {
        parent[i] = i;
    }
}

//  get root value
int root(int x) {
    if (parent[x] == x) {
        return x;
    } else
        return parent[x] = root(parent[x]);
}

// unit value
void unit(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;

    parent[rx] = ry;
}

// is same set ?
bool same(int x, int y) { return root(x) == root(y); }

int main(void) {
    int n, m, k;
    cin >> n >> m >> k;

    init(n);

    vector<int> f(n, 0);
    rep(_m, 0, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        f[a]++;
        f[b]++;
        unit(a, b);
        // cout << "(" << a << ", " << b << "): ";
        // cout << "set: [";
        // rep(i, 0, n) {
        //     cout << parent[i] << ", ";
        // }
        // cout << "]" << endl;
    }
    // cout << "Friend: [";
    // rep(i, 0, n) {
    //     cout << f[i] << ", ";
    // }
    // cout << "]" << endl;

    vector<int> block(n, 0);
    rep(_k, 0, k) {
        int c, d;
        cin >> c >> d;

        c--;
        d--;
        if (same(c, d)) {
            block[c]++;
            block[d]++;
        }
    }
    // cout << "Block: [";
    // rep(i, 0, n) {
    //     cout << block[i] << ", ";
    // }
    // cout << "]" << endl;

    vector<int> cnt(n, 0);
    // cout << "set: [";
    // rep(i, 0, n) {
    //     cout << root(i) << ", ";
    // }
    // cout << "]" << endl;

    rep(i, 0, n) {
        cnt[root(i)]++;
    }

    // cout << "Cnt: [";
    // rep(i, 0, n) {
    //     cout << cnt[i] << ", ";
    // }
    // cout << "]" << endl;

    rep(i, 0, n) {
        cout << cnt[root(i)] - f[i] - block[i] - 1;
        if (i < n - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
//#summon tourist
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int W,H;
    cin >> W >> H;
    vl p(W),q(H);
    priority_queue<P,vector<P>,greater<P>> pq;
    rep(i,W){
        cin >> p[i];
        pq.push(make_pair(p[i],0));
    }
    rep(i,H){
        cin >> q[i];
        pq.push(make_pair(q[i],1));
    }
    ll ans=0;
    while(!pq.empty()){
        P nowp=pq.top();
        pq.pop();
        int num;
        if(nowp.second==0){
            num=H+1;
            W--;
        }
        else{
            num=W+1;
            H--;
        }
        ans+=nowp.first*num;
    }
    cout << ans << endl;
}
/*
overflow checked
corner case checked
boundary checked
not TLE in worst case checked
*/

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    string A, B, C;
    cin >> A >> B >> C;
    int a = 0, b = 0, c = 0;
    char turn = 'a';
    while (true) {
        if (turn == 'a') {
            if (a == A.size()) {
                cout << "A" << endl;
                return 0;
            }
            turn = A.at(a);
            a++;
            
        }
        else if (turn == 'b') {
            if (b == B.size()) {
                cout << "B" << endl;
                return 0;
            }
            turn = B.at(b);
            b++;
            
        }
        else if (turn == 'c') {
            if (c == C.size()) {
                cout << "C" << endl;
                return 0;
            }
            turn = C.at(c);
            c++;
            
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,b;
	int t,n;
	int s,f;
	scanf("%d",&t);
	while(t!=0){
		b=0;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			b+=f-s;
		}
		if(t<=b){
			printf("OK\n");
		}
		else{
			printf("%d\n",t-b);
		}
		scanf("%d",&t);
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#define SIZE 1001
#define gcode __gcd
#define bitcoin __builtin_popcount
#define check(n, pos) (n & (1<<pos))
#define set(n, pos) (n | (1<<pos))
using namespace std;

vector<int>ini;
vector<int>pb;
vector<int>name;
vector<int>life;
vector<char>who;
vector<char>love;
set<int>kshe;
set<int>namenai;
map<int,int>mp;
vector<pair<int,int> >mk;

int main(){
//	freopen("input","r",stdin);
	int a;
	scanf("%d",&a);
	int s[1001];
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
		kshe.insert(s[i]);
	}
	printf("%ld\n",kshe.size());
	//cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HUPC_day2
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            int h = hw[0];
            int w = hw[1];
            List<int[]> poses = new List<int[]>();
            List<int> plus = new List<int>();
            List<int> minus = new List<int>();
            for(int i = 0; i < h; i++)
            {
                string s = Read();
                for(int j = 0; j < w; j++)
                {
                    if (s[j] == 'B')
                    {
                        plus.Add(i + j);
                        minus.Add(i - j);
                    }
                }
            }
            plus.Sort();
            minus.Sort();

            WriteLine(Max(plus[plus.Count - 1] - plus[0],
                minus[minus.Count - 1] - minus[0]));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 29976
//D
#include <iostream>
#include <algorithm>
using namespace std;

const int N=2333;
typedef long long LL;
const int INF=0x3f3f3f3f;
LL num[N];

int main(){
    LL n,z,w;
    cin>>n>>z>>w;
    for(LL i=1;i<=n;i++) cin>>num[i];
    if(n==1) cout<<abs(num[1]-w)<<endl;
    else cout<<max(abs(num[n]-w),abs(num[n-1]-num[n]))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
ll sum;
ll sumsum;
int main(void) {
    ll n;
    cin >> n;
    sum = INF;
    sumsum = -INF;
    vector<ll> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
        sum = min(sum, vec[i]);
        sumsum = max(sumsum, vec[i]);
    }
    cout << sumsum - sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

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

int n, a, b, c, dat[10];

int fun(int x, int y, int z, int cur)
{
	int ret0, ret1, ret2, ret3;
	if (cur == n) {
		if (min(x, min(y, z)) <= 0) return (int)1e9;
		return abs(x - a) + abs(y - b) + abs(z - c);
	}
	ret0 = fun(x, y, z, cur + 1);
	ret1 = fun(x + dat[cur], y, z, cur + 1) + (x ? 10 : 0);
	ret2 = fun(x, y + dat[cur], z, cur + 1) + (y ? 10 : 0);
	ret3 = fun(x, y, z + dat[cur], cur + 1) + (z ? 10 : 0);
	return min(ret0, min(ret1, min(ret2, ret3)));
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) cin >> dat[i];
	cout << fun(0, 0, 0, 0) << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int main(){
    double a,b,x;cin>>a>>b>>x;




    if(x>=a*a*b/2){
        printf("%.10lf\n",atan(2*(b/a-x/a/a/a))/M_PI*180);
    }else{
        printf("%.10lf\n",atan(a*b*b/2/x)/M_PI*180);
    }


    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i = 0; i < n; i++){
			num[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(i % 2 == 0 && num[i] % 2 == 1){
				ans ++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35764
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut x = vec![0i64; n];
    for i in 0..n {
        x[i] = input();
    }
    let mut y = x.clone();
    y.sort();

    for i in 0..n {
        let bb = if x[i] >= y[n / 2] {
            y[n / 2 - 1]
        } else {
            y[n / 2]
        };
        println!("{}", bb);
    }
}


Measured memory_bytes: 10364
/* Manish Pant - insider_pants, hello_my_friend */
    
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N = 2e5 + 5;
vector<vector<int>> v(N);
vector<int> val(N);
vector<int> pre(N);
vector<int> ans(N);
vector<int> segtree(4 * N);
int n, c = 1;

void update(int x, int val, int node = 0, int l = 0, int r = c)
{
    if(l == r)
    {
        segtree[node] = max(segtree[node], val);
        return;
    }
    int mid = (l+r)>>1;
    if(x <= mid) update(x, val, 2*node+1, l, mid);
    else update(x, val, 2*node+2, mid+1, r);
 
    segtree[node] = max(segtree[2*node+1], segtree[2*node+2]);
}

void update2(int x, int val, int node = 0, int l = 0, int r = c)
{
    if(l == r)
    {
        segtree[node] = val;
        return;
    }
    int mid = (l+r)>>1;
    if(x <= mid) update2(x, val, 2 * node + 1, l, mid);
    else update2(x, val, 2*node+2, mid + 1, r);
 
    segtree[node] = max(segtree[2*node+1], segtree[2*node+2]);
}
 
int query(int x, int y, int node = 0, int l = 0, int r = c)
{
    if(l > y || r < x || x > y) return 0;
    if(l >= x && r <= y)
    {
        return segtree[node];
    }
    int mid = (l + r) >> 1;
    return max(query(x, y, 2 * node + 1, l, mid), query(x, y, 2 * node + 2, mid + 1, r));
}

void dfs(int a, int par)
{
    int temp = query(0, val[a] - 1);
    pre[a] = query(val[a], val[a]);
    update(val[a], temp + 1);
    ans[a] = query(0, c);

    for(int i:v[a])
    {
        if(i == par) continue;
        dfs(i, a);
    }

    update2(val[a], pre[a]);
}


void solve()
{
    map<int, int> m;
    for(int i = 1; i <= n; i++) m[val[i]] = 0;
    
    for(auto &i:m) i.S = c++;

    for(int i = 1; i <= n; i++) val[i] = m[val[i]];

    dfs(1, 0);

    for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}

int main()
{
    fast();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> val[i];
    for(int i = 1; i < n; i++)
    {
        int a, b; cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    solve();
}


Measured memory_bytes: 34772
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

allxor = 0
for a in A:
    allxor ^= a

L = max(A).bit_length()

dp = [[] for _ in range(L+1)]
for a in A:
    b = (a|allxor)^allxor
    if b != 0:
        dp[b.bit_length()-1].append(b)

a1 = 0
for l in reversed(range(L)):
    if not dp[l]: continue
    c = dp[l].pop()
    if not a1&(1<<l):
        a1 ^= c
    for p in dp[l]:
        b = c^p
        if b != 0:
            dp[b.bit_length()-1].append(b)


ans = 2*a1 + allxor
print(ans)

Measured memory_bytes: 109088
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
ulong MIDDLE = 100_000;
alias Pair = Tuple!(long, "flag", long, "num");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto s = n * (n - 1) / 2;
    s.writeln();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  set<P> ds;
  rep(i,n){
    int s,t,x;
    cin >> s >> t >> x;
    ds.emplace(s-x,x);
    ds.emplace(t-x,-x);
  }
  set<int> s; auto itr = ds.begin();
  rep(i,q){
    int d;
    cin >> d;
    while(itr!=ds.end() && itr->first<=d){
      if(itr->second>0) s.insert(itr->second);
      else s.erase(-itr->second);
      ++itr;
    }
    cout << (s.empty() ? -1 : *s.begin()) << endl;
  }
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n)
    {
        cin >> a[i];
    }
    vector<ll> counter(40,0);
    rep(i,n)
    {
        rep(j,40)
        {
            ll a_i = a[i];
            if ( (a_i >> j) & 1)
            {
                counter[j]++;
            }
        }
    }
    
    vector<int> bit_k(40);
    k++;
    rep(i,40)
    {
        bit_k[i] = (k >> i)&1;
    }
    ll ans = 0;
    ll temp_ans = 0;
    rep(i,40)
    {
        if (bit_k[i]==0)
        {
            continue;
        }
        temp_ans = 0;
        //cout << i << endl;
        for (int j = 0; j < 40; j++)
        {
            if (j<i)
            {
                temp_ans += max(n - counter[j], counter[j]) * (1ull << j);
                continue;
            }
            if (j==i)
            {
                temp_ans += (counter[j]) * (1ull << j);
                continue;
            }
            temp_ans += (bit_k[j] ? (n - counter[j]) * (1ull << j) : (counter[j]) * (1ull << j));
        }

        //cout << temp_ans << endl;
        ans = max(ans, temp_ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	swap(X, Y);
	swap(X, Z);
	cout << X << ' ' << Y << ' ' << Z << endl;
	return 0;
}


Measured memory_bytes: 256
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
//#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define bublic public
#define kektor vector
#define x1 x1228
#define y1 y1228
#define pii pair<int, int>
#define pp pair
#define left left1
#define right right1
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rand() (rand() << 15 | rand())
 
using namespace std;
 
typedef long long ll;
 
const int maxn = 3e5, mod = 1e9 + 7, inf = 1e9;
const double eps = 1e-9, pi = acos(-1);

int get(int a) {
	int ans = 0; 
	while (a) {
		ans += a % 10; 
		a /= 10; 
	}
	return ans; 
}

void solve() {
	int n; cin >> n; 
	int ans = inf; 
	for (int i = 1; i < n; ++i) {
		ans = min(ans, get(i) + get(n - i));
	}
	cout << ans; 
}             
 
signed main() {
    //  freopen("bricks.in", "r", stdin);
    //  freopen("bricks.out", "w", stdout);
    #ifdef offline_judge
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    #endif
    srand(228);
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}   

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
int col[100005];
bool self[100005];
vector<P>edge[100005];

int par[100005],ran[100005];
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
bool ok; int C,val[100005];
void dfs(int v,int u){
	col[v] = u;
	if(self[v]) ok = 0;
	for(int i=0;i<edge[v].size();i++){
		int nxt = (u+edge[v][i].sc+6)%3; C++;
		if(col[edge[v][i].fi] >= 0 && col[edge[v][i].fi] != nxt) ok=0;
		else{
			if(col[edge[v][i].fi] == -1){
				dfs(edge[v][i].fi,nxt);
			}
		}
	}
}
vector<int>R[100005];
bool clq[100005];
int main(){
	cin>>n>>m;//n=100000,m=100000;
	init();
	rep(i,m){
		int a,b;cin>>a>>b;
		if(a==b) self[a] = 1;
		else{
			edge[a].pb(mp(b,1));
			edge[b].pb(mp(a,-1));
			unite(a,b);
		}
	}
	memset(col,-1,sizeof(col));
	repn(i,n){
		if(find(i)==i){
			ok = 1; C = 0;
			dfs(i,0);
			if(!ok) clq[i] = 1;
			val[i] = C/2; //cout<<C<<endl;
		}
		R[find(i)].pb(i);
	}
	ll ans = 0;
	repn(i,n){
		if(find(i) != i) continue;
		if(clq[i]){
			ans += 1LL*R[i].size()*R[i].size();
		}
		else{
			int A[3]={};
			for(int j=0;j<R[i].size();j++){
				A[col[R[i][j]]]++;
			}
			if(A[0]==0||A[1]==0||A[2]==0){
			    ans+=val[i];
			}
			else ans += 1LL*A[0]*A[1]+1LL*A[2]*A[1]+1LL*A[0]*A[2];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15100
#include <stdio.h>
#include <stdlib.h>
struct tree{
  int key;
  struct tree *parent;
  struct tree *left;
  struct tree *right;
};
struct tree *T,*NIL;
void insert(struct tree *);
void inorder(struct tree *);
void preorder(struct tree *);
int main(){
  int n,k,i;
  char command[10],a;
  struct tree *A;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%c",command,&a);
    if(command[0]=='i'){
      scanf("%d",&k);
      A=malloc(sizeof(struct tree));
      A->key=k;
      A->left=NIL;
      A->right=NIL;
      insert(A);
    }
    else {
      inorder(T);
      printf("\n");
      preorder(T);
      printf("\n");
    }
  }
  return 0;
}
void insert(struct tree *z){
  struct tree *x,*y;
  x=T;
  y=NIL;
  while(x!=NIL){
    y=x;
    if(x->key>z->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL){
    T=z;
  }
  else {
    if(y->key<z->key)y->right=z;
    else y->left=z;
  }
}
void inorder(struct tree *A){
  if(A==NIL)return;
  inorder(A->left);
  printf(" %d",A->key);
  inorder(A->right);
}
void preorder(struct tree *A){
  if(A==NIL)return;
  printf(" %d",A->key);
  preorder(A->left);
  preorder(A->right);
}



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

int main() {
  int N, A = 0, B = 0, i;
  cin >> N;
  vector<int> a(N);
  for(i=0;i< N;i++) cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());
  for(i = 0; i < N; i ++) {
    if(i % 2 == 0) A += a.at(i);
    else B += a.at(i);
  }
  cout << A - B << endl;
}

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

int main(){
  int num, divisor = 0;
  cin >> num;
  int first = num;
  
  while(1){
    divisor += num % 10;
    num /= 10;
    if(num == 0)
      break;
  }
  
  if(first % divisor == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  
  
  

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

int main() {
    const double PI=3.14159265358979323846;
    
    double A,B;//hari
    double H,M;// Hzi Mhun
    cin >> A >> B >> H >> M;
    
    //Anokakudo
    double kak_A,kak_B,kak_sa;//dode
    kak_A = H*30 + 0.5*M;
    kak_B = 6*M;
    kak_sa = kak_A - kak_B;
    //cout << kak_sa << endl;
    
    //yogenteiri
    double numcos = cos((kak_sa/180)*PI);
    double ans2 = A*A + B*B - (2*A*B*numcos);
    ans2 = sqrt(ans2);
    //cout << M_PI <<endl;
    
    cout  << fixed << setprecision(15) << ans2 << endl;
    
}


Measured memory_bytes: 4212
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
    stack<int> st;
    int a, b;
    string s;

    while (cin >> s) {
        if (s[0] == '+') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a + b);
        } else if (s[0] == '-') {
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            st.push(a - b);
        } else if (s[0] == '*') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a * b);
        } else {
            st.push(atoi(s.c_str()));
        }
    }

    cout << st.top() << endl;
}



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

const int INPUT_SIZE = 12;

int main(void){

  std::vector<int> stickVec(INPUT_SIZE);
  for(int i = 0; i < INPUT_SIZE; i++){
    std::cin >> stickVec[i];
  }

  std::sort(stickVec.begin(), stickVec.end());

  int cnt = 0;
  bool flag = true;
  for(int i = 0; i < INPUT_SIZE - 1; i++){

    if(cnt == 3){
      cnt = 0;
    }
    else if(stickVec[i] == stickVec[i+1]){
      cnt++;
    }
    else{
      flag = false;
      break;
    }
  }

  if(flag){
    std::cout << "yes" << std::endl;
  }
  else{
    std::cout << "no" << std::endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}
#define yes cout<<"Yes"<<nl
#define no cout<<"No"<<nl
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int n;
  cin>>n;
  if(n<4)
  {
    no;
    return;
  }
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=n;j++)
    {
      if(4*i+7*j==n)
      {
        yes;
        return;
      }
    }
  }
  no;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String t = scanner.nextLine();
        if(t.startsWith(s)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 27004
#include<stdio.h>
int main()
{
    int k;
    scanf("%d",&k);
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    if(k>=0 && k<=32)
        printf("%d",a[k-1]);
    return 0;
}


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

typedef long long ll;

int main() {
    int N, K, ans = 1;
    cin >> N >> K;
    rep(i, N) {
        if (ans < K) ans += ans;
        else ans += K;
    }
    cout << ans << "\n";
}

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

const int MAX_=1000000;

bool is_prime[MAX_];
vector<int> prime;

bool sieve(){
	fill(is_prime,is_prime+MAX_,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<MAX_; ++i){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2*i; j<MAX_; j+=i){
				is_prime[j]=false;
			}
		}
	}
}

int solve(int n,int p){
	vector<int> sum_prime;
	auto it=upper_bound(prime.begin(),prime.end(),n);
	//cout << *it << endl;
	for(int i=0; it!=prime.end()&&i<p; ++it,++i){
		auto it_=it;
		for(int j=0; it_!=prime.end()&&j<p; ++it_,++j){
			sum_prime.push_back((*it)+(*it_));
			//cout << (*it)+(*it_) << endl;
		}
	}
	sort(sum_prime.begin(),sum_prime.end());
	return sum_prime[p-1];
}

int main(){
	int N,P;
	sieve();
	while(cin>>N>>P&&!(N==-1&&P==-1)){
		cout << solve(N,P) << endl;
	}
	return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;

        s = "";

        while(n){
            l = n%26;
            s.push_back('a' + (l - 1 + 26)%26);
            if(l == 0) l = 26;
            n -= l;
            n /= 26;
        }

        reverse(s.B, s.E);
        cout << s << nl;
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

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

int w, h, n;
int x, y, a;;

int main () {
  cin >> w >> h >> n;
  int x_min = 0, x_max = w, y_min = 0, y_max = h;
  
  for (int i = 0; i < n; i++){
    cin >> x >> y >> a;
    if (a == 1) 
      x_min = max(x, x_min);
    else if (a == 2)
      x_max = min(x, x_max);
    else if (a == 3)
      y_min = max(y, y_min);
    else
      y_max = min(y, y_max);
  }
  cout << (max(0, x_max-x_min))*(max(0, y_max-y_min)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vv<pair<string, pair<int, int>>> a;
  rep(i, 0, n) {
    int p;
    string s;
    cin >> s >> p;
    a.pb(mp(s, mp(-p, i+1)));
  }
  sort(ALL(a));
  rep(i, 0, n) {
    cout << a[i].S.S << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	string s,res="";
	cin>>s;
	int n=s.length();
	for (int i=0; i <= n-1; i++)
		if (s[i] != 'B')
			res+=s[i];
		  else
		  	{
		  		if (res.length() != 0)
		  			res.erase(res.length()-1,1);
			}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int N;
	int square[100000];
	int err=0;
	int flag;
	int i;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++)scanf("%d",&square[i]);
	
	for(i=0;i<N;i++)
	{
		int x;
		flag=0;
		for(x=1;x*x<square[i];x++)
		{
			if(square[i]%(2*x+1)-x)continue;
			{flag++;break;}
		}
		if(flag==0)err++;
	}
	printf("%d\n",err);
	return 0;
}

Measured memory_bytes: 796
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int K;
  cin>>K;
  if (!K&1) cout << (K/2)*(K/2) << endl;
  else cout << ((K+1)/2)*(K/2) << endl;
}


Measured memory_bytes: 256
N = int(input())
TA = [tuple(map(int, input().split()))for _ in range(N)]
ans = TA[0]
for ta in TA[1:]:
    x = max((ans[0] + ta[0] - 1) // ta[0], (ans[1] + ta[1] - 1) // ta[1])
    ans = (x * ta[0], x * ta[1])
print(sum(ans))

Measured memory_bytes: 3064
N, R = map(int, input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return len(out)

print(Base_10_to_n(N, R))

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)


using namespace std;

class Point{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }///这里注意，没有$
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double a) { return Point(x*a,y*a); }
    Point operator / (double a) { return Point(x/a,y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;
///Program 16.3 表示线段的结构体
struct Segment{
    Point p1,p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;


///内积，cos()函数
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
///外积，sin()函数
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

///判断向量a和向量b是否正交
///法一
bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

///法二
bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

///判断平行
///法一
bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}
bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
        Point p0,p1,p2,p3;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p0.x,&p0.y,&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y);
        if(isParallel(p0,p1,p2,p3))
            printf("2\n");
        else if(isOrthogonal(p0,p1,p2,p3))
            printf("1\n");
        else
            printf("0\n");
    }
    return 0;
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll lcm(ll a, ll b)  
{  
	ll ga = gcd(a,b);
    return (a*b)/ga;  
} 
int main()
{
   // fast;
   
    ll a,b;
    cin>>a>>b;
    cout<<lcm(a,b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> h(n);
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
    x.at(i)=1;
  }
  vector<vector<int>> b(m, vector<int>(2));
  for(int i=0;i<m;i++){
    cin>>b.at(i).at(0)>>b.at(i).at(1);
  }
  for(int i=0;i<m;i++){
    if(h.at(b.at(i).at(0)-1)==h.at(b.at(i).at(1)-1)){
      x.at(b.at(i).at(1)-1)=0;
      x.at(b.at(i).at(0)-1)=0;
    }
    else if(h.at(b.at(i).at(0)-1)>h.at(b.at(i).at(1)-1)){
      x.at(b.at(i).at(1)-1)=0;
    }
    else{
      x.at(b.at(i).at(0)-1)=0;
    }
  }
  int y=0;
  for(int i=0;i<n;i++){
    y+=x.at(i);
  }
  cout<<y<<endl;



}

Measured memory_bytes: 9596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
//typedef long double ld;

const int MAX_N = 3005;

int n;
double p[MAX_N];
double dp[MAX_N][MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];

	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= n; j++)
		{
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}

	double result = 0;
	for (int i = (n + 1) / 2; i <= n; i++)
		result += dp[n][i];
	cout << setprecision(15) << fixed << result << endl;
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    if (i == 0) A[i] = x;
    else A[i] = A[i-1] + x;
  }
  map<ll,ll> mp;
  for (auto e : A) mp[e] += 1;
  mp[0] += 1;
  ll ans = 0;
  for (auto m : mp) {
    ll q = m.second;
    ans += q*(q-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 17224
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(12);
    cout << sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)) << endl;
}


Measured memory_bytes: 3300
// atcoder13A.cpp : 定义控制台应用程序的入口点。
//
#include<bits/stdc++.h>
using namespace std;
int n, dp[2][101000],a[100010];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	memset(dp, 0x7f, sizeof dp);
	dp[0][1] = dp[1][1] = 1;
	for (int i = 2; i <= n; i++)
	{
		dp[0][i] = min(dp[0][i - 1] + (a[i] > a[i - 1]), dp[1][i - 1] + 1);
		dp[1][i] = min(dp[1][i - 1] + (a[i] < a[i - 1]), dp[0][i - 1] + 1);
	}
	cout << min(dp[0][n], dp[1][n]) << endl;
    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define ve vector
const ll INF=0x3f3f3f3f3f3f;

void floyd(vector<vector<ll>> &a,ll n){
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= n; j++) {
			for (ll k = 1; k <= n; k++) {
				a[k][j]=a[j][k]=min(a[j][i]+a[i][k],a[j][k]);
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	ll n,m;
	while(cin>>n>>m){
		if(n==0 && m==0)break;
		vector<vector<ll>> s(n+1,vector<ll>(n+1,INF));
		for (ll i = 1; i <= n; i++) {
			s[i][i]=0;
		}
		vector<vector<ll>> l=s;
		for (ll i = 0; i < m; i++){
			ll x,y,t;
			char sl;
			cin>>x>>y>>t>>sl;
			if(sl=='S'){
				s[y][x]=s[x][y]=min(s[x][y],t);
			}
			else l[y][x]=l[x][y]=min(l[x][y],t);
		}
		floyd(l,n);
		floyd(s,n);
		ll r;
		cin>>r;
		vector<ll> z;
		for (ll i = 0; i < r; i++){
			ll t;
			cin>>t;
			z.push_back(t);
		}
		ve<ve<ll>> dp(r,ve<ll>(n+1,INF));
		dp[0][z[0]]=0;
		for (ll i = 1; i <= r-1; i++) {
			for (ll j = 1; j <= n; j++) {
				for (ll k = 1; k <= n; k++) {
					if(j==k)dp[i][j]=min(dp[i][j],dp[i-1][k]+l[z[i-1]][z[i]]);
					else dp[i][j]=min(dp[i][j],dp[i-1][k]+l[z[i-1]][k]+s[k][j]+l[j][z[i]]);
				}
			}
		}
		ll ret=INF;
		for(ll i=1;i<=n;i++)ret=min(ret,dp[r-1][i]);
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 5288
#include <stdio.h>

int main ()
{
    int p, q, r, count = 0;
    int routeA, routeA1, routeB, routeB1, routeC, routeC1;
    int arr[6];

    scanf("%d %d %d", &p, &q, &r);

    routeA = p + q;
    routeA1 = r + q;
    routeB = p + r;
    routeB1 = q + r;
    routeC = r + p;
    routeC1 = q + p;

    arr[0] = routeA;
    arr[1] = routeA1;
    arr[2] = routeB;
    arr[3] = routeB1;
    arr[4] = routeC;
    arr[5] = routeC1;

    for(int i = 0; i < 6; i++)
    {
        if(count == 0)
        {
            count = arr[i];
        }
        if(arr[i] < count)
        {
            count = arr[i];
        }
    }

    printf("%d\n", count);


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    ll a, b;
    cin >> a >> b;
    ll dif = 0;
    if ( a >= 0 && b >= 0 ) {
        cout << "Positive" << endl;
    }
    if ( a < 0 && b < 0 ) {
        dif = abs(a-b);
        if ( dif&1 ) cout << "Positive" << endl;
        else         cout << "Negative" << endl;
    }
    if ( a >= 0 && b < 0 || a < 0 && b >= 0 ) {
        cout << "Zero" << 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);
        
        String S=sc.next();
        String x=S.substring(0,1);
        String y=S.substring(1,2);
        String z=S.substring(2,3);
        if(x.equals(y)||y.equals(z)||z.equals(x)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    int n = int(s.size());
    for(int i = 0; i<n; i++) {
        if(s[i] == 'A') a++;
        else if(s[i] == 'B') b++;
    }
    if(a == n || b == n) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int main() {
  int M, N, P[10000], C[500], E[500];
 
  cin >> M >> N;
  for(int i = 0; i < M; i++) {
    cin >> P[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i] >> E[i];
  }
 
  int dp[10001];
  fill_n( dp, 10001, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = M; j >= 0; j--) {
      dp[min( j + C[i], M)] = min( dp[min( j + C[i], M)], dp[j] + E[i]);
    }
  }
 
  sort(P, P + M, greater< int >());
  int ret = 0, sum = 0;
  for(int i = 0; i < M; i++){
    sum += P[i];
    ret = max( ret, sum - dp[i + 1]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1256
//copied
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 100005
using namespace std;
inline int in() {
	int x = 0;
	bool f = 0;
	char c;
	for (; (c = getchar()) < '0' || c > '9'; f = c == '-')
		;
	for (x = c - '0'; (c = getchar()) >= '0' && c <= '9';
			x = (x << 3) + (x << 1) + c - '0')
		;
	return f ? -x : x;
}
struct edge {
	int to, nxt;
} e[MN << 1];
int h[MN], dep[MN], fa[MN], siz[MN];
int n, x, y, cnt, d;
inline void ins(int x, int y) {
	e[++cnt].to = y;
	e[cnt].nxt = h[x];
	h[x] = cnt;
}
inline void dfs(int u) {
	siz[u] = 1;
	for (int i = h[u]; i; i = e[i].nxt) {
		int v = e[i].to;
		if (v == fa[u])
			continue;
		dep[v] = dep[u] + 1;
		fa[v] = u;
		dfs(v);
		siz[u] += siz[v];
	}
}
int main() {
	n = in();
	for (int i = 1; i < n; ++i) {
		x = in();
		y = in();
		ins(x, y);
		ins(y, x);
	}
	fa[n] = 0;
	dep[n] = 0;
	dfs(n);
	d = (dep[1] + 1) >> 1;
	for (int i = 1; i; i = fa[i])
		if (dep[i] == d) {
			printf((siz[i] > n - siz[i]) ? "Fennec" : "Snuke");
			return 0;
		}
	return 0;
}


Measured memory_bytes: 12512
// author : tfg

#include <iostream>
#include <vector>
#include <chrono>
#include <random>
 
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
 
struct Edge {
	int u, v, c;
	void read() {
		std::cin >> u >> v >> c;
		u--;v--;
	}
};
 
int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m, p;
	std::cin >> n >> m >> p;
	std::vector<Edge> edges(m);
	for(int i = 0; i < m; i++) {
		edges[i].read();
		edges[i].c = p - edges[i].c;
	}
	const long long INF = 1e18;
	std::vector<long long> dist(n, INF);
	auto bellman = [&]() {
	    for(int i = 0; i < n; i++) {
	        for(auto e : edges) {
	            if(dist[e.u] < INF) {
	                dist[e.v] = std::min(dist[e.v], dist[e.u] + e.c);
	            }
	        }
	    }
	};
	dist[0] = 0;
	bellman();
	auto ori = dist;
	long long ans = dist[n-1];
	bellman();
	for(int i = 0; i < n; i++) {
	    if(dist[i] != ori[i]) {
	        dist[i] = -INF;
	    }
	}
	bellman();
	if(ans == dist[n-1]) {
		ans = std::max(-ans, 0LL);
	} else {
		ans = -1;
	}
	std::cout << ans << '\n';
	
}


Measured memory_bytes: 3736