akhauriyash/Code-Regression huggingface dataset:
import collections
 
input()
p = list(map(int, input().split()))
map1 = collections.defaultdict(lambda:0)
map2 = collections.defaultdict(lambda:0)
 
for i, v in enumerate(p):
  map1[i+v] += 1
  map2[i-v] += 1

ans = 0
for i in map1:
  if i in map2:
    ans += map1[i] * map2[i]

print(ans)

Measured memory_bytes: 57656
#include <bits/stdc++.h>
using namespace std;
vector<int> s1;
vector<int> s2;

bool isSumSame(){
  int t_sum = 0, h_sum = 0;
  for(int i=0; i < s1.size(); i++){
    t_sum += s1[i];
  }
  for(int i=0; i < s2.size(); i++){
    h_sum += s2[i];
  }
  return t_sum == h_sum;
}

int main(void){
  int n, m;
  while(cin >> n >> m, n | m){
    int card_sum = 1e5;
    int t2h, h2t;
    s1.clear(); s2.clear();
    
    for(int i=0; i < n; i++){
      int tmp; cin >> tmp;
      s1.push_back(tmp);
    }
    for(int i=0; i < m; i++){
      int tmp; cin >> tmp;
      s2.push_back(tmp);
    }
    
    for(int i=0; i < n; i++){
      for(int j=0; j < m; j++){
	int tmp;
	tmp = s1[i];
	s1[i] = s2[j];
	s2[j] = tmp;
	if(isSumSame()){
	  if(card_sum > s1[i] + s2[j]){
	    t2h = s2[j]; h2t = s1[i];
	    card_sum = s1[i] + s2[j];
	  }
	}
	tmp = s1[i];
	s1[i] = s2[j];
	s2[j] = tmp;
      }
    }
    
    if(card_sum == 1e5) cout << -1 << endl;
    else                cout << t2h  << " " << h2t << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N =nextInt();
		int M =nextInt();

		long ans =((M*19)+(N-M))*(long)Math.pow(2, M);



		System.out.println(ans+"00");
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 303;
const LL INF = 1e18 + 7;

int n;
LL T[N][N], d[N][N];

vector < pair < int, PII > > V;

int main()
{
    _upgrade
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> T[i][j];
            if(i != j) V.push_back({T[i][j], {i, j}}), d[i][j] = INF;
        }
    }
    sort(all(V));
    bool ok = 1;
    LL sm = 0;
    for(auto x: V)
    {
        int a = x.second.first, b = x.second.second; LL c = x.first;
        if(d[a][b] < c) {ok = 0; break;}
        if(d[a][b] == c) continue;
        sm += c; d[a][b] = d[b][a] = c;
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                d[i][j] = min({d[i][j], d[i][a] + d[a][b] + d[b][j], d[i][b] + d[b][a] + d[a][j]});
    }
    if(!ok) cout << "-1\n";
    else cout << sm << "\n";
    return 0;
}


Measured memory_bytes: 2936
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, A[3];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[0] >> A[1] >> A[2];
		sort(A, A + 3);
		if (A[0] * A[0] + A[1] * A[1] == A[2] * A[2]) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3072
import numpy as np


def round_up_mean(posi_int_a, posi_int_b):
    val_mean = np.array([posi_int_a, posi_int_b]).mean()
    val_ceiled = int(np.ceil(val_mean))
    print(val_ceiled)


a, b = [int(i) for i in input().split()]
round_up_mean(a, b)


Measured memory_bytes: 14460
include Math

while line = gets do
	v0 = line.to_f

	n = 1
	loop {
		y = 5.0 * n - 5.0
		t = sqrt(y/4.9)
		v = 9.8 * t
		
		if v >= v0 then
			break
		end
		
		n += 1
	}
	puts n
end

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

struct TCoordinate
{
	float x;
	float y;
};

struct TLine
{
	TCoordinate StartPoint;
	TCoordinate EndPoint;
	float GetInclination()
	{
		return (EndPoint.y - StartPoint.y) / (EndPoint.x - StartPoint.x);
	}
};

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TLine AB, CD;
		cin >> AB.StartPoint.x >> AB.StartPoint.y
		    >> AB.EndPoint.x   >> AB.EndPoint.y
		    >> CD.StartPoint.x >> CD.StartPoint.y
		    >> CD.EndPoint.x   >> CD.EndPoint.y;
		if(AB.GetInclination() == CD.GetInclination()){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0043
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var Nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[] result = new int[N];

            for (int i = 0; i < N; i++)
            {
                result[Nums[i] - 1] = i + 1;
            }

            for (int i = 0; i < result.Length; i++)
            {
                Console.Write(result[i] + " ");
            }

            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 39208
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;

using P = pair<int, int>;
P p[200000];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> p[i].second >> p[i].first;
	}

	ARY_SORT(p, N);

	int sum = 0;
	REP(i, N)
	{
		sum += p[i].second;
		if (sum > p[i].first)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}











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

int main()
{
    long a, b, k;
    cin >> a >> b >> k;
    long ans_a, ans_b;

    ans_a = max(a - k, (long)0);
    ans_b = max(b - max(k - a, (long)0), (long)0);

    cout << ans_a;
    cout << ' ';
    cout << ans_b << endl;
    return 0;
}

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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
	int n;
	cin>>n;
	int c=7;
	int i;
	for(i=1;i<=n;i++){
		if(c%n==0){
			break;
		}
		else{
			c=(c*10+7)%n;
		}
	}
	if(i<=n){
		cout<<i<<endl;
	}
	else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 3616
//#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
long long n,ans1,f[100001],a[100001];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
   	cin>>n;
   	for(int i=1;i<=n;i++)
   		cin>>a[i];
    for(int i=n-1;i>=1;i--){
        if(a[i]>=a[i+1])f[i]=f[i+1]+1;
        ans1=max(ans1,f[i]); 
    }
    cout<<ans1;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A1 = getint();
	int B = getint();
	A1 -= B;
	int A2 = A1 - 1;
	ll H[100000];
	rep(i, N) *(H + i) = getint();

	int L = 0, R = 1e9;

	while (L + 1 != R) {
		ll half = (L + R) / 2;
		ll damage = B * half - A2;
		ll cnt = 0;
		rep(i, N) {
			ll kari = *(H + i) - damage;
			if (kari > 0) {
				cnt += kari / A1;
			}
		}
		if (half >= cnt) R = half;
		else L = half;
	}

	co(R);

	Would you please return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(len([ i for i in range(A,B+1) if str(i) == str(i)[::-1] ]))



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
        int[] c = new int[n-1];
		
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
		    b[i] = sc.nextInt();
		}
		for(int i = 0; i < n - 1; i++){
		    c[i] = sc.nextInt();
		}

		// 計算
		int result = 0;
		int pre = -1;

		for(int i = 0; i < n; i++){
		    result = result + b[a[i]-1];
		    if(a[i] == pre + 1) result = result + c[pre - 1];
		    pre = a[i];
		    //System.out.println("pre " + pre + " res " + result);
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000

struct Set { int value, cnt_r; };
Set L[MAX/2 + 2], R[MAX/2 + 2];

void merge(Set A[], int left, int right, int mid){
    int n1 = mid - left;
    int n2 = right - mid;
    int idx_l, idx_r;
    
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = SENTINEL;
    R[n2].value = SENTINEL;
    
    idx_l = 0;
    idx_r = 0;
    for(int i = left; i < right; i++){
        if(L[idx_l].value <= R[idx_r].value){
            A[i] = L[idx_l];
            idx_l++;
        }
        else{
            A[i] = R[idx_r];
            A[i].cnt_r += n1 - idx_l;
            idx_r++;
        }
    }
}

void mergeSort(Set A[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right ) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, right, mid);
    }
}

int main(){
    int n;
    long long reverse;
    Set A[MAX];
    reverse = 0;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i].value;
        A[i].cnt_r = 0;
    }
    
    mergeSort(A, 0, n);
    
    for(int i = 0; i < n; i++){
        reverse += A[i].cnt_r;
    }
    
    cout << reverse << endl;
    
    return 0;
}




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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    LL a,b,c;
    cin >> a >> b >> c;
    LL count = 0;
    if (a == b and b == c) {
        if (a % 2 == 0) {
            cout << -1 << endl;
        }
        else {
            cout << 0 << endl;
        }
        return 0;
    }
    while (a%2 == 0 and b%2 == 0 and c%2 == 0) {
        LL d,e,f;
        d = b/2+c/2;
        e = a/2+c/2;
        f = a/2+b/2;
        a = d,b = e,c = f;
        count++;
    }
    cout << count << endl;
    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MOD = 1000000007;

inline void add(int &a, int b) {
    a += b;
    if (a >= MOD) {
     a -= MOD;
 }
}

inline void sub(int &a, int b) {
    a -= b;
    if (a < 0) {
     a += MOD;
 }
}

inline int mul(int a, int b) {
    return (long long) a * b % MOD;
}

inline int power(int a, int b) {
    int res = 1;

    while (b > 0) {
        if (b & 1) res = mul(res, a);
        b >>= 1;
        a = mul(a, a);
    }

    return res;
}

inline int inverse(int x) {
    return power(x, MOD - 2);
}

const int MK = 10010;

int dp[MK][100][2];
int D;

int main() {
    string k; cin >> k;
    dp[0][0][0] = 1;
    int D; cin >> D;

    int sz = k.size();
    rep(i, sz) {
        int c = k[i] - '0';

        //smaller
        rep(j, D) {
            rep(k, 10) {
                add(dp[i+1][(j+k)%D][1], dp[i][j][1]);
            }
        }

        rep(j, D) {
            for (int k = 0; k <= c; ++k) {
                add(dp[i+1][(j+k)%D][(k < c)], dp[i][j][0]);
            }
        }
    }

    int ans = MOD - 1;
    add(ans, dp[sz][0][0]);
    add(ans, dp[sz][0][1]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
// AOJ 2275: Fox Number
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define MAX  707106			// sqrt(10^12/2)
char tbl[MAX+1];
//int prime[79000] = { 
int sz;						// max sz = 57084, prime[0] = 2, prime[57083] = 707099
int prime[57100] = {  		// prime[146] = 853, prime[147] = 857
  2, 3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97,101,103,107,109,113, 
127,131,137,139,149,151,157,163,167,173,
179,181,191,193,197,199,211,223,227,229, 
233,239,241,251,257,263,269,271,277,281, 
283,293,307,311,313,317,331,337,347,349, 
353,359,367,373,379,383,389,397,401,409, 
419,421,431,433,439,443,449,457,461,463, 
467,479,487,491,499,503,509,521,523,541, 
547,557,563,569,571,577,587,593,599,601, 
607,613,617,619,631,641,643,647,653,659, 
661,673,677,683,691,701,709,719,727,733, 
739,743,751,757,761,769,773,787,797,809, 
811,821,823,827,829,839,853 };

void sieve()
{
	int i, j, k;

	for (i = 1; i < 147; i++) {
		k = prime[i];
		for (j = k*k; j < MAX; j += k) tbl[j] = 1;
	}
	for (sz = 146, i = 853; i <= MAX; i += 2) if (!tbl[i]) prime[sz++] = i;
//	printf("sz %d, prime[%d]=%d\n", sz, sz-1, prime[sz-1]);
//	        sz 57084, prime[57083]=707099
}

int base[1000002];
int idx [1000002];
long long pp[70];

int bsch(int x)
{
	int m, l = 0, r = sz;

    while (l < r) {
        m = (l + r) >> 1;
		if (prime[m] == x) return m;
        if (prime[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int i, k, p, ans;
	long long A, B, a, b, j, ll, rr;

	sieve();

	scanf("%lld%lld", &A, &B);
	a = A-B, b = A+B;
	if (b <= 1) { puts("0"); return 0; }
	if (a <= 1) a = 2;

	sz = bsch((int)sqrt((double)(b >> 1)));

	memset(idx, 1, sizeof(idx));
	for (i = 0; i <= sz; i++) {
		p = prime[i];
		for (k = 1, j = p; j <= b; j *= p) pp[k++] = j;
		while (--k) {
			j = pp[k], ll = j*(1+(a-1)/j), rr = j*(b/j);
			for (; ll <= rr; ll += j) {
				int x = (int)(ll-a);
				if (!idx[x] || base[x] == p) continue;
				if (idx[x] < k) idx[x] = 0;
				else base[x] = p, idx[x] = k;
			}
		}
	}

	ans = 0, i = (int)(b-a+1); while (i--) if (idx[i]) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 1000000007;
#define ff(i,n) for(i=0;i<n;i++) 
void dfs(ll i,ll vis[],ll p[],vector<vector<ll> > &adj,ll par)
{
	vis[i] = 1;
	p[i] = par;
	ll j;
	for(j=0;j<adj[i].size();j++)
	{
		if(vis[adj[i][j]]==0)
		{
			dfs(adj[i][j],vis,p,adj,i);
		}
	}
}
int main()
{
	ll i,j,n,k;
	cin>>n;
	ll arr[n+1];
	ff(i,n)
	   cin>>arr[i];
	arr[n] = -1;   
	ll money = 1000,stock=0;
	for(i=0;i<n;i++)
	{
		if(arr[i]>=arr[i+1])
			continue;
		for(j=i+1;j<n;j++)
		{
			if(arr[j]>arr[j+1])
			{
				money = ((money/arr[i])*arr[j] + money%arr[i]);
				i = j;
				break;
			}
		}	
	}     
	cout<<money<<endl;
	return 0;
} 

Measured memory_bytes: 3628
#include <cstdio>

int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    char a[h][w];
    bool b[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("\n%c",&a[i][j]);
            b[i][j] = true;
        }
    }

    int H = h,W = w;

    int count_a_r;
    int count_b_r;
    for(int j = 0; j < h; j++){
        count_a_r = 0;
        count_b_r = 0;
        for(int k = 0; k < w; k++){
            if(b[j][k] == true){
                count_b_r++;
                if(a[j][k] == '.'){
                    count_a_r++;
                    continue;
                }else if(a[j][k] == '#'){
                    break;
                }
            }
        }
        if(count_a_r == count_b_r){
            for(int l = 0; l < w; l++){
                b[j][l] = false;
            }
            H--;
        }
    }

    int count_a_c;
    int count_b_c;
    for(int j = 0; j < w; j++){
        count_a_c = 0;
        count_b_c = 0;
        for(int k = 0; k < h; k++){
            if(b[k][j] == true){
                count_b_c++;
                if(a[k][j] == '.'){
                    count_a_c++;
                    continue;
                }else if(a[k][j] == '#'){
                    break;
                }
            }
        }
        if(count_a_c == count_b_c){
            for(int l = 0; l < h; l++){
                b[l][j] = false;
            }
            W--;
        }
    }

    int count_w = 0;
    for(int i = 0; i < h; i++){
        count_w = 0;
        for(int j = 0; j < w; j++){
            if(b[i][j]){
                printf("%c",a[i][j]);
                count_w++;
            }
            if(count_w == W){
                printf("\n");
                break;
            }
        }
    }

    return 0;
}

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

int main(int argc, char const *argv[])
{
    int radius;
    cin >> radius;

    float pi = 3.141592;
    float area = radius * radius * pi;
    float ans = area / pi;

    cout << (int)ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n;

int beki(int a, int b){
	int c = 1;
	for(int i = 0; i < b; i++){
		c *= a;
	}
	return c;
}

int main(){
	cin >> n;
	int ans = 1;
	for(int i = 2; i < n; i++){
		for(int j = 2; beki(i,j) <= n; j++){
			if(beki(i,j) <= n) ans = max(ans, beki(i,j));
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;


int main() {
	int m, f, r;
	char ch;
	while (true)
	{
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)
			break;
		else if (m == -1 || f == -1 || m + f < 30)
			ch = 'F';
		else if (m + f >= 80)
			ch = 'A';
		else if (m + f >= 65)
			ch = 'B';
		else if (m + f >= 50 || r >= 50)
			ch = 'C';
		else if (m + f >= 30)
			ch = 'D';
		cout << ch << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include<assert.h>
#include<complex.h>
#include<ctype.h>
#include<errno.h>
#include<fenv.h>
#include<float.h>
#include<inttypes.h>
#include<iso646.h>
#include<limits.h>
#include<locale.h>
#include<math.h>
#include<setjmp.h>
#include<signal.h>
#include<stdalign.h>
#include<stdarg.h>
#include<stdatomic.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdnoreturn.h>
#include<string.h>
#include<tgmath.h>
#include<time.h>


int main(){
    int X;
    int Vhund,V;
    scanf("%d",&X);
    Vhund = (int)X / 500;
    X -= Vhund * 500;
    V = (int)X / 5;
    printf("%d",Vhund*1000+V*5);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	ll N,K,sum=0;
	cin>>N>>K;

	if(K==0) sum=N*N;
	else{
		FOR(b,K+1,N+1){
			sum+=(b-K)*(N/b);
			if(N%b>=K) sum+=(N%b-K+1);
		}
	}

	print(sum);
	return 0;
}




Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    char op;
    cin>>a>>op>>b;
    switch(op)
    {
        case '+':
        cout<<a+b;
        break;
        case '-':
        cout<<a-b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;
ll ma=1000000007;
ll power(ll p,ll t){
if(t==0)
    return 1;
ll y=power(p,t/2);
y=(y*y)%ma;
if(t%2==1)
    y=(y*p)%ma;
return y;
}


int mod(int a){
if(a>=0)
    return a;
else return -a;
}



 int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,l;
cin>>n>>l;
int a[n+1];

int x=0;int ma=mod(l);
int k=1;
for(int i=1;i<=n;i++){
    a[i]=l+i-1;
    x+=a[i];
    if(ma>mod(a[i])){
        ma=mod(a[i]);
        k=i;
    }


}
cout<<x-a[k]<<endl;

}











Measured memory_bytes: 256
program test
  implicit none
  integer :: a,b,k
  
  read ( unit = *, fmt = * ) a, b

  if ( mod ( a + b, 2 ) == 0 ) then

     k = ( a + b ) / 2

     write ( unit = *, fmt = '(i0)')  k

  else

    write ( unit = *, fmt = '(a10)') 'IMPOSSIBLE'

  end if
  
  stop
  
end program test


Measured memory_bytes: 640
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

enum mod = 1_000_000_007L;


bool check(int N, int k) {
    return k * (k - 1) / 2 == N;
}

void main() {
    int N;
    scan(N);

    int k = 1;
    while (k * (k - 1) / 2 < N) {
        k++;
    }

    bool can = check(N, k);

    if (!can) {
        writeln("No");
        return;
    }

    writeln("Yes");
    writeln(k);

    auto ans = new int[][](k, 0);
    int num = 1;
    foreach (i ; 0 .. k) {
        foreach (j ; i + 1 .. k) {
            ans[i] ~= num;
            ans[j] ~= num;
            num++;
        }
    }
    foreach (i ; 0 .. k) {
        writefln("%s %(%s %)", k - 1, ans[i]);
    }
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

int main() {
  string S; cin >> S;
  if ((S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) ||
      (S[0]==S[2] && S[1]==S[3] && S[0]!=S[1]) ||
      (S[0]==S[3] && S[1]==S[2] && S[0]!=S[1])) cout << "Yes";
  else cout << "No";
}

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

int main(){
  long long int a, b, c;
  
  scanf("%lld %lld %lld", &a, &b, &c);
  
  long long int haa = c - a - b;
  
  if(haa > 0 && 4 * a * b < haa * haa){
    puts("Yes");
  }
  else{
    puts("No");
  }
}


Measured memory_bytes: 128
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::BinaryHeap;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc160-E
// #[fastout]
fn main() {
    let (X, Y, a, b, c) = (read(), read(), read(), read(), read());

    let (mut p, mut q, mut r) = (BinaryHeap::new(), BinaryHeap::new(), BinaryHeap::new());

    let read_closure = |v: &mut BinaryHeap<i128>, count| {
        for _ in 0..count {
            v.push(read());
        }
    };

    read_closure(&mut p, a);
    read_closure(&mut q, b);
    read_closure(&mut r, c);

    let (mut x, mut y, mut z) = (0, 0, 0);

    let mut ans = 0;
    while x + y + z < X + Y {
        let a_max = if x == X { -1 } else { *p.peek().unwrap() };
        let b_max = if y == Y { -1 } else { *q.peek().unwrap() };
        let c_max = *r.peek().unwrap_or(&-1);

        if a_max >= b_max && a_max >= c_max {
            ans += a_max;
            x += 1;
            p.pop();
        } else if b_max >= c_max && b_max >= a_max {
            ans += b_max;
            y += 1;
            q.pop();
        } else if c_max >= a_max && c_max >= b_max {
            ans += c_max;
            z += 1;
            r.pop();
        }
    }

    println!("{}", ans);
}

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {}


Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == '0'){
      t.push_back('0');
    }
    if(s.at(i) == '1'){
      t.push_back('1');
    }
    if(s.at(i) == 'B'){
      if(t.size()==0){
      }else{
        t.pop_back();
      }
    }
  }
  cout << t << endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

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

	int ans = 0, v[n],c[n];
	FOR(i, n){
		cin >> v[i];
	}

	FOR(i, n){
		cin >> c[i];
	}

	FOR(i, n){
		if(v[i] > c[i]){
			ans += v[i]-c[i];
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1, i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n;vector<ll>v;
void input(){
    cin>>n;
    scanv(n,v);
}
void src(){
    ll sum1 = accumulate(ALL(v),0ll);
    ll sum2 = 0;
    ll min = 1e12;
    rep(i,n){
        sum1 -= v[i];
        sum2 += v[i];
        chmin(min,abs(sum1-sum2));
    }
    cout<<min;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}

}


Measured memory_bytes: 24660
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    ret = 1
    while X <= Y:
        X *= 2
        ret += 1
    ret -= 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import itertools

n = int(input())
num = list(map(int, input().split()))
per = list(itertools.permutations(num))

per.sort()
index = per.index(tuple(num))

if index != 0:
    print(' '.join(str(n) for n in per[index-1]))
print(' '.join(str(n) for n in per[index]))
if index != len(per)-1:
    print(' '.join(str(n) for n in per[index+1]))




Measured memory_bytes: 53368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = in.nextInt();
		}

		int j = 0;
		int max = 0;

		int prev = h[j++];
		while(j < h.length) {
			int c = 0;

			int current = h[j++];
			while(prev >= current && j < h.length) {
				prev = current;
				current = h[j++];
				c++;
			}

			if(j == h.length) {
				if(prev >= current)
					c++;
			}

			if(max < c)
				max = c;

			prev = current;
		}

		System.out.println(max);
		return;
	}
}


Measured memory_bytes: 48984
(N, K) = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

L = 0
H = max(A)

def feasible(M): # M: maximum length    
    S = sum([(a - 1) // M for a in A])
    #print("S = {}, K = {}".format(S, K))
    return S <= K

# assert(not feasible(L))
assert(feasible(H))

while H - L > 1:
    #print(H, L)
    M = (H + L) // 2
    if feasible(M):
        H = M
    else:
        L = M

print(H)



Measured memory_bytes: 30844
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, q, cnt = 0, maxn = 0, minn = 9999999999;
	string s, s1;
	vector<int>list(100005, 0);


	cin >> n >> q;
	cin >> s;

	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A' && s[i] == 'C') {
			cnt++;
		}

		list[i] = cnt;
	}

	vector<int>list2;

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		
		list2.push_back(list[r] - list[l]);
		//cout << list[r] - list[l] << endl;
	}
	

	for (int i = 0; i < list2.size(); i++) {
		cout << list2[i] << endl;
	}



	return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n,k;cin >> n >> k;
    vector<LL> h(n+1,0);
    for (int i = 0; i < n; i++) {
        cin >> h[i+1];
    }
    vector<vector<vector<LL>>> dp(n+2,vector<vector<LL>> (k+2,vector<LL>(n+2,LINF)));
    dp[0][0][0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            for (int l = 0; l <= i; l++) {
                dp[i+1][j+1][l] = min(dp[i+1][j+1][l], dp[i][j][l]);
                dp[i+1][j][i] = min(dp[i+1][j][i], dp[i][j][l] + max(0LL,h[i] - h[l]));
            }
        }
    }
    LL ans = LINF;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= n; j++) {
            ans = min(ans, dp[n+1][i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n;
  string str;
  cin >> n >> str;
  int cnt = 0;
  for(int i=0; i<n-2; i++){
    if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C')
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
	double n , k ;
	cin >> n >> k ;
	double ans = 0 ; 
	for(int i = 1 ; i <= n ; i++){
		if(i < k)
		ans += 1/(n*pow(2,ceil(log2(k/i)))) ;
		else{
			ans += 1.0/n ;
		}
	}
	cout <<fixed<<setprecision(15) << ans ;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;

lli fact(lli n){
	lli ret = 1;
	for(int i=2; i<=n; i++){
		ret = (ret*i)%mod;
	}
	return ret;
}

int main(){
	int m,n;
	cin >> m >> n;
	if(m==n){
		cout << (2*fact(m)*fact(n))%mod << endl;
	}else if(m==n-1 || m==n+1){
		cout << (fact(m)*fact(n))%mod << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        for (int j = i; j <= n; j++) {
            string s2 = "";
            for (int k = 0; k < n; k++) {
                if (k >= i && k < j) continue;
                s2 += s[k];
            }
            if (s2 == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n],i;
  for(i=n-1;i>=0;i--){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

map<ll,int> mp; 

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  bool b = true;
  rep(i,n) {
    ll t = a[i];
    if (mp[t]) {
      b = false;
      break;
    } else {
      mp[t]++;
    }
  }
  cout << (b ? "YES" : "NO") << endl;
}

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

Measured memory_bytes: 17088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
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 count2(ll n){
    ll a=0;
    while(n%2==0){
        a++;
        n/=2;
    }
    return a;
}
int main(void){
    ll n,m,a[100000];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]/=2;
    }
    ll count=count2(a[0]);
    bool zero=false;
    for(int i=1;i<n;i++){
        if(count!=count2(a[i])){
            zero=true;
            break;
        }
    }
    ll L=1;
    for(int i=0;i<n;i++){
        L=lcm(L,a[i]);
        if(L>m){
            zero=true;
            break;
        }
    }
    if(zero) cout<<0<<endl;
    else cout<<m/L-m/(2*L)<<endl;
}

Measured memory_bytes: 1024
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {
    ll N;
    cin>>N;
    vector<ll> P(N);
    rep(i,0,N) cin>>P[i];
    vector<ll> Q(N);
    rep(i,0,N) {
        if (i==0) Q[i] = (ll)2e5+100;
        else Q[i] = min(Q[i-1],P[i-1]);
    }
    // rep(i,0,N) {
    //     cout<<P[i]<<" "<<Q[i]<<endl;
    // }
    ll ans = 0;
    rep(i,0,N) {
        if (P[i]<=Q[i]) ans++;
    }
    cout<<ans<<endl;




   return 0;
}

Measured memory_bytes: 3328
N = int(input())
Xlist = list(map(int, input().split()))

Xlist_sorted = sorted(Xlist)
idx = (N-1) // 2
candidates = [Xlist_sorted[idx], Xlist_sorted[idx+1]]

for i in range(N):
    if Xlist[i] >= candidates[1]:
        print(candidates[0])
    else:
        print(candidates[1])


Measured memory_bytes: 26772
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;

    if(a<10 && b<10){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
using namespace std;




int main() {
	int a,b;
	cin >> a >> b;
	if(a >= 10 || b >= 10){
		cout << -1 << endl;
	}else{
		cout << a * b << endl;
	}
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
int a[100001];
vector<int> nei[100001],con,lef;
bool vis[100001];
bool cmp(int x,int y){return a[x]<a[y];}
void dfs(int x){
	con.pb(x);
	vis[x]=true;
	for(int i=0;i<sz(nei[x]);i++){
		int to=nei[x][i];
		if(vis[to])continue;
		dfs(to);
	}
}
int main(){
	int n,m,i,j;scanf("%d%d",&n,&m);
	ll tot=0;
	if(n<2*(n-m-1))return !puts("Impossible");
	if(n-m==1)return !puts("0");
	for(i=1;i<=n;i++)scanf("%d",a+i);
	for(i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);x++;y++;
		nei[x].pb(y);nei[y].pb(x);
	}
	for(i=1;i<=n;i++)if(!vis[i]){
		con.clear();
		dfs(i);
		int mn=0x7fffffff,mnid;
//		cout<<c<<". ";for(j=0;j<sz(con);j++)cout<<con[j]<<" ";puts("");
		for(j=0;j<sz(con);j++)if(a[con[j]]<mn)mn=a[con[j]],mnid=j;
		tot+=mn;
		for(j=0;j<sz(con);j++)if(j!=mnid)lef.pb(con[j]);
	}
//	cout<<sz(lef)<<"\n";
	if(n-m==2)return !printf("%lld\n",tot);
	sort(all(lef),cmp);
	for(i=0;i<n-m-2;i++)tot+=a[lef[i]];
	printf("%lld\n",tot);
	return 0;
}
/*1
7 5
1 2 3 4 5 6 7
3 0
4 0
1 2
1 3
5 6
*/
/*2
5 0
3 1 4 1 5
*/
/*3
1 0
5
*/

Measured memory_bytes: 7420
#include <stdio.h>

int main(){
  /* Max is the greatest common divisor of two natural numbers x and y*/
  int i, x, y, c, Max;
  scanf("%d %d", &x, &y);
  while(1){
    if (x % y  == 0) break;
    c = x%y;
    x = y;
    y = c;
  }
  printf("%d\n", y);
  return 0;
}

Measured memory_bytes: 592
#x = input().split()
#print (x)
#n = int(x[0])
n = int(input())

#print(n)

#p = list(map(int,x[1:]))
p = list(map(int,input().split()))

#print(p)

#print(len(p))
c = 0
#print(len(p))
#print(p)
for i in range(1,n-1):
  if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
    c += 1
      

print(c)

Measured memory_bytes: 3060
while True :
    h, w = [int(x) for x in input().split()]
    if h == w == 0 :
        break
    for i in range(h) :
        for j in range(w) :
            if (i + j)%2 == 0 :
                print('#', end = '')
            else :
                print('.', end = '')
        print()
    print()


Measured memory_bytes: 7012