akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL n,a;
LL mx = 0,cnt[100005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> a; mx = max(mx,a);
		cnt[a] ++;
	}
	for(LL i = 0;i <= mx;i ++) cnt[max(i,mx - i)] --;
	for(LL i = 1;i <= n;i ++) if(cnt[i] < 0){ cout << "Impossible" << endl; return 0; }
	
	for(LL i = 0;i <= ((mx + 1) >> 1);i ++) if(cnt[i] > 0){ cout << "Impossible" << endl; return 0; }

	cout << "Possible" << endl;
	return 0;
}
//

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int index = 1, num = 0;
    while(1)
    {
        index = a[index - 1];
        if(index == 2)
        {
            cout << num + 1;
            return 0;
        }
        if(num > 100000)
        {
            cout << -1;
            return 0;
        }
        num++;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;
void nu(){}


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    REP(i,3){
        if(s[i] == 'R') cnt++;
    }
    if(s[1] == 'S'){
        cnt = min(cnt,(int)1);
    }

    print(cnt);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3572
import math
import sys
readline = sys.stdin.readline


def main():
    x = int(readline().rstrip())
    a, b, c = 0, 0, 1

    while a < 1000:
        k = a ** 5 - x
        c = 1 if k >= 0 else - 1
        b = abs(k) ** 0.2
        if int(b) ** 5 == abs(k):
            print(a, c * abs(int(b)))
            return
        a += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    vector<int> A(N); cin >> A;
    sort(ALL(A));
    int ans=0;
    for (int i=0;i<K;++i) ans+=A[i];
    cout << ans << '\n';
}

Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws IOException {
        Pattern space = Pattern.compile(" ");
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(stdin.readLine());
        int[] a = space.splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();

        int sum = Arrays.stream(a).sum();
        List<Integer> distances = Arrays.stream(a).map(v -> Math.abs(v * n - sum)).boxed().collect(Collectors.toList());
        Integer min = Collections.min(distances);
        System.out.println(distances.indexOf(min));

    }
}

Measured memory_bytes: 26836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// (行き先,容量,逆辺)
struct edge{ 
    int to;
    ll cap;
    int rev;
};

const int MAX_V = 2000; // TODO:initialize
const ll F_INF = LLONG_MAX/100000; // TODO:initialize
vector<edge> G[MAX_V];
int level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

void add_edge(int from, int to, ll cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,0,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをdfsで探す
ll dinic_dfs(int v, int t, ll f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)G[v].size(); ++i){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流
ll max_flow(int s, int t){
    ll flow = 0;
    while(1){
        dinic_bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        ll f;
        while( (f=dinic_dfs(s,t,F_INF)) > 0 ) flow+=f;
    }
}

const int N = 55;
vector<int> neighbor[N][N];

int main(){
    int h,w,W;
    cin >>h >>w >>W;
    vector<vector<int>> b(h, vector<int>(w));
    rep(i,h)rep(j,w) cin >>b[i][j];

    // 予めもらうreward
    ll s = 0;
    rep(i,h)rep(j,w) s += b[i][j];

    vector<ll> a;
    vector<int> flip;
    int P = 0;
    rep(i,h-1)rep(j,w-1)if((i+j)%2 == 0){
        ll t = 0;
        rep(ii,2)rep(jj,2){
            int y=i+ii, x = j+jj;
            neighbor[y][x].pb(P);
            t += b[y][x];
        }
        a.pb(t);
        flip.pb(i%2);
        ++P;
    }
    
    int S = MAX_V-2, T = MAX_V-1;
    rep(i,P){
        // on だとpenalty W
        // off だとpenalty a[i]
        if(flip[i]){
            add_edge(i,T,a[i]);
            add_edge(S,i,W);
        }
        else{
            add_edge(i,T,W);
            add_edge(S,i,a[i]);
        }
    }

    rep(i,h)rep(j,w)if(neighbor[i][j].size()==2){
        int x = neighbor[i][j][0], y = neighbor[i][j][1];
        assert((flip[x]^flip[y]) == 1);
        // 2つの電源が両方on だとpenalty b[i][j]
        s += b[i][j];
        if(flip[x]) add_edge(y,x,b[i][j]);
        else add_edge(x,y,b[i][j]);
    }

    cout << s - max_flow(S,T) << endl;
    return 0;
}



Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int K=sc.nextInt();
	 int index=0;
	 int display=1;
	 while(true) {
		 if(index==N) {
			 break;
		 }
		 if(display*2>=display+K) {
			 display+=K;
		 }else {
		 display*=2;
		 }
		 
		 
		 index++;
		 
		 
	 }
	 System.out.println(display);
	 
	 
	 
 }
	


}



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

#define ll long long
using namespace std;

int x, y, N, ans[ 2003 ], ara[ 200000 + 3 ], hi;
vector <int> adj[ 2003 ];
int vis[ 2003 ], lev[ 2003 ];


void solve(int s)
{
  queue <int> q;
  q.push(s);
  for (int i=0; i<N+1; i++) {
    lev[ i ] = 0;
    vis[ i ] = 0;
  }
  vis[ s ] = 1;
  while ( !q.empty() ) {
    int u = q.front();
    for (int i=0; i<adj[ u ].size(); i++) {
      if ( !vis[ adj[ u ][ i ] ] ) {
       	q.push( adj[ u ][ i ] );
        vis[ adj[ u ][ i ] ] = 1;
        lev[ adj[ u ][ i ] ] = lev[ u ] + 1;
    	ans[ lev[ adj[ u ][ i ] ] ]++;// cout << lev[ adj[ u ][ i ] ] << " ";
      }
    }
    q.pop();
  }
}

int main()
{
  cin >> N >> x >> y;
  
  for (int i=0; i<N-1; i++){
    adj[ i ].push_back( i + 1 );
    adj[ i + 1 ].push_back( i );
  }
  
  adj[ x - 1 ].push_back( y - 1 );
  adj[ y - 1 ].push_back( x - 1 );
 
  for (int i=0; i<N; i++){
    solve(i);//cout << endl;
  }
  
  for (int i=1; i<N; i++)
  	cout << ans[ i ] / 2 << "\n";
  
  return 0;
}

Measured memory_bytes: 384
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int sz[maxn] , par[maxn];
int n;
ll a[maxn];
vector < int > srt;

bool cmp(int i , int j){
    return(a[i] > a[j]);
}

ll ans = 0;

int getpar(int v){
    return((v == par[v]) ? v : par[v] = getpar(par[v]));
}

ll merge(int x , int y){
    if(a[y] < a[x])
        return(0);
    x = getpar(x) , y = getpar(y);
    ll ans = sz[y];
    if(sz[x] < sz[y])
        swap(x , y);
    sz[x] += sz[y];
    par[y] = x;
    return(ans);
}

int32_t main(){
    migmig
    cin >> n ;
    for(int i = 0 ; i < n ; i ++)
        cin >> a[i],srt.pb(i);
    sort(srt.begin() , srt.end() , cmp);
    for(int i : srt){
        sz[i] = 1;
        par[i] = i;
        ll val = 1;
        val += merge(i , i + 1);
        val *= (merge(i , i - 1)+1);
        ans += val*a[i];
    }
    cout << ans;
    return(0);
}

Measured memory_bytes: 7208
#include<stdlib.h>
#include<string>
#include <iostream>
using namespace std;
int main() {

    string a;
    cin >> a;
    //a = "AAA";
    bool aflag = false;
    bool bflag = false;
    for (int i = 0; i <= 2; i++) {
        if (a[i] == 'A') { aflag = true; }
        if (a[i] == 'B') { bflag = true; }
    }
    if (aflag and bflag) { printf("Yes"); }
    else { printf("No"); }

}


Measured memory_bytes: 3660
#!/usr/bin/python

import sys

H, W = [int(w) for w in sys.stdin.readline().split()]
N = int(sys.stdin.readline())
a = [int(w) for w in sys.stdin.readline().split()]

m = sorted([(i,a[i]) for i in range(len(a))], key=lambda p: p[1], reverse=True)

color = 0
for y in range(H):
  row = []
  for x in range(W):
    while m[color][1] <= 0: color += 1
    row.append(m[color][0] + 1)
    m[color] = (m[color][0], m[color][1] - 1)
  if y % 2 != 0: row = reversed(row)
  s = ' '.join([str(x) for x in row])
  print(s)


Measured memory_bytes: 4100
N = int(input())
if N == 2:
    print(1)
    exit()
ans = 1
divisors = []
d = 2
while d*d < N:
    if N % d == 0:
        divisors.append(d)
        divisors.append(N//d)
    d += 1
if d*d == N:
    divisors.append(d)

for d in divisors:
    dummyN = N
    while dummyN % d == 0:
        dummyN //= d
    if dummyN % d == 1:
        ans += 1

N -= 1
divisors = []
d = 2
while d*d < N:
    if N % d == 0:
        divisors.append(d)
        divisors.append(N//d)
    d += 1
if d*d == N:
    divisors.append(d)

ans += len(divisors)+1
print(ans)

Measured memory_bytes: 66336
from collections import defaultdict

N, M = map(int, input().split())
A = [0] + list(map(int, input().split()))

B = 0
n = defaultdict(int)
for i in range(N + 1):
    B += A[i]
    B %= M
    n[B] += 1

ans = 0
for ni in n.values():
    ans += ni * (ni - 1) // 2
print(ans)


Measured memory_bytes: 14748
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	string s;
	int K;
	cin >> s >> K;
	vector<string>substring;
	for (int i = 0; i < s.length(); i++) {
		for (int j = i; j < i + 5; j++) {
			//substr(pos,n):pos番目からn要素の文字列を返す
			substring.push_back(s.substr(i, j - i + 1));
			//ソート
			sort(substring.begin(), substring.end());
			//重複を除く
			unique(substring.begin(), substring.end());
			//末尾を削除
			if (substring.size() >= 6)substring.pop_back();
		}
	}
	cout << substring[K - 1] << endl;
	return 0;
}

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

namespace AtTest.ABC_176
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nxt = ReadInts();
            int n = nxt[0];
            int x = nxt[1];
            int t = nxt[2];

            int cnt = n / x;
            if (n % x > 0)
            {
                cnt++;
            }

            WriteLine(cnt * t);
        }

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


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

int main(void){
    int n, k;
    cin >> n >> k;
    int check[n];
    int num;
    int ans=1000000;
    for(int i = 0; i < n; i++){
        cin >> check[i];
        if(check[i]==1)
            num = i+1;
    }
    int MAX, MIN;
    if(n!=k){
    for(int i = 0; i < k; i++){
    int count = 1;
    MIN = num-i;
    MAX = num+(k-1-i);
    if(MIN < 1 || MAX > n) continue;
    count += (MIN-1)/(k-1)+(n-MAX)/(k-1);
    if((MIN-1)%(k-1)!=0 && MIN != 1)
        count++;
    if((n-MAX)%(k-1)!=0 && MAX != n)
        count++;
    ans = min(ans, count);
    }
    }
    if(n==k)
        ans = 1;
    cout << ans << endl;
    return 0;
}

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

int N, M;
int par[100010];
int depth[100010];


void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i+1] = i+1;
    depth[i+1] = 0;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  
  if (depth[x] < depth[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (depth[x] == depth[y]) depth[x]++;
  }
  
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  
  cin >> N >> M;
  int P[N+1];

  
  init(N);
  
  for (int i = 0; i < N; i++)  cin >> P[i+1];
  
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    unite(x, y);
  }
  
  
  
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (same(i, P[i])) ans++;
  }

  cout << ans << endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  string s;
  cin>>s;
  if(s[0] !='R' && s[1]!='R' && s[2]!='R')
  {
    cout<<0<<endl;
    return 0;
  }
  int maxi = 1;
  if(s[0] == 'R')
  {
    if(s[1] == 'R')
    {
       if(s[2] == 'R')
         maxi = 3;
      else
         maxi = 2;
    }
  }
  else if(s[1] == 'R')
  {
    if(s[2] == 'R')
      	maxi = 2;
  }
  cout<<maxi<<endl;
}

Measured memory_bytes: 3624
#include <iostream>                                          
using namespace std;                                         
                                                             
int main(void) {                                             
  int a, b;                                                  
  char op;                                                   
  while (true) {                                             
    cin >> a >> op >> b;                                     
    if (op=='?') {                                           
      break;                                                 
    }                                                        
    int ans;                                                 
    switch (op) {                                            
    case '+':                                                
      ans = a+b;                                             
      break;                                                 
    case '-':                                                
      ans = a-b;                                             
      break;                                                 
    case '*':                                                
      ans = a*b;                                             
      break;                                                 
    case '/':                                                
      ans = a/b;                                             
      break;                                                 
    default:                                                 
      break;                                                 
    }                                                        
    cout << ans << endl;                                     
  }                                                          
  return 0;                                                  
}                                                            
                         

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B;
string s;

int main(void){
    
    scanf("%d %d", &A, &B);
    cin >> s;
    
    int sum = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '-'){
            if(sum != A){ printf("No\n"); return 0; } 
            sum = 0;
        }
        else ++sum;
    }
    if(sum != B){ printf("No\n"); return 0; } 
	
	printf("Yes\n");
	
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define For(i, a, b) for(register int i = a; i <= b; ++i)
using namespace std;
const int maxn = 55;
char a[maxn][maxn];
char b[maxn][maxn];
int an, bn;

bool compare(int x, int y) {
	For(i, 0, bn - 1)
		For(j, 0, bn - 1)
			if(a[x + i][y + j] != b[i][j])
				return false;
	return true;
}

int main() {
	scanf("%d%d", &an, &bn);
	For(i, 0, an - 1) scanf("%s", a[i]);
	For(i, 0, bn - 1) scanf("%s", b[i]);
	For(i, 0, an - bn)
		For(j, 0, an - bn) {
			if(compare(i, j)) {
				printf("Yes");
				return 0;
			}
		}
	printf("No");
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        long K = in.nextLong();
        long A[] = new long[N];
        for (int i = 0; i <= N - 1; i++) {
            A[i] = in.nextLong();
        }

       
        long[][] bA = new long[41][2];
        for (int i = 0; i <= N - 1; i++) {
            long ac = A[i];
            for (int j = 0; ac > 0; j++) {
                bA[j][0] += ac % 2;
                ac /= 2;
            }
        }

        
        long kc = K;
        int keta = 0;
        for (int i=0; kc > 0; i++){
            bA[i][1] = (int)(kc%2);
            kc /= 2;
            keta++;
        }


        long dp[][] = new long[2][keta+1];
        Arrays.fill(dp[0], -1);
        Arrays.fill(dp[1], -1);
        dp[0][0] = 0; 


        long pow = pow(2, keta);

        
        for (int d = 0; d <= keta-1; d++) {
            pow /= 2;
            long c0 = pow * bA[keta-1-d][0];
            long c1 = pow * (N-bA[keta-1-d][0]);

            
            if (dp[1][d] != -1) {
                dp[1][d+1] = Math.max(dp[1][d+1], dp[1][d] + Math.max(c0, c1)); 
            }

            
            if (dp[0][d] != -1) {
                if (bA[keta-1-d][1] == 1) { 
                    dp[1][d+1] = Math.max(dp[1][d+1], dp[0][d] + c0);
                }
            }

           
            if (dp[0][d] != -1) {
                if (bA[keta-1-d][1] == 1) { 
                    dp[0][d+1] = Math.max(dp[0][d+1], dp[0][d] + c1);
                } else { 
                    dp[0][d+1] = Math.max(dp[0][d+1], dp[0][d] + c0);
                }
            }
        }

        long ans = Math.max(dp[0][keta], dp[1][keta]);
        pow = pow(2, keta);
        for (int d = keta; d <= 40; d++) {
            ans += bA[d][0] * pow;
            pow *= 2;
        }

        out.println(ans);
    }

public   static long pow(long x, long n) {
        long sum = 1;
        while (n > 0) {
            if ((n & 1) == 1) { 
                sum *= x;        
            }
            x *= x;              
            n >>= 1;
        }
        return sum;
    }

}
}



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

const ll mod = 1e9 + 7;

ll dp[100010];
bool mm[100010];
bool vis[100010];

ll rec(ll n){
    if(vis[n]) return dp[n];
    vis[n] = true;
    if(mm[n]) return dp[n] = 0;
    if(n == 0) return dp[n] = 1;
    if(n >= 2) return dp[n] = (rec(n - 1) + rec(n - 2)) % mod;
    return dp[n] = rec(n - 1);
}

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

    ll n,m;
    cin >> n >> m;
    
    rep(i,m){
        ll a;
        cin >> a;
        mm[a] = true;
    }
    
    cout << rec(n) << endl;
    
}

Measured memory_bytes: 4352
import numpy as np
N,M=list(map(int,input().split()))
n=4*10**4
prime=[i for i in range(n)]
prime[1]=0
for i in range(2,n):
    tmp =i*i
    if prime[tmp]==0 or tmp > n:
        break
    while tmp<n:
        prime[tmp]=0
        tmp+=i

prime=np.array(prime)
prime=prime[prime!=0]

dic={}
for x in prime:
    while M%x==0:
        if dic.get(x,0)==0:
            dic[x]=1
        else:
            dic[x]+=1
        M/=x
    if M==1:
        break
if M !=1:
    dic[M]=1
ans = 1
for x in dic.values():
    tmp1=1
    tmp2=1
    for i in range(x,0,-1):
        tmp1*=(i+N-1)
        tmp2*=i
    ans*=tmp1//tmp2
    ans%=10**9+7
print(int(ans))

Measured memory_bytes: 14052
require 'thread'

N = gets.to_i

@q = Queue.new
9.times { |i| @q.push(i+1) }

def culpop
    val = @q.pop
    low = val % 10
    @q.push(val*10 + low-1) if low != 0
    @q.push(val*10 + low)
    @q.push(val*10 + low+1) if low != 9
    return val
end
(N-1).times { culpop }

puts @q.pop

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

int main(){
  int x[3], i, j, a;

  for(i=0;i<3;i++) cin >> x[i];


  for(i=0;i<3;i++) {
    for(j=2;j>i;j--) {
      if(x[j]<x[j-1]) {
        a = x[j];
        x[j] = x[j-1];
        x[j-1] = a;
      }
    }
  }



  for(i=0;i<3;i++) {
    cout << x[i];
    if(i!=2) cout << " ";
    else cout << endl;
}


}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<vector>

int main(){
	int N;
	std::string A,B,C;
	int res=0;
	
	std::cin >> N;
	std::cin >> A >> B >> C;
	
	for(int i=0;i<N;i++){
		if(A[i] == B[i]){
			if(B[i] != C[i]){
				res++;
			}
		}else{
			if(A[i] == C[i] || B[i] == C[i]){
				res++;
			}else{
				res+=2;
			}
		}
	}
	
	std::cout << res << std::endl;
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 2019
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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 ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    int n=s.size();
    ll k[n+1],a[n];
    vl sum(n+1,0);
    mem(k,0);mem(a,0);
    k[0]=1;
    rep(i,n){
        k[i+1]=k[i]*10%MOD;
    }
    rep(i,n){
        a[i]=(s[i]-'0')*k[n-1-i]%MOD;
    }
    sum[0]=0;
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
        sum[i+1]%=MOD;
    }
    map<ll,ll>c;
    rep(i,n+1){
        c[sum[i]]++;
    }
    ll ans=0;
    sort(all(sum));
    sum.erase(unique(all(sum)),sum.end());
    rep(i,sum.size()){
        ans+=c[sum[i]]*(c[sum[i]]-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    int cnt[m] = {};
    rep(i, 0, n) {
        int k;
        cin >> k;
        rep(j, 0, k) {
            int a;
            cin >> a;
            a--;
            cnt[a]++;
        }
    }

    int ans = 0;
    rep(i, 0, m) {
        if (cnt[i] == n) ans++;
    }

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


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

int main() {
    long long int X;
    cin >> X;
    long long int i = 0;
    while(true) {
        long long int b = pow(i, 5);
        long long int tmp = X + b;
        long long int A = pow(tmp, 1.0/5.0);
        long long int a = pow(A, 5);
        if(a - b == X) {
            cout << A << " " << i << endl;
            return 0;
        }
        tmp = X - b;
        if(tmp < 0) {
            A = -pow(tmp, 1.0/5.0);
        } else {
            A = pow(tmp, 1.0/5.0);
        }
        a = pow(A, 5);
        if(a + b == X) {
            cout << A << " " << -i << endl;
            return 0;
        }
        i++;
    }
    return 0;
}

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

struct map
{
    double x;
    double y;
};

int main()
{
    double a, b;
    map c;
    vector<map> m;

    cin >> a >> b;

    for( int i = 0; i <= b; i++ )
    {
        c.y = i;
        c.x = - a * 2 / b * i + a * 2;
        m.push_back(c);
    }

    for( int i = 0; i <= a * 2; i += 2 )
    {
        c.x = i;
        c.y = - b / ( a * 2 ) * i + b;
        bool judge = true;
        for( int j = 0; j < m.size(); j++ )
        {
            if( m[j].x - c.x < 0.00000001 && m[j].y - c.y < 0.00000001 )
                judge = false;
        }
        if( judge )
            m.push_back(c);
    }

    cout << m.size() << endl;

    return 0;
}


Measured memory_bytes: 3300
s1 = input()
s2 = input()

def Levenshtein_d(X,Y):
    XL = len(X)
    YL = len(Y)
    dp = [[0 for j in range(YL+1)] for i in range(XL+1)]
    for i in range(1,XL+1):
        dp[i][0] = i
    for j in range(1,YL+1):
        dp[0][j] = j
    for i in range(XL):
        for j in range(YL):
            if X[i] == Y[j]:
                dp[i+1][j+1] = min(dp[i][j+1]+1,dp[i+1][j]+1,dp[i][j])
            else:
                dp[i+1][j+1] = min(dp[i][j+1]+1,dp[i+1][j]+1,dp[i][j]+1)
    return dp[XL][YL]

print(Levenshtein_d(s1,s2))



Measured memory_bytes: 43476
// abc135_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    if ((A - B) % 2 == 0){
        print(B + (A - B) / 2);
    } else {
        print("IMPOSSIBLE");
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ara[100002];
const ll num=1e18;

int main()
{
    ll n,i,ans,rm;
    cin>>n;
    for(i=1; i<=n; i++)scanf("%lld",&ara[i]);
    sort(ara+1,ara+n+1);
    if(ara[1]==0)printf("0\n");
    else
    {
        ans=1,rm=num;
        for(i=1; i<=n; i++)
        {
            if(ara[i]>rm)printf("-1\n"),exit(0);
            ans*=ara[i];
            rm=num/ans;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4496
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    sa = a[i] - (i+1)
    b[i] = sa
b.sort()
idx = int(n/2) 

p = b[idx]
ans = 0
for i in range(n):
    ans += abs(i+1+p-a[i])
print(ans)




Measured memory_bytes: 26756
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#define N 100005
using namespace std;
int a[N],x;
int gcd(int m,int n){
	if(m%n==0)return n;
	else return gcd(n,m%n);
}
int main(){
	int i,t,n;
 	scanf("%d%d",&n,&x);
 	for(i=0;i<n;i++)
 		scanf("%d",&a[i]);
 	a[n]=x;
 	sort(a,a+1+n);
 	for(i=0;i<n;i++)
 		a[i]=a[i+1]-a[i];
	t=a[0];
	for(i=1;i<n;i++){
		t=gcd(a[i],t);
		if(t==1){
			cout<<1;
			return 0;
		}
	}
	cout<<t; 
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <utility>
#include <cassert>
using namespace std;
typedef long long ll;
set<int> s,t;
pair<pair<ll,ll>,ll> p[100010];
int main(){
	long long i,n,k;
	cin >> n >> k;
	if(k*n<=n*(n + 1)/2){
		if(n%2==0){
			for(i=0;i<n/2;i++){
				p[i] = {{i,2*n - 2 - 2*i},2*n - 1 - i};
			}
			for(i=n/2;i<n;i++){
				p[i] = {{i,3*n - 1 - 2*i},3*n - 1 - i}; 
			}
		}else{
			for(i=0;i<n/2;i++){
				p[i] = {{i,2*n - 2 - 2*i},2*n - 2 - i};
			}
			for(i=n/2;i<n;i++){
				p[i] = {{i,3*n - 2 - 2*i},3*n - 2 - i};
			}
		}
		for(i=0;i<n;i++){
			cout << p[i].first.first + k << " " << p[i].first.second + k << " " << p[i].second + k + (n + 1)/2 << endl;
		}
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	while(1){
		int a[10];
		cin >> a[0];
		if(a[0]==0)break;
		for(int i=1;i<10;i++){
			cin >> a[i];
			a[0]-=a[i];
		}
		cout << a[0] << endl;
	}
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, K;
string S;
vi va, vb;
const int MAX = 2 * (1e6 + 5);
long long fac[MAX], finv[MAX], inv[MAX];
void com_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long com(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void input() {
  ;
  cin>>N>>K;
  ;
}

int sm(int start, int end){
 return  (end + end+1)/2 - (start+start+1)/2;
}


int minrskw[MX*2];
int maxrskw[MX*2];
void solve() {
  minrskw[0] = 0;
  maxrskw[0] = 0;
  maxrskw[1] = N;
  minrskw[1] = 0;
  rep(i,2,N+1){
    minrskw[i] = minrskw[i-1] + i-1;
    maxrskw[i] = maxrskw[i-1] + (N-i+1);
    maxrskw[i] %= MOD;
    minrskw[i] %= MOD;
  }

  // H, H+1, H+2, H+3, .. , H+N まで 
  // から　K 個 以上
  // -> K個選ぶ, K+1個選ぶ, ... , N個選ぶ

  // K 個選ぶ　　-> K*H + SUM(0,K-1) + SUM(N-K, N)

  // N=3, K=2 -> 5 + 4 + 1
  int ans = 0;
  rep(i,K,N+1){
    ans += maxrskw[i]-minrskw[i]+1;
    ans %= MOD;
  }
  cout<<(ans+MOD+MOD)%MOD<<endl;


  ;
  ;
}
signed main() {
  com_init();
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 53620
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n = int(input())
l  = list(collections.Counter(prime_factorize(n)).values())
count = 0
for i in l:
    x = i
    check = 1
    while True:
        if x >= check:
            x -= check
            count += 1
            check += 1
        else:
            break
print(count)

Measured memory_bytes: 65936
def main():
    MAX = 1_000_000_000_000_000_000
    n = int(input())
    nums = [int(_x) for _x in input().split()]
    if 0 in nums:
        print(0)
        return

    result = 1
    for num in nums:
        result = result * num
        if result > MAX:
            print(-1)
            return
    print(result)


main()


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        PriorityQueue pq = new PriorityQueue();
        while (!line.equals("end")) {
            String[] split = line.split(" ");
            if (split[0].equals("insert")) {
                pq.insert(Integer.parseInt(split[1]));
            } else {
                System.out.println(pq.extractMax());
            }
            line = in.readLine();
        }
    }
}

class PriorityQueue {
    private ArrayList<Integer> list;

    PriorityQueue() {
        list = new ArrayList<>();
    }

    private static int getParentIndex(int i) {
        return (i - 1) / 2;
    }

    private static int getLeftIndex(int i) {
        return i * 2 + 1;
    }

    private static int getRightIndex(int i) {
        return i * 2 + 2;
    }

    private void swap(int i, int j) {
        int temp = list.get(i);
        list.set(i, list.get(j));
        list.set(j, temp);
    }

    void insert(int k) {
        list.add(k);
        propagateUp(list.size() - 1);
    }

    private void propagateUp(int currentIndex) {
        if (currentIndex > 0) {
            int currentVal = list.get(currentIndex);
            int parentIndex = getParentIndex(currentIndex);
            int parentVal = list.get(parentIndex);
            if (currentVal > parentVal) {
                swap(parentIndex, currentIndex);
            }
            propagateUp(parentIndex);
        }
    }

    int extractMax() {
        int max;
        if (list.size() > 1) {
            max = list.get(0);
            list.set(0, list.remove(list.size() - 1));
            heapify(0);
        } else {
            max = list.remove(0);
        }
        return max;
    }

    private void heapify(int i) {
        int leftIndex = getLeftIndex(i);
        if (leftIndex < list.size()) {
            int rightIndex = getRightIndex(i);
            int maxIndex = leftIndex;
            if (rightIndex < list.size() && list.get(rightIndex) > list.get(leftIndex)) {
                maxIndex = rightIndex;
            }
            if (list.get(maxIndex) > list.get(i)) {
                swap(maxIndex, i);
                heapify(maxIndex);
            }
        }
    }
}


Measured memory_bytes: 333368
import sys
input = sys.stdin.readline
a = [list(input())[: -1] for _ in range(3)]
for i in range(3): a[i].reverse()
x = 0
c = ["a", "b", "c"]
C = ["A", "B", "C"]
while True:
  if len(a[x]) == 0:
    print(C[x])
    break
  t = a[x].pop()
  for i in range(3):
    if t == c[i]:
      x = i
      break

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll n;
set<ll> s;
inline ll mi(ll a, ll b)
{
    ll ret = 1;
    while (b)
    {
        if (b & 1)
            ret *= a;
        a *= a;
        b >>= 1;
    }
    return ret;
}

void check(ll d)
{
    for (ll i = 1; i <= 60; ++i)
    {
        ll k = pow(d * 1.0, 1.0 / i);
        if (k == 1)
            continue;
        if (mi(k, i) == d)
        {
            if ((n / d - 1 + k) % k == 0)
                s.insert(k);
        }
        if (mi(k + 1, i) == d)
        {
            if ((n / d - 1 + k + 1) % (k + 1) == 0)
                s.insert(k + 1);
        }
        if (k > 1 && mi(k - 1, i) == d)
        {
            if ((n / d - 1 + k - 1) % (k - 1) == 0)
                s.insert(k - 1);
        }
    }
}

void solve()
{
    cin >> n;
    for (ll i = 1; i * i <= n - 1; ++i)
    {
        if ((n - 1) % i == 0)
        {
            s.insert(i);
            s.insert((n - 1) / i);
        }
    }
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            check(i);
            check(n / i);
        }
    }
    check(n);
    s.erase(1);
    cout << s.size() << '\n';
    // for (auto i : s)
    //     cout << i << ' ';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc020/tasks/agc020_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll K;
  cin >> K;

  VL as(K);
  rep(i, K) cin >> as[i];

  // [low, high]
  ll low = 2;
  ll high = 2;

  repr(i, K) {
    ll a = as[i];

    // low ~ high の間に a の倍数が無いかどうかを確認
    if (low / a == high / a && low % a != 0 && high % a != 0) {
      drop(-1);
    }

    ll mi = (low + a - 1) / a;
    ll ma = high / a;

    low = a * mi;
    high = a * ma + (a - 1);
  }

  print_ints({low, high});
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,L;
  cin>>N>>L;
  vector<int>a(N);
  for(int i=0;i<N;i++)a[i]=L+(i+1)-1;
  int Min=INF;
  int memo=0;
  for(int i=0;i<N;i++){
    if(abs(a[i])<Min){
      Min=min(Min,abs(a[i]));
      memo=a[i];
    }
  }
  int ans=0;
  for(auto it:a)ans+=it;
  ans-=memo;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256