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

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
int N, M, Q;
vector<vector<int>> imos;
vector<pair<int, int>> query;





//サブ関数
//入力
void input()
{
	cin >> N >> M >> Q;
	imos.resize(N + 1, vector<int>(N + 1, 0));
	int a, b;
	REP(i, M) {
		cin >> a >> b;
		imos[a][b]++;
	}
	REP(i, Q) {
		cin >> a >> b;
		query.push_back({ a,b });
	}
}


//計算
void calc()
{
	REP(i, N + 1)REP(j, N)imos[i][j + 1] += imos[i][j];
	for (auto q : query) {
		int l = q.first;
		int r = q.second;
		int res = 0;
		FOR(i, l, r + 1)res += imos[i][r];
		cout << res << endl;
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 2804
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ll n;
    ll bx,by,bh;
    cin>>n;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> h(n);
    rep(i,n){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]>=1) bx=x[i],by=y[i],bh=h[i];
    }
    ll hh;
    ll ax,ay,hhh;
    bool f=false;
    rep(i,101){
        rep(j,101){
            hh=abs(i-bx)+abs(j-by)+bh;
            hh=max(hh,0LL);
            f=true;
            rep(k,n){
                ll h2=hh-abs(i-x[k])-abs(j-y[k]);
                h2=max(h2,0LL);
                if(h2!=h[k]) f=false;
            }
            if(f==true){
                ax=i,ay=j,hhh=hh;
            }
        }
    }
    cout<<ax<<" "<<ay<<" "<<hhh<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  int num=1;
  
  cin >> N >> K;
  
  for (int i=0; i<N; i++){
  	if(num<=K){
    	num=num*2;
    }else{
    	num=num+K;
    }
  }
  cout << num <<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
const int INF = (1e9+7);
using namespace std;

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

	vector<int> a(n);

	for (int& x : a){
		cin >> x;
	}

	vector<int> dp(n , INF);
	dp[0] = 0;
	for (int i = 0 ; i < n ; i++){
		for (int j = i+1 ; j <= i+k ; j++){
			dp[j] = min(dp[j] , dp[i]+abs(a[i] - a[j]));
		}
	}

	cout << dp[n-1] << endl;
	return 0;
}


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

int main()
{
    long long int n,a[1000],i,d;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    d=a[n-1]-a[0];
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = I()
    A = LI()
    cnt = 0
    for i, a in enumerate(A):
        if (i+1) % 2 == 1 and a % 2 == 1:
            cnt += 1
    print(cnt)



main()



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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

int dp[100005][13];

void Main() {
    string S;
    cin >> S;
    dp[0][0] = 1;
    int N = S.length();
    for (int i = 0; i < N; ++i) {
        if (S[i] == '?') {
            for (int j = 0; j < 10; ++j) {
                for (int k = 0; k < 13; ++k) {
                    dp[i + 1][(10 * k + j) % 13] += dp[i][k];
                    dp[i + 1][(10 * k + j) % 13] %= MOD;
                }
            }
        } else {
            int j = S[i] - '0';
            for (int k = 0; k < 13; ++k) {
                dp[i + 1][(10 * k + j) % 13] += dp[i][k];
                dp[i + 1][(10 * k + j) % 13] %= MOD;
            }
        }
    }
    cout << dp[N][5] << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 5712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong a[100005];
map<llong, llong> cnt;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    llong ans = 0;
    for (auto x:cnt) {
        if (x.first <= x.second) {
            ans += x.second - x.first;
        }
        else {
            ans += x.second;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7040
#!/usr/bin/env python3

import math, itertools, operator
from math import *
from math import factorial as fact
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd
#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

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

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################

S = input()

cnt1 = 0  # Black first
cnt2 = 0  # White first
BLACK = '0'
WHITE = '1'
for i in range(len(S)):
    if i & 1:
        if S[i] != WHITE:
            cnt1 += 1
        if S[i] != BLACK:
            cnt2 += 1
    else:
        if S[i] != BLACK:
            cnt1 += 1
        if S[i] != WHITE:
            cnt2 += 1
print(min(cnt1, cnt2))


Measured memory_bytes: 5440
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            int[] cnt = new int[110000];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                if (a[i] != 0) cnt[a[i] - 1]++;
                cnt[a[i]]++;
                cnt[a[i] + 1]++;
            }
            int ans = 0;

            for (int i : cnt) {
                ans = Math.max(ans, i);
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 48824
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int a,b=0,c;
	string s,t;
	vi v;
	cin>>a>>b;
	c=a+b;
	if(c%2==1){
	c++;
}

	cout<<c/2;

	
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (c-b >= a+1) cout << "dangerous" << endl;
  else if (c-b <= 0) cout << "delicious" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 256
import numpy as np
n,d = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(n)]
x = np.array(x)
cnt = 0
for i in range(n):
    for j in range(n):
        if i >=j:
            continue
        elif np.linalg.norm(x[i]-x[j]).is_integer():
            cnt+=1
print(cnt)

Measured memory_bytes: 12500
h,w=map(int,input().split())
s=[["."]*(w+2)]
for i in range(h):
    s+=[["."]+list(input())+["."]]
s+=[["."]*(w+2)]
for j in range(1,h+1):
    for k in range(1,w+1):
        if s[j+1][k]=="." and s[j-1][k]=="." and s[j][k+1]=="." and s[j][k-1]=="." and s[j][k]=="#":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
MOD = 10**9 + 7
MAX = 5*10**5 + 1

fact = [0 for _ in range(MAX)]
factinv = [0 for _ in range(MAX)]

fact[0] = 1
for k in range(1, MAX):
    fact[k] = fact[k - 1]*k
    fact[k] %= MOD

factinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)
for k in range(MAX - 1, 0, -1):
    factinv[k - 1] = factinv[k]*k
    factinv[k - 1] %= MOD

def nCk(n, k):
    return fact[n]*factinv[k]*factinv[n - k] % MOD

def nPk(n, k):
    return fact[n]*factinv[n - k] % MOD

n, m = map(int, input().split(' '))

ans = 0
for k in range(n + 1):
    tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD
    if not k % 2: ans += tmp
    else: ans -= tmp
    ans %= MOD

print(ans)

Measured memory_bytes: 140224
#include<iostream>
using namespace std;
#define MAX 100

int main()
{
	int i,n;
	int a[MAX];

	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> a[i] ;
	}

	for(i=n-1;i>0;i--)
	{
		if(n!=1)cout << a[i] << ' ' ;
	}

	cout << a[i] << endl ;	

	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
#define ll long long
#define INF 2147483647
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, T,minv,maxv = -INF; cin >> N >> T;
	vector<ll> A(N+1);
	for (int i = 1; i <= N;i++) {
		cin >> A[i];
	}
	minv = A[1];
	for (int i = 2; i <= N;i++) {
		maxv = max(maxv, A[i] - minv);
		minv = min(minv, A[i]);
	}

	ll Maxv = maxv;
	ll count = 0;

	minv = A[1];
	for (int i = 2; i <= N;i++) {
		if (A[i] - minv == Maxv) count++;
		maxv = max(maxv, A[i] - minv);
		minv = min(minv, A[i]);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
def main():
    h,w=map(int,input().split(' '))
    if h%3 == 0 or w%3 ==0:
        print(0)
        exit()
    ans = h*w
    for i in range(1,w):
        a=h*i
        b=(w-i)*(h//2)
        c=(w-i)*-(-h//2)
        if ans > max(a,b,c)-min(a,b,c):
            ans = max(a,b,c)-min(a,b,c)
    for j in range(1,h):
        a=w*j
        b=(h-j)*(w//2)
        c=(h-j)*-(-w//2)
        if ans > max(a,b,c)-min(a,b,c):
            ans = max(a,b,c)-min(a,b,c)
    print(min(ans,h,w))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

int  main()
{
	int n; cin >> n;
	int ans = pow(n, 3);
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ACanYouGetAC {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        bool ok = false;
        REP(i, s.size() - 1) {
            if (s[i] == 'A' && s[i+1] == 'C') {
                ok = true;
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ACanYouGetAC solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (a == 0 && b == 0) break;
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    if (i == 0 || i % 2 == 0) {
                        if (j == 0 || j % 2 == 0) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    } else {
                        if (j == 0 || j % 2 == 0) {
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }
                    if (j == b - 1) {
                        System.out.println();
                    }
                }
            }
            System.out.println();
        }
    }
}


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

#define REP(i, a, b)    for(int i = a, _b = b; i < _b; ++i)
#define FOR(i, a, b)    for(int i = a, _b = b; i <= _b; ++i)
#define endl            "\n"
#define puts(_content_) cout << (_content_) << "\n"
#define newline         cout << "\n"

using namespace std;
typedef long long llong;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef Home 
	freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
#endif
	llong n;
	cin >> n;
	for(llong x = 1; x <= 3500; ++x) {
		for(llong y = x; y <= 3500; ++y) {
			llong M = 4*x*y - n*x - n*y;
			if(M == 0) continue;
			llong z = n*x*y/M;
			if(z >= y && 4*x*y*z == n*(x*y + y*z + x*z)) {
				cout << x  << " " << y << " " << z << endl;
				return 0;
			}
		}
	}			
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = 998244353;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

struct UnionFindTree{
    int N;
    vector<int> par, rank, siz;

    void init(int n){
        N = n;
        par.resize(N);
        rank.resize(N, 0);
        siz.resize(N, 1);
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    int find(int i){
        if(par[i] == i) return i;
        else return par[i] = find(par[i]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return ;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        x = find(x);
        return siz[x];
    }
};

ll n, a[MAX_N], ans = 0, cnt = 0;
bool used[MAX_N]{};

int main() {
    vector<pair<ll,ll> > v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        v.push_back({a[i], i+1});
    }
    v.push_back({-IINF/2,n+1});
    sort(v.rbegin(), v.rend());
    //UnionFindTree g;
    //g.init(n+5);
    for(int i=0;i<n;i++){
        if(v[i].first == 0) break;
        ll id = v[i].second;
        used[id] = true;
        cnt++;
        if(used[id] && used[id-1]){
            //g.unite(id, id-1);
            cnt--;
        }
        if(used[id] && used[id+1]){
            //g.unite(id, id+1);
            cnt--;
        }
        if(v[i].first > v[i+1].first){
            ans = max(ans, cnt);
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5460
import sys
sys.setrecursionlimit(10**8)

class UnionFind():
    def __init__(self, n):
        self.par = [-1]*n

    def find(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def union(self, x, y):
        if x > y:
            x, y = y, x
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            self.par[rx] += self.par[ry]
            self.par[ry] = rx

    def size(self, x):
        return -self.par[self.find(x)]

    def same(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        return rx == ry

    def return_par(self):
        return self.par

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))
print(ans)


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

int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n);
    for (auto &e : h) cin >> e;
    vector<array<int, 2>> edge(m);
    for (auto &e1 : edge) for (auto &e2 : e1) cin >> e2;

    vector<bool> score(n, true);
    for (auto e : edge) {
        int h1 = h[e[0] - 1];
        int h2 = h[e[1] - 1];

        if (h1 == h2) {
            score[e[0] - 1] = score[e[1] - 1] = false;
        }
        if (h1 < h2) {
            score[e[0] - 1] = false;
        }
        if (h1 > h2) {
            score[e[1] - 1] = false;
        }
    }

    int ans = 0;
    for (auto e : score) ans += e;

    cout << ans << endl;
}



Measured memory_bytes: 4564
#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)

int main(void){
    // Your code here!
   int n;
   int k;
   cin >> n;
   if(n%2==1) n++;
    cout << int(n/2) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::int64_t N, K;
	std::cin >> N >> K;
	N -= (N / K) * K;
	std::cout << std::min(N, std::abs(N - K)) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
N = int(input())
heap = list(map(int, input().split()))

for i, a in enumerate(heap, start=1):  # enumerate : リストなどのイテラブルオブジェクトの要素と同時にインデックスを取得できる
    print("node {}: key = {}, ".format(i, a), end ="")
    if i//2 != 0: # 親が存在する場合
        print("parent key = {}, ".format(heap[i//2-1]), end = "") # heapは実際には0オリジンなので-1で調整
    if 2*i <= N: # 左子が存在する場合
        print("left key = {}, ".format(heap[2*i-1]), end = "")
    if 2*i +1 <= N: # 右子が存在する場合
        print("right key = {}, ".format(heap[2*i]), end = "")
    print()






Measured memory_bytes: 5676
#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i,a) for(int i = 0; i < a; i++)
#define repd(i,a,b) for(int i = a; i > b; i--)
#define pb push_back
#define INF 10000000

int main(){
    string str;
    while(getline(cin,str)){
        vector<int> r;
        stringstream s(str);
        int n = 0, w;
        s >> w;
        while(!s.eof()){
            int t;
            s >> t;
            r.pb(t);
            n++;
        }
        vector<vector<double> > dp(1<<n,vector<double> (n,INF));
        rep(i,n) dp[(1<<n)-1-(1<<i)][i] = r[i];

        repd(i,(1<<n)-2,-1) rep(j,n){
            if(!(i&(1<<j))){
                rep(k,n) {
                    dp[i][j] = min(dp[i][j],dp[i|(1<<j)][k]+2*sqrt(r[j]*r[k]));
                }
            }
        }
        double ans = INF;
        rep(i,n) ans = min(ans,dp[0][i]+r[i]);
        cout << ((ans <= w)? "OK": "NA") << endl;
    }
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#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 LOCAL
~debug() { cerr << '\n'; }
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 fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int a , b , c , d ;
    cin >> a >> b >> c >> d ;
    if ( c > a ) {
        swap(a, c) ;
        swap(b, d) ;
    }
    int ans = -INF ;
    ans = max(ans, a * d) ;
    ans = max(ans, a * c) ;
    ans = max(ans, b * c) ;
    ans = max(ans, b * d) ;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3628
n = int(input())
values = list(map(int, input().split()))

from itertools import accumulate

copy = values[:]
copy.reverse()
acc = list(accumulate(copy))
acc.reverse()

b = 1
total = 1
for i in range(n+1):
    a = values[i]
    bCandidate = b - a
    if bCandidate < 0:
        print(-1)
        exit()
    b = min(2*bCandidate, acc[i] - a)
    total += b
print(total)

Measured memory_bytes: 84560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>

#define data _data
 
using namespace std;
const int maxn=5e5+50;
map<int,int> mp;
int data[maxn];
int a[maxn];
int ans[maxn];
struct node{
    int l,r,id;
    bool operator<(node t)const{
        return r<t.r;
    }
}q[maxn];
int sum(int i){
    int ans=0;
    while(i>0){
        ans+=data[i];
        i-=i&-i;
    }
    return ans;
}
void add(int i,int x){
    while(i<maxn){
        data[i]+=x;
        i+=i&-i;
    }
}
 
int main()
{
    int n;
    while(~scanf("%d",&n)){
        int m;
        scanf("%d",&m);
        fill(data,data+n+2,0);
        mp.clear();
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        
        
        for(int i=0;i<m;i++){
            scanf("%d%d",&q[i].l,&q[i].r);
            q[i].id=i;
        }
        sort(q,q+m);
        int pre=1;
        for(int i=0;i<m;i++){
            for(int j=pre;j<=q[i].r;j++){
                if(mp[a[j]]!=0){
                    add(mp[a[j]],-1);
                }
                add(j,1);
                mp[a[j]]=j;
            }
            pre=q[i].r+1;
            ans[q[i].id]=sum(q[i].r)-sum(q[i].l-1);
        }
        for(int i=0;i<m;i++){
            printf("%d\n",ans[i]);
        }
    }
    return 0;
}


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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> cnt(n+1,0);
	ll ans_base = 0;
 	rep(i,n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	rep(i,n+1) {
		ans_base += cnt[i] * (cnt[i]-1) / 2;
	}
	rep(i,n) {
		cout << ans_base - (cnt[a[i]] - 1) << endl;
	}

	return 0;
}


Measured memory_bytes: 5760
use List::Util 'sum';

while(<>){
	chomp;
	if($. == 1){
		($k, $n) = split(/ /, $_);
	}else{
		@p = split(/ /, $_);
	}
}

@r = ();
for $i (0 .. $#p){
	if($i != $#p){
		push(@r, $p[$i + 1] - $p[$i]);
	}else{
		push(@r, $k - $p[$i] + $p[0]);
	}
}

@r  = sort{$a <=> $b}(@r);
print sum(@r[0 .. $n - 2]) . "\n";


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

int main() {
    int n; cin >> n;
    vector<vector<int>> d(n, vector<int>(2, 0));
    for (int i = 0; i < n; i++) {
        cin >> d.at(i).at(0) >> d.at(i).at(1);
    }

    bool ans = false;

    for (int i = 0; i <= n-3; i++) {
        if (d.at(i).at(0) == d.at(i).at(1) ) {
            if (d.at(i + 1).at(0) == d.at(i + 1).at(1)) {
                if (d.at(i + 2).at(0) == d.at(i + 2).at(1)) ans = true;
            }
        }
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i;
	int j;
	int maxj;
	int N;
	int a[110];
	int A_sum = 0;
	int B_sum = 0;

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

	for (i = 0; i < N; ++i) {
		maxj = i;
		for (j = i; j < N; ++j) {
			if (a[j] > a[maxj]) {
				maxj = j;
			}

		}
		swap(a[i], a[maxj]);
	//	cout << a[i] << endl;
	}

	for (i = 0; i < N; ++i) {
		
	}

	for (i = 0; i < N; ++i) {
		if (i % 2 == 0) {
			A_sum += a[i];
		}
		else {
			B_sum += a[i];
		}
	}

	//cout << "Asum" << A_sum << endl;
	//cout << "Bsum" << B_sum << endl;
	cout << A_sum - B_sum<< endl;




}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long D,N;

int main(){
  cin >> D >> N;
  if(N==100){
    N++;
  }
  if( D == 0){
    cout << N << endl;
  } else if (D == 1){
    cout << N*100<< endl;
  } else if (D == 2){
    cout << N*10000<< endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a/b;
    r = a%b;
    f = (double)a/b;
    printf("%d %d %.5lf\n", d, r, f);
    return 0;
}


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

void call(int n) {
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			for (; x; x /= 10) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}

Measured memory_bytes: 3108
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int X = reader.nextInt();
		int Y = reader.nextInt();
		System.out.println(X+Y/2);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

    public static void main(String[] args) throws NumberFormatException, IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	// ?¨?????????°
	int vertical = Integer.parseInt(br.readLine());
    // ???????????°
	int horizontal = Integer.parseInt(br.readLine());

	List<int[]> changeRequests = new ArrayList<>();
	for (int i = 0; i < horizontal; i++) {
	    String[] changeRequestStr = br.readLine().split(",");
	    int[] changeRequest = new int[2];
	    changeRequest[FIRST_NUMBER] = Integer.parseInt(changeRequestStr[FIRST_NUMBER]);
	    changeRequest[SECOND_NUMBER] = Integer.parseInt(changeRequestStr[SECOND_NUMBER]);
	    changeRequests.add(changeRequest);
	}

	int[] outputArray = getDrawedArray(changeRequests, vertical, horizontal);

	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    /**
     *
     * @param changeRequests
     * @param vertical
     * @param horizontal
     */
    private static int[] getDrawedArray(List<int[]> changeRequests, int vertical, int horizontal) {
	int[] outputArray = new int[vertical + 1];
	for (int i = 1; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	for (int[] changeRequest : changeRequests) {
	    int mediator = 0;
	    mediator = outputArray[changeRequest[FIRST_NUMBER]];
	    outputArray[changeRequest[FIRST_NUMBER]] = outputArray[changeRequest[SECOND_NUMBER]];
	    outputArray[changeRequest[SECOND_NUMBER]] = mediator;

	}

	return outputArray;

    }

}

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

using namespace std;
const int mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	vector<double> p(n);
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	vector<vector<double> > dp(n,vector<double>(n+1));
	dp[0][1] = p[0]*100;
	dp[0][0] = (1-p[0])*100;
	
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= n; j++){
			if(j)dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]);
			else dp[i][j] = dp[i-1][j] * (1-p[i]);    
		}
	}
	double ans = 0.0;
	for(int j = n/2+1; j<= n; j++) ans+=dp[n-1][j];
	cout << fixed << setprecision(12);
	cout << ans/100 << "\n";
 	return 0;
}


Measured memory_bytes: 70656
N, A, B = map(int, input().split())
S = input()
cnt1, cnt2 = 0, 1

for Si in S:
    if Si=='a' and cnt1<A+B:
        print('Yes')
        cnt1 += 1
    elif Si=='b' and cnt1<A+B and cnt2<=B:
        print('Yes')
        cnt1 += 1
        cnt2 += 1
    else:
        print('No')

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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
//int t = 1; int ti;



const int N = 3e3 + 5;
int dp[N][N];
string s, t;


void solve(){
    cin>>s>>t;    

    // fori(i, 0, sz(s))
    // dp[0][i] = 0;
    int n = sz(s), m = sz(t);

    fori(i, 1, n){
        fori(j, 1, m){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string ans = "";

    int i = n, j = m;

    while(i >= 1 && j >= 1){
        if(s[i-1] == t[j-1]){
            ans += s[i-1];
            i--;
            j--; 
        } else {
            if(dp[i][j-1] > dp[i-1][j]){
                j--;
            } else {
                i--;
            }
        }
    }

    reverse(all(ans));
    
    cout<<ans;

}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 35456
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  ll ans = 0;
  rep(i, n) {
    rep(j, n) {
      if(i == j) continue;
      ans = max(ans, abs(a[i] - a[j]));
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
X = [int(i) for i in input().split()]
ans=[]
Y=sorted(X)
a=Y[N//2 -1]
b=Y[N//2]
for x in X:
    if x<= a:
        ans.append(b)
    else:
        ans.append(a)
print('\n'.join(map(str,ans)))

Measured memory_bytes: 30272
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29) 
#define all(n) (n).begin(),(n).end()
#define MAX_V 1100
using namespace std;

//follow
struct edge
{
  int to,cap,rev;
  edge(int to=inf,int cap=inf,int rev=inf):to(to),cap(cap),rev(rev){}
};
 
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
bool used[MAX_V];
 
void init(int V)
{
  rep(i,V)G[i].clear();
}
 
void add_edge(int from,int to,int cap)
{
  G[from].push_back(edge(to,cap,G[to].size()));
  G[to].push_back(edge(from,0,G[from].size()-1));
}

int dfs(int v,int t,int f)
{
  if(v == t)return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++)
    {
      edge &e = G[v][i];
      if(e.cap > 0 && !used[e.to])
	{
	  int d = dfs(e.to,t,min(f,e.cap));
	  if(d > 0)
	    {
	      e.cap -= d;
	      G[e.to][e.rev].cap += d;
	      return d;
	    }
	}
    }
  return 0;
}
 
int max_flow(int s,int t)
{
  int flow = 0;
  for(;;)
    {
      memset(used,0,sizeof(used));
      int f = dfs(s,t,inf);
      if(f == 0)
	{
	  return flow;
	}
      flow += f;
    }
}
 
//

int main()
{
  int N,k,K,s,t,day;
  while(cin >> N,N)
    {
      cin >> k;
      K = k;
      s = k + N;
      t = s + 1;
      init(t+1);
      map<int,int> days;
      vector<int> vday;
      rep(i,k)
	{
	  cin >> day;
	  vday.push_back(day);
	}
      sort(all(vday));
      vday.erase(unique(all(vday)),vday.end());
      rep(i,vday.size())
	{
	  days[vday[i]] = i;
	  add_edge(s,i,1);
	}

      rep(i,N)
	{
	  cin >> k;
	  rep(j,k)
	    {
	      cin >> day;
	      if(days.find(day) != days.end())
		{
		  add_edge(days[day],K+i,1);
		}
	    }
	  add_edge(K+i,t,1);
	}

      cout << max_flow(s,t) << endl;

    }
  return 0;
}

Measured memory_bytes: 1536
def div(num):
    counter = 0
    for i in range(num):
        if num % (i+1) == 0:
            counter += 1
    return counter
N = int(input())
sumcount = 0
for i in range(N):
    if div(i+1)==8:
        if (i+1) % 2 != 0:
            sumcount += 1
print(sumcount)

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

int main() {
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	cout << fixed << setprecision(5);
	cout << d << " " << r << " " << f << endl;
	return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
vll a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vll acca(n + 1, 0);
    for (int i = 0; i < n; i++) acca[i + 1] = acca[i] + a[i];
    map<ll, int> acm;
    ll ans = 0;
    for (int i = 0; i < n + 1; i++) {
        ans += acm[acca[i]];
        acm[acca[i]]++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9+7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    int x , y  ,  z ;
    cin >> x >> y >> z ;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;

    //cin >> t ;
    while(t--){
        solve( );
    }
}


Measured memory_bytes: 256
def main():
    while True:
        n, r = map(int, input().split())
        if n == 0:
            break
        cards = [i for i in range (1, n+1)]
        cards.reverse()
        
        for i in range (r):
            p, c = map(int,input().split())
            top = cards[0 :  p-1]
            mid = cards[p-1 : p+c-1]
            btm = cards[p+c-1:]
            cards = mid + top + btm
        print(cards[0])
main()




Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
vector<char>v;
int main(){
 string s;
 cin >> s;
 //for(int i=0;i<s.size();i++){
   // v.push_back();
 //}
 string res="";
 for(int i=0;i<s.size();i++){
    if(s[i]=='0')
        res+='0';
    else if(s[i]=='1')
        res+='1';
    else{
      int sz=res.size();
      if(sz>=1)
         res.erase(sz-1,1);

    }
 //cout << res <<endl;
 }
 //cout << s <<endl;
 cout << res <<endl;
 return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
    
    while (1) {
        char ch;
        scanf("%c", &ch);

        if (ch == '\n') {
            printf("\n");
            break;
        } else {
            if ('a' <= ch && ch <= 'z') {
                ch += 'A' - 'a';
            } else if ('A' <= ch && ch <= 'Z') {
                ch -= 'A' - 'a';
            }
            printf("%c", ch);
        }

    }
    return 0;
}


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

int main(){
  long long int n, chance, atimes=0, btimes=0, as=0, bs=0; cin >> n;
  long long int a[n], b[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    as += a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
    bs += b[i];
  }

  chance = bs-as;

  for(int i=0; i<n; i++){
    if(a[i]>b[i]){
      btimes += a[i]-b[i];
    }
    else if(a[i]<b[i]){
      atimes += (long long int)ceil((b[i]-a[i])/2);
      btimes += (b[i]-a[i])%2;
    }
  }

  if(chance<max(atimes, btimes)) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

using namespace std;

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

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,c;
  string s;
  cin>>a>>b>>c;

  if(a<=c && c<=b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}


Measured memory_bytes: 256
N,M=map(int,input().split())
F=[0]*(M+1)
for i in range(N):
  A=list(map(int,input().split()))
  #print(A)
  for j in range(1,A[0]+1):
    F[A[j]]+=1
#print(F)

ans=0
for i in range(1,M+1):
  if F[i]==N:
    ans+=1
print(ans)

Measured memory_bytes: 3060
($m,$n)=split / /,<stdin>;
chomp $n;
for(my $i=0;$i<2;$i++){
    if($m>$n){
        $a+=$m;
        $m-=1;
    }else{
        $a+=$n;
        $n-=1;
    }
}
print "$a";

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  int A[100];
  int N,i,j,minj,count=0,tmp;
  scanf("%d",&N);
  for(i=0;i<N && 1<=N && N<=100;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<N;i++)
    {
      minj=i;
      for(j=i;j<N;j++)
        {
          if(A[j]<A[minj])
            {
              minj=j;
            }
	}
      if(minj!=i) count++;
	  tmp=A[i];
	  A[i]=A[minj];
	  A[minj]=tmp;
    }
   for(i=0;i<N;i++)
    {
  printf("%d",A[i]);
  if(i!=N-1)printf(" ");
    }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



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

using namespace std;

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

int main(){
  int a, b; cin >> a >> b;
  string r;
  if (a*b%2 ==0) {
    r = "Even";
  } else {
    r = "Odd";
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256