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

using namespace std;

int main(){
    int n,x;

    cin >> n;

    if(n == 1){
        cout << 0 << endl;
    }
    else{
        vector<int> v(n+1,0);
        vector<int> dp(n+1,0);

        for(int i = 1;i<=n;i++){
            cin >> x;
            v[i] = x;
        }

        dp[2] = abs(v[1] - v[2]);

        for(int i = 3;i<=n;i++){
            dp[i] = min(dp[i-1] + abs(v[i-1] - v[i]), dp[i-2] + abs(v[i-2] - v[i]));
        } 

        cout << dp[n] << endl;
    }

    
}

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

const int sz = 2e5+5;
int n, a[sz];

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

    sort(a, a+n, greater<int>());

    priority_queue<array<int, 3>> pq;
    pq.push({a[0], a[0], a[0]});

    ll ans = 0;
    for(int i = 1; i < n; ++i){
        auto t = pq.top();
        pq.pop();
        ans += t[0];
        pq.push({min(t[1],a[i]), t[1], a[i]});
        pq.push({min(t[2],a[i]), t[2], a[i]});
    }

    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 7152
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  priority_queue<int> A;
  for(int i = 0;i < N;i++){
    int a;
    cin >> a;
    A.push(a);
  }
  for(int i = 0;i < M;i++){
    int x = 0;
    x = A.top();
    A.pop();
    A.push(x/2);
  }
  long long ans = 0;
  for(int i = 0;i < N;i++){
    int xx = A.top();
    ans += xx;
    A.pop();
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  bool swi = false;
  for (int i = 0; i < N; i++) {
    char x;
    cin >> x;
    
    if (x == 'Y')
      swi = true;
  }
  
  if(swi)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define PI acos(-1)
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		int ans[n+1] = {};
		rep(i,2,n+1){
			int t;
			cin >> t;
			ans[t]++;
		}
		rep(i,1,n+1) cout << ans[i] << endl;
	}
}

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

int main()
{
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;

    string res = "";

    for (int i = 0; i < n; i++) {
        res = res + s[i] + t[i];
    }

    cout << res << endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Problem Specific Parameter:
const ll mod = 1000000007LL;

using pii = pair<int, int>;
vector<pii> check[310];
ll dp[310][310][310];

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

	rep(i, m) {
		int l, r, x;
		cin >> l >> r >> x;
		check[r].push_back(pii(l, x));
	}

	dp[0][0][0] = 1LL;

	rep(total, 3 * n + 1)rep(cr, n + 1)rep(cg, n + 1) {
		const int cb = total - cr - cg;
		if(cb < 0 or n <=cb) continue;
		if(cr == cg and cr !=0) continue; 
		if(cg == cb and cg !=0) continue; 
		if(cb == cr and cb !=0) continue; 
		if (dp[cr][cg][cb] == 0) continue;
		
		const int nxt = max({cr, cg, cb}) + 1;

		{
			// Red
			bool ok = true;
			for (auto &it2 : check[nxt]) {
				int cnt = 1;
				cnt += (it2.first <= cg);
				cnt += (it2.first <= cb);
				if (cnt != it2.second) ok = false;
			}

			if (ok) {
				dp[nxt][cg][cb] += dp[cr][cg][cb];
				dp[nxt][cg][cb] %= mod;
			}
		}

		{
			// Green
			bool ok = true;
			for (auto &it2 : check[nxt]) {
				int cnt = 1;
				cnt += (it2.first <= cr);
				cnt += (it2.first <= cb);
				if (cnt != it2.second) ok = false;
			}

			if (ok) {
				dp[cr][nxt][cb] += dp[cr][cg][cb];
				dp[cr][nxt][cb] %= mod;
			}
		}

		{
			// Blue
			bool ok = true;
			for (auto &it2 : check[nxt]) {
				int cnt = 1;
				cnt += (it2.first <= cg);
				cnt += (it2.first <= cr);
				if (cnt != it2.second) ok = false;
			}

			if (ok) {
				dp[cr][cg][nxt] += dp[cr][cg][cb];
				dp[cr][cg][nxt] %= mod;
			}
		}
	}

	ll ans = 0LL;
	rep(i, n + 1)rep(j, n + 1)rep(k, n + 1) {
		if (max({i, j, k}) != n) continue;
		ans += dp[i][j][k];
		ans %= mod;
	}

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

Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    ll n, h, w, ans = 0;
    cin>>n>>h>>w;

    REP(i,n) {
        ll a, b;
        cin>>a>>b;
        if (a >= h && b >= w) {
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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!{
        b : String
    };
    let mut b = b;

    println!("{}", change_char(b.pop()));
}

fn change_char(b : Option<char>) -> char{
    match b {
        Some('A') => 'T',
        Some('T') => 'A',
        Some('C') => 'G',
        Some('G') => 'C',
        _ => 'N'
    }
}




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

string solve(int a, int b, int c, int d, int e, int k){
    return (min({a-b,a-c,a-d,a-e,b-c,b-d,b-e,c-d,c-e,d-e}) * (-1)) > k ? ":(" : "Yay!";
    //multipliquei por -1 pro número sempre retornar positivo se min for negativo
}
int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    cout<<solve(a,b,c,d,e,k)<<"\n";
    return 0;
}


Measured memory_bytes: 256
import math

N , M = [int(i) for i in input().split()]
lis = {}
lis[0] = 1
now = 0
for i in input().split():
    now += int(i)
    now %= M
    if now  in lis:
        lis[now % M] +=1
    else:
        lis[now % M] = 1

ans = 0
for i in lis.values():
    ans += i * (i - 1) // 2

print(ans)
#print(lis)


Measured memory_bytes: 16100
cards = {
    'S':[r for r in range(1,13+1)],
    'H':[r for r in range(1,13+1)],
    'C':[r for r in range(1,13+1)],
    'D':[r for r in range(1,13+1)]
}

n = int(input())
for nc in range(n):
    (s,r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S','H','C','D']:
    for r in cards[s]:
            print(s,r)

Measured memory_bytes: 6724
n = gets.to_i
memo = {}
max = 0

n.times do
  hoge = gets.chomp
  if (memo[hoge]) 
    memo[hoge] += 1
    max = memo[hoge] if (memo[hoge] > max)
  else
    memo[hoge] = 0
  end
end

memo.select! {|k,v| v == max}

puts memo.keys.sort


Measured memory_bytes: 34792
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if (s.length() == 2) {
        cout << s << endl;
    }    
    else {
        std::reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

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

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

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

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

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	ll d;
	scanf("%d%lld", &n, &d);
	d *= d;
	int ans = 0;
	rep(i, n) {
		ll x, y;
		scanf("%lld%lld", &x, &y);
		if (x * x + y * y <= d)++ans;
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 3808
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3==0 || i%5==0)continue;
		else sum+=i;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3624
W,H,N = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]

area = []
for i in range(H):
    area.append([])
    for j in range(W):
        area[i].append('o')

for value in A:
    if value[2] == 1:
        for i in range(H):
            for j in range(value[0]):
                area[i][j] = 'x'
    if value[2] == 2:
        for i in range(H):
            for j in range(value[0], W):
                area[i][j] = 'x'
    if value[2] == 3:
        for j in range(W):
            for i in range(value[1]):
                area[i][j] = 'x'
    if value[2] == 4:
        for j in range(W):
            for i in range(value[1], H):
                area[i][j] = 'x'

tmp = []
for i in range(H):
    for j in range(W):
        tmp.append(area[i][j])
print(tmp.count('o'))

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int max = 0;

        if (a <= k) {
            max += a;
            k -= a;
        } else {
            max += k;
            k = 0;
        }

        if (b <= k) {
            k -= b;
        } else {
            k = 0;
        }

        if (c <= k) {
            max -= c;
            k -= c;
        } else {
            max -= k;
            k = 0;
        }
        
        // 出力
        System.out.println(max);
    }
}


Measured memory_bytes: 35544
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
const ll maxm = 5;
ll n,m,res;
ll getbit(ll x,ll y) 
{
	return (x>>y)&1;
}
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n >> m;
	res=(m*1900+100*(n-m))*(1<<m);
	cout << res;		
	return 0;
}

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

int main() {
	while(true){
		int n;
		cin>>n;
		
		if(n==0){
			break;
		}
		
		int sum_a=0,sum_b=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			
			if(a>b){
				sum_a+=a+b;
			} else if(a<b){
				sum_b+=a+b;
			} else{
				sum_a+=a;
				sum_b+=b;
			}
		}
	
		cout<<sum_a<<" "<<sum_b<<endl;
	}
	return 0;
}

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

int main(){
    int64_t N, d, sum = 0, mul = 0, i;

    cin >> N;
    for(i = 0; i < N; i++){
        cin >> d;
        sum += d * mul;
        mul += d;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/*
問題文

*/

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

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        String c = b.substring(0, b.length()-1);
        if (a.equals(c)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0037
{
    public class Program

    {
        public static void Main(string[] args)
        {

            List<int>[,] map = new List<int>[5, 5];

            //配列の初期化
            for (int i = 0 ; i < 5 ; i++)
            {
                for (int j = 0 ; j < 5 ; j++)
                {
                    map[i, j] = new List<int>();
                }
            }

            for (int i = 0 ; i < 9 ; i++)
            {
                string line = RSt();
                for (int j = 0 ; j < line.Length ; j++)
                {
                    if (line[j] == '1')
                    {
                        if (i % 2 == 0)
                        {
                            map[i / 2, j].Add(0);
                            map[i / 2, j + 1].Add(180);
                        }
                        else
                        {
                            map[i / 2, j].Add(270);
                            map[i / 2 + 1, j].Add(90);
                        }
                    }
                }
            }

            int[] dx = new int[] { 1, 0, -1, 0 };
            int[] dy = new int[] { 0, -1, 0, 1 };
            LinkedList<int> res = new LinkedList<int>();
            res.AddLast(0);
            int x = 1; int y = 0;

            while (x != 0 || y != 0)
            {
                int ingressOrientation = (res.Last.Value + 180) % 360;
                int next = GetOrientation(ingressOrientation, x, y, map[y, x]);
                res.AddLast(next);
                x += dx[next / 90];
                y += dy[next / 90];
            }

            string[] directions = new string[] { "R", "U", "L", "D" };
            Console.WriteLine(WAr(res.Select(item => directions[item / 90]),""));
        }

        private static int GetOrientation(int ingressOrientation, int x, int y, List<int> list)
        {
            int next = ingressOrientation;
            while (true)
            {
                next = (next + 270) % 360;
                if (list.Contains(next)) return next;
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 14684
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define int long long int

using namespace std;

int32_t main(void) {
    fast;
    int h, a; cin>>h>>a;
    if(h%a) cout<<h/a+1;
    else cout<<h/a;
}



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

//abc134B
int main(void) {
  int n, k, i, r,d, cou=0, tmp, len, m;
  long long mod=1000000007;
  scanf("%d %d", &n,&d);
  if(n%(d*2+1)==0) printf("%d", n/(d*2+1));
  else printf("%d", n/(d*2+1)+1);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

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

ll N,K;
cin >> N >> K;

mint cnt[101010];

for(ll g = K; g >= 1; --g) {
    cnt[g] = modpow(mint(K/g), N);
    ll gg = g * 2;
    while (gg <= K) {
        cnt[g] -= cnt[gg];
        gg += g;
    }
}

mint ans = 0;
rrep(g,K) ans += cnt[g]*g;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 4384
#include<iostream>
#include<climits>
using namespace std;
int main(){
	int n,m,x,y,p,q,min,s[200],t[200];
	while(cin>>n>>m,n||m){
		x=0;
		y=0;
		min=INT_MAX;
		for(int i=0;i<n;i++){
			cin>>s[i];
			x+=s[i];
		}
		for(int i=0;i<m;i++){
			cin>>t[i];
			y+=t[i];
		}
		for(int i=0;i<n;i++)
		for(int k=0;k<m;k++){
			if(x-s[i]+t[k]==y-t[k]+s[i]){
				if(s[i]+t[k]<min){
					min=s[i]+t[k];
					p=s[i];q=t[k];
				}
			}
		}
		if(min==INT_MAX)
		cout<<-1<<endl;
		else
		cout<<p<<' '<<q<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (auto &x : arr)
        cin >> x;

    sort(arr.begin(), arr.end());
    ll ans = INF;

    for (int i = 0; i <= 100; i++)
    {
        ll curr = 0;
        for (int x : arr)
        {
            curr += (x - i) * (x - i);
        }
        ans = min(ans, curr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    
    int N,i,j,x;
    int a[50]={0};
    scanf("%d",&N);
    x = 0;
    
    for (i=0; i<N; i++) {
        scanf("%d", &a[i]);
    }
    for (j=0; j<N-1; j++) {
        for (i=j+1; i<N; i++) {
            x += a[i]*a[j];
        }
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main()
{
    ll n, m,ans;
    cin >> n >> m;
    if(n==1){
        if(m>=2){
            ans = m - 2;
        }
        else{
            ans = 1;
        }
    }
    else if (m == 1)
    {
        if (n >= 2)
        {
            ans = n - 2;
        }
        else
        {
            ans = 1;
        }
    }

    else{
        ans = (n - 2) * (m - 2);

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int a[5000];
  int n;
  
  while( cin >> n )
    {
      int mv = -200000;
      
      if ( n == 0 )
        break;

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

      unique_ptr<int[][5000]> c(new int[n][5000]);
      
      for ( int i = 0; i < n; ++i )
        {
          for ( int j = 0; j <= i; ++j )
            {
              if ( i == j )
                {
                  c[i][j] = a[i];
                }
              else
                {
                  c[i][j] = c[i - 1][j] + a[i];
                }
              mv = max( mv, c[i][j] );
            }
        }

      cout << mv << endl;
      
    }
  
  return 0;
}

Measured memory_bytes: 58976
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N 998244353
#define INF 1e9

 
ll power(ll x, ll y, ll m) { 
    if (y == 0) return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    
    ll n ;
    cin >> n ;
    ll ans = (n/500)*1000 ;
    ans+= ((n%500)/5 )*5 ;
    cout << ans ;


    return 0 ;
    
}


Measured memory_bytes: 256
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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 printMatrix(mat,n,m){ \
    F(i, 0, n){               \
        F(j, 0, m){           \
            cout << mat[i][j] << space;\
        }\
        cout << endl;\
    }\
}

void printM(vector<vector<int> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
    cout << endl;
    }
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double ans = sqrt( pow(abs(x1-x2), 2) + pow(abs(y1-y2), 2) );
    printf("%1.8lf\n",ans);

#if TST==1
#endif
}



Measured memory_bytes: 3212
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;
const int MN = 1e5 + 10;

int n , arr[MN];

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n;
	for(int i=0;i<n;++i) cin >> arr[i];
	bool fl = false;
	if(n == 1){
		if(arr[0]&1) cout << "Second\n";
		else cout << "First\n";
		return 0;
	}
	while(1){
		if(*min_element(arr , arr+n) == 1){
			ll sm = 0;
			for(int i=0;i<n;++i) sm += arr[i];
			if((sm-n)%2){
				if(!fl) cout << "First\n";
				else cout << "Second\n";
			}else{
				if(!fl) cout << "Second\n";
				else cout << "First\n";
			}
			return 0;
		}
		int cnt = 0;
		for(int i=0;i<n;++i) if(arr[i]%2 == 0) ++cnt;
		if(cnt&1){
			if(fl) cout << "Second\n";
			else cout << "First\n";
			return 0;
		}else if(n-cnt > 1){
			if(fl) cout << "First\n";
			else cout << "Second\n";
			return 0;
		}
		if(*max_element(arr , arr+n) == 1){
			if(!fl) cout << "Second\n";
			else cout << "First\n";
			return 0;
		}
		for(int i=0;i<n;++i) if(arr[i]&1) arr[i]--;
		int g = -1;
		for(int i=0;i<n;++i){
			if(g == -1) g = arr[i];
			else g = __gcd(g , arr[i]);
		}
		for(int i=0;i<n;++i) arr[i]/=g;
		fl = !fl;
	}
	return 0;
}


Measured memory_bytes: 768
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N, Q = map(int, input().split())
    S = input()
    l = [0]*Q
    r = [0]*Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())

    cs = [0]*(N+1)
    for i in range(N-1):
        if S[i]=='A' and S[i+1]=='C':
            cs[i+2] = cs[i+1] + 1
        else:
            cs[i+2] = cs[i+1]

    for q in range(Q):
        print(cs[r[q]]-cs[l[q]])

if __name__ == '__main__':
    resolve()


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

typedef struct{
	int a, b, c, d, e, f;
}Dice;

typedef struct{
	int a, b, c, d, e, f;
}Dice2;

int main(void)
{
	Dice dice;
	Dice2 dice2;
	
	int temp;
	
	scanf("%d %d %d %d %d %d", &dice.a, &dice.b, &dice.c, &dice.d, &dice.e, &dice.f);
	scanf("%d %d %d %d %d %d", &dice2.a, &dice2.b, &dice2.c, &dice2.d, &dice2.e, &dice2.f);
	
	int i, j;
	if(dice.a!=dice2.a){
		for(i=0;i<3;i++){
			temp=dice.a; dice.a=dice.b; dice.b=dice.f; dice.f=dice.e; dice.e=temp;//N
				if(dice.a==dice2.a){goto LABEL;}
			temp=dice.a; dice.a=dice.d; dice.d=dice.f; dice.f=dice.c; dice.c=temp;//E
				if(dice.a==dice2.a){goto LABEL;}
		}
		if(i==2){puts("No");return 0;}
		LABEL:
		;
	}
	for(i=0;i<4;i++){
		temp=dice.b; dice.b=dice.c; dice.c=dice.e; dice.e=dice.d; dice.d=temp;//横回し
		if((dice.b==dice2.b)&&(dice.c==dice2.c)&&(dice.d==dice2.d)&&(dice.e==dice2.e))break;
	}
	if((dice.a==dice2.a)&&(dice.b==dice2.b)&&(dice.c==dice2.c)&&(dice.d==dice2.d)&&(dice.e==dice2.e)&&(dice.f==dice2.f)){puts("Yes"); return 0;}
	
	temp=dice.a; dice.a=dice.b; dice.b=dice.f; dice.f=dice.e; dice.e=temp;//N
	if(dice.b==dice2.b){goto label;}
	temp=dice.a; dice.a=dice.e; dice.e=dice.f; dice.f=dice.b; dice.b=temp;//S
	temp=dice.a; dice.a=dice.e; dice.e=dice.f; dice.f=dice.b; dice.b=temp;//S
	if(dice.e==dice2.e){goto label;}
	temp=dice.a; dice.a=dice.b; dice.b=dice.f; dice.f=dice.e; dice.e=temp;//N
	temp=dice.a; dice.a=dice.c; dice.c=dice.f; dice.f=dice.d; dice.d=temp;//W
	if(dice.d==dice2.d){goto label;}
	temp=dice.a; dice.a=dice.d; dice.d=dice.f; dice.f=dice.c; dice.c=temp;//E
	temp=dice.a; dice.a=dice.d; dice.d=dice.f; dice.f=dice.c; dice.c=temp;//E
	
	label:
	if((dice.a==dice2.a)&&(dice.b==dice2.b)&&(dice.c==dice2.c)&&(dice.d==dice2.d)&&(dice.e==dice2.e)&&(dice.f==dice2.f)){puts("Yes");}
	else puts("No");
	
	return 0;
}


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

using namespace std;
using LL = long long;

int main () {


	ios_base :: sync_with_stdio (0); cin.tie(NULL);

	LL N; cin >> N;

	LL moves = 1e18;

	for (LL i = 1; i * i <= N; ++i) {
		LL j = N / i;
		if (i * j == N) {
			moves = min(moves, i - 1LL + j - 1LL);
		}
	}

	cout << moves << '\n';


	return 0;
}





Measured memory_bytes: 256
a, b, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
coupon = [list(map(int, input().split())) for i in range(m)]
cm = (10**5) * 2


for i in range(m):
  cm = min(a[coupon[i][0]-1] + b[coupon[i][1]-1] - coupon[i][2], cm)

a.sort()
b.sort()

print(min(a[0]+b[0],cm))
                      


Measured memory_bytes: 38884
import sys
n, k = map(int, sys.stdin.readline().split())
if k > (n-1)*(n-2)//2:
    print(-1)
    quit()
t = (n-1)*(n-2)//2 - k
print(n-1+t)
for i in range(2, n+1):
    sys.stdout.write("{} {}\n".format(1, i))
for i in range(2, n+1):
    for j in range(i+1, n+1):
        if t == 0:
            break
        sys.stdout.write("{} {}\n".format(i, j))
        t -= 1
    if t == 0:
        break

Measured memory_bytes: 3188
#include <iostream>

typedef unsigned long long ull;

#define MAX_SIZE (100000 + 10)

bool prime[MAX_SIZE];

int main()
{
  prime[2] = true;
  for (int i = 3; i < MAX_SIZE; i += 2)
  {
    prime[i] = true;
  }

  for (int i = 3; i < MAX_SIZE; i += 2)
  {
    if (prime[i])
    {
      for (int j = i * 2; j < MAX_SIZE; j += i)
      {
        prime[j] = false;
      }
    }
  }

  int a, b;

  std::cin >> a >> b;
  int maxN = (a > b) ? a : b;
  ull ans = 1;
  for (int i = 2; i <= maxN; ++i)
  {
    if (a < i && b < i) break;
    if (!prime[i]) continue;
    while (a % i == 0 && b % i == 0)
    {
      a /= i;
      b /= i;
      ans *= static_cast<ull>(i);
    }
  }

  ans *= static_cast<ull>(a) * b;

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a) for(int i=0; i<a; i++)
using namespace std;
typedef pair<int, int> P;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
bool cmp(int a, int b)
{
	return a > b;
}
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge one, two;
	one.from = a; one.to = b; one.weight = c;
	two.from = b; two.to = a; two.weight = c;
	V[a].push_back(one);
	V[b].push_back(two);
}


//////////////////////////////////////////


void solve()
{
	int ans = 0;
	cin >> a;
	for(int i=1; i<34; i++)
	{
		int temp = i * i;
		while(temp <= a)
		{
			ans = max(ans, temp);
			temp *= i;
			if(i == 1) break;	
		}
	}
	printf("%d\n",ans);
}
int main()
{
	int times = 1;
//	cin << times;
	loop(times)
	{
		solve();
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;


namespace templete
{
    class BinarySearch
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] num_n = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.ReadLine();
            int[] num_q = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count=0;
            foreach(var key in num_q){
                if(Search(num_n,key))count++;
            }
            Console.WriteLine(count);
        }

        static bool Search(int[] num, int key){
            int left=0;
            int right=num.Length;

            while(left<right){
                int mid = (left+right)/2;
                if(num[mid] == key){
                    return true;
                }else if(num[mid] < key){
                    left = mid+1;
                }else{
                    right = mid;
                }
            }
            return false;
        }
    }
}


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


void solve(long long N, long long A, long long B){
    long long dist = B - A - 1;
    if (dist % 2 == 1)  { cout << "Alice" << endl;}
    else                { cout << "Borys" << endl;}  
    return;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
class Integer
  @@fact
  @@factinv
  @@mod
  def self.init_fact(max,mod)
    @@mod=mod
    @@fact=[1,1]
    (2..max).each{|i|
      @@fact[i]=@@fact[i-1]*i%mod
    }
    @@factinv=[1,1]
    @@factinv[max]=@@fact[max].pow({},mod-2)%mod
    (max-1).downto(1){|i|
      @@factinv[i]=@@factinv[i+1]*(i+1)%mod
    }
  end
  def pow(memo,n)
    return 1 if n==0
    return memo[n] if memo[n]
    memo[n] = pow(memo,n/2)*pow(memo,n/2)*(n%2==0?1:self)%@@mod
  end
  def combination(k)
    return 0 if self < k
    @@fact[self]*@@factinv[k]*@@factinv[self-k]%@@mod
  end
end

n=gets.to_i
a=gets.split.map(&:to_i)
cnt=[0]*(n+1)
dup=a.find{|i|cnt[i]+=1;cnt[i]>1}
l,r=[a.index(dup),a.rindex(dup)]
Integer.init_fact(100001,1000000007)
puts (1..n+1).map{|i|((n+1).combination(i)-(l+n-r).combination(i-1))%1000000007}


Measured memory_bytes: 14988
#include <bits/stdc++.h> 
 
using namespace std;
 
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_LONG_MAX;
const double EPS=0.00001;
 
int main(){
    string SS;
    cin>>SS;
    LL N=SZ(SS);
    LL res=N*(N-1LL)/2LL+1LL;
    vector<LL>vec[26];
    REP(i,N)vec[SS[i]-'a'].PB(i);
    REP(i,26)if(SZ(vec[i])>1){
        LL N2=SZ(vec[i]);
        res-=N2*(N2-1LL)/2LL;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

LL l, r, ret[26], fib[100], cnt[100][26];
int n, f[MAXN];
char s[MAXN];

inline void Solve(LL r, int v)
{
	if (n % v == 0)
	{
		for (int i = 1; i <= n && i <= r; i ++)
			ret[s[i] - 'a'] ++;
		if (r >= n)
		{
			r -= n;
			for (int i = 1; i <= v; i ++)
				ret[s[i] - 'a'] += r / v + (r % v >= i);
		}
	}
	else
	{
		mset(cnt, 0);
		for (int i = 1; i <= v; i ++)
			cnt[0][s[i] - 'a'] ++;
		for (int i = 1; i <= n; i ++)
			cnt[1][s[i] - 'a'] ++;
		fib[0] = v, fib[1] = n;
		int i;
		for (i = 2; fib[i - 1] <= r; i ++)
		{
			fib[i] = fib[i - 1] + fib[i - 2];
			for (int j = 0; j < 26; j ++)
				cnt[i][j] = cnt[i - 1][j] + cnt[i - 2][j];
		}
		for (i --; i; i --)
			if (r >= fib[i])
			{
				for (int j = 0; j < 26; j ++)
					ret[j] += cnt[i][j];
				r -= fib[i];
			}
		for (int i = 1; i <= r; i ++)
			ret[s[i] - 'a'] ++;
	}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	scanf("%s", s + 1); n = strlen(s + 1) >> 1;
	cin >> l >> r;
	f[1] = 0;
	for (int i = 2, j = 0; i <= n; j += s[i] == s[j + 1], f[i ++] = j)
		while (j && s[i] != s[j + 1])
			j = f[j];
	Solve(l - 1, n - f[n]);
	for (int i = 0; i < 26; i ++)
		ret[i] = -ret[i];
	Solve(r, n - f[n]);
	for (int i = 0; i < 26; i ++)
		printf("%lld%c", ret[i], i == 25 ? '\n' : ' ');
	return 0;
}


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

int main() {
	int n; cin >> n;
	int x[n+1], y[n+1], t[n+1];
	x[0] = y[0] = t[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> t[i] >> x[i] >> y[i];
	}
	bool ok = true;
	for (int i = 1; i <= n; i++)
	{
		if((t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) || (t[i] - t[i-1]) % 2 != (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) % 2) {
			ok = false;
			break;
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4792
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, m = [int(x) for x in input().rstrip().split(" ")]

    ac = [False for _ in range(n)]
    wa = [0 for _ in range(n)]
    wa_sum = 0

    for i in range(m):
        p, s = input().rstrip().split(" ")
        p = int(p) - 1
        if ac[p]:
            continue
        if s == "WA":
            wa[p] += 1
        else:
            ac[p] = True
            wa_sum += wa[p]
    print(len([x for x in ac if x]), wa_sum)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 85632
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int> > F(N, vector<int>(10));
    vector<vector<int> > P(N, vector<int>(11));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }
    int ret = -1000000000;
    for(int i = 1; i < (1<<10); ++i) { // 0000000001 to 1111111111
        vector<int> open(N, 0);
        for(int j = 0; j <= 10; ++j) {
            if(i & 1<<j) {
                for(int k = 0; k < N; k++) {
                    if(F[k][j] == 1)
                        open[k]++;
                }
            }            
        }
        int temp = 0;
        for(int j = 0; j < N; ++j) {
            temp += P[j][open[j]];
        }
        ret = max(temp, ret);
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
    int n, m, a[110][110], b[110], c;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; ++i) cin >> b[i];

    for (int i = 0; i < n; ++i) {
        c = 0;
        for (int j = 0; j < m; ++j) {
            c += a[i][j] * b[j];
        }
        cout << c << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3128
#include <stdio.h>
int main(void){
    // Your code here!
    int X,n500,n5,h;
    
    scanf("%d",&X);
    n500=X/500;
    n5=(X-(500*n500))/5;
    h=(n500*1000)+(n5*5);
    printf("%d\n",h);
    return 0;
}

Measured memory_bytes: 128
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll dp[MAX];

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }

    return res;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;

    cin>>n>>k;

    ll sum = 0;
    for(int i = k; i >= 1; i--){
        int rem = k / i;
        ll temp = powmod(rem, n) % MOD;
        ll gSum = 0;
        for(int j = i * 2; j <= k; j += i){
            gSum = (gSum + dp[j]) % MOD;
        }
        dp[i] = (temp - gSum + MOD) % MOD;
    }

    ll ans = 0;
    for(int i = 1; i <= k; i++){
        ans = (ans + (dp[i] * i) % MOD) % MOD;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4416
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn = 2000 + 10;
const ll MOD = 1000000007;

int n, k;
ll fac[maxn], inv[maxn];

int power(int x, int k) {
  if(k < 0) return 1;
  if(k == 0) return 1;
  int tmp = 1LL;
  while(k) {
    if(k & 1) tmp = 1LL * tmp * x % MOD;
    x = 1LL * x * x % MOD;
    k >>= 1;
  }
  return tmp;
}

ll dp[maxn][maxn], s[maxn];
int main() {
  scanf("%d%d", &n, &k);
  for(int i = 1;i <= n + 1;i ++) s[i] = 1;
  for(int i = 1;i < k;i ++) {
    for(int j = 1;j <= n - i + 1;j ++) dp[i][j] = (dp[i - 1][j] + s[j + 1]) % MOD;
    for(int j = n - i;j <= n + 1;j ++) s[j] = 0;
    for(int j = n - i + 1;j >= 0;j --) s[j] = (s[j + 1] + dp[i][j]) % MOD;
  }
  ll ans = 0;
  for(int i = 2;i <= n;i ++) ans = (ans + dp[k - 1][i]) % MOD;
  if(k == 1) ans = 1;
  ans = 1LL * ans * power(2,n - k - 1) % MOD;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 31104
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""


N = int(input())
A = [int(i) for i in input().split()]

T = sum(A)

kisu = sum([A[i] for i in range(N) if not i%2])
gusu = sum([A[i] for i in range(N) if i%2])


#print(kisu)
#print(gusu)

zero = T - gusu*2
print(zero,end=" ")
for i in range(1,N):
	n = int((A[i-1]-zero/2)*2)
	print(n,end=" ")
	zero = n
print("")

Measured memory_bytes: 15292
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int b[3][3];

	REP(i, 3) {
		REP(j, 3) {
			cin >> b[i][j];
		}
	}

	int n;
	cin >> n;

	vector<int>bb(n);

	REP(i, n) {
		cin >> bb[i];
	}

	int yes = 0;

	int t[3][3] = { {0,0,0},{0,0,0},{0,0,0} };


	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < n; k++) {
				if (b[i][j] == bb[k]) {
					t[i][j] = 1;
				}
			}
		}
	}

	int okok = 0;
	REP(i, 3) {
		REP(j, 3) {
			if (t[i][j] == 1) okok = 1;
		}
	}


	if (okok == 0) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < 3; i++) {
		int ok = 1;
		for (int j = 0; j < 3; j++) {
			if (t[i][j] == 0) ok = 0;
		}
		if (ok == 1) yes = 1;
	}

	for (int j = 0; j < 3; j++) {
		int ok = 1;
		for (int i = 0; i < 3; i++) {
			if (t[i][j] == 0) ok = 0;
		}
		if (ok == 1) yes = 1;
	}

	if (t[0][0]==1 && t[0][0] == t[1][1] && t[1][1] == t[2][2]) yes = 1;
	if (t[0][2] == 1 && t[0][2] == t[1][1] && t[1][1] == t[0][2]) yes = 1;

	if (yes) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256