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

void trace(int A[], int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N){
	int j, i, v;
	for(i = 1; i < N; i++){
		v = A[i];
		j = i-1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A, N);
	}
}

int main(){
	int N, i, j;
	int A[100];

	scanf("%d", &N);
	for( i = 0; i < N; i++ ) scanf("%d", &A[i]);

	trace(A, N);
	insertionSort(A, N);
	
	return 0;
}

Measured memory_bytes: 1032
while(1):
    try:
        alist = list(map(int, input().split()))
        blist = list(map(int, input().split()))
    except:
        break

    hit = 0
    blow = 0

    for i in range(4):
        for j in range(4):
            if alist[i] == blist[j]:
                if i == j:
                    hit += 1
                else:
                    blow += 1

    print(hit, blow)



Measured memory_bytes: 5596
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,t,e,x[100111],fr,rr=1,q[100111];
LL dp[100111],premn[100111];

int main()
{
	get3(n,e,t);
	for(int i=1;i<=n;i++)get1(x[i]);
	int cur=0;
	premn[0]=-2*x[1];
	for(int i=1;i<=n;i++)
	{
		while((x[i]-x[cur+1])*2>t)
		{
			if(fr!=rr&&q[fr]==cur)fr++;
			cur++;
		}
		if(cur)dp[i]=premn[cur-1]+2*x[i];else dp[i]=Linf;
		if(fr!=rr)dp[i]=min(dp[i],dp[q[fr]]+t);
		while(fr!=rr&&dp[q[rr-1]]>dp[i])rr--;
		q[rr++]=i;
		premn[i]=min(premn[i-1],dp[i]-2*x[i+1]);
	}
	printendl(dp[n]+e);
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
yes = True
for _ in range(N):
  t, x, y = map(int, input().split())
  margin = t - (x + y)
  if margin < 0 or margin % 2 != 0:
    yes = False
if yes:
  print("Yes")
else:
  print("No")



  
  


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3140
#include <cstdio>
#include <algorithm>
#define N 100005

int n;
int c[5];
char s[N][5], ans[N];

int main() {
    int *a = c - 'A';
    scanf("%d%d%d%d", &n, a + 'A', a + 'B', a + 'C');
    for (int i = 1; i <= n; ++i) scanf("%s", s[i]);
    for (int i = 1; i <= n; ++i)
        if (!a[s[i][0]] && !a[s[i][1]]) {
            puts("No");
            return 0;
        } else if (a[s[i][0]] < a[s[i][1]] || (a[s[i][0]] == a[s[i][1]] && i < n && (s[i][0] == s[i + 1][0] && s[i][1] != s[i + 1][1] || s[i][0] == s[i + 1][1] && s[i][1] != s[i + 1][0]))) ++a[s[i][0]], --a[s[i][1]], ans[i] = s[i][0];
        else --a[s[i][0]], ++a[s[i][1]], ans[i] = s[i][1];
    puts("Yes");
    for (int i = 1; i <= n; ++i) printf("%c\n", ans[i]);
}


Measured memory_bytes: 2288
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;

enum lim = 10^^6;

void main() {
    auto f = new int[](2000);
    foreach (i ; 1 .. 2000) {
        f[i] = f[i - 1] + i;
    }
    foreach (i ; 1 .. 2000) {
        f[i] += f[i - 1];
    }
    f = f.filter!(x => x < lim).array;
    debug {
        writeln(f);
        writeln(f.length);
    }
    auto n = f.length.to!int;
    auto dp = new int[](lim);
    auto dp2 = new int[](lim);
    dp[] = inf;
    dp2[] = inf;
    dp[0] = dp2[0] = 0;

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. lim) {
            if (j + f[i] < lim) {
                chmin(dp[j + f[i]], dp[j] + 1);
                if (f[i] % 2) chmin(dp2[j + f[i]], dp2[j] + 1);
            }
        }
    }

    while (true) {
        int x;
        scan(x);
        if (x == 0) return;
        writefln("%s %s", dp[x], dp2[x]);
    }
}














void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    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;
}



Measured memory_bytes: 10080
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const M = Number(input[N + 1][0]);

  const counts: { [key: string]: number } = {};

  for (let i = 1; i < N + 1; i++) {
    const s = input[i][0];

    counts[s] = (counts[s] || 0) + 1;
  }

  for (let i = N + 2; i < M + N + 2; i++) {
    const t = input[i][0];

    counts[t] = (counts[t] || 0) - 1;
  }

  return Math.max(0, ...Object.values(counts));
};

console.log(main(read()));


Measured memory_bytes: 29620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
int cmp(const int *a, const int *b){return *a - *b;}

int n, d[55];

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &d[i]);
    }
    d[n] = 0; n++;
    qsort(d, n, 4, cmp);
    for(int i=1; i<n; i++){
        if(d[i-1] > 0 && d[i]!=12)d[i] *= -1;
    }
    qsort(d, n, 4, cmp);
    int ans = d[1] - d[0];
    for(int i=1; i<n; i++){
        ans = min(ans, d[i] - d[i-1]);
    }
    ans = min(ans, min(abs((d[n-1]-d[0]+24)%24), abs(24-abs((d[n-1]-d[0]+24)%24))));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    i64 L, R;
    read(L, R);
    unordered_set<i64> S;
    i64 ans = LINF;
    reps(i, L, R) {
        const i64 a = i % 2019;
        if (S.count(a)) break;
        S.insert(a);
        unordered_set<i64> T;
        reps(j, i+1, R) {
            const i64 b = j % 2019;
            if (T.count(b)) break;
            chmin(ans, a * b % 2019);
            T.insert(b);
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 512
// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;
static const size_t MAX_N = 100001;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll &r) { return (x + r.x) % MOD; }
	modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll &r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}

int main(int argc, char *argv[]) {
	int n, d;
	cin >> n;
	vector<int> pos(n + 1, -1);
	for (int i = 0; i <= n; ++i) {
		int a;
		cin >> a;
		if (pos[a] >= 0) {
			d = i - pos[a];
		}
		pos[a] = i;
	}
	for (int i = 1; i <= n + 1; ++i) {
		modll ans = combination(n + 1, i) - combination(n - d, i - 1);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define MOD (1000000007)

int main(void) {

    int a, b;
    cin >> a >> b;

    int c, r;
    if(a < b) {
        c = a;
        r = b;
    } else {
        c = b;
        r = a;
    }
    string ans = string(r, '0'+c);
    cout << ans;


    return 0;
}

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

int p[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

bool leap(int y){

  if(y%400 == 0) return true;
  if(y%100 == 0) return false;
  if(y%4 == 0) return true;
  return false;
}

int solve(int y1, int m1, int d1, int y2, int m2, int d2){

  if(y1 == y2 && m1 == m2 && d1 == d2) return 0;

  if(leap(y1) && m1 == 2 && d1 == 28) return solve(y1,3,1,y2,m2,d2)+2;
  else if(m1 == 12 && d1 == 31) return solve(y1+1,1,1,y2,m2,d2)+1;
  else if(p[m1] == d1) return solve(y1,m1+1,1,y2,m2,d2)+1;
  else return solve(y1,m1,d1+1,y2,m2,d2)+1;

}

int main(){

  int y1,m1,d1,y2,m2,d2;

  while(true){
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    if(y1 < 0 || m1 < 0 || d1 < 0) break;
    if(y2 < 0 || m2 < 0 || d2 < 0) break;

    cout << solve(y1, m1, d1, y2, m2, d2) << endl;
  }

}

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

int main(){
  int s,m,l;
  cin >> s;
  m = 0;l = 0;
  if(s >= 100){
  m = s/100;
  }
  l = s - m*100;
  if(m == 0){
    if(l != 0 && l < 13){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }else if(m < 13){
    if(l >= 13 || l == 0){
      cout << "MMYY" << endl;
    }else if(l < 13){
      cout << "AMBIGUOUS" << endl;
    }
  }else{
    if(l != 0 && l < 13){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl;
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define is_bit(x,y) (x%(1<<(y+1))>=(1<<y))
#define eror(x) cout<<#x<<'='<<(x)<<endl;
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define Gett(x,y) scanf("%d%d",&x,&y);
#define f(i,a,b) for(int i=a;i<b;i++)
#define get(x) scanf("%I64d",&x);
#define All(x) x.begin(),x.end()
#define gett(x) scanf("%d",&x);
#define Add(x,y) x=(x+y)%p
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=1e5+9;

int n,frd,a[N];
ll sum;
string s[2]={"First","Second"};

void solve(int trn){
    int g=0,b=0;
    sum=0;
    f(i,0,n)
        if(a[i]!=1)
            b=1;
    if(!b){
        cout<<s[trn^1];
        return ;
    }
    f(i,0,n)
        sum+=a[i]-1;
    if(sum&1){
        cout<<s[trn]<<endl;
        return ;
    }
    f(i,0,n)
        if(a[i]==1){
            cout<<s[trn^1];
            return ;
        }
    f(i,0,n) 
        if(a[i]&1){
            a[i]--;
            break;
        }
    f(i,0,n)
        g=__gcd(g,a[i]);
    f(i,0,n)
        a[i]/=g;
    solve(trn^1);
}
int main(){
    cin>>n;
    f(i,0,n){ gett(a[i]); sum+=a[i]-1; frd++; }
    if(n==1) return cout<<s[1],0;
    solve(0);
        
}

Measured memory_bytes: 4072
#include <stdio.h>
int main(void)
{
	int i, x;
	for (i = 1; i <= 10000; i++)
	{
		scanf("%d", &x);
		if (x == 0)
			break;
		printf("Case %d: %d\n", i, x);
	}
	return 0;
}


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


int main(){
int n; cin >>n;
  vector<ll> dp(2*n+100,10e9),s;
    int x=0;
  while(pow(6,x)<=n){
    s.push_back(pow(6,x));
    x++;}
  x=0;
  while(pow(9,x)<=n){
    s.push_back(pow(9,x));
    x++;}
  
  
  dp[0]=0;
  for(int i=0; i<n;i++){
    for( auto j:s){
      dp[i+j]=min(dp[i+j],dp[i]+1);
    }}
 
    cout << dp[n] << endl;}
    

Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * Created by malone on 2018/3/9.
 */
public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int n = 0;

        for (int i = a; i < b + 1; i++) {
            if (c % i == 0) {
                n++;
            }
        }
        System.out.println(n);
    }
}


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     string s;
     cin >> s;
     int n =s.size();
     int j = -1;
     int k =0;
     for(int i=0;i<n;i++){
        if(s[i]=='A' && j==-1)j=i+1;
        if(s[i]=='Z')k=i+1;
     }
     // D1(k);D1(j);
     cout << k-j+1;
  }


  int main(){
    IOS
       solve();
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 720
// C.

#include <iostream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

typedef long long LL;

template<typename F> class [[nodiscard]] FixPoint: private F {
public:
	explicit constexpr FixPoint(F && f) noexcept : F(std::forward<F>(f)) {}

	template<typename... Args> constexpr decltype(auto)
	operator()(Args &&... args) const noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...))) {
		return F::operator()(*this, std::forward<Args>(args)...);
	}
};

template<typename F> static inline constexpr decltype(auto)
makeFixPoint(F&& f) noexcept {
	return FixPoint<F>{std::forward<F>(f)};
}

int main() {
	int n, m, q, a, b, c, d;
	vector<tuple<int, int, int, int>> v;

	cin >> n >> m >> q;
	for (int i = 0; i < q; ++i) {
		cin >> a >> b >> c >> d;
		v.emplace_back(a, b, c, d);
	}

	auto push_back = [](vector<int> seq, int next) {
		vector<int> v = seq;
		seq.emplace_back(next);
		return seq;
	};
	auto ans = makeFixPoint([&](auto dfs, vector<int> seq) -> int {
		int r = 0;
		if (seq.size() <= n) {
			for (int d = seq.back(); d <= m; ++d) {
				r = max(r, dfs(push_back(seq, d)));
			}
		} else {
			for (int i = 0; i < q; ++i) {
				if (seq[get<1>(v[i])] - seq[get<0>(v[i])] == get<2>(v[i])) {
					r += get<3>(v[i]);
				}
			}
		}
		return r;
	})(push_back({}, 1));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int GCD(int x, int y){

  int G, i, j;

  if(x >= y){

      j = x % y;

      while(j>0){

        x = y;

        y = j;

        j = x % y;

    }

      G = y;

  }else{

      j = y % x;

      while(j>0){

        y = x;

        x = j;

        j = y % x;

      }

      G = x;

  }

  return G;

}

int LCM(int x, int y){

  int i, L;

  for(i=1;i>=1;i++){

    L = x * i;

    if(L % y == 0){

      break;

    }

  }

    return L;

}

int main(){

  int x, y, G, L;

  while(scanf("%d%d", &x, &y)!=-1){

    G = GCD(x, y);

    L = LCM(x, y);

    printf("%d %d\n", G, L);

  }

  return 0;

}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt()-1;
		int b = in.nextInt()-1;
		int c = in.nextInt()-1;
		int d = in.nextInt()-1;
		String s = in.next();
		boolean possible = true;
		if(possible) {
			char tmp = s.charAt(a);
			for(int i=a+1;i<=c-1&&i<n;i++) {
				if(tmp=='#'&&s.charAt(i)=='#') {
					possible = false;
					break;
				}
				tmp = s.charAt(i);
			}
		}
		if(possible) {
			char tmp = s.charAt(b);
			for(int i=b+1;i<=d-1&&i<n;i++) {
				if(tmp=='#'&&s.charAt(i)=='#') {
					possible = false;
					break;
				}
				tmp = s.charAt(i);
			}
		}
		if(possible && d<c) {
			int count = 0;
			int tmp_count = 0;
			for(int i=b-1;i<=d+1&&i<n;i++) {
				if(s.charAt(i)=='.') tmp_count++;
				else {
					count = Math.max(count, tmp_count);
					tmp_count = 0;
				}
			}
			count = Math.max(count, tmp_count);
			if(count<3) possible = false; 
		}
		
		System.out.println(possible?"Yes":"No");
		in.close();
	}

}

Measured memory_bytes: 28592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cassert>
#include <map>
using namespace std;
using lint = long long;
const lint mod = 256;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << 5 + (N - 1) / min({A, B, C, D, E}) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,i,a[10001],m,b[10001];
main()
{
      cin>>n;
      m=0;
      for(i=0;i<n;i++){
         cin>>a[i];
         b[a[i]]+=1;
         if(a[m]<a[i]) m=i; 
      }
      m=a[m];
      for(i=1;i<=m;i++)
        b[i]-=2;
      
      
      for(i=(m+1)/2+1;i<=m;i++)
         if(b[i]<0){
           cout<<"Impossible"<<endl;
           return 0;
         }
      
      if(m%2==0 && b[(m+1)/2]!=-1){
        cout<<"Impossible"<<endl;
        return 0;
      }
      if(m%2==1 && b[(m+1)/2]!=0){
        cout<<"Impossible"<<endl;
        return 0;
      }
      
      for(i=1;i<=m;i++)
         if(i<=(m+1)/2 && b[i]>0){
           cout<<"Impossible"<<endl;
           return 0;
         }
      
      cout<<"Possible"<<endl;
      //system("pause");      
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int n,m,cnt,ans,p,x[100010],y[100010],cx,cy,sd=8000;
char ss[10000];
bool f[16010],g[16010],flag=1;
int main()
{
	int i,s,a,b,j,k;
	scanf(" %s",ss);n=strlen(ss);
	scanf("%d%d",&a,&b);
	for(i=s=0;i<n;i++)
	{
		if(ss[i]=='T')
		{
			if(!p)x[++cx]=s;
			else y[++cy]=s;
			s=0;
			p^=1;
		}
		else s++;
	}
	if(!p)x[++cx]=s;
	else y[++cy]=s;
	
	//for(i=1;i<=cx;i++)cout<<" "<<x[i];cout<<endl;
	//for(i=1;i<=cy;i++)cout<<" "<<y[i];cout<<endl;
	
	f[sd+x[1]]=1;
	for(i=2;i<=cx;i++)
	{
		for(s=0;s<=16000;s++)g[s]=0;
		for(s=0;s<=16000;s++)
		{
			if(!f[s])continue;
			if(s>=x[i])g[s-x[i]]=1;
			if(s+x[i]<=16000)g[s+x[i]]=1;
		}
		for(s=0;s<=16000;s++)f[s]=g[s];
	}
	if(!f[sd+a])flag=0;
	
	for(i=0;i<=16000;i++)f[i]=0;
	f[sd]=1;
	for(i=1;i<=cy;i++)
	{
		for(s=0;s<=16000;s++)g[s]=0;
		for(s=0;s<=16000;s++)
		{
			if(!f[s])continue;
			if(s>=y[i])g[s-y[i]]=1;
			if(s+y[i]<=16000)g[s+y[i]]=1;
		}
		for(s=0;s<=16000;s++)f[s]=g[s];
	}
	if(!f[sd+b])flag=0;
	if(flag)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 384
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
const int N = 100001;
int ans, a[N], b[N];

int main() {
	//freopen("x.in", "r", stdin);

	cin >> n;
	ll sa = 0, sb = 0;
	F0(i, n) {
		cin >> a[i];
		sa += a[i];
	}
	ll add = 0;
	F0(i, n) {
		cin >> b[i];
		sb += b[i];
		if (a[i] > b[i]) {
			add += 2*(a[i] - b[i]);
		} 
	}
	ll need = 0;
	F0(i, n) if (a[i] < b[i]) {
		need += (b[i] - a[i]);
		if ((b[i] - a[i]) % 2 == 1) need--;
	}
	
	//cout << add << " " << need << endl;
	if (add <= need) cout << "Yes"; else cout << "No";
		
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define MAX_N 2020

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(1){
    C = C-B;
    if(C<=0){
      cout << "Yes" << endl;
      break;
    }
    A = A-D;
    if(A<=0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3644
import java.util.*;
import java.math.*;
import java.text.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			for(int i=0; i<4; i++){
				a[i] = in.nextInt();
			}
			for(int i=0; i<4; i++){
				b[i] = in.nextInt();
			}
			int hi = 0;
			int bl = 0;
			for(int i=0; i<4; i++){
				for(int j=0; j<4; j++){
					if(b[i] == a[j]){
						if(i==j) hi++;
						else bl++;
					}
				}
			}
			System.out.println(hi+" "+bl);
		}
	}
}

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

using namespace std;

int main() {
  int64_t A, B;
  cin >> A >> B;
  int result = 0;
  for (int i = 0; i < 100; i++) {
    if (A > B) {
      break;
    }
    result++;
    A *= 2;
  }
  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; i++)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; i--)
#define vi vector<int>
#define vs vector<string>
#define all(x) (x).begin(),(x).end()
int main() {
    int n,m;

    cin >> n;
    vs s(n);
    repp(i,0,n){
        cin >> s[i];
    }

    cin>> m;
    vs t(m);
    repp(i,0,m){
        cin >> t[i];
    }

    vi cnt(n+1,0);
    repp(i,0,n){
        repp(j,0,n){
            if(s[i]==s[j]){
                cnt[i]++;
            }
        }
        repp(j,0,m){
            if(s[i]==t[j]){
                cnt[i]--;
            }
        }
    }
    cout<< *max_element(all(cnt)) <<endl;
}

Measured memory_bytes: 3620
a = int(input())

b = list(map(int,input().split()))

c = [0]*8
d = 0
for i in range(a):
	if 1 <= b[i] and b[i] <=399:
		c[0] = 1
	elif 400 <= b[i] and b[i] <=799:
		c[1] = 1
	elif 800 <= b[i] and b[i] <=1199:
		c[2] = 1
	elif 1200 <= b[i] and b[i] <=1599:
		c[3] = 1
	elif 1600 <= b[i] and b[i] <=1999:
		c[4] = 1
	elif 2000 <= b[i] and b[i] <=2399:
		c[5] = 1
	elif 2400 <= b[i] and b[i] <=2799:
		c[6] = 1
	elif 2800 <= b[i] and b[i] <=3199:
		c[7] = 1
	else:
		d += 1

ma = sum(c) + d

if sum(c) == 0:
	print(1,ma)
else:
	print(sum(c),ma)

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  ll p = 0;
  rep(i,n){
    cin>>a[i];
    if(i%2==0) p+=a[i];
    else p-=a[i];
  }
  
  rep(i,n){    
    cout << p << " ";
    p = (p-a[i])*(-1)+a[i];
  }
}




Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int M = scn.nextInt(), D = scn.nextInt();
		int ans = 0;
		for(int i = 1;i <= M;i++) {
			for(int j = 22;j <= D;j++) {
				int a = j/10;
				int b = j%10;
				if(b <2)continue;

				if(a*b == i) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

}


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

int main(){
    int N,D;
    ll ans=0;
    cin >> N >> D;
    vector<vector<double>> X(N,vector<double>(D)); 
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            double nakami=0;
            for(int k=0;k<D;k++){
                nakami+=pow(X[i][k]-X[j][k],2);
            }
            double sqrt_nakami=sqrt(nakami);
            if(sqrt_nakami==(int)sqrt_nakami) ans++;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    deque<ll> v(n);
    rep(i,n) cin>>v[i];
    ll ans=0;
    rep(i,k+1)rep(j,k+1){
      if(i+j>k) continue;
      deque<ll> v2(v);
      ll ret=k-i-j;
      multiset<ll> now;
      rep(l,i){
        if(!v2.empty()){
          now.insert(v2.front());
          v2.pop_front();
        }
      }
      rep(l,j){
        if(!v2.empty()){
          now.insert(v2.back());
          v2.pop_back();
        }
      }
      rep(l,ret){
        if(*begin(now)<0){
          now.erase(begin(now));
        }else{
          break;
        }
      }
      ll cnt=0;
      for(auto itr: now){
        cnt+=itr;
      }
      if(ans<cnt) ans=cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K,C=map(int,input().split())
    S=list(map(int,input().replace('o','1').replace('x','0')))
    T=[0]*(N+1)
    for i in range(N):
        T[i+1]=T[i]+S[i]
    l0=[]
    l1=[]
    r0=-INF
    r1=-INF
    for i in range(N):
        if len(l0)<K and i>r0 and S[i]==1:
            l0.append(i)
            r0=i+C
        if len(l1)<K and i>r1 and S[N-1-i]==1:
            l1.append(N-1-i)
            r1=i+C
    l1.reverse()
    ans=[]
    for i in range(K):
        if l0[i]==l1[i]:
            if i==0 or i==K-1:
                ans.append(l0[i])
            else:
                q=T[l1[i+1]-C]-T[l0[i-1]+C+1]
                if l0[i-1]+C+1<l1[i+1]-C and q<2:
                    ans.append(l0[i])
    ans.sort()
    for x in ans:
        print(x+1)
    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 74232
from collections import deque
k=int(input())

q = deque([1,2,3,4,5,6,7,8,9])
ans = 0
flg = 0
cnt = 0

while(flg != 1):
    ans = q.popleft()
    cnt += 1

    tmp = ans % 10
    if tmp != 0:
        q.append(ans * 10 + tmp - 1)
    
    q.append(ans * 10 + tmp)
    
    if tmp != 9:
        q.append(ans * 10 + tmp + 1)

    if cnt == k:
        print(ans)
        flg = 1

Measured memory_bytes: 11944
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,kk;
int main()
{
    cin>>a>>b>>c;
    if(b>=a) 
    {
        cout<<1<<endl;
        exit(0); 
    }
    if(c>=b) 
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)kk=1;
    cout<<((a-b)/(b-c)+kk)*2+1<<endl;
} 

Measured memory_bytes: 256
n=int(input())
a=[0]*n
x=[[] for i in range(n)]
for i in range(n):
    a[i]=int(input())
    for j in range(a[i]):
        p,q=map(int,input().split())
        x[i].append([p,q])
ans1=0
for i in range(2**n):
    ans=False
    for j in range(n):
        if i>>j&1:
            for k in range(a[j]):
                if (i>>(x[j][k][0]-1)&1)!=x[j][k][1]:
                    ans=True
                    break
            if ans:
                break
    cnt=0
    if not ans:
        for j in range(n):
            cnt+=i>>j&1
    ans1=max(cnt,ans1)
print(ans1)


Measured memory_bytes: 3188
#include<iostream>
using namespace std ;
int main()
{
	int ten ,a = 0 ,b = 0 ;
	for( short i = 0 ; i < 4 ; i++ )
	{
		cin >> ten ;
		a += ten ;
	}
	for( short i = 0 ; i < 4 ; i++ )
	{
		cin >> ten ;
		b += ten ;
	}
	cout << ( a < b ? b : a ) << endl ;
	return 0 ;
}

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

int main() {
  int n,sum = 0;
  cin >> n;
  rep(i,0,n){
    int a;
    cin >> a;
    sum ^= a;
  }
  if(sum) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
X = int(input())
M = 10 ** 10
# M = 3
for i in range(1, M):
    A = i ** 5
    ok = 10 ** 5
    ng = -(10 ** 5)
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if A - mid ** 5 <= X:
            ok = mid
        else:
            ng = mid
    if A - ok ** 5 == X:
        print(i, ok)
        break


Measured memory_bytes: 9184
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<iostream>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define INF 1000000000000000000
struct edge {
	ll to, cost;
};
vector<edge>G[100010];
ll d[100010];

void dijkstra(ll s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + 100010, INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();que.pop();
		ll v = p.second;
		if (d[v] < p.first)continue;
		for (ll i = 0;i < G[v].size();i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	ll n, q, k, a, b, c, x, y;
	cin >> n;
	for (ll i = 0;i < n - 1;i++) {
		cin >> a >> b >> c;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	cin >> q >> k;
	dijkstra(k);
	for (ll i = 0;i <q;i++) {
		cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 11120
n = int(input())
step = list(map(int,input().split()))

s = 0
res = 0

for i in range(1, n):
  if step[i-1] >= step[i]:
    s = s + 1
    if (i == n - 1) & (res < s):
      res = s
      
  if step[i-1] < step[i]:
    if res < s:
      res = s
    s = 0

print(res)

Measured memory_bytes: 15020
const main = input => {
  const lines = input.trim().split("\n")
  const k = Number.parseInt(lines[0])
  const s = lines[1]
  return s.slice(0, k) + (s.length > k ? "..." : "")
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')))

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#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
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N; cin >> N;
	int ans = (N - 1) / 2;
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var K = ReadLong();
            var S = ReadText();

            if (S.Length <= K) return S;

            return S.Substring(0, (int)K) + "...";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27552
#include<stdio.h>
int main(){
	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	int sum;
	if(A<B){
		sum=sum +A;
	}
	else{
		sum+=B;
	}
	if(C<D){
		sum+=C;
	}
	else{
		sum+=D;
	}
	printf("%d",sum);
	return 0;
}

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

//myfuncs
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

int main(int argc, char const* argv[])
{
	int m,nmin,nmax;
	while (1) {
		cin >> m >> nmin >> nmax;
		if (m == 0 && nmin == 0 && nmax == 0) {
			return 0;
		}
		int p[m];
		for (int i = 0; i < m; i++) {
			cin >> p[i];
		}
		int Max = -1;
		int ans = 0;
		for (int i = nmin-1; i <= nmax-1; i++) {
			Max = max(Max,p[i] - p[i+1]);
			if (Max == p[i] - p[i+1]) {
				ans = i + 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i
m = gets.chomp.split.map(&:to_i)

sums = []
[0,1].repeated_permutation(n) do |arr|
  sum = 0
  n.times do |i|
    sum += arr[i]*a[i]
  end
  sums.push sum
end

sums.sort!.uniq!

m.each do |t|
  if sums.bsearch{|s| s >= t} == t
    puts 'yes'
  else
    puts 'no'
  end
end



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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define Rrep(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1000000007

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

ll N, A, B;
ll X[100000];

int main() {
	scanf("%lld %lld %lld", &N, &A, &B);
	rep(i, N) scanf("%lld", &X[i]);
	ll ans = 0;
	rep(i, N - 1) {
		ll tmp = (X[i + 1] - X[i]) * A;
		ans += (tmp < B) ? tmp : B;
 	}
 	printf("%lld\n", ans);
	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N;
int a[20][20];
int dp[1<<16];
int USE[1<<16];

signed main() {
  cin >> N;
  rep (i, N) {
    rep (j, N) {
      scanf("%lld", &a[i][j]);
    }
  }

  for (int use = 0; use < (1 << N); use++) {
    int score = 0;
    rep (i, N) {
      repp (j, i, N) {
        if (((use >> i)&1) and ((use >> j)&1)) {
          score += a[i][j];
        }
      }
    }
    USE[use] = score;
  }

  for (int used = 0; used < (1 << N); used++) {
    int unused = used ^ ((1 << N) - 1);
    for (int use = unused; use > 0; use=(use-1)&unused) {
      if (!(use > used)) continue;
      int score = USE[use];
      // rep (i, N) {
      //   repp (j, i, N) {
      //     if (((use >> i)&1) and ((use >> j)&1)) {
      //       score += a[i][j];
      //     }
      //   }
      // }
      chmax(dp[use | used], dp[used] + score);
    }
  }

  cout << dp[(1<<N)-1] << endl;

  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

const int MOD = 998244353; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

typedef __int128 ulll;

const ulll ONE = 1;

Modint dpb (int length, ulll mask);

map<pair<int, ulll>, Modint> memoa;
Modint dpa (int length, ulll mask) { // only exp aulllowed
  if (memoa.count(make_pair(length, mask))) return memoa[{length, mask}];
  Modint ans (0);

  if (length == 1) {
    if (mask == 1) ans = Modint(2);
    else ans = Modint(1);
  }
  
  for (int i = 2; i <= length; i++) {
    if (length % i == 0) {
      ulll nlen = length / i;
      ulll nmask = (ONE << nlen) - 1;
      ulll curm = mask;
      for (int j = 0; j < i; j++) {
        nmask &= curm;
        curm >>= nlen;
      }
      ans += dpb(nlen, nmask);
    }
  }
  
  memoa[{length, mask}] = ans;
  // cerr << length << " " << mask << " a: " << ans << endl;
  return ans;
}

map<pair<int, ulll>, Modint> memob;
Modint dpb (int length, ulll mask) { // only concat aulllowed
  if (memob.count(make_pair(length, mask))) return memob[{length, mask}];

  vector<Modint> dp (length + 1, Modint(0));
  dp[0] = Modint(1);
  for (int i = 1; i <= length; i++) {
    for (int j = 0; j < i; j++) {
      ulll nmask = mask >> j;
      nmask &= (ONE << (i - j)) - 1;
      dp[i] += dp[j] * dpa(i - j, nmask);
    }
  }

  Modint ans = dp[length];
  memob[{length, mask}] = ans;
  // cerr << length << " " << mask << " b: " << ans << endl;
  return ans;
}

int main () {
  string s;
  cin >> s;

  ulll mask = 0;
  for (char c : s) {
    mask <<= 1;
    mask += c - '0';
  }

  cout << dpb(s.size(), mask) << endl;
}


Measured memory_bytes: 10184
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 N = Sarray()[0];
            var ai = Sarray();
            Array.Sort(ai);
            Array.Reverse(ai);
            var ans = 0L;
            for (var i = 0; i < N; ++i)
                ans += ai[2 * i + 1];
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 46228