akhauriyash/Code-Regression huggingface dataset:
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;



   cin>>a>>str;

   if(a<3200)cout<<"red"<<endl;

   else cout<<str<<endl;









}



Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	string s, t; cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
		s = s.back() + s.substr(0, s.size() - 1);
	}
	cout << "No" << endl;
	return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int[] nums = sc.IntArray();
        nums = nums.OrderBy(i => i).ToArray();

        string answer = nums[0] + nums[1] == nums[2] ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    sll a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 256
using System;
class hoge
{
    static void Main(String[] args)
    {
        int input = int.Parse(Console.ReadLine());
        int h = input / 3600;
        int m = (input % 3600)/60;
        int s = input % 60;
        Console.WriteLine("{0}:{1}:{2}", h, m, s);
}}

Measured memory_bytes: 9136
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

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

	if ((A == 5 && B == 7 && C == 5)
		||(A == 5 && B == 5 && C == 7)
		|| (A == 7 && B == 5 && C == 5)) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
  vector<int> n(3);
  for(int i = 0; i < 3; ++i) cin >> n.at(i);
  
  sort(n.begin(), n.end());
  bool a = true;
  if(n.at(0) == n.at(1) || n.at(1) == n.at(2)){
    if(!(n.at(0) == n.at(2))){
      cout << "Yes" << endl;
      a = false;
    }
  }
  
  if(a) cout << "No" << endl;
}

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

#define F first
#define S second

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

const int oo = 1e9 + 4;
const int SZ = 2e5 + 4;

int n, m, k;
bool g[10][1010];

void read() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++)
            g[i][j] = s[j] - '0';
    }
}

int go(vector <vector <int> > d) {
    int t = d.size();
    int res = t - 1;
    vector <int> sum(t, 0);

    for (int i = 0; i < m; i++) {
        bool ok = 1;
        for (int j = 0; j < t; j++)
            for (auto r : d[j]) {
                sum[j] += g[r][i];
                if (sum[j] > k) ok = 0;
            }
        if (!ok) {
            ok = 1;
            res++;
            sum.clear();
            sum.resize(t, 0);
            for (int j = 0; j < t; j++)
                for (auto r : d[j]) {
                    sum[j] += g[r][i];
                    if (sum[j] > k) ok = 0;
                }
        }
        if (!ok) return oo;
    }
    return res;
}

void solve() {
    ll ans = oo;
    for (int mask = 0; mask < (1 << (n - 1)); mask++) {
        vector <vector <int> > d(1);
        for (int i = 0; i < n; i++) {
            d.back().push_back(i);
            if (i < n - 1 && ((mask >> i) & 1)) d.push_back(vector <int> ());
        }
        ans = min(ans, 1ll * go(d));
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    read();
    solve();
}


Measured memory_bytes: 256
N = int(raw_input())

s = []

for i in range(N):
    s.append(int(raw_input()))

s.sort()

ans = sum(s)

for i in range(N):
    if ans % 10 == 0:
        if s[i] % 10 == 0:
            pass
        else:
            ans -= s[i]
    else:
        break

if ans % 10 == 0:
    print 0
else:
    print ans

Measured memory_bytes: 2568
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	vector<int> s;
	cin>>n;
	for(int i=0;i<n;i++){
		int h;
		cin>>h;
		s.push_back(h); 
	}
	int minn=n+1; 
	int now=0;
	for(int i=0;i<n;i++){
		if(s[i] < minn){
			now++;
			minn=s[i];
		}
	}
	cout<<now;
	return 0;
} 

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

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

using namespace std;

int gcd(int a, int b){
  if(a==1 || b==1)return 1;
  if (a < b)swap(a,b);
  
  return b ? gcd(b, a % b) : a;
}

int main(){
  ll n,k;cin>>n>>k;
  vector<ll> a(n);
  ll maxa=0,c=-1;
  set<ll> s;
  bool f=true;
  rep(i,n){
    cin>>a[i];
    if(c==-1){
      c=a[i];
    }else{
      c = gcd(a[i], c);
    }
    maxa=max(maxa, a[i]);
    s.insert(a[i]);
  }

  if(maxa<k || s.size()<2 && a[0]!=k || k%c!=0){
//cout<<s.size()<<' '<<a[0]<<' '<<c<<endl;
    cout<<"IMPOSSIBLE"<<endl;
  }else{
    cout<<"POSSIBLE"<<endl;
  }

  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
using namespace std;
int k,n,m,o;
int l[51]={};
int ans=0;

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	for(int i=0;i<k;i++){
		m=0;
		for (int j = 0; j<n; j++) {
			if(m<l[j]){
				m=l[j];
				o=j;
			}
		}
		ans+=m;
		l[o]=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

#define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define en '\n'
#define S second
#define F first
#define pll pair<ll,ll>
#define PB push_back

const ll N = 1e6+7;
ll mod = 1e9+7;
#define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
ll fac[N] = {0};

ll gen_base(const ll before, const ll after) {
    auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::mt19937 mt_rand(seed);
    int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
    return base % 2 == 0 ? base-1 : base;
}

ll pow(ll a,ll b)
{
    if(!b)
        return 1;
    ll p = pow(a,b/2);
    if(b%2)
        return (a*((p*p)%mod))%mod;
    else
        return (p*p)%mod;
}

ll modInv(ll a)
{
    //cout<<a<<" "<<mod<<en;
    return pow(a%mod,mod-2);
}

ll nCr(ll n,ll r)
{
    return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
}

ll hashf(ll r,ll x,ll mod)
{
    return (x+r)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    fac[0] = 1;
    calncr;
    ll n,k;
    cin>>n>>k;
    ll arr[n],crr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    for(ll i=0;i<n;i++)
        cin>>crr[i];
    ll visit[n]={0};
    vector<vector<ll>> vec;
    for(ll i=0;i<n;i++){
        if(visit[i])
            continue;
        vector<ll> v;
        v.PB(i);
        visit[i]++;
        ll j=arr[i]-1;
        while(j!=i){
            v.PB(j);
            visit[j]++;
            j = arr[j]-1;
        }
        vec.PB(v);
    }
    ll ans=LLONG_MIN;
    for(ll i=0;i<vec.size();i++){
        ll m = vec[i].size();
        ll sm=0;
        for(ll j=0;j<m;j++){
            ll ss=0;
            sm+=crr[vec[i][j]];
            for(ll kk=0;kk<min(m,k);kk++){
                ss+=crr[vec[i][(j+kk)%m]];
                ans = max(ans,ss);
            }
        }
        if(m>=k)
            continue;
        ll tt = k/m-1;
        sm = (sm*tt);
        ll t = k%m+m,ssm=LLONG_MIN;
        for(ll j=0;j<m;j++){
            ll ss=0;
            for(ll kk=0;kk<t;kk++){
                ss+=crr[vec[i][(j+kk)%m]];
                ssm = max(ssm,ss);
            }
        }
        sm+=max((ll)0,ssm);
        ans = max(ans,sm);
    }
    cout<<ans<<en;
}


Measured memory_bytes: 11652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,x;cin >> a >> b >> x;
	if(a==0) cout << b/x+1 << endl;
	else if(b==0) cout << 1 << endl;
	else cout << b/x-(a-1)/x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
vector<string> strs;
int H,W;
bool isroad(int fx,int fy,int tx,int ty){
    int fromx,fromy,tox,toy;
    fromx=min(fx,tx);
    fromy=min(fy,ty);
    tox=max(fx,tx);
    toy=max(fy,ty);
    if(fromx<1 || tox<1 || tox>W || fromx>W || fromy<1 || toy<1 || fromy>H || toy>H) return false;
    if(fromx==tox){
        if(strs[(fromy-1)*2+1][fromx-1]=='1') return true;
        else{
            return false;
        }
    }else{
        if(strs[(fromy-1)*2][fromx-1]=='1') return true;
        else{
            return false;
        }
    }
}
int vx[]={1,0,-1,0},vy[]={0,-1,0,1};
int main(){
    string ins;
    while(cin>>ins){
        strs.push_back(ins);
    }
    W=strs[0].size()+1;
    H=strs.size()/2+1;
    int nx=2,ny=1,v=0;
    string outs="R";
    while(nx!=1 || ny!=1){
        for(int i=5;i>=2;i--){
            bool r=isroad(nx,ny,nx+vx[(v+i)%4],ny+vy[(v+i)%4]);
            if(r){
                v=(v+i)%4;
                nx+=vx[v];
                ny+=vy[v];
                if(v==0) outs+='R';
                else if(v==1) outs+='U';
                else if(v==2) outs+='L';
                else outs+='D';
                break;
            }
        }
    }
    cout<<outs<<endl;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
import java.math.*;
class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int arr[] = new int[n+3];
		for(int i=1;i<=n;i++)
			arr[i]=sc.nextInt();
		int dp[] = new int[n+3];
		Arrays.fill(dp,Integer.MAX_VALUE);
		dp[1]=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=2;j++){
				if(i+j>n)
					continue;
				int y = arr[i+j]-arr[i];
				if(y<0)
					y*=-1;
				dp[i+j]=(Math.min(dp[i+j],(dp[i]+y)));
			}
		}
		System.out.println(dp[n]);
	}
	
	
	
	public static class pair{
		long a;
		long b;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o2.a-o2.b).compareTo(Long.valueOf(o1.a-o1.b));
		}
	}
	
	
	
	public static long sum(long a, long d, long n){
		
		long total = ((n)*((2*a)+(n-1)*d))/2;
		return total;
	}
	
	public static class trie{
		char ch;
		HashMap<Character,trie> hm = new HashMap<>();
		int count;
		boolean isterminal;
	}
	
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
 
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Measured memory_bytes: 33284
#include <stdio.h>

void sort(int,int[]);

int main(void)
{
	int i, n, card_a[110] = {};

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &card_a[i]);
	}
    
    sort(n,card_a);

	return 0;
}

void sort(int num,int card[])
{
    int i, v, j, k;
	for (i = 0; i < num; i++) {
	    if(i!=0){
	        v=card[i];
	        j=i-1;
	        while(j>=0 && card[j]>=v){
	            card[j+1]=card[j];
	            j--;
	            card[j+1]=v;
	        }
        }
		for (k = 0; k < num; k++) {
			printf("%d", card[k]);
			if (k != num - 1)
				printf(" ");
			else
				printf("\n");
		}
	}
}


Measured memory_bytes: 2044
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n,m,k = get_nums_l()
    A = get_nums_l()
    B = get_nums_l()

    ruisekiA = [0] * (n+1)
    ruisekiB = [0] * (m+1)
    for i in range(n):
        ruisekiA[i+1] = ruisekiA[i] + A[i]
    for i in range(m):
        ruisekiB[i+1] = ruisekiB[i] + B[i]

    ans = 0

    # i = Aの本を読む冊数
    for i in range(n+1):

        if ruisekiA[i] > k:
            # Aだけでk分をオーバーしていたらNG
            continue

        # Bの本を読める冊数を二分探索で求める
        # OKの下限
        l = 0
        # NGの下限
        r = m+1

        while l+1 < r:
            c = (l+r) // 2

            # log(i,c)
            if ruisekiA[i] + ruisekiB[c] <= k:
                l = c
            else:
                r = c
        
        ans = max(ans, i+l)

    print(ans)

main()

Measured memory_bytes: 121140
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

#define M 1000000007

ll power_mod(ll a,ll index,ll divider){
    ll ret = 1;
    for(;index>0;index/=2,a=a*a%divider){
        if(index%2==1){
            ret = ret * a % divider;
        }
    }
    return ret;
}

int main(){
    int N,B;cin>>N>>B;
    int R = N - B;
    vector<ll> fuctorial_mod(N+1);
    fuctorial_mod[0] = 1;
    ll fuctorial = 1;
    for(int i=1;i<=N;i++){
        fuctorial = fuctorial * i % M;
        fuctorial_mod[i] = fuctorial;
    }
    for(int i=1;i<=B;i++){
        if(i>R+1){
            cout << 0 << endl;
            continue;
        }
        ll R_ans = fuctorial_mod[R+1] * power_mod(fuctorial_mod[i],M-2,M) % M;
        R_ans = R_ans * power_mod(fuctorial_mod[R+1-i],M-2,M) % M;
        ll B_ans = fuctorial_mod[B-1] * power_mod(fuctorial_mod[i-1],M-2,M) % M;
        B_ans = B_ans * power_mod(fuctorial_mod[B-i],M-2,M) % M;
        cout << R_ans * B_ans % M << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;
vector<ll> p;

int main(){
    cin >> N;
    p.resize(N);
    rep(i,N) cin>>p[i];

    vector<ll> sum(N,0);
    vector<ll> a(N),b(N);
    rep(i,N)sum[p[i]-1]=i+1;

    for(ll d=1;d<=N;d++){
        rep(i,N) a[i] = i*d+1;
        rep(i,N) b[i] = sum[i] - a[i];
        ll mn = *min_element(all(b));
        if(mn<0){
            for_each(all(a),[&](ll& x){ x+=abs(mn)+1; });
            for_each(all(b),[&](ll& x){ x+=abs(mn)+1; });
        }

        bool ok=true;
        rep(i,N-1){
            if(b[i]>b[i+1]) continue;
            else ok=false;
        }
        if(ok){
            rep(i,N){
                if(i) cout << " ";
                cout << a[i];
            }
            cout << endl;
            rep(i,N){
                if(i) cout << " ";
                cout << b[i];
            }
            cout << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

string hid="38sk1fGCU9odOA4krAMk30G8pelwdy65nAanpqyHp54FofcbIH6iOj5w2KEtPN7B8pyIUoSQOVl4DqQZNLXGFN9u4butNvmkrvERoTUwSbD5TMz1sK0iZ3FXVDmXkEx3";

const int N = 866;
int L=128,cntQ;


int qry(string s){
	/*cntQ++;
	static int dp[N][N];
	rep(i,0,SZ(hid))rep(j,0,SZ(s))dp[i][j]=1e9;dp[0][0]=0;
	rep(i,0,SZ(hid))rep(j,0,SZ(s)){
		dp[i][j]=hid[i]==s[j];
		if(i-1>=0&&j-1>=0)dp[i][j]+=dp[i-1][j-1];
		if(i-1>=0)umax(dp[i][j],dp[i-1][j]);
		if(j-1>=0)umax(dp[i][j],dp[i][j-1]);
		umin(dp[i+1][j],dp[i][j]+1);
		umin(dp[i][j+1],dp[i][j]+1);
		if(i+1<=SZ(hid)&&j+1<=SZ(s))umin(dp[i+1][j+1],dp[i][j]+(hid[i]!=s[j]));
	}
//	cerr<<SZ(hid)<<' '<<SZ(s)<<' '<<dp[SZ(hid)][SZ(s)];
	return dp[SZ(hid)][SZ(s)];*///SZ(hid)+SZ(s)-2*dp[SZ(hid)-1][SZ(s)-1];
	cout<<"? "<<s<<endl;fflush(stdout);int x;read(x);return x;
}
char zf[666];int sz,n,b[666],gs[666];string a[666];int pos[N];
priority_queue<Pii,vector<Pii>,greater<Pii> >heap;
void solve(int x, int y, int l, int r, int lo, int hi){
	if(l>r)return;int p=(l+r)/2,L=lo,R=hi;
	while(L<R){
		int mid=(L+R+1)/2;
		string A;rep(i,0,mid)A+=a[y][i];
		rep(i,p,gs[x]-1)A+=a[x][i];
		if(qry(A)==n-SZ(A))L=mid;else R=mid-1;
	}
	pos[p]=L;
	solve(x,y,l,p-1,lo,L);
	solve(x,y,p+1,r,L,hi);
}
int main() {
	rep(i,'a','z')zf[++sz]=i;
	rep(i,'A','Z')zf[++sz]=i;
	rep(i,'0','9')zf[++sz]=i;
	cerr<<sz<<endl;
	
//	string oo;while(SZ(oo)<128)oo+=zf[R()%sz+1];cout<<oo<<endl;hid=oo;
//	hid="abc";
	
	rep(i,1,sz){
		string s;rep(j,1,L)s+=zf[i];b[i]=qry(s);//n+=b[i];
	}
//	cerr<<b[1]<<endl;return 0;
//	n-=sz*L;assert(n%(sz-2)==0);n/=sz-2;
	rep(i,1,sz){
		gs[i]=L-b[i];n+=gs[i];rep(j,1,gs[i])a[i]+=zf[i];
		if(gs[i])heap.push(mp(gs[i],i));
	}
	while(SZ(heap)>1){
		int i=heap.top().se;heap.pop();
		int j=heap.top().se;heap.pop();
		
		solve(i,j,0,gs[i]-1,-1,gs[j]-1);
		string s;int p=-1;
		rep(t,0,gs[i]-1){
			while(p+1<=pos[t])s+=a[j][++p];
			s+=a[i][t];
		}
		while(p+1<gs[j])s+=a[j][++p];
		
		a[j]=s;
		gs[j]+=gs[i];heap.push(mp(gs[j],j));
	}
	printf("! ");cout<<a[heap.top().se]<<endl;fflush(stdout);
	cerr<<cntQ<<endl;
	return 0;
}


Measured memory_bytes: 3788
#include <cstdio>

const int N = 2e4 + 10;
int n, p[N], a[N], b[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", p + i);
    for (int i = 0; i < n; i++)
        a[i] = n * i + 1;
    for (int j = 0; j < n; j++)
        b[j] = n * (n - j - 1) + 1;
    for (int i = 0; i < n; i++)
        ((i & 1) ? b[p[i] - 1] : a[p[i] - 1]) += i;
    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);
    putchar('\n');
    for (int j = 0; j < n; j++)
        printf("%d ", b[j]);
    putchar('\n');
    return 0;
}



Measured memory_bytes: 768
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-03-07 21:21:27 +0900
# LastModified: 2020-03-07 22:31:57 +0900
#




def main():
    A,B = map(int,input().split())
    a_min = (A/0.08)
    a_max = (A+1)/0.08
    b_min = (B/0.1)
    b_max = (B+1)/0.1
    if a_min!=int(a_min):
        a_min = int(A/0.08)+1
    if b_min!=int(b_min):
        b_min = int(B/0.1)+1
    s_a = [i for i in range(int(a_min),int(a_max))]
    s_b = [i for i in range(int(b_min),int(b_max))]
    for common in s_a:
        if common in s_b:
            print(common)
            return
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    ll ans=0;
    ll x;

    cin>>x;

    ans+=(x/500)*1000;
    x-=(x/500)*500;

    if(x>=5){
        ans+=(x/5)*5;
    }

    cout<<ans<<endl;

  
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
int main()
{
	int n,i,j,x;
	scanf("%d",&n);
	vi a;
	int sum = 0;
	for(i=0;i<n;++i)
	{
		scanf("%d",&x);
		a.push_back(x);
		sum += x;
	}
	int m = 100000;
	bool dp[n][m];
	for(i=0;i<n;++i)
	{
		for(j=0;j<m;++j)
		{
			dp[i][j] = false;
		}
	}
	dp[0][a[0]] = true;
	for(i=0;i<n-1;++i)
	{
		for(j=0;j<m;++j)
		{
			if(dp[i][j]==true)
			{
				if(j<=a[i+1])
				{
					dp[i+1][a[i+1]-j] = true;
				}
				else 
				{
					dp[i+1][j-a[i+1]] = true;
				}
				if(j+a[i+1]<m)
				{
					dp[i+1][j+a[i+1]] = true;
				}
			}
		}
	}
	for(i=0;i<m;++i)
	{
		if(dp[n-1][i]==true)
		{
			printf("%d",(sum+i)/2);
			return 0;
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";

    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	cout<<fixed<<setprecision(7);
	int n, a;
	cin>>n>>a;
	
	cout<<n*n-a<<endl;
	
	
	
	return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, 0, n){
        if(s[i] != s[n - i - 1]){
            cout << "No" << endl;
            return 0;
        }
    }
    string s1 = s.substr((n + 3) / 2 - 1, n);
    int n1 = s1.size();
    string s2 = s.substr(0, (n - 1) / 2);
    int n2 = s2.size();
    rep(i, 0, n1){
        if(s1[i] != s1[n1 - i - 1]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, 0, n2){
        if(s2[i] != s2[n2 - i - 1]){
            cout << "fuck" << endl;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int t,d,l;
  
  scanf("%d%d%d",&t,&d,&l);

  if(t == 0) return false;

  int ans = 0;
  int sec = 0;
  
  for(int i=0;i<t;i++){
    int x;

    scanf("%d",&x);

    if(t-1 == i) continue;
    
    sec--;
    if(x >= l){
      sec = d;
    }

    if(sec > 0) ans++;
  }

  
  printf("%d\n",ans);

  return true;
}

int main(){
  while(solve());
  
  return 0;
}

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

int v[110], dp[55][55][110];

int f(int i, int j, int k) {
	if (k == 0 || i > j)
		return 0;
  
	if (dp[i][j][k] != -1)
		return dp[i][j][k];
  
	int ans = 0;
	if (k > 0) {
      
      
		ans = max(v[i] + f(i + 1, j, k - 1), ans);
		ans = max(v[j] + f(i, j - 1, k - 1), ans);
	}
	if (k > 1) {
      
		ans = max(f(i + 1, j, k - 2), ans);
		ans = max(f(i, j - 1, k - 2), ans);
	}
	return dp[i][j][k] = ans;
}

int main() {
	int n, k;
  cin >> n >> k;
  
	for (int i = 0; i < n; i++) cin >> v[i];
  
	memset(dp, -1, sizeof(int) * 250000);
  
	cout << f(0, n - 1, k) << endl;

	return 0;
}


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

long long MOD = 1e9 +7;

long long Repeat(long long a,long long cnt){
  if(cnt==0)return 1LL;
  if(cnt%2==1){
    long long x = Repeat(a,cnt/2);
    return (((a*x)%MOD)*x)%MOD;
  }
  else {
    long long x = Repeat(a,cnt/2);
    return (x*x)%MOD;
  }
}

long long fact(long long a){
  if(a == 0)return 1LL;
  else return (a*fact(a-1))%MOD;
}

long long conb(long long a, long long b){
  long long fa,fb,fab;
  fa = fact(a);
  fb = fact(b);
  fab = fact(a-b);
  fb = Repeat(fb,MOD-2);
  fab = Repeat(fab,MOD-2);
  return (((fa*fb)%MOD)*fab)%MOD;
}

int main(){
  long long a,i,j,k,ret=1,n,m,c=0;
  cin >> n >> m;
  for(j=2;j*j<=m;j++){
    c = 0;
    while(m%j==0){
      m/=j;
      c++;
    }
    if(c!=0)ret=(ret*conb(c+n-1,c))%MOD;
  }
  if(m>1)ret=(ret*n)%MOD;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc155/tasks/abc155_c

#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;
typedef long double ld;
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 N;
  cin >> N;

  map<string, ll> ct_map;

  rep(i, N) {
    string s;
    cin >> s;
    ct_map[s]++;
  }

  ll max_ct = 0;
  for (auto e : ct_map) {
    chmax(max_ct, e.se);
  }

  for (auto it = ct_map.begin(); it != ct_map.end(); it++) {
    auto e = *it;
    if (e.se == max_ct) {
      cout << e.fi << endl;
    }
  }
}

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: 23808
n = int(input())
a = list(map(int,input().split()))
b =list(map(int,input().split()))
c =list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
i=0
k=0
ans=0
acnt=0
ccnt=n
for x in b:
    aok=True
    cng=True
    while aok:
        if acnt == n:
            break
        if a[i]<x:
            i+=1
            acnt+=1
        else:
            aok=False
    while cng:
        if ccnt == 0:
            break
        if c[k]<=x:
            k+=1
            ccnt-=1
        else:
            cng=False
    ans+=acnt*ccnt
    #print(i,acnt,k,ccnt)
print(ans)

            

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

int main(){

  int N; cin >> N;
  vector<int> H(N, 0);
  for(int i = 0 ; i < N ; ++i){
    cin >> H[i];
  }

  int cnt = 0;
  int max = 0;

  for(int i = 0 ; i < N ; ++i){
    max = std::max(max, H[i]);
    if(max == H[i]) ++cnt;
  }

  cout << cnt << endl;

}

Measured memory_bytes: 256
import math
import itertools
N,M=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N<=1:
    if M<=1:
        print(0)
    else:
        b = combinations_count(M, 2)
        print( b)
else:
    if M<=1:
        a = combinations_count(N, 2)
        print(a )
    else:
        a = combinations_count(N, 2)
        b = combinations_count(M, 2)
        print(a + b)


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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n+1];
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	int ans=0;
	for(int i=2;i<=n-1;i++)
		if((a[i-1]<a[i] && a[i+1]>a[i]) || (a[i-1]>a[i] && a[i+1]<a[i]))
			ans++;
	cout<<ans<<endl;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////

string A="AGCT";

string hen(ll t,ll cnt){
    string s;
    rep(z,0,cnt){
        s+=A[t%4];
        t/=4;
    }
    reverse(s.begin(),s.end());
    return s;
}
vector<string>out={"AGC","GAC","ACG"};
bool check(ll t){
    string s=hen(t,2);
    for(auto x:out)if(x==s)return true;
    return false;
}
bool che(string s){
    
    rep(i,0,3){
        string t;
        rep(j,0,3){
            if(i==j)continue;
            t+=s[j];
        }
        if(t=="AGC")return true;
    }
    return false;
}
bool check2(ll t){
    
    if(check(t%64))return true;
    if(check(t/4))return true;
    string s=hen(t,3);
    
    if(che(s))return true;
    return false;
}

ll SOLVE(){
    ll n;cin>>n;
    ll dp[n][64];memset(dp,0,sizeof(dp));
    rep(j,0,63){
        if(!check(j))dp[2][j]=1;
    }
    
    rep(i,1,n-2){
        rep(j,0,63){
            rep(k,0,3){
                ll sumj=j*4+k;
                ll nxtj=sumj%64;
                if(check2(sumj))continue;
                
                Add(dp[i+1][nxtj],dp[i][j]);
            }
        }
    }
    ll ans=0;
    rep(j,0,63)Add(ans,dp[n-1][j]);
    cout<<mod(ans)<<endl;
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#! python3
# disjoint_set_union_find_tree.py

n, q = [int(x) for x in input().split(' ')]

sets = [set([i]) for i in range(n)]

def unite(Sx, Sy):
    return Sx | Sy

def search(x):
    global sets
    flag = False
    for i in range(len(sets)):
        if x in sets[i]:
            flag = True
            break
    if flag:
        return i
    else:
        return None

def same(x, y):
    global sets
    flag = 0
    for set in sets:
        if x in set:
            if y in set:
                 flag = 1
            break
    return flag

for i in range(q):
    query, x, y = input().split(' ')
    x, y = int(x), int(y)
    if query == '0':
        # unite
        i_x = search(x)
        i_y = search(y)
        if i_x != None and i_y != None and i_x != i_y:
            sets[i_x] = unite(sets[i_x], sets[i_y])
            del sets[i_y]
    elif query == '1':
        # same
        print(same(x, y))


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 1010

int N;
vector< pair<int, int> > AB;    // first 位 の人が second 点

signed main()
{
    cin >> N;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        AB.push_back({a, b});
    }
    SORT(AB);
    int ans = 0;
    // 上位の人数を加算
    ans += AB[AB.size()-1].first;
    // 一番下は、整数のバリエーションが許す限りいる
    ans += AB[AB.size()-1].second;
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

template <typename T> bool is_prime(T n) {
  if (n == 0 || n == 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (T i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X;
  cin >> X;
  for (int i = X;; i++) {
    if (is_prime(i)) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}


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

int main() {
    string s;
    int K;
    cin >> s >> K;
    
    rep(i, s.size() - 1) {
        if (s[i] == 'a') continue;
        if ('{' - s[i] <= K) {
            K -= ('{' - s[i]);
            s[i] = 'a';
        }
    }
    K %= 26;
    while (K > 0) {
        --K;
        ++s[s.size() - 1];
        if (s[s.size() - 1] == '{') s[s.size() - 1] = 'a';
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int dp[100001];

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (auto &e : h)
    cin >> e;

  for (int i = 0; i < n; ++i)
  {
    if (i < 1)
      continue;
    else if (i < 2)
      dp[i] = abs(h[i] - h[i - 1]) + dp[i - 1];
    else
      dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << endl;

  return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int32 n = s.size();
  if(s[0] == '0' || s[n-1] == '1'){
    ANS(-1);
    return 0;
  }
  REP(i,n-1){
    if(s[i] != s[n-2-i]){
      ANS(-1);
      return 0;
    }
  }
  int32 pre = 1;
  REP(i,n-1){
    cout << pre << " " << i+2 << endl;
    if(s[i] == '1'){
      pre = i+2;
    }
  }
  return 0;
}

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

int main(){
  string S, T;
  vector<int> s(26);
  vector<int> t(26);
  cin >> S >> T;
  for(int i=0; i<S.size(); i++){
    s[S[i]-'a']++;
  }
  for(int i=0; i<T.size(); i++){
    t[T[i]-'a']++;
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  for(int i=0; i<26; i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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


int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    int oddcnt = 0;
    int cnt_4 = 0;
    rep(i,n){
        if(a[i] % 2 == 1) oddcnt++;
        if(a[i]%4 == 0) cnt_4++;
    }
    if(oddcnt + cnt_4 == n){
        if(oddcnt - 1 <= cnt_4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        if(oddcnt <= cnt_4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
def main():
    d = int(input())
    c = list(map(int,input().split()))
    s = [list(map(int,input().split())) for _ in range(d)]
    t = [int(input()) for _ in range(d)]
    
    ptn = len(c)
    last = [0]*ptn
    res = 0

    for i in range(d):
        sel = t[i] - 1
        last[sel] = i+1

        mns = 0
        for j in range(ptn):
            mns += c[j] * (i+1 - last[j])

        res += s[i][sel] - mns
        print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68468
//BISMILLAHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
void solve()
{
   ll n,k;
   cin>>n>>k;
   vector<int>Numbers;
   ll sum=0;
   for(int i=1;i<=n;i++)
   {
     ll a;
     cin>>a;
     Numbers.push_back(a);
   }
   sort(Numbers.begin(),Numbers.end());
   for(int i=0;i<k;i++)sum+=Numbers[i];
   cout<<sum<<endl;
}
int  main()
{
    IOS
        solve();
    return 0;
}


Measured memory_bytes: 3652
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

loop do
  n=gets.to_i
  break if n.zero?
  ans=0
  (n/4).times do|i|
    ans+=gets.to_i
  end
  puts ans
end


Measured memory_bytes: 6876
#include <iostream>
using namespace std;
int d[] = {5, 2};
//bool primes[300000];

bool checkMSN(int x) {
	int k = 0;
	for (int i = 6; i < x; k = (k + 1) % 2, i += d[k]) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	while (cin >> n, n != 1) {
		cout << n << ":";
		int k = 0;
		int outCount = 0;
		for (int i = 6; i <= n; k = (k + 1) % 2, i += d[k]) {
			if (n % i == 0 && checkMSN(i)) {
				cout << " " << i;
				outCount++;
			}
		}
		if (outCount == 0) cout << " " << n << endl;
		else cout << endl;
	}
}

Measured memory_bytes: 868
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    vector<int> a;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin>> tmp;
        a.push_back(tmp);
    }
    int ct=0;
    int i=0;
    for(;;){
        if(i==1){
            cout<< ct<<endl;
            break;
        }

        if(ct>=n){
            cout << -1 << endl;
            break;
        }
        ct++;
        i = a[i]-1;
    }
}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	string s;
	REP(i, SZ(S)) {
		if (S[i] != 'x')s += S[i];
	}
	REP(i, SZ(s)) {
		if (s[i] != s[SZ(s) - 1 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	vi X;
	int cnt = 0;
	REP(i, SZ(S)) {
		if (S[i] == 'x') {
			cnt++;
		}
		else {
			X.push_back(cnt);
			cnt = 0;
		}
	}
	X.push_back(cnt);
	int ans = 0;
	REP(i, SZ(X)) {
		if (i * 2 >= SZ(X)) {
			break;
		}
		ans += abs(X[i] - X[SZ(X) - 1 - i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1228