akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

#define BUF_SIZE 20

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

struct pairs {
    int v1;
    int v2;
};

#define BRIDGES_MAX 100000
#define LANDS_MAX 100000

struct vertex {
    int parent;
    int depth;
    int num;
};

void init_ufind(struct vertex ufind[], int size) {
    int i;
    for(i = 0; i < size; i++) {
        ufind[i].parent = i;
        ufind[i].depth = 1;
        ufind[i].num = 1;
    }
    return;
}

int get_root(struct vertex ufind[], int v) {
    int base = v;
    struct vertex *vertex = &ufind[v];
    while(base != vertex->parent) {
        base = vertex->parent;
        vertex = &ufind[base];
    }
    return base;
}

// res: diff
uint64_t connect(struct vertex ufind[], int v1, int v2) {
    int rv1 = get_root(ufind, v1);
    int rv2 = get_root(ufind, v2);
    if(rv1 == rv2) return 0;
    // ensure that v1 and v2 are separated with each other.
    struct vertex *root1 = &ufind[rv1];
    struct vertex *root2 = &ufind[rv2];
    int cnt1 = root1->num;
    int cnt2 = root2->num;
#ifdef DEBUG
    printf("connect: root%d: %d, root%d: %d\n", rv1, cnt1, rv2, cnt2);
#endif
    if(root1->depth >= root2->depth) { // root1 <- root2
        if(root1->depth == root2->depth) {
            root1->depth++;
        }
        // update root2
        root2->depth = root1->depth;
        root2->parent = rv1;
        root1->num += root2->num;
    } else { // root2 <- root1
        root1->depth = root2->depth;
        root1->parent = rv2;
        root2->num += root1->num;
    }
    // nC2 - (n1_C_2 + n2_C_2)
    return (uint64_t)cnt1 * cnt2;
}

int main(void) {
    int lands, bridges;
    struct pairs ps[BRIDGES_MAX];
    get_int2(&lands, &bridges);

    int i;
    for(i = 0; i < bridges; i++) {
        int v1, v2;
        get_int2(&v1, &v2);
        // 1-indexed -> 0-indexed
        v1--; v2--;
        ps[i].v1 = v1; ps[i].v2 = v2;
    }

    // conn[<# of removed bridges>] = <# of connected>
    uint64_t conn[BRIDGES_MAX+1];
    struct vertex ufind[LANDS_MAX];
    init_ufind(ufind, lands);
    // None of the bridges are removed
    conn[0] = ((uint64_t)lands)*(lands-1)/2;
    conn[bridges] = 0; // all bridges are removed..
    int br;
    for(br = bridges-1; br >= 1; br--) {
        uint64_t diff = connect(ufind, ps[br].v1, ps[br].v2);
#ifdef DEBUG
        printf("[%d<->%d]diff: %llu\n", ps[br].v1, ps[br].v2,diff);
#endif
        conn[br] = conn[br+1] + diff;
    }
    
    uint64_t sum = conn[0];
    for(i = 1; i <= bridges; i++) {
        printf("%llu\n", sum - conn[i]);
    }
    return 0;
}

Measured memory_bytes: 3968
import sys


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    if (a - b) % 2 == 0:
        print("Alice")
    else:
        print("Borys")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,mod;
int s[3005][3005],C[3005][3005];
inline ll qpow(ll x,int k,int mod,ll r=1){
	for(;k;k>>=1,x=x*x%mod) if(k&1) r=r*x%mod;
	return r;
}
int main(){
	scanf("%d%d",&n,&mod); ll ans=0;
	for(int i=0;i<=n+1;++i) for(int j=C[i][0]=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	for(int i=s[0][0]=1;i<=n+1;++i) for(int j=1;j<=i;++j) s[i][j]=(s[i-1][j-1]+1ll*s[i-1][j]*j)%mod;
	for(int i=0;i<=n;++i){
		ll v=qpow(2,qpow(2,n-i,mod-1),mod)*(i&1?mod-1:1)%mod*C[n][i]%mod;
		for(int j=0;j<=i;++j) (ans+=v*qpow(2,(n-i)*j,mod)%mod*s[i+1][j+1])%=mod;
	}
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 58820
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[2*n];
        for(int i = 0; i < 2*n; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = 0;
        for(int i = 0; i < 2*n; i+=2) ans += a[i];
        System.out.println(ans);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main(){
    int a, b, c, k, m, ans;
    cin >> a >> b >> c >> k;
    m = max(max(a,b), c);
    ans = (a+b+c) + m*pow(2,k) -m;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NKQ = Sarray();
            var N = NKQ[0];
            var K = NKQ[1];
            var Q = NKQ[2];
            var sankasya = new long[N];
            for (var i = 0; i < Q; ++i)
            {
                var ai = Sarray()[0];
                ++sankasya[ai - 1];
            }
            for (var i = 0; i < N; ++i)
            {
                if (sankasya[i] > Q - K)
                    WriteLine("Yes");
                else
                    WriteLine("No");
            }
            Out.Flush();
        }
    }
}

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

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  int C[N], A[N][M];
  for (int i=0; i<N; i++) {
    cin >> C[i];
    for (int j=0; j<M; j++)
      cin >> A[i][j]; 
  }


  int H[1<<N][M];
  int sum[1<<N];
  int min=-1;
  for (int bit=0; bit < (1<<N); bit++) {
    //initialize
    for (int i=0; i<M; i++) 
      H[bit][i] = 0;
    sum[bit] = 0;

    //bit search
    for (int i=0; i<N; i++) {
      if (bit & (1<<i)) {
	for (int j=0; j<M; j++)
	  H[bit][j] += A[i][j];
	sum[bit] += C[i];
      }
    }


    //determine
    for (int j=0; j<M; j++) {
      if (H[bit][j] >= X && j==M-1) {
	if (min > sum[bit] || min<0)
	  min = sum[bit];
      }	
      
      if (H[bit][j] >= X) {
	continue;
      } else 	break;
    }
  }

  cout << min << endl;
  
  return 0;
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N;
bitset <100005> cr;
vector <int> primes;
vector <int> bases;

map<LL, LL> cnt, ops, viz;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    for(int i = 2; i * i <= 100000; i++)
        if(!cr[i])
        {
            for(int j = i * i; j <= 100000; j += i)
                cr[j] = 1;
        }
    for(int i = 2; i <= 100000; i++)
        if(!cr[i])
            primes.push_back(i);


    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        LL x, aux;
        scanf("%lld", &x);
        aux = x;

        LL nmb = 1;
        LL opos = 1;

        for(int i = 0; i < primes.size() && 1LL * primes[i] * primes[i] * primes[i] <= aux && aux > 1; i++)
        {
            LL qube = 1LL * primes[i] * primes[i] * primes[i];
            while(aux % qube == 0)
                aux /= qube;
        }

        nmb = aux;

        //bases.clear();
        for(int i = 0; i < primes.size() && 1LL * primes[i] * primes[i] * primes[i] <= aux && aux > 1; i++)
        {
            int e = 0;
            while(aux % primes[i] == 0)
            {
                aux /= primes[i];
                e++;
            }
            if(e > 0)
            {
                //bases.push_back( primes[i] );
                e %= 3;
                if(e == 1)  opos *= 1LL * primes[i] * primes[i];
                if(e == 2)  opos *= primes[i];
            }
        }

        if(aux > 1)
        {
            //bases.push_back(aux);
            LL rad = sqrt(aux);
            if(rad * rad == aux)
                opos *= rad;
            else
                opos *= 1LL * aux * aux;
        }

        cnt[nmb]++;
        cnt[opos];
        ops[nmb] = opos;
        ops[opos] = nmb;
    }

    int ans = 0;
    if(cnt[1] > 0)  ans++;
    viz[1] = 1;
    for(auto pr: cnt)
    {
        if(viz.count(pr.first)) continue;
        ans += max(pr.second, cnt[ ops[pr.first] ]);
        viz[pr.first] = viz[ ops[pr.first] ] = 1;
    }

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

    return 0;
}


Measured memory_bytes: 37888
N = int(input())
print(0)
while True:
    x = input().strip()
    if x=="Vacant":break
    high = N
    low = 0
    while high-low>1:
        mid = (high+low)//2
        print(mid)
        y = input().strip()
        if x=="Vacant":break
        if (mid%2==0 and y==x) or (mid%2==1 and y!=x):
            low = mid
        else:
            high = mid

Measured memory_bytes: 38852
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
//
//public class atcoder0221_C{
public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> X = new ArrayList<Integer>();
		for(int i=0;i<N;i++) {
			X.add(scan.nextInt());
		}

		int i = 0;
		int sum = 0;
		for(int tmp:X) {
			sum = sum+tmp;
			i++;
		}

		int av = sum/i;
		int av2 = av;

		if(sum%i>0) {
			av2 = av++;
		}
		int result = 0;
		int result2 = 0;
		//
		//		if(i>1) {
		for(int tmp2:X) {
			result=result+(tmp2-av)*(tmp2-av);
		}

		for(int tmp3:X) {
			result2=result2+(tmp3-av2)*(tmp3-av2);
		}
		if(result>result2) {
			result = result2;
		}
		//			if(result==0) {
		//				result = av;
		//			}
		//		}else {
		//			result=av;
		//		}
		System.out.println(result);
	}
}



Measured memory_bytes: 21588
import math
N = int(input())
 
i = math.floor(math.sqrt(2*N))
while i * (i+1) // 2 - N < 0:
  i += 1

x = i * (i+1) // 2 - N
for j in range(1, i+1):
  if j != x:
	  print(j)


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

int main(void){
    int n,l;
    cin >> n >> l;
    list<string> dict;
    for (size_t i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        dict.push_back(move(s));
    }
    dict.sort();
    for(auto var : dict)cout << var;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]
heapq.heapify(lst)
r = []
heapq.heapify(r)
ans = 0
d = 1

while True:
    while True:
        if len(lst) != 0:
            p_lst = heapq.heappop(lst)
            if p_lst[0] <= d:
                heapq.heappush(r, - p_lst[1])
            else:
                heapq.heappush(lst, p_lst)
                break
        else:
            break
    if len(r) != 0:
        ans += - heapq.heappop(r)
    d += 1
    if d > m:
        print(ans)
        exit()



Measured memory_bytes: 27880
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();

        for (int i = 0; i < n; i++) {
            if (s.charAt(i) != s.charAt(n - i - 1)) {
                System.out.println("No");
                return;
            }
        }

        String s2 = s.substring(0, n / 2);
//        debug(s2);
        int n2 = s2.length();
        for (int i = 0; i < n2; i++) {
            if (s2.charAt(i) != s2.charAt(n2 - i - 1)) {
                System.out.println("No");
                return;
            }
        }

        String s3 = s.substring(n / 2 + 1, n);
//        debug(s3);
        int n3 = s3.length();
        for (int i = 0; i < n3; i++) {
            if (s3.charAt(i) != s3.charAt(n3 - i - 1)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21844
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(50): a+=[a[i]*2+3]; p+=[p[i]*2+1]
def f(n,x):
  return int(x>0) if n<1 else p[n-1]+1+f(n-1,x-2-a[n-1]) if x>a[n]//2 else f(n-1,x-1)
print(f(n,x))

Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define int int64_t

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

template<typename STL> inline void print_STL(STL c, string ab = ""){
	cout << ab << '\n';
	for(auto t : c) cout << t << ' '; cout << '\n';}

template<typename VEC> inline void import_VEC(VEC& c, int n){
	typename VEC::value_type tmp;
	for(int i = 0; i < n; ++i){	cin >> tmp; c.push_back(tmp);} }

#define SPRE(x) setprecision(x) // 精度を指定

signed main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string ans;
	int dx = 0;
	int dy = 0;
	ans+='U';
	dx = (tx-1)-sx;
	dy = ty - (sy+1);
	REP(i,0,dy)
		ans+='U';
	REP(i,0,dx)
		ans+='R';
	ans+='R';

	ans += 'D';
	dx = tx - (sx+1);
	dy = ty-1 - sy;
	REP(i,0,dy)
		ans+='D';
	REP(i,0,dx)
		ans+='L';
	ans+='L';

	ans+='L';
	dx = tx - (sx - 1);
	dy = ty + 1 - sy;
	REP(i,0,dy)
		ans+='U';
	REP(i,0,dx)
		ans+='R';
	ans+='D';

	ans+='R';
	dx = tx + 1 - sx;
	dy = ty - (sy-1);
	REP(i,0,dy)
		ans+='D';
	REP(i,0,dx)
		ans+='L';
	ans+='U';

	cout << ans << '\n';

}



Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int a, b, c;

	cin >> a >> b >> c;

	int ans = 0;
	if (b >= c){
		ans = c + b;
	} else {
		ans = min(c, a + b + 1) + b;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(void) {
    int n;
    string s;
    cin >> n >> s;
    int left = 0;
    int right = 0;

    string s_temp = s;
    string temp;

    if (s.length() == 1) {
        cout << "()" << endl; 
        return 0;
    }

    while (1) {
        if (s_temp == "") {
            break; 
        }
        temp = s_temp;
        string new_str = "";
        for (int i = 0; i < temp.length() - 1; i++) {
            if (temp[i] == '(' && temp[i + 1] == ')') {
                temp[i] = '#';
                temp[i + 1] = '#';
            }
        }
        for (int i = 0; i < temp.length(); i++) {
            if (temp[i] != '#') {
                new_str += temp[i]; 
            }
        }
        if (s_temp == new_str) {
            break; 
        } else {
            s_temp = new_str;
        }
    }

    for (int i = 0; i < s_temp.length(); i++) {
        if (s_temp[i] == '(') {
            left++; 
        } else {
            right++;
        }
    }

    for (int i = 0; i < right; i++) {
        cout << '(';
    }
    cout << s;
    for (int i = 0; i < left; i++) {
        cout << ')';
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll f(ll b, ll n){
    if(n<b) return n;
    else return f(b,n/b)+n%b;
}

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    ll n, s;
    cin >> n >> s;
    vector<ll> d = divisor(n-s);
    d.push_back(n);
    SORT(d);
    for(auto i : d){
        if(f(i+1,n)==s){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	static bool cards[4][13];
	const int SPADE = 0;
	const int HEART = 1;
	const int DIA = 3;
	const int CLUB = 2;
	int n, suit, rank;
	char cSuit;

	scanf("%d\n", &n);

	for (int i = 0; i < n; i++) {
		scanf("%c %d\n", &cSuit, &rank);
		switch (cSuit) {
			case 'S':
				suit = SPADE;
				break;
			case 'H':
				suit = HEART;
				break;
			case 'D':
				suit = DIA;
				break;
			case 'C':
				suit = CLUB;
				break;
			default:
				break;
		}
		cards[suit][rank - 1] = true;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0;j < 13;j++) {
if (!cards[i][j]) {
			switch (i) {
				case SPADE:
					cSuit = 'S';
					break;
				case HEART:
					cSuit = 'H';
					break;
				case DIA:
					cSuit = 'D';
					break;
				case CLUB:
					cSuit = 'C';
					break;
				default:
					break;
			}
			rank = j+1;
			printf("%c %d\n", cSuit, rank);
		}
		
		}
	}
	return 0;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

int main(){
    int N, M; cin >> N >> M;
    vector<int> s(N+1), t(M+1);
    for(int i=1; i<=N; ++i) cin >> s[i];
    for(int i=1; i<=M; ++i) cin >> t[i];

    vector<vector<ll>> a(2020, vector<ll>(2020, 0));
    vector<vector<ll>> sum(2020, vector<ll>(2020, 0));

    for(int i=1; i<=N; ++i){
        for(int j=1; j<=M; ++j){
            if(s[i] == t[j]){
                a[i][j] = sum[i-1][j-1]+1;
                a[i][j] %= mod;
            }
            sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j]+mod;
            sum[i][j] %= mod;
        }
    }

    cout << sum[N][M]+1 << endl;

    return 0;
}

Measured memory_bytes: 64256
import numpy as np
import copy

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

#買い0_売り1
trigger = 0

As_seiri = []

tmp = 0
for i in range(N-1):
    if(As[i] < As[i+1] and trigger == 0):
        As_seiri.append(As[i])
        trigger = 1
        continue

    elif(As[i] > As[i+1] and trigger == 1):
        As_seiri.append(As[i])
        trigger = 0
        continue

#print(As_seiri, trigger)

if(len(As_seiri) == 0):
    print("1000")
    exit()


money = 1000
kabu = 0

for A in As_seiri:
    if(kabu == 0):
        kabu = money // A
        money = money - kabu * A
    
    else:
        money = money + (kabu * A)
        kabu = 0

print(money + kabu * As[-1])

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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(string S) {
    reverse(all(S));
    S += '0';
    vvi dp(S.size() + 1, vi(2, inf));
    dp[0][0] = 0;
    rep(i, S.size()) rep(j, 2) {
        int v = S[i] - '0';
        v += j;
        rep(a, 10) {
            int ni = i + 1, nj = 0;
            int b = a - v;
            if (b < 0) {
                nj = 1;
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
        }
    }
    cout << dp[S.size()][0] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 ;
    cin >> num1 >> num2 ;
    cout << round((num1 + num2) / 2.0 ) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k, n, x, y;
    cin >> k >> n;
    unordered_map<int, bool> a;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a[x] = true;
    }
    x = k;
    y = k;
    if (a.find(k) == a.end())
    {
        cout << k;
    }
    else
    {
        while (1)
        {
            x--;
            y++;
            if (a.find(x) == a.end())
            {
                cout << x;
                break;
            }
            if (a.find(y) == a.end())
            {
                cout << y;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3516
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    int ans=0;
    int n=s.size();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-1-i]) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
array = [int(input()) - 1 for _ in range(n)]

count = 0
index = 0

while count < n:
  count += 1
  if array[index] == 1:
    break
  else:
    index = array[index]

if count != n:
  print(count)
else:
  print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    map<int,int> A;
    rep(i,N) {
        int a; cin >> a;
        A.insert({a,i});
    }
    for (auto x : A) {
        cout << x.second + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, L;
  cin >> N >> L;
  int taste;
  for(int i = 1; i <= N; i++){
    taste += L + i - 1;
  }
  vector<int> tst(N);
  for(int i = 1; i <= N; i++)
    tst.at(i-1) = L + i - 1;
  int absmin = 10000;
  int negative = 0;
  for(int i = 0; i < N; i++){
    if(abs(tst.at(i) < absmin)){
      if(abs(tst.at(i) < absmin) && tst.at(i) < 0){
        absmin = abs(tst.at(i));
        negative = 1;
      }
      else
        absmin = abs(tst.at(i));
    }
  }
  if(negative)
    cout << taste + absmin << endl;
  else
    cout << taste - absmin << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = a % 10
B = b % 10
C = c % 10
D = d % 10
E = e % 10

if A == 0:
    A = 10
if B == 0:
    B = 10
if C == 0:
    C = 10
if D == 0:
    D = 10
if E ==0:
    E = 10

MIN = min(A,B,C,D,E)

Af = (a - A) + 10
Bf = (b - B) + 10
Cf = (c - C) + 10
Df = (d - D) + 10
Ef = (e - E) + 10

if A == MIN:
    print( Bf + Cf + Df + Ef + a)
elif B == MIN:
    print(Af + Cf + Df + Ef + b)
elif C == MIN:
    print(Af + Bf + Df + Ef + c)
elif D == MIN:
    print(Af + Bf + Cf + Ef + d)
else:
    print(Af + Bf + Cf + Df + e)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

char G[105][105];

int main() {
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            cin >> G[i][j];

    vector<bool> height(H), width(W);
    for (int h = 0; h < H; ++h) {
        height[h] = false;
        for (int w = 0; w < W; ++w)
            if (G[h][w] == '#') {
                height[h] = true;
                break;
            }
    }
    for (int w = 0; w < W; ++w) {
        width[w] = false;
        for (int h = 0; h < H; ++h)
            if (G[h][w] == '#') {
                width[w] = true;
                break;
            }
    }

    for (int h = 0; h < H; ++h) {
        if (!height[h])
            continue;
        for (int w = 0; w < W; ++w) {
            if (width[w])
                cout << G[h][w];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
L=[0]*200000
for a in A:
  L[a-1]+=1
L=sorted(L)
ans=0
count=len(set(A))
for l in L:
  if count<=K:
    break
  if l!=0:
    ans+=l
    count-=1
    
print(ans)

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N,K;
int A[220000];
signed main() {
    cin>>N>>K;
    rep(i,N)cin>>A[i];
    for(int i=K;i<N;i++){
        if(A[i]>A[i-K])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 5196
#include <iostream>
#include <vector>


using namespace std;

int main(){

	long long int n;
	vector<long long int> a;

	cin>>n;
	long long int *dpNum;
	dpNum = new long long int[n];
	long long int *dp;
	dp = new long long int[n];
	for(int i=0;i<n;i++){
		long long int tmp;
		cin>>tmp;
		a.push_back(tmp);
		dpNum[i] = tmp;
		dp[i]=0;
	}

	long long int ans=0;
	/*dp[i]: iの箇所からどこまでandを連続で取れるか*/


	for(int i=n-1;i>=0;i--){
		//cout<<"i="<<i<<endl;
		long long int tmp=a.at(i);
		int cnt=0;
		int flag=0;
		for(int j=i;j<n-1;){
			//cout<<"j="<<j<<endl;
			if(flag==0){
				if((tmp ^ dpNum[j+1]) == (tmp+dpNum[j+1])){
					tmp ^= dpNum[j+1];
					cnt+=(dp[j+1]+1);
					//break;
					j += (dp[j+1]+1);
				}
				flag++;
			}
			else{
				if((tmp ^ a[j+1]) != (tmp+a[j+1])){
					break;
				}
				tmp ^= a[j+1];
				j++;
				cnt++;
			}
		}
		dpNum[i] = tmp;
		dp[i] = cnt;
	}

	/*学習結果表示*/
	/*
	cout<<"dp = ";
	for(int i=0;i<n;i++){
		cout<<dp[i]<<" ";
	}
	cout<<endl<< "dpNum = ";
	for(int i=0;i<n;i++){
		cout<<dpNum[i]<<" ";
	}
	cout<<endl;
	*/

	for(int i=0;i<n;i++){
		ans += dp[i]+1;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y, z;
  cin >> x >> y >> z;
  priority_queue <int> pq;
  pq.push(abs(x-y));
  pq.push(abs(y-z));
  pq.push(abs(z-x));
  pq.pop();
  int ans = pq.top();
  pq.pop();
  ans += pq.top();
  cout << ans << endl;
}

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

fun solve(K: Long, X: Long){
    (X-K+1 until X+K).joinToString(separator=" ").let{ println(it) }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val K = sc.next().toLong()
    val X = sc.next().toLong()
    solve(K, X)
}



Measured memory_bytes: 31736
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;

long double tx,ty;
int n;
long double x[1005],y[1005],r[1005];
bool vis[1005];
long double dis[1005];

long double d(int p,int q){return max((long double)0,sqrt((x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]))-r[p]-r[q]);}

int main(){
	cin>>x[0]>>y[0]>>tx>>ty;
	scanf("%d",&n); x[n+1]=tx, y[n+1]=ty;
	F(i,1,n) cin>>x[i]>>y[i]>>r[i];
	F(i,1,n+2) dis[i]=1e20;
	int now=0; vis[0]=1;
	F(k,1,n+2){
		F(i,1,n+1) dis[i]=min(dis[i],dis[now]+d(now,i));
		int nxt=n+2;
		F(i,1,n+1) if(!vis[i]&&dis[nxt]>dis[i]) nxt=i;
		vis[nxt]=1;
		now=nxt;
	}
	printf("%.15lf",(double)dis[n+1]);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D, X[10][10];
    cin >> N >> D;
    REP(i, N) {
        REP(j, D) {
            cin >> X[i][j];
        }
    }
    int res = 0;
    REP(i, N - 1) {
        FOR(j, i + 1, N, 1) {
            int sum = 0;
            REP(k, D) {
                int d = X[i][k] - X[j][k];
                sum += d * d;
            }
            int sq = sqrt(sum);
            if (sum == sq * sq) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int k;
    cin >> k;
    for(double i=1; i<=k ; i++){
        double sum =(i*360)/k;
        int sumInt = (i*360)/k;
        if(sumInt - sum == 0) {
            cout << sum;
            break;
        }
    }
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

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

    int a = 1;
    int b = n-1;
    int min_sum_digits = 100000000;
    while(a <= b) {
        int tmp_sum_digits = sum_digits(a) + sum_digits(b);
        if(min_sum_digits > tmp_sum_digits) {
            min_sum_digits = tmp_sum_digits;
        }
        a++;
        b--;
    }
    cout << min_sum_digits << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}
// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10;
        rtn += tmp;
        num /= 10;
    } 
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



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

int main() {
  int n, i, j, k, ans;
  scanf("%d",&n);
  ans = n;
  for(k=1;k<n/2+1;k++) {
    int count = 0;
    i = k;
    j = n-k;
    while(i>0) {
      count += i%10;
      i = i/10;
    }
    while(j>0) {
      count += j%10;
      j = j/10;
    }
    if(ans > count) {
      ans = count;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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


int main() {
	unordered_map<string, int> m;
	m["AC"] = 0;
	m["WA"] = 0;
	m["TLE"] = 0;
	m["RE"] = 0;
	int n;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		m[s]++;
	}
	string a[] = {"AC" , "WA" , "TLE" , "RE"};
	for (int i = 0; i < 4; i++) {
		cout << a[i] << " x " << m[a[i]] << endl;
	}
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n;
	cin >> n;
	std::vector<int> h(n);
	rep(i,n) cin >> h[i];

	bool flag=true;
	rep(i,n-1){
		if(h[i] == h[i+1])continue;
		if(h[i] == h[i+1]+1){
			h[i+1] += 1;
			continue;
		}else if(h[i]>h[i+1]){
			flag = false;
			break;
		}
	}

	if(flag) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

  return 0;
}


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


void solve() {
  int A, B;
  scanf("%d %d", &A, &B);

  int sum = 0;
  if (B>1) {
    sum++;
  }
  if (A<B) {
    if ((B-A)%(A-1) ==0) {
      sum += (B-A)/(A-1);
    } else {
      sum += (B-A)/(A-1)+1;
    }
  }

  cout << sum << "\n";
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int L, R, mod_min = 1000000;
	int c = 0;

	cin >> L >> R;

	for (int i = L; i < R; i++)
	{
		for (int j = i + 1; j < R + 1; j++)
		{
			if (c >= 2039190)break;

			if (((i % 2019)*(j % 2019)) % 2019 < mod_min)
			{
				mod_min = ((i % 2019)*(j % 2019)) % 2019;
			}
			c++;
		}
	}

	cout << mod_min << endl;

	return 0;
}

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

c=[0]*9
for i in range(N):
    c[min(8,a[i]//400)]+=1
cnt=0
for i in range(8):
    if c[i]>0:
        cnt+=1
if cnt==0:
    cnt=1
    c[8]-=1
minimum=cnt
maximum=cnt+c[8]
print(minimum,maximum)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, m; cin >> n >> m;
  vll x(n), y(m);
  REP(i, n) cin >> x[i];
  REP(i, m) cin >> y[i];
  ll xsum=0, ysum=0;
  REP(i, n) {
    xsum += i*x[i] - (n-i-1)*x[i];
    if (xsum >= MOD) xsum %= MOD;
    else if (xsum < 0) while(xsum<0) xsum += MOD;
  }
  cout << endl;
  REP(i, m) {
    ysum += i*y[i] - (m-i-1)*y[i];
    if (ysum >= MOD) ysum %= MOD;
    else if (ysum < 0) while(ysum<0) ysum += MOD;
  }
  cout << xsum * ysum % MOD << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i, N) cin >> L[i];
  int ans = 1;
  int d = 0;
  for(int i = 0; i < N; i++) {
    d += L[i];
    if(d > X) { break; }
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<cmath>
#define int long long int
#define inf 2001
int memo[1001][1001];
int function(char mat[1001][1001],int i,int j,int n,int m,bool visited[1001][1001])
{
	if(i<0||i>=n||j<0||j>=m)
	    return inf;
	if(visited[i][j]==true)
	   return inf;
	if(mat[i][j]=='#')
	   return 0;
	else
	{
		visited[i][j]=true;
		int x=1+function(mat,i+1,j,n,m,visited);
		int y=1+function(mat,i-1,j,n,m,visited);
		int z=1+function(mat,i,j-1,n,m,visited);
		int t=1+function(mat,i,j+1,n,m,visited);
		memo[i][j]=min(memo[i][j],min(min(x,y),min(z,t)));
		return memo[i][j];
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


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

    if (n == 2) {
        if (x == 2) {
            printf("Yes\n 1 2 3\n");
            ret();
        } else {
            cout << "No" << endl;
            ret();
        }
    }

    int ma = 2 * n - 1;
    if (x == 1 || x == ma) {
        cout << "No" << endl;
        ret();
    }

    vector<int> ans(ma, 0);
    ans[n - 1] = x;

    set<int> a;
    rep(i, ma) a.insert(i + 1);
    a.erase(x);

    if (x > n) {
        ans[n - 2] = x - 1;
        ans[n] = x + 1;
        ans[n + 1] = x - 2;

        a.erase(x - 1);
        a.erase(x + 1);
        a.erase(x - 2);

    } else {
        ans[n - 2] = x + 1;
        ans[n] = x - 1;
        ans[n + 1] = x + 2;

        a.erase(x + 1);
        a.erase(x - 1);
        a.erase(x + 2);
    }

    rep(i, ma) if (ans[i] == 0) {
            int k = *a.begin();
            ans[i] = k;
            a.erase(k);
        }

    cout << "Yes" << endl;
    for (int i : ans) cout << i << endl;

}


Measured memory_bytes: 12928
N = int(input())
tree = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1); tree[b-1].append(a-1)


def calc_dist(node):
  dist = [0]*N
  d = [[node, -1]]
  while d:
    node, par = d.pop()
    children = tree[node]
    for child in children:
      if child == par:
        continue
      dist[child] = dist[node] + 1
      d.append([child, node])
  return dist

# 木の直径を求める
dist = calc_dist(0)
end = 0
max_dist = 0
for i, di in enumerate(dist):
  if max_dist < di:
    max_dist = di
    end = i

dist = calc_dist(end)
R = max(dist) + 1
if (R+1) % 3 == 0:
  print('Second')
else:
  print('First')

Measured memory_bytes: 64440