akhauriyash/Code-Regression huggingface dataset:
import collections
N = int(input())
A = list(map(int, input().split()))
A.sort()
A2 = collections.deque(A)
#print(N, A)
x = [0] * (N-1)
y = [0] * (N-1)
for i in range(N -1):
    amin = A2.popleft()
    amax = A2.pop()
    mainasuflag = 0
    plusflag = 0
    if i != N - 2:
        if A2[0] > 0:
            mainasuflag = 1
        if A2[len(A2) - 1] < 0:
            plusflag = 1
        amin2 = abs(A2[0])
        amax2 = abs(A2[len(A2) -1])
        if i == N - 3:
            if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
        else:
            if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

    else:
        A2.append(amax - amin)
        x[i] = amax
        y[i] = amin

    #print("A", A2, mainasuflag, plusflag)

print(A2[0])
#print(x, y)
for i in range(N - 1):
    print(x[i], y[i])

Measured memory_bytes: 14936
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	string s;
	cin>>s;
	int t,i;
	t=a;
	for (i=0;i<=s.size()-1;i++)
	{
		t=t*10+s[i]-'0';
	}
	//cout<<t<<endl;
	if (sqrt(t)==int(sqrt(t)))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var xyxy = Sarray();
            var x1 = xyxy[0];
            var y1 = xyxy[1];
            var x2 = xyxy[2];
            var y2 = xyxy[3];
            
            var dx = x2 - x1;
            var dy = y2 - y1;

            var x3 = x2 - dy;
            var y3 = y2 + dx;
            var x4 = x3 - dx;
            var y4 = y3 - dy;
            WriteLine($"{x3} {y3} {x4} {y4}");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char array[] = br.readLine().toCharArray();
		int area = 0,sum = 0,j;
		Deque<Integer> stack1 = new ArrayDeque<>();
		Deque<Data> stack2 = new ArrayDeque<>();
		for (int i = 0; i < array.length; i++) {
			if (array[i] == '\\') {
				stack1.push(i);
			} else if (array[i] == '/') {
				if (!stack1.isEmpty()) {
					j = stack1.pop();
					area = i - j;
					sum += area;
					while (!stack2.isEmpty() && stack2.peek().index > j) {
						area += stack2.pop().area;
					}
					stack2.push(new Data(j, area));
				}
			}
		}
		System.out.println(sum);
		System.out.print(stack2.size());
		while (!stack2.isEmpty()) {
			System.out.print(" " + stack2.pollLast().area);
		}
		System.out.println();
	}
}

class Data {
	int index, area;

	Data(int index, int area) {
		this.index = index;
		this.area = area;
	}
}


Measured memory_bytes: 26516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int N;
	cin >> N;
	double ans = 0.0;
	for(int i=0;i<N;i++){
		string s;
		double x;
		cin >> x >> s;
		if(s=="JPY")ans += x;
		else ans += 380000.0*x;
	}
	cout << setprecision(16) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
l = [int(x) for x in list(str(N))]
if l[-1] == 0 or l[-1] == 1 or l[-1] == 6 or l[-1] == 8:
    print('pon')
elif l[-1] == 3:
    print('bon')
else:
    print('hon')


Measured memory_bytes: 9112
import java.util.Scanner;
import java.util.*;
import java.util.Map.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();

        Map<Integer, Long> guu = new HashMap<>();
        Map<Integer, Long> kisu = new HashMap<>();

        guu.put(-1, 0L);
        kisu.put(-1, 0L);

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (i % 2 == 0) {
                if (!guu.containsKey(x)) {
                    guu.put(x, 0L);
                }
                guu.put(x, guu.get(x) + 1L);
            } else {
                if (!kisu.containsKey(x)) {
                    kisu.put(x, 0L);
                }
                kisu.put(x, kisu.get(x) + 1L);
            }
        }

        List<Entry<Integer, Long>> list_guu = createList(guu);
        List<Entry<Integer, Long>> list_kisu = createList(kisu);

        long cnt = 0;
        if (list_guu.get(0).getKey().equals(list_kisu.get(0).getKey())) {
            long ans1 = list_guu.get(0).getValue() + list_kisu.get(1).getValue();
            long ans2 = list_guu.get(1).getValue() + list_kisu.get(0).getValue();
            cnt = n - Math.max(ans1, ans2);
        } else {
            long ans = list_guu.get(0).getValue() + list_kisu.get(0).getValue();
            cnt = n - ans;
        }
        System.out.println(cnt);
    }
    public static List<Entry<Integer, Long>> createList(Map<Integer, Long> map) {
        List<Entry<Integer, Long>> list_entries = new ArrayList<>(map.entrySet());
        Collections.sort(list_entries, new Comparator<Entry<Integer, Long>>() {
            @Override
            public int compare(Entry<Integer, Long> obj1, Entry<Integer, Long> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
        return list_entries;
    }
}


Measured memory_bytes: 60532
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int num[15]={0},ans;
    string code;
    char port;
    while(cin>>code){
        for(int i=0;i<10;i++){
            port=code[i];
            num[i]=atoi(&port);
        }
        for(int n=9;n>=0;n--){
            for(int i=0;i<n;i++){
                if(num[i]+num[i+1]>=10)num[i]=num[i]+num[i+1]-10;
                else num[i]=num[i]+num[i+1];
            }
        }
        cout<<num[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 10000
#define MAXD 100
#define MOD 1000000007

int mod(int num, int m) {
    if (num >= 0)
        return num%m;
    else
        return (abs(num)/m + (abs(num)%m == 0 ? 0 : 1))*m + num;
}

string K;
int D;
int dp[MAXN + 3][MAXD + 3];

LL solve(string s) {
    int len = (int) s.length();

    LL ans = 0;
    LL currMod = 0;
    for (int i = 0; i < len; i++) {
        int currDigit = s[i] - '0';
        for (int dig = 0; dig < currDigit; dig++) {
            ans = (ans + dp[len - i - 1][mod(-(currMod + dig), D)])%MOD;
        }

        currMod = (currMod + currDigit)%D;
    }

    return ans;
}

int main() {
    cin >> K >> D;

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= MAXN; i++) {
        for (int m = 0; m < D; m++) {
            for (int dig = 0; dig < 10; dig++) {
                int prvMod = mod(m - dig, D);
                dp[i][m] += dp[i - 1][prvMod];
                dp[i][m] %= MOD;
            }
        }
    }

    LL ans = solve(K);

    int sum = 0;
    for (int i = 0; i < K.length(); i++)
        sum = (sum + (K[i] - '0'))%D;

    if (sum == 0)
        ans = (ans + 1)%MOD;

    ans = (ans - 1 + MOD)%MOD; //exclude 0

    cout << ans << endl;
}


Measured memory_bytes: 7640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, H = MAP() 
ab = [LIST() for _ in range(N)]

a, b = zip(*ab)
b = list(b)

b.sort()
A = max(a)

B = b[bisect(b, A):][::-1]
if B:
	B = list(accumulate(B))
else:
	B = [0]


if H <= B[-1]:
	print(bisect_left(B, H)+1)
else:
	if B[-1] == 0:
		print(ceil(H/A))
	else:
		print(len(B) + ceil((H-B[-1])/A))


Measured memory_bytes: 36232
#include <iostream>

auto input (int (& a) [4] , int (& b) [4]) -> bool
{
    for (auto && elem : a)
    {
        if (! (std::cin >> elem))
        {
            return 0;
        }
    }
    for (auto && elem : b)
    {
        std::cin >> elem;
    }
    return 1;
}

auto main () -> int
{
    int a [4] , b[4];
    while (input (a , b))
    {
        auto flag = 0;
        for (auto i = 0; i < 4; ++ i)
        {
            for (auto j = 0; j < 4; ++ j)
            {
                if (a [i] == b [j])
                {
                    ++ flag;
                    break;
                }
            }
        }
        auto hit = 0;
        for (auto i = 0; i < 4; ++ i)
        {
            if (a [i] == b [i])
            {
                ++ hit;
            }
        }
        std::cout << hit << ' ' << (flag - hit) << std::endl;
    }
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    const int MAXN = 101;
    int N;
    int A[3][MAXN];
    cin >> N;
    for(int i = 1; i <= 2; ++i) {
        for(int j = 1; j <= N; ++j) {
            cin >> A[i][j];
        }
    }
    int maxima = -1;
    for(int i = 1; i <= N; ++i) {
        int ans = 0;
        for(int j = 1; j <= i; ++j) {
            ans += A[1][j];
        }
        ans += A[2][i];
        for(int j = i+1; j <= N; ++j) {
            ans += A[2][j];
        }
        maxima = max(maxima,ans);
    }
    cout << maxima << endl;
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T cost; //辺の重み
    Edge(int t, T w) : srch(-1), to(t), cost(w) {}
    Edge(int src, int t, T w) : srch(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = vector<vector<Edge<T>>>;   //重み付きグラフ
using Graph = vector<vector<int>>;         //通常グラフ
template<typename T>
using Matrix = vector<vector<T>>;          //隣接行列(使わなさそう...)

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n, a, b; cin >> n;
    Graph tree(n);
    rep(i,n-1) {
        cin >> a >> b;
        --a;--b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vi c(n); rep(i,n) cin >> c[i];
    priority_queue<int> cque;
    rep(i,n) cque.push(c[i]);

    //達成できるmを計算
    int m = 0;
    rep(i,n) {
        m += c[i];
    }
    m -= *max_element(all(c));

    //根を探す
    int root = -1;
    int root_siz = -1;
    rep(i,n) {
        if(chmin(root_siz, tree[i].size())) root = i;
    }

    //構築
    vi d(n);
    queue<int> que;
    que.push(root);
    while(que.size()) {
        int v = que.front();  que.pop();
        //debug(cque.top());
        d[v] = cque.top(); cque.pop();
        for(auto u : tree[v]) {
            if(d[u]!=0) continue;
            que.push(u);
        }
    }

    //出力
    cout << m << '\n';
    rep(i,n) {
        cout << d[i] << (i!=n-1 ? ' ' : '\n');
    }
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
   int N, i, j;
   long int sum=0;
   scanf("%d", &N);
   long int a[N], s[N];
   for(i=0; i<N; i++) scanf("%ld", &a[i]);
   s[0]=a[0];
   for(i=1; i<N; i++) s[i]=s[i-1]+a[i];
   for(i=0; i<N-1; i++) sum=(sum+a[i]*((s[N-1]-s[i])%1000000007))%1000000007;
   printf("%ld", sum);
}

Measured memory_bytes: 4848
#include "bits/stdc++.h"
#define SIZE          100005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){
 
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
 
template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}
 
bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

int main(){
	FAST;
	string s;
	cin>>s;
	if(s[2]==s[3] and s[4]==s[5]) printf("Yes\n");
	else printf("No\n");
	//cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}



Measured memory_bytes: 256
/*
Problem : atcoder abc123 D
Algorithm :
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 1005;

int x,y,z,K;
ll a[MAXN],b[MAXN],c[MAXN];
vector<ll> ans;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	scanf("%d%d%d%d",&x,&y,&z,&K);
	
	for(int i = 1;i <= x;i++)
	    scanf("%lld",&a[i]);
	
	for(int i = 1;i <= y;i++)
	    scanf("%lld",&b[i]);
	
	for(int i = 1;i <= z;i++)
	    scanf("%lld",&c[i]);
	
	sort(a + 1,a + 1 + x,greater<ll>());
	sort(b + 1,b + 1 + y,greater<ll>());
	sort(c + 1,c + 1 + z,greater<ll>());
	
	for(int i = 1;i <= x;i++){
		for(int j = 1;j <= y;j++){
			for(int k = 1;k <= z;k++){
				if(i * j * k > K)
				    break;
				ans.push_back(a[i] + b[j] + c[k]);
			}
		}
	}
	
	sort(ans.begin(),ans.end(),greater<ll>());
	
	for(int i = 0;i < K;i++)
	    printf("%lld\n",ans[i]);
	return 0;
}








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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++){
  	cin >> S;
  	if(S == "Y"){
  		cout << "Four" << endl;
  		break;
  	}
  	if(i == (N - 1)){
  		cout << "Three" << endl;
  	}
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[103];
char t[2];
int main()
{
    scanf("%s",s);
    int len = strlen(s);
    t[0] = s[0];
    t[1] = s[len - 1];
    printf("%c%d%c",t[0],len - 2,t[1]);
    return 0;
}


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

int main()
{
    int n;cin>>n;
    long long int h[n];
    
    int b[n],ans;
    
    for(int i=0;i<n;++i){
        cin>>h[i];
    }
    
    b[0]=0;

    for(int i=1;i<n;++i){
        if(h[i]<=h[i-1])b[i]=b[i-1]+1;
        else b[i]=0;
    }
    sort(b,b+n);
    ans=b[n-1];

    cout<<ans<<endl;
}

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

using namespace std;
const int N = 2e5+10;
typedef long long LL;
int a[N];

int main()
{
    int n, sum=0;
    scanf("%d", &n);
    for(int i=0;i<n;i++) scanf("%d", &a[i]), sum+=a[i];

    if(sum%10)
    {
        cout<<sum<<endl;
         return 0;
    }


    sort(a,a+n);

    int flag=0;

    for(int i=0;i<n;i++)
    {
        if(a[i]%10)
        {
            sum-=a[i];
            flag=1;
            break;
        }
    }
    if(flag) cout<<sum<<endl;
    else cout<<0<<endl;

    return 0;
}





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

int main() {
    int A, B;
    cin >> A >> B;
    if (A==B) cout << "Draw\n";
    else if (A!=1 and B!=1) {
        if (A>B) cout << "Alice\n";
        else cout << "Bob\n";
    }
    else if (A==1) cout << "Alice\n";
    else cout << "Bob\n";
}

Measured memory_bytes: 256
# ITP1_11_B: Dice2

class Dice
  attr_reader :top, :front, :right, :left, :back, :bottom

  def initialize(labels)
    @top, @front, @right, @left, @back, @bottom = labels
  end
 
  def roll_to(direction)
    case direction
    when 'N'
      @top, @front, @bottom, @back = front, bottom, back, top
    when 'E'
      @top, @left, @bottom, @right = left, bottom, right, top
    when 'S'
      @top, @back, @bottom, @front = back, bottom, front, top
    when 'W'
      @top, @right, @bottom, @left = right, bottom, left, top
    end
  end
end
 
labels     = gets.split.map &:to_i
n_changes  = gets.to_i
directions = %w(N E S W)
dice       = Dice.new labels

n_changes.times do
  top, front = gets.split.map &:to_i
  while true
    dice.roll_to directions.sample
    if dice.top == top && dice.front == front
      puts dice.right
      break
    end
  end
end

Measured memory_bytes: 8740
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

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

    cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust" : "win") << endl;
    return 0;
}

Measured memory_bytes: 256
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize
    }
    let mut ans = 1;
    for i in 0..n {
        if ans < k {
            ans *= 2;
        } else {
            ans += k;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

void func_A() {

    string s;
    cin >> s;

    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
}

void func_B() {

    int n, k;
    cin >> n >> k;

    int d, a;
    vector<int> sunuke(n, 0);

    for (int i = 0; i < k; ++i) {
        cin >> d;
        for (int j = 0; j < d; ++j) {
            cin >> a;
            ++sunuke[a - 1];
        }
    }

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

    cout << count;
}

void func_C() {

    int n, m;
    cin >> n >> m;
    vector<long long> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];


}

int main() {

    //func_A();
    func_B();
    //func_C();

    return 0;

}

Measured memory_bytes: 3628
#! /usr/local/bin/python3
# coding: utf-8

from sys import stdin
from math import inf

def merge(A, left, mid, right):
    L = A[left:mid]; L.append(("", inf))
    R = A[mid:right]; R.append(("", inf))
    i = iter(L); l = next(i)
    j = iter(R); r = next(j)
    for k in range(left, right):
        if l[1] <= r[1]:
            A[k] = l
            l = next(i)
        else:
            A[k] = r
            r = next(j)

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    
def swap(A, i, j):
    tmp = A[i]
    A[i] = A[j]
    A[j] = tmp

def partition(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            swap(A, i, j)
    swap(A, i + 1, r)
    return i + 1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)

def main():
    n = int(stdin.readline())
    A = []
    for l in stdin:
        suit, num = l.split()
        A.append((suit, int(num)))
    B = A[:]
    quick_sort(A, 0, n - 1)
    merge_sort(B, 0, n)
    print("Stable" if A == B else "Not stable")
    [print(*a) for a in A]

main()



Measured memory_bytes: 17712
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
int dp[110][410];
int v[110];
int w[110];

int main(){
  long long N,W;
  cin >> N >> W;
  vector<int> v0;
  vector<int> v1;
  vector<int> v2;
  vector<int> v3;
  long long w0;
  for(int i = 0; i < N; i++){
    cin >> w[i] >> v[i];
    if(i == 0) w0 = w[i];
    if(w[i] - w0 == 0) v0.push_back(v[i]);
    if(w[i] - w0 == 1) v1.push_back(v[i]);
    if(w[i] - w0 == 2) v2.push_back(v[i]);
    if(w[i] - w0 == 3) v3.push_back(v[i]);
  }
  sort(v0.begin(),v0.end(),greater<int>());
  sort(v1.begin(),v1.end(),greater<int>());
  sort(v2.begin(),v2.end(),greater<int>());
  sort(v3.begin(),v3.end(),greater<int>());

  for(int i = 1; i < v0.size(); i++) v0[i] += v0[i-1];
  for(int i = 1; i < v1.size(); i++) v1[i] += v1[i-1];
  for(int i = 1; i < v2.size(); i++) v2[i] += v2[i-1];
  for(int i = 1; i < v3.size(); i++) v3[i] += v3[i-1];

  long long maxValue = 0;

  for(int i = 0; i <= v0.size(); i++){//w0
    for(int j = 0; j <= v1.size(); j++){//w0+1
      for(int k = 0; k <= v2.size(); k++){//w0+2
        for(int l = 0; l <= v3.size(); l++){//w0+3
          if( w0 * i + (w0 + 1) * j + (w0 + 2) * k +(w0 + 3) * l <= W){
            long long value = 0;
            if(i != 0) value += v0[i-1];
            if(j != 0) value += v1[j-1];
            if(k != 0) value += v2[k-1];
            if(l != 0) value += v3[l-1];

            maxValue = max(maxValue,value);
          }
        }
      }
    }
  }
  cout << maxValue << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();
// const int N = 1e5 + 5 ;



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while(t--){
	int a ;
	cin >> a ;
	cout << a + a*a + a*a*a << "\n";







	// }







	return 0 ;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
  int n, k;
  cin >> n >> k;
  vector<bool> v(n);
  rep(i, k)
  {
    int d;
    cin >> d;
    int a;
    rep(j, d)
    {
      cin >> a;
      a--;
      v[a] = true;
    }
  }
  int ans = 0;
  rep(i, n)
  {
    if(v[i]==false)
      ++ans;
  }
  cout << ans;
}

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



Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

h,a = mii()
cnt=0
while h >0:
    h -=a
    cnt+=1
    
print(cnt)

Measured memory_bytes: 65516
import sys
sys.setrecursionlimit(10**7)

n,m,q = map(int,input().split())
abcd = [[int(i) for i in input().split()] for j in range(q)]

s = [1] * (n)

#global ans
ans = 0

def dfs(k, c,old):
    global ans
    #awr = 0
    #ans = 0
    #print(s,k)
    if k == n:
        tmp = 0
        for i in range(q):
            if s[abcd[i][1]-1] - s[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        ans = max(ans,tmp)
        #ans.append(tmp)
        return# ans
    for i in range(old,c+1):
        #print(old,c+1)
        s[k] = i
        dfs(k+1, m,i)
        #print(k+1,c)
    #s[k] = chr(c+ord('a'))
    #dfs(k+1, c+1)
    #return ans

#print(max(dfs(0, m,1,ans)))
dfs(0, m,1)
print(ans)

Measured memory_bytes: 71604
#include<bits/stdc++.h>
using namespace std;
const int N=50+2;
int n,d[N];
long long sum;
void init(){scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&d[i]);}
void work(){for(int i=1;i<=n-1;++i) for(int j=i+1;j<=n;++j) sum+=d[i]*d[j];}
void prin(){printf("%lld",sum);}
int main(){init(); work(); prin(); return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int main() {
    int a;
    int x = 0;
    cin >> a; x += a * 100;
    cin >> a; x += a * 10;
    cin >> a; x += a * 1;
	cout << (x % 4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  int n,k,q;cin>>n>>k>>q;
  vi v(n);
  rep(i,q){
    int a;
    cin>>a;
    v[a-1]++;
  }
  rep(i,n){
    if(k-(q-v[i])<=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      //int n=sc.nextInt();
      long n=sc.nextLong();
      long a=0,b=0;
      for(int i=(int)Math.ceil(Math.sqrt((double)n));i>=1;i--)
      {
          if(n%i==0)
          {
              a=i;
              b=n/i;
              break;
          }
      }
      System.out.println(((a-1)+(b-1)));
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Zp {
	const int p = 1000000007;
	ll r;
	void set(ll x) {
		while (x < 0) x += p;
		r = x % p;
	}

public:
	Zp(ll x) { set(x); }
	Zp() { set(0); }

	Zp operator-() const { return Zp(-r); }
	Zp &operator=(ll y) {
		set(y);
		return *this;
	}
	Zp &operator=(const Zp &y) { return *this = y.r; }

	Zp &operator+=(ll y) {
		set(r + y);
		return *this;
	}
	Zp &operator-=(ll y) { return *this += -y; }
	Zp &operator*=(ll y) {
		set(r * y);
		return *this;
	}
	Zp &operator/=(ll y) { return *this *= inv(y); }
	Zp operator+(ll y) const { return Zp(r + y); }
	Zp operator-(ll y) const { return *this + (-y); }
	Zp operator*(ll y) const { return Zp(r * y); }
	Zp operator/(ll y) const { return *this * inv(y); }

	Zp &operator+=(const Zp &y) { return *this += y.r; }
	Zp &operator-=(const Zp &y) { return *this -= y.r; }
	Zp &operator*=(const Zp &y) { return *this *= y.r; }
	Zp &operator/=(const Zp &y) { return *this /= y.r; }
	Zp operator+(const Zp &y) const { return *this + y.r; }
	Zp operator-(const Zp &y) const { return *this - y.r; }
	Zp operator*(const Zp &y) const { return *this * y.r; }
	Zp operator/(const Zp &y) const { return *this / y.r; }

	Zp pow(int n) const {
		if (n == 0) return 1;
		if (n % 2) return *this * pow(n - 1);
		Zp tmp = pow(n / 2);
		return tmp * tmp;
	}
	Zp inv(int x) const { return Zp(x).pow(p - 2); }
	Zp inv() const { return inv(r); }

	ll get() const { return r; }

	friend istream &operator>>(istream &istr, Zp &x) {
		istr >> x.r;
		x.set(x.r);
		return istr;
	}
	friend ostream &operator<<(ostream &ostr, const Zp &x) {
		ostr << x.r;
		return ostr;
	}
};
class Comb {
	vector<Zp> fact, ifact;

public:
	Comb(int N) : fact(N + 1), ifact(N + 1) {
		fact[0] = 1;
		REP(i, N)
		fact[i + 1] = fact[i] * (i + 1);
		ifact[N] = fact[N].inv();
		REPR(i, N)
		ifact[i] = ifact[i + 1] * (i + 1);
	}
	Zp operator()(int n, int k) const {
		return fact[n] * ifact[n - k] * ifact[k];
	}
	Zp f(int k) const { return fact[k]; }
	Zp invf(int k) const { return ifact[k]; }
};

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

	int N;
	string S;
	cin >> N;
	cin >> S;
	int memo[26] = {0};
	REP(i, N) { memo[S[i] - 'a']++; }
	Zp res = 1;
	REP(i, 26) { res *= memo[i] + 1; }
	res -= 1;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 512
use std::vec::Vec;
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();

    let mut vq: VecDeque<i64> = VecDeque::new();

    for i in 0..n {
      if i % 2 == 0 {
        vq.push_back(a[i]);
      } else {
        vq.push_front(a[i]);
      }
    }

    if n % 2 == 1 {
      vq = vq.into_iter().rev().collect();
    }
    for e in vq {
      print!("{} ", e);
    }
}


Measured memory_bytes: 11376
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
#define VSORT(v) sort(v.begin(), v.end());

int main(){
    int N;
    cin >> N;
    int sum = 0;
    vector<int> ans;
    if(N < 6){
        ans = {2,5,63,20,30};
    }
    else{
        int i = 0;
        while(i < N){
            if(i%4 == 0){
                ans.pb(6*(i/4)+2);
                sum += 6*(i/4)+2;
            }
            else if(i%4 == 1){
                ans.pb(6*(i/4)+3);
                sum += 6*(i/4)+3;
            }
            else if(i%4 == 2){
                ans.pb(6*(i/4)+4);
                sum += 6*(i/4)+4;
            }
            else{
                ans.pb(6*(i/4)+6);
                sum += 6*(i/4)+6;
            }
            i++;
        }
        if(sum%6 == 2) ans[4] = 30000;
        if(sum%6 == 3) ans[5] = 30000;
        if(sum%6 == 5) ans[5] = 29998;
    }
    REP(i,N-1) cout << ans[i] << " ";
    cout << ans[N-1] << endl;
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	ans := 1
	for i := 0; i < n; i++ {
		ans = smaller(ans+k, ans*2)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
/* ex2_3 melo */
 
#include <stdio.h>
 
int main(void){
  int N ,A;//整数の箱を二つ作る
  scanf("%d\n",&N);//Nに整数値を代入
  scanf("%d\n",&A);//Nに整数値を代入
  printf("%d\n",N*N-A);//Nの二乗（全てのマスの数）から色が変わったマスを引く
  return 0;
 
}


Measured memory_bytes: 128
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F1 first
#define S2 second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ll N, out = 0, i;
    cin >> N;
    vector<vector<ll>> v(N, vector<ll>(4));
    for(i = 0; i < N; i++)
    {
        cin >> v[i][0] >> v[i][1];
        v[i][2] = v[i][0] + v[i][1];
        v[i][3] = v[i][0] - v[i][1];
    }
    sort(v.begin(), v.end(),[](const vector<ll> &a, const vector<ll> &b) -> bool
        {
            return (a[2] < b[2]);
        }
        );
    out = v[N-1][2] - v[0][2];
    sort(v.begin(), v.end(),[](const vector<ll> &a, const vector<ll> &b) -> bool
        {
            return (a[3] < b[3]);
        }
        );
    out = MAX(out, v[N-1][3] - v[0][3]);
    cout << out << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    //cin >> T;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 17064
n = int(input())
csf = [list(map(int, input().split())) for i in range(n - 1)]
for i in range(n):
    ans = 0
    for j in range(i, n - 1):
        c, s, f = csf[j][0], csf[j][1], csf[j][2]
        if ans < s:
            ans = s
        elif ans % f != 0:
            ans += f - ans % f
        ans += c
    print(ans)

Measured memory_bytes: 9172
#include <algorithm>
#include <cstdio>
#include <vector>

int scan() {
  int r = 0, c;
  while ((c = getchar_unlocked()) >= '0')
    r = r * 10 + c - '0';
  return r;
}

inline bool test(const int x, const int y) noexcept { return x & 1 << y; }

int main() {
  const int n = scan();
  std::vector<int> v(n, 0);
  for (int i = 0; i != n - 1; i += 1) {
    const int x = scan();
    const int y = scan();
    const int a = scan();
    v[x] ^= a;
    v[y] ^= a;
  }
  int ans = n;
  int b = 0;
  for (const int e : v) {
    if (e == 0) {
      ans -= 1;
      continue;
    }
    if (test(b, e))
      ans -= 1;
    b ^= 1 << e;
  }
  std::vector<int> dp(b / 2 + 1, -1);
  dp[b / 2] = 0;
  for (int s = b; s != 0; s -= 2) {
    if (dp[s >> 1] == -1)
      continue;
    int i = 16;
    while (i != 0) {
      i -= 1;
      if (test(s, i))
        break;
    }
    for (int j = 0; j != i; j += 1) {
      if (!test(s, j))
        continue;
      const int k = i ^ j;
      if (k > j)
        continue;
      int &d = dp[(s ^ 1 << i ^ 1 << j ^ 1 << k) >> 1];
      if (test(s, k))
        d = std::max(d, dp[s >> 1] + 1);
      else
        d = std::max(d, dp[s >> 1]);
    }
  }
  printf("%d", ans - dp[0]);
}


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

long long int a[2*100000 + 5];

int main() {

    int n;

    cin >> n;

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

    long long int ans = 0;

    int ncount = 0,pcount = 0;
    priority_queue<long long int> ne,po;
    for(int i=0; i<n; i++){
        a[i] -= (i+1);
        if(a[i] >= 0){
            po.push(-a[i]);//絶対値が小さいものから取り出せるようにする
            pcount++;
        }
        else{
            ne.push(a[i]);//絶対値が小さいから取り出せるようにする。
            ncount++;
        }
    }

    if(ncount < pcount){
        int count = pcount - n/2;
        for(int i=0; i<count-1; i++){
            po.pop();
        }
        long long int to = -po.top();
        for(int i=0; i<n; i++){
            a[i] -= to;
            ans += abs(a[i]);
        }
    }
    else if(ncount > pcount){
        int count = ncount - n/2;
        for(int i=0; i<count-1; i++){
            ne.pop();
        }
        long long int to = ne.top();
        for(int i=0; i<n; i++){
            a[i] -= to;
            ans += abs(a[i]);
        }
    }
    else{
        for(int i=0; i<n; i++){
            ans += abs(a[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3956
import fractions
 
N = int(input())
A = list(map(int, input().split()))
 
left = [0] * (N+1) # 左半分の最大公約数を一つずつ比較していくことでだす
right = [0] * (N+1) # 右半分の最大公約数を一つずつ比較していくことでだす
for i in range(N):
    left[i+1] = (fractions.gcd(left[i], A[i]))
    right[N-i-1] = (fractions.gcd(right[N - i],A[N - 1 - i]))
 
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(left[i], right[i+1]))
    
print(ans)

Measured memory_bytes: 16148