akhauriyash/Code-Regression huggingface dataset:
import math

MOD = 1000000007

def revKey(v):
    if v == (1,0):
        return (0,1)

    if v[1] < 0:
        return (-v[1], v[0])
        
    return (v[1], -v[0])


N = int(input())

POW2 = [0]*(N+1)
p = 1
for i in range(N+1):
    POW2[i] = p
    p = p*2%MOD


V = {}
for _ in range(N):
    A,B = map(int, input().split())

    v = None
    if A == 0:
        if B == 0:
            v = (0,0)
        else:
            v = (0, 1)
    elif B == 0:
        v = (1, 0)

    else:
        if A < 0:
            A,B = -A,-B

        g = math.gcd(A,B)
        A //= g
        B //= g

        v = (A,B)

    if not(v in V):
        V[v] = 0

    V[v] += 1


ans = 1
for v in V:
    if v == (0,0):
        continue

    n = V[v]
    if n == None:
        continue

    n2 = 0
    revV = revKey(v)
    if revV in V:
        n2 = V[revV]
        V[revV] = None
        ans = ans * (POW2[n] + POW2[n2] - 1) % MOD
    else:
        ans = ans * POW2[n] % MOD

if (0,0) in V:
    ans += V[(0,0)]

ans -= 1
print(ans % MOD)
        




        



Measured memory_bytes: 54556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-k){
        if(a[k+i] > a[i]) dunk("Yes");
        else dunk("No");
    }
    return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int s,c,flag=0;
    int n[N];
    for(int i=0; i<N; i++){
        n[i]=-1;
    }
    for(int i=0; i<M; i++){
        cin >> s >> c;
        if(s==1 && c==0 && N>1){
            flag=1;
        }else if(n[s-1]!=-1 && n[s-1]!=c){
            flag=1;
        }else{
            n[s-1]=c;
        }
    }
    if(flag>0){
        cout << -1;
    }else{
        for(int i=0; i<N; i++){
            if(n[i]==-1){
                if(i==0 && N>1) n[i]=1;
                else n[i]=0;
            }
            cout << n[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 17.11.2019 02:36:53       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> at(2 * m + 2);
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    at[r].push_back(l + m);
  }
  multiset<int> s;
  int ans = 0;
  for (int i = 0; i < (int) at.size(); i++) {
    for (int j : at[i]) {
      s.insert(j);
    }
    while (!s.empty() && *s.begin() < i) {
      s.erase(s.begin());
    }
    if (!s.empty()) {
      ++ans;
      s.erase(s.begin());
    }
  }
  cout << n - min(ans, m) << '\n';
  return 0;
}


Measured memory_bytes: 19968
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    for i in range(60):
        cnt_one = 0
        for a in A:
            if (a >> i) & 1:
                cnt_one += 1
        res += (n - cnt_one) * cnt_one * pow(2, i)
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 50800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    if (A % 2 == 0)
    {
        ans += (B - A + 1) / 2 % 2;
        if (B % 2 == 0)
        {
            ans ^= B;
        }
    }
    else
    {
        if (B % 2 == 1)
        {
            ans += (B - (A + 1) + 1) / 2 % 2;
            ans ^= A;
        }
        else
        {
            ans += (B - 1 - (A + 1) + 1) / 2 % 2;
            ans ^= A;
            ans ^= B;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val ans = when (N % 10) {
        2, 4, 5, 7, 9 -> "hon"
        0, 1, 6, 8 -> "pon"
        else -> "bon"
    }
    println(ans)
}

Measured memory_bytes: 34344
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 2019;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

string str;
ll cnt[M],sm[M];

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

	ll n,i,p,ans = 0;

	cin >> str;
	n = str.size();
	p = 1;
	cnt[0]++;

	for(i=n;i>=1;i--)
	{
		sm[i] = (sm[i+1]+1ll*p*(str[i-1]-'0')%md)%md;
		ans += cnt[sm[i]];
		cnt[sm[i]]++;
		p = (p*10)%md;
	}

	cout << ans << "\n";
}

	

Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
int main(){
  using BS = bitset<32>;
  Int x, y;
  cin>>x >> y;
  BS b(x&y), c(x|y), d(x^y);
  cout<<b<<endl;
  cout<<c<<endl;
  cout<<d<<endl;
  return 0;
}


Measured memory_bytes: 3164
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".to!(char[]);

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    foreach (i; 0..H) {
        foreach (j, w; readln.split.to!(string[])) {
            if (w == "snuke") {
                writefln("%c%d", AB[j], i+1);
            }
        }
    }
}

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

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

    int n;
    cin >> n;

    vector<int> isyes(111000, 0);
    int base = 1;
    while(base*(base+1)/2 <= 110000){
        isyes[base*(base+1)/2] = base;
        ++base;
    }

    if(isyes[n] == 0){
        puts("No");
        return 0;
    }

    int len_s = isyes[n];
    int num_s = len_s+1;

    vector<vector<int>> res(num_s, vector<int>(len_s));
    int now = 1;
    rep(i, num_s){
        for(int j = i; j < len_s; ++j){
            res[i][j] = now;
            ++now;
        }
    }

    now = 1;
    rep(j, len_s){
        for(int i = j+1; i < num_s; ++i){
            res[i][j] = now;
            ++now;
        }
    }

    cout << "Yes" << endl;
    cout << num_s << endl;
    rep(r, num_s){
        cout << len_s << " ";
        rep(c, len_s) cout << res[r][c] << " ";
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 4468
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4
1 2 2 4
2 1 4
3 0
4 1 3

output:
1 0
2 1
3 2
4 1
"""

import sys
from collections import deque

UNVISITED, VISITED_IN_QUEUE, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index, adj_num, *adj_list = map(int, v_detail)
        # assert len(adj_list) == adj_num
        init_adj_table[v_index].extend(adj_list)
    return init_adj_table


def graph_bfs(v_init):
    status[v_init] = VISITED_IN_QUEUE
    distance[v_init] = 0
    queue.appendleft(v_init)

    while queue:
        current = queue.popleft()
        for v in adj_table[current]:
            if status[v] is UNVISITED:
                status[v] = VISITED_IN_QUEUE
                distance[v] = distance[current] + 1
                queue.append(v)
        status[current] = POPPED_OUT
    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    vertices_info = list(map(lambda x: x.split(), _input[1:]))
    init_adj_table = [[] for _ in range(vertices_num + 1)]
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    queue = deque()
    status = [UNVISITED] * (vertices_num + 1)
    distance = [-1] * (vertices_num + 1)

    adj_table = generate_adj_matrix(vertices_info)
    ans = graph_bfs(1)
    for k, v in enumerate(ans[1:], 1):
        print(k, v)

Measured memory_bytes: 8020
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
  //Ai<10^5
  ll n, x, m;scanf("%lld %lld %lld", &n, &x, &m);
  vvl d = VV(m, 40, -1, ll);
  vvl s = VV(m, 40, -1, ll);

  for(ll i=0;i<40;i++){
    for(ll j=0;j<m;j++){
      if(i==0) {
        d[j][0] = (j*j)%m;
        s[j][0] = d[j][0];
      }else {
        d[j][i] = d[d[j][i-1]][i-1];
        s[j][i] = s[j][i-1] + s[d[j][i-1]][i-1];
      }
    }
  }

  auto f = [&](ll k){//k項目を求める
    int cnt = 0;
    ll ret = x;
    ll ans = x;
    while(k){
      if(k%2) {
        ans += s[ret][cnt];
        ret = d[ret][cnt];
      }
      k/=2;
      cnt++;
    }
    return ans;
  };
  std::cout << f(n-1) << '\n';
}


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

string replaceAll(string &replacedStr, string from, string to) {
    int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}


int main() {

  string s;
  cin >> s;

  reverse(s.begin(), s.end());

  replaceAll(s, "resare", "");
  replaceAll(s, "esare", "");
  replaceAll(s, "remaerd", "");
  replaceAll(s, "maerd", "");
  
  if (s == "") {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;

}

Measured memory_bytes: 512
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: chars,
    }
    let abcd: Vec<_> = s
        .into_iter()
        .map(|x| (x as u8 - '0' as u8) as i32)
        .collect();

    for i in 0..(1 << 3) {
        let mut result = abcd[0];
        let mut ops = Vec::new();
        for j in 0..3 {
            if i & (1 << j) != 0 {
                result += abcd[j + 1];
                ops.push('+');
            } else {
                result -= abcd[j + 1];
                ops.push('-');
            }
        }
        if result == 7 {
            print!("{}", abcd[0]);
            for i in 0..3 {
                print!("{}{}", ops[i], abcd[i + 1]);
            }
            print!("=7\n");
            return;
        }
    }
    unreachable!();
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   vector<ll> v(n+1,0);
   for(ll x=1;x<=100;x++)
        for(ll y=1;y<=100;y++)
            for(ll z=1;z<=100;z++)
            {
                ll temp = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (x*z);
                if(temp<=n)
                    v[temp]++;
            }
   
   for(ll i=1;i<=n;i++)
        cout<<v[i]<<"\n";
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 3648
S = input()

L = ["eraser","erase","dreamer","dream"]
 
while len(S) > 0:
  for i in range(len(L)):
    if L[i] in S:
      S = S.replace(L[i],"")
  else:break
 
if len(S) == 0:
  print("YES")
else:print("NO")

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

string N;

int main() {
    cin >> N;
    if (N.find('9') != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	int n, m, a, b;
	map <int, int> c1, c2;

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		if (a == 1)
		{
			c1[b] = 1;
		}
		if (b == n)
		{
			c2[a] = 1;
		}
	}

	bool ok = false;

	for (auto it : c1)
	{
		if (c2[it.first] == 1 && it.second == 1)
		{
			ok = true;
			break;
		}
	}

	if (ok == true)
	{
		cout << "POSSIBLE\n";
	}
	else
	{
		cout << "IMPOSSIBLE\n";
	}

	return 0;
}


Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main(void){
    // Your code here!
   int x, a, b;
   cin >> x >> a >> b;
   if(abs(x-a) < abs(x-b)){
       cout << 'A' << endl;
   } else {
       cout << "B" << endl;
   }
   return 0;
}


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

#define ALL(V) (V).begine(),(V).end()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)

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

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

#define SZ(x) ((int)(x).size())

typedef vector<int> vi;
typedef long long ll;

double PI = 3.1415;

/* 入力 */
int N,M;

void calc()
{
    cin >> N;
    cout << 6.28 * (double)(N) << endl;
}

int main()
{
    calc();
}

Measured memory_bytes: 3748
S = list(input())
output = "Yes"
a = []
b = []
for i in range(4):
    if S[i] in b:
        output = "No"
    if S[i] in a:
        b.append(S[i])
    a.append(S[i])

if len(b)>2:
    output = "No"
if len(b)<2:
    output = "No"

print(output)


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int x,n;
    cin >> x >> n;
    set <int> s;
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        s.insert(k);
    }
    for(int i=0;i<200;i++){
        if(s.count(x-i)==0){
            cout << x-i ;
            return 0;
        }
        if(s.count(x+i)==0){
            cout << x+i ;
            return 0;
        }
    }
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main()
{
  int D, N;
  cin >> D >> N;
  int ans = 1;
  for (int i = 0; i < D; ++i) ans *= 100;
  if (N == 100) {
    ans *= 101;
  }
  else {
    ans *= N;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n = 5;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!a[i]) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}

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

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var Slist = new List<char[]>();
            for(var i = 0;i<n;i++)
            {
                Slist.Add(Console.ReadLine().ToCharArray());
            }
            var resultStr = "";
            for (var i = 0; i < Slist[0].Length; i++)
            {
                var c = Slist[0][i];
                var all = true;
                for(var k = 1;k<Slist.Count;k++)
                {
                    var tmp = false;
                    for(var j = 0;j<Slist[k].Length;j++)
                    {
                        if(Slist[k][j]==c)
                        {
                            tmp = true;
                            Slist[k][j] = '_';
                            break;
                        }
                    }
                    if(!tmp)
                    {
                        all = false;
                        break;
                    }
                }
                if (all) resultStr += c;
            }

            Console.WriteLine(resultStr.OrderBy(c=>c).ToArray());
        }
    }

Measured memory_bytes: 13396
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

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

B = [0]*N

for i in range(N):
    B[A[i]-1] =i+1

print(*B)  


Measured memory_bytes: 24672
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    int hoge=0;
    while(cin>>n,n){
        if(hoge++)cout<<endl;
        vector<pii>v;
        vector<string>amausa;
        rep(i,n){
            int gotiusa=0;
            string rabit; cin>>rabit;
            amausa.push_back(rabit);
            int kokoa,rize,tino; cin>>kokoa>>rize>>tino;
            gotiusa+=kokoa*3+tino;
            v.push_back(pii(gotiusa,-i));
        }
        sort(all(v),greater<pii>());
        rep(i,n)cout<<amausa[-1*v[i].second]<<","<<v[i].first<<endl;
    }
}

Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define endl '\n'
#define ll long long

using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll x;
	vector<int> v;
	cin >> x;

	for (ll a = -118; a < 120; a++)
	{
		for (ll b = -119; b < 119; b++)
			if (a * a * a * a * a - b * b * b * b * b == x) {
				cout << a << " " << b << endl;
				return 0;
			}
	}

	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int bubbleSort(int *A, int N) {
	int i, j;
	int tmp;
	int cnt = 0;

	for (i = 0; i < N - 1; i++) {
		for (j = N - 1; j > i; j--) {
			if (A[j] < A[j - 1]) {
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				cnt++;
			}
		}
	}

	return cnt;
}


int main(void) {
	int N;
	int A[100];
	int i;
	int cnt;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	
	cnt = bubbleSort(A, N);
	for (i = 0; i < N; i++) {
	    if(i){
	        printf(" ");
	    }
		printf("%d", A[i]);
	}
	printf("\n%d\n", cnt);

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int X; cin >> X;
	if(X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3608
double M,N,e,f,g,a[20][3],*x,*y;
n,i,j,v[20];
D(d,m,c){
	if(m==0){
		for(N=i=0;i<d-1;i++)for(j=i+1;j<d;j++)x=a[v[i]],y=a[v[j]],N+=(e=x[0]-y[0])*e+(f=x[1]-y[1])*f+(g=x[2]-y[2])*g;
		if(M<N)M=N;
	}else for(;c<=n-m;c++)v[d]=c,D(d+1,m-1,c+1);
}
main(m){
	scanf("%d%d",&n,&m);if(m<2)puts("0"),exit(0);
	for(i=0;i<n;i++)for(j=0;j<3;j++)scanf("%lf",a[i]+j);
	M=0;D(0,m,0);printf("%f\n",M),exit(0);
}

Measured memory_bytes: 664
N,M=map(int,input().split())
A=list(map(int,input().split()))
D={0:1}
S=[0 for i in range(N)]
S[0]=A[0]%M
if S[0] in D:
    D[S[0]]+=1
else:
    D[S[0]]=1
for i in range(1,N):
    S[i]=(S[i-1]+A[i])%M
    if S[i] in D:
        D[S[i]]+=1
    else:
        D[S[i]]=1
ans=0
for i in D:
    ans+=(D[i]*(D[i]-1))//2
print(ans)


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

vector <int> v;

int main () {

	int n, k;
	string s;

	cin >> n >> k >> s;

	if (s[0] == '0')
		v.push_back (0);

	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		++cnt;
		if (i == n - 1 || s[i + 1] != s[i]) {
			v.push_back (cnt);
			cnt = 0;
		}
	}

	if (v.size() % 2 == 0)
		v.push_back (0);

	k += k + 1;

	if (v.size() < k) {
		cout << n << endl;
		return 0;
	}

	int sum = 0;
	int ans = 0;
	for (int i = 0; i < k; ++i)
		sum += v[i];

	ans = sum;
	for (int i = k; i < v.size(); i += 2) {
		sum += v[i] + v[i + 1];
		sum -= v[i - k] + v[i - k + 1];
		ans = max (ans, sum);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1020
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define ll long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const ll MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	REP(i, n) {
		REP(k, n) {
			int gcd_a = GCD(i + 1, k + 1);
			REP(m, n) {
				ans += GCD(m + 1, gcd_a);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS = 1e-8;

const int INF = 1000000;
const int MAXV = 10001;
int rest[MAXV];

struct E {
    int to, w;
};
vector<vector<E>> G;

void dfs(int u, int d, int prev) {
    rest[u] = d;
    for (E e: G[u]) {
        if (rest[e.to] > rest[u]+e.w) {
            dfs(e.to, rest[u]+e.w, u);
        }
    }
}

vec gauss(mat A, vec b) {
    int N = A.size();
    mat X(N, vec(N+1));
    for (int i=0; i<N; ++i) {
        for (int j=0; j<N+1; ++j) {
            X[i][j] = (j != N ? A[i][j] : b[i]);
        }
    }
    for (int i=0; i<N; ++i) {
        int pivot = i;
        for (int j=i+1; j<N; ++j) {
            if (abs(X[pivot][i]) < abs(X[j][i])) {
                pivot = j;
            }
        }
        swap(X[i], X[pivot]);

        if (abs(X[i][i]) < EPS) {
            return vec();
        }

        double d = X[i][i];
        for (int j=i; j<N+1; ++j) {
            X[i][j] /= d;
        }

        for (int j=0; j<N; ++j) {
            if (j == i) continue;
            double t = X[j][i];
            for (int k=0; k<N+1; ++k) {
                X[j][k] -= t * X[i][k];
            }
        }
    }
    vec ret(N);
    for (int i=0; i<N; ++i) {
        ret[i] = X[i][N];
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    rdfile("_input.txt");

    int n, s, t;
    while (cin >> n >> s >> t) {
        if (n==0 && s==0 && t==0) break;
        s--; t--;

        vector<int> sign(n);
        for (int i=0; i<n; ++i) cin >> sign[i];

        G.clear();
        G.resize(n);
        int a;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> a;
                if (a == 0) continue;
                G[i].push_back((E){j, a});
            }
        }

        for (int i=0; i<MAXV; ++i) rest[i] = INF;
        dfs(t, 0, -1);

        if (rest[s] == INF) {
            cout << "Impossible" << endl;
            continue;
        }

        mat A(n, vec(n, 0));
        vec b(n, 0);

        for (int i=0; i<n; ++i) {
            if (i == t) {
                A[i][i] = 1;
                b[i] = 0;
                continue;
            }
            if (sign[i] == 0) { // without sign
                for (E e: G[i]) {
                    A[i][e.to] = -1;
                    b[i] += e.w;
                }
                A[i][i] = G[i].size();
            } else { // with sign
                int cnt = 0;
                for (E e: G[i]) {
                    if (rest[e.to]+e.w != rest[i]) continue;
                    cnt ++;
                    A[i][e.to] = -1;
                    b[i] += e.w;
                }
                A[i][i] = cnt;
            }
        }

        vec ans = gauss(A, b);
        printf("%.10f\n", ans[s]);
    }
    return 0;
}


Measured memory_bytes: 3388
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int c[500][500];
int d[30][30];

int amari[500][500];
int inic[3][30];
int co[3];

int main()
{
	int n,cc;
	int score;
	int ans=1e9-1;
	
	cin>>n>>cc;
	for(int i=0;i<cc;i++)
		for(int j=0;j<cc;j++)
			cin>>d[i][j];
	
	fill(inic[0],inic[3],0);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			cin>>c[i][j];
			inic[(i+j+2)%3][c[i][j]-1]++;
		}
	
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			amari[i][j]=(i+j+2)%3;
	
	for(co[0]=0;co[0]<cc;co[0]++)
	{
		for(co[1]=0;co[1]<cc;co[1]++)
		{
			if(co[0]==co[1])
				continue;
			for(co[2]=0;co[2]<cc;co[2]++)
			{
				int cnt=0;
				if(co[0]==co[2] || co[1]==co[2])
					continue;
				
				for(int i=0;i<3;i++)
				{
					for(int j=0;j<cc;j++)
					{
						cnt+=inic[i][j]*d[j][co[i]];
					}
				}
				
				ans=min(ans,cnt);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll count(ll x,int n,vector<ll>th,vector<ll>pa){
    if(n==0)return 1;
    if(x==1)return 0;
    if(2<=x&&x<=th[n-1]+1)return count(x-1,n-1,th,pa);
    if(x==th[n-1]+2)return pa[n-1]+1;
    if(th[n-1]+3<=x&&x<=th[n]-1)return pa[n-1]+1+count(x-th[n-1]-2,n-1,th,pa);
    if(x==th[n])return pa[n];
}
int main(void){
    vector<ll>th(51),pa(51);
    th[0]=1;pa[0]=1;
    rep(i,50){
        th[i+1]=2*th[i]+3;
        pa[i+1]=2*pa[i]+1;
    }
    int n;ll k;cin>>n>>k;
    cout<<count(k,n,th,pa)<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N, M = IL(int)
    AB = ILL(int, M)
    graph = [[] for _ in range(N)]
    for a, b in AB:
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)
    que = deque()
    que.append(0)
    visited = [False] * N
    visited[0] = True
    route = [0] * N
    while len(que):
        current = que.popleft()
        for next in graph[current]:
            if not visited[next]:
                visited[next] = True
                que.append(next)
                route[next] = current + 1

    print('Yes')
    for i in route[1:]:
        print(i)


solve()


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

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

	if(n <= 9) cout << n << endl;
	else if(n <= 99) cout << 9 << endl;
	else if(n <= 999) cout << 9 + (n - 100 + 1) << endl;
	else if(n <= 9999) cout << 9 + (999 - 100 + 1) << endl;
	else if(n <= 99999) cout << 9 + (999 - 100 + 1) + (n - 10000 + 1) << endl;
	else cout << 9 + (999 - 100 + 1) + (99999 - 10000 + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<ctime>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

int n, k;
int f[20];

bool check (int x) {
	while (x) {
		if (!f[x % 10]) return 0;
		x /= 10;
	}
	return 1;
}

int main() {
	read(n);
	read(k);
	rep(i, 0, 9) f[i] = 1;
	while (k--) {
		int x;
		read(x);
		f[x] = 0;
	}
	while (!check(n)) ++n;
	cout << n << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string str,str1;
  cin>>str>>str1;
  for(int i=0;i<str.size();i++)
    cout<<str[i]<<str1[i];
  cout<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n,d,x;cin>>n>>d>>x;
    rep(i,n){
        int a;cin>>a;
        x+=(d-1)/a+1;
    }
    cout<<x;
    return 0;
}


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

vector<vector<pair<int, int>>> g;
vector<int> ans;

int dfs(int v, int p, int c) {
    int color = 1;
    int res = c;
    for (auto e: g[v]) {
        if (e.first == p) continue;
        if (color == c) color++;
        ans[e.second] = color;
        res = max(res, dfs(e.first, v, color));
        color++;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(make_pair(b, i));
        g[b].push_back(make_pair(a, i));
    }
    int c_num = dfs(0, -1, -1);
    cout << c_num << endl;
    for (int i = 0; i < n-1; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/25  Problem: 076_abc_c / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string S, T;
	while (cin >> S >> T) {
		string res = "";
		for (int i = 0; i < S.size(); ++i) {
			bool check = true;
			string tmp = S;
			for (int j = 0; j < T.size(); ++j) {
				if (i + j >= S.size()) { check = false; break; }
				if (S[i + j] != '?' && S[i + j] != T[j]) { check = false; break; }
				tmp[i + j] = T[j];
			}
			if (check) {
				for (int i = 0; i < tmp.size(); ++i) {
					if (tmp[i] == '?') tmp[i] = 'a';
				}
				if (res == "") res = tmp;
				else res = min(res, tmp);
			}
		}
		if (res != "") cout << res << endl;
		else cout << "UNRESTORABLE" << endl;


		return 0;
	}
}

Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	READV(K);
	READV(C);
	string S;
	cin>>S;
	vector<ll> R(N,-1),L(N,-1);
	ll tot=0;
	ll cnt=0;
	FORI(i,0,N)
	{
		if(cnt>=K)
		{
			break;
		}
		if(tot==0 && S[i]=='o')
		{
			R[cnt]=i;
			tot=C;
			cnt++;
		}
		else
		{
			tot=max(0LL,tot-1);
		}
	}
	tot=0,cnt=1;
	reverse(S.begin(),S.end());
	FORI(i,0,N)
	{
		if(cnt>K)
		{
			break;
		}
		if(tot==0 && S[i]=='o')
		{
			L[K-cnt]=N-1-i;
			tot=C;
			cnt++;
		}
		else
		{
			tot=max(0LL,tot-1);
		}
	}
	FORI(i,0,K)
	{
		if(L[i]==R[i])
		{
			cout<<L[i]+1<<endl;
		}
	}


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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 5012
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#define N 100
using namespace std;

void hukugou(char str2[]){
  int i;

  while(1){

    for(i = 0;str2[i] != '\0';i++){
      if(str2[i] != ' ' && str2[i] != '\n' && str2[i] != '.'){
	str2[i] = (str2[i] - 'a' + 1) % 26 + 'a';
      }
    }

    if(strstr(str2, "the") != NULL || strstr(str2, "this") != NULL || strstr(str2, "that") != NULL){
      cout << str2;
      break;
    }
  }

}

int main(){
  char str[N];

  while(fgets(str, sizeof(str), stdin) != NULL){

  hukugou(str);

  }

  return 0;
}

Measured memory_bytes: 1100
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    cout << max(C - (A - B), 0) << endl;

    return 0;
}


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


public class Main{
	
	public static void main(String[] args){
	
	MyScanner sc = new MyScanner();
	out = new PrintWriter(new BufferedOutputStream(System.out));
	
	/**/

	int numberOfPersons = sc.nextInt();
	long[] persons = new long[numberOfPersons];
	long counter = 0;
	
	for(int i = 0; i < numberOfPersons; i++){
		
		persons[i] = sc.nextLong();
		
	}
	
	for(int i = 1; i < persons.length; i++){
		
		if(persons[i] < persons[i - 1]){
		
			counter += persons[i - 1] - persons[i];
			persons[i] = persons[i - 1];
		
		}
		
	}
	
	System.out.println(counter);
	
	
	
	/**/
	 
	 out.close();	
	}
	
	
	
	public static PrintWriter out;
	
	public static class MyScanner{
		
		BufferedReader br;
		StringTokenizer st;
		
		public MyScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
	
}


Measured memory_bytes: 55608
n = int(raw_input())
a = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    tmp = map(int, raw_input().split())
    if tmp[1]:
        for j in range(1, tmp[1]+1):
            a[i][tmp[j+1]-1] = 1
for i in range(n):
    print ' '.join(map(str, a[i]))

Measured memory_bytes: 6448
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 1;
        while (true) {
            int a = sc.nextInt();
            if(a == 0){
                break;
            }
            System.out.printf("Case %d: %d\n", n, a);
            n++;
        }
    }
}


Measured memory_bytes: 62136
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std; 
using namespace std::chrono; 
using namespace __gnu_pbds;
#define ll long long int 
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,  
                 tree_order_statistics_node_update>  
          ordered_set;  
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
};
 
void addEdge(vector<ll> adj[], ll u, ll v) 
{ 
   adj[u].push_back(v); 
   adj[v].push_back(u); 
} 
vector<ll> z_function(string s) {
    ll n = s.length();
    vector<ll> z(n);
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
ll mod=1e9+7;
ll power(ll x,ll y) 
{ 
    ll res = 1; // Initialize result 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = ((res%mod) * (x%mod))%mod; 
  
        // n must be even now 
        y = y >> 1; // y = y/2 
        x = ((x%mod) * (x%mod))%mod; // Change x to x^2 
    } 
    return res; 
}

int main() 
{ 
 	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin); 
    //freopen("output1.txt", "w", stdout); 
    ll n,ww;
	cin>>n>>ww;
	ll dp[100009]={0};
	ll w[n+1],v[n+1];
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<100005;i++) dp[i] = -1e18;
	dp[0] = 0;
	for(int i=1;i<=n;i++){
		for(int j=ww;j>=w[i];j--){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	ll ans = 0;
	for(int i=0;i<=ww;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;
    return 0; 
} 


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int n;
 
void compute(int depth,double x1,double y1,double x2,double y2){
  double si60 = sqrt(3.0)/2.0;
  double co60 = 0.5;
   
  double sx = (x1+x1+x2)/3.0;
  double sy = (y1+y1+y2)/3.0;
  double tx = (x1+x2+x2)/3.0;
  double ty = (y1+y2+y2)/3.0;
   
  double vx = tx-sx;
  double vy = ty-sy;
   
  double ux = sx + co60*vx - si60*vy;
  double uy = sy + si60*vx + co60*vy;
   
  if(depth>=n)return;
   
  compute(depth+1,x1,y1,sx,sy);
  printf("%.8f %.8f\n",sx,sy); 
  compute(depth+1,sx,sy,ux,uy);
  printf("%.8f %.8f\n",ux,uy);
  compute(depth+1,ux,uy,tx,ty);
  printf("%.8f %.8f\n",tx,ty);   
  compute(depth+1,tx,ty,x2,y2);
 
   
}
 
int main(){
  cin>>n;
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

Measured memory_bytes: 1196
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int a, b, c;
	char t;
	int hishigata=0;
	int chohokei=0;
	while(cin >> a >> t >> b >> t >> c){
		if(a*a+b*b==c*c){
			chohokei++;
		}else if(a==b){
			hishigata++;
		}
	}
	cout << chohokei << endl;
	cout << hishigata << endl;
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int, input().split()))

left = a[0]
right = a[-1]
center = 0
sum_a = sum(a)
flg = False
for i in range(1, n-1):
    if left + a[i] > sum_a/2 and flg is False:
        flg = True
        center = a[i]
        right -= a[i]
    elif left + a[i] == sum_a / 2:
        print(0)
        exit()
    if flg is False:
        left += a[i]
    else:
        right += a[i]

print(abs(min(left+center-right, right+center-left)))


Measured memory_bytes: 26220
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int DigitsSum(int num){
	int digits;
	int sum = 0;
	while (num) {
		digits = num % 10;
		sum += digits;
		num /= 10;
	}
	return sum;
}

int main() {
	//vector<int> a(N);
	//for (int i = 0; i < N; i++) cin >> a[i]
	//sort(a.begin(), a.end() , greater<int>());

	int H,A;
	cin >> H >> A;

	cout << (int)ceil((double)H/ A);

	//vector<int> p(M);
	//vector<string> S(M);
	//for (int i = 0; i < M; i++) cin >> p[i] >> S[i];

	//int ac=0, wa=0;
	//int pnum = 1;
	//int ppnum = 0;
	//int flag = 0;

	//for (int i = 0; i < M; i++) {
	//	if (pnum != ppnum) {
	//		flag = 0;
	//	}
	//	if (pnum == p[i]) {
	//		if (S[i] == "WA" && flag == 0) {
	//			wa++;
	//		}

	//		if (S[i] == "AC" && flag == 0) {
	//			ac++;
	//			pnum++;
	//			flag = 1;
	//			continue;
	//		}
	//	}
	//	ppnum = pnum;
	//}

	//cout << ac << " " << wa;
	return 0;
}


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

l_A = len(A)
cnt = 0
for i in range(l_A):
    j = l_A - i - 1
    if i >= j:
        break
    # left
    if A[i] + A[i+1] > x:
        diff = (A[i] + A[i+1]) - x
        if A[i+1] >= diff:
            cnt += diff
            A[i+1] = A[i+1] - diff
        else:
            remain_diff = diff - A[i+1]
            A[i+1] = 0
            A[i] = A[i] - remain_diff
            cnt += diff

    # right
    if A[j-1] + A[j] > x:
        diff = (A[j-1] + A[j]) - x
        if A[j-1] >= diff:
            cnt += diff
            A[j-1] = A[j-1] - diff
        else:
            remain_diff = diff - A[j-1]
            A[j-1] = 0
            A[j] = A[j] - remain_diff
            cnt += diff

print(cnt)


Measured memory_bytes: 14052