akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

using mint = modint998244353;
#define N 212345
int n, k;
int p[N], pi[N];
fenwick_tree<mint> s(N), t(N);
mint kappa;

mint gpsum(mint a, int p, int q){
	mint ret = (a.pow(p) - a.pow(q+1)) / (1-a);
	// DEBUG("gpsum(%d/200000000, %d, %d) = %d/200000000\n", (a*200000000).val(), p, q, (ret*200000000).val());
	return ret;
}

// For test
int h(int i, int j){
	int ret = max(j - (k-1), 0) - max(i - (k-1), 0);
	// DEBUG("h(%d, %d) = %d\n", i, j, ret);
	return ret;
}
mint g(int i, int j){
	mint ret = kappa.pow(h(i, j)) / 2;
	// DEBUG("g(%d, %d) = %d/200000000\n", i, j, (ret*200000000).val());
	return ret;
}

mint s1(int i){
	// mint ret = 0;
	// FOR(j, i+1, n) ret += g(i, j);
	if (i < k-1){
		mint ret2 = ((k-1) - (i+1) + gpsum(kappa, 0, n-k))/2;
		// DEBUG("s1(%d) %d/200000000 %d/200000000\n", i, (ret*200000000).val(), (ret2*200000000).val());
		return ret2;
	} else {
		mint ret2 = gpsum(kappa, i+1-i, n-1-i) / 2;
		// DEBUG("s1(%d) %d/200000000 %d/200000000\n", i, (ret*200000000).val(), (ret2*200000000).val());
		return ret2;
	}
	// return ret;
}
mint s2(int i){
	// mint ret = 0;
	// FOR(j, i+1, n) if(p[i] > p[j]) ret += g(i, j);
	if(i < k-1){
		mint ret2 = t.sum(i+1, n) / 2;
		// if(ret != ret2)
		// 	DEBUG("s2(%d) %d/200000000 %d/200000000\n", i, (ret*200000000).val(), (ret2*200000000).val());
		return ret2;
	} else {
		mint ret2 = t.sum(i+1, n) / kappa.pow(i-(k-1)) / 2;
		// if(ret != ret2)
		// 	DEBUG("s2(%d) %d/200000000 %d/200000000\n", i, (ret*200000000).val(), (ret2*200000000).val());
		return ret2;
	}
	// return ret;
}

int main(){
	scanf("%d%d", &n, &k);
	REP(i, n){
		scanf("%d", p+i);
		pi[p[i]] = i;
	}
	kappa = mint(k-1) / k;
	mint ans = 0;

	FOR(pp, 1, n+1){
		int i = pi[pp];
		ans += s1(i) + s.sum(i, n) - 2 * s2(i);
		s.add(i, 1);
		t.add(i, kappa.pow(max(i-(k-1), 0)));
	}

	printf("%d\n", ans.val());
}


Measured memory_bytes: 6480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e18)
#define MOD (1000000007)

/////////////////////////////////////////////////////////

void Main(){
  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  vector<int> v(9, 0);
  rep(i, 0, N){
    int tmp;
    tmp = a[i] / 400;
    if(tmp > 8) tmp = 8;
    v[tmp]++;
  }
  int res = 0;
  rep(i, 0, 8){
    if(v[i] > 0) res++;
  }
  cout << max(1, res) << " " << res + v[8] << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
	int64_t x;
	mint(int64_t x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(int64_t t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	//for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//head

const int X = 1e5;
int n, k;
int m, m_;
vi cor(1);
mint dp1[X];
mint sum[X];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	m = sqrt(n);
	rep(i, m) {
		cor.push_back(i+1);
		cor.push_back(n/(i+1));
	}
	if(m*m == n) cor.pop_back();
	sort(all(cor));
	
	m_ = cor.size()-1;
	fill(dp1, dp1+m_, 1);
	rep(i, m_) {
		sum[i+1] = cor[i+1];
	}
	rep(i, k-1) {
		rep(j, m_) {
			dp1[j] = sum[m_-j];
		}
		memset(sum, 0, sizeof(sum));
		rep(j, m_) {
			sum[j+1] = sum[j] + dp1[j] * (cor[j+1]-cor[j]);
		}
	}

	cout << sum[m_] << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    int b;
    for (int j = 0; j < k; j++) {
      cin >> b;
      a[b - 1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++)
    if (a[i] == n)
      ans++;
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
using p = pair<string, int>;

int main()
{
    int n, max_cnt = 0;
    cin >> n;
    
    unordered_map<string, int> m;
    set<string> set;

    string tmp;
    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        m[tmp]++;
        max_cnt = max(m[tmp], max_cnt);
    }

    for(auto &i: m)
    {
        if(i.second == max_cnt)
            set.insert(i.first);
    }

    for(auto &i: set) cout << i << "\n";
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int dp_eq[101][5];
int dp_lo[101][5];

int main() {
  CIN(string, N);
  CIN(int, K);
  dp_eq[0][0] = 1;
  REP(i, N.size()) {
    for (int nonzeros = 0; nonzeros <= 3; ++nonzeros) {
      for (int d = 0; d < 10; ++d) {
        int sign = d - (N[i] - '0');
        int n_nonzeros = nonzeros + (d != 0);
        if (sign == 0) {
           dp_eq[i + 1][n_nonzeros] += dp_eq[i][nonzeros];
           dp_lo[i + 1][n_nonzeros] += dp_lo[i][nonzeros];
        }
        if (sign < 0) {
          dp_lo[i + 1][n_nonzeros] += dp_eq[i][nonzeros] + dp_lo[i][nonzeros];
        }
        if (sign > 0) {
          dp_lo[i + 1][n_nonzeros] += dp_lo[i][nonzeros];
        }
      }
    }
    for (int nonzeros = 0; nonzeros <= 3; ++nonzeros) {
      DBG(i, nonzeros, dp_eq[i + 1][nonzeros], dp_lo[i + 1][nonzeros]);
    }
  }
  COUT(dp_eq[N.size()][K] + dp_lo[N.size()][K])
}


Measured memory_bytes: 256
#include <stdio.h>

//Tenki

int main() {
	int count = 0;
	char Yohou[4];
	char Jissai[4];

	scanf("%s", Yohou);
	scanf("%s", Jissai);
	
	if (Yohou[0] == Jissai[0])
		count++;
	if (Yohou[1] == Jissai[1])
		count++;
	if (Yohou[2] == Jissai[2])
		count++;

	printf("%d",count);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,x,y,ans,T;
int main()
{
	cin>>a>>b>>c>>x>>y;
	ans+=min(x,y)*min(a+b,2*c);
	T=min(x,y);x-=T;y-=T;
	if(y)a=b,x=y;
	ans+=x*min(2*c,a);
	cout<<ans<<endl;
}

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


int main(){

    char texto[100];

    scanf("%s", texto);

    for (int i = 0; i < sizeof(texto); i++) {
        if (texto[i] == ',') {
            texto[i] = ' ';
        }
    }

    printf("%s\n", texto );

return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define int long long
#define endl '\n'
typedef long long ll;

int n,m,v,p;

bool possible(const vector<int> &arr, int x) {
    if(x <= p) return true;
    if(arr[p] - arr[x] > m) return false;
    int votes = 0;
    for(int i = 1; i <= n; ++i) {
        if(i <= (p-1)) votes += m;
        else if(i >= x) votes += m;
        else {
            votes += max(0LL, arr[x]+m - arr[i]);
        }
    }
    return votes >= m*v;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> v >> p;
    vector<int> arr(n+1);
    for(int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }
    sort(arr.begin()+1,arr.end());
    reverse(arr.begin()+1,arr.end());


    //number of problems with strictly greater score is <= (p-1)
    int start = 0, end = n+1, mid;
    while(start+1 < end) {
        mid = (start + end) / 2;
        if(possible(arr, mid)) start = mid;
        else end = mid;
    }
    cout << start << endl;
}


Measured memory_bytes: 1024
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
h_list = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h_list[1]-h_list[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h_list[i]-h_list[i-1]), dp[i-2]+abs(h_list[i]-h_list[i-2]))

print(dp[n-1])

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

int main() {
  	int x, ans = 0; 
  	cin >> x;
  	for (int c = 500, h = 1000; c > 0 and x > 0; h /= 200, c /= 100)
    	ans += h*(x/c), x %= c;
  	cout << ans; }
  

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

added = As[0] + As[1]
xored = 0
for A in As[2:]:
    xored ^= A

anded = added - xored
if anded % 2 == 1:
    print(-1)
    exit()
else:
    anded >>= 1

left_stones_l_A0 = '' # <= A[0] for sure.
left_stones_e_A0 = '' #not sure if this is <= A[0].
for i, (a, x) in enumerate(zip(format(anded, '045b'), format(xored, '045b'))):
    if x == '0':
        if a == '0':
            left_stones_l_A0 += '0'
            left_stones_e_A0 += '0'
        else:
            left_stones_l_A0 += '1'
            left_stones_e_A0 += '1'
    else:
        if a == '0':
            if int(left_stones_l_A0 + '1' + '1' * (44 - i), base = 2) <= As[0]:
                left_stones_l_A0 += '1'
            else:
                left_stones_l_A0 += '0'
            if int(left_stones_e_A0 + '1' + '1' * (44 - i), base = 2) <= As[0]:
                left_stones_e_A0 += '1'
                left_stones_l_A0 = left_stones_e_A0
            elif int(left_stones_e_A0 + '1' + '0' * (44 - i), base = 2) <= As[0]:
                left_stones_l_A0 = left_stones_e_A0 + '0'
                left_stones_e_A0 += '1'
            elif int(left_stones_e_A0 + '0' + '0' * (44 - i), base = 2) <= As[0]:
                left_stones_e_A0 += '0'
            else:
                left_stones_e_A0 = left_stones_l_A0
        else:
            print(-1)
            exit()

if int(left_stones_e_A0, base = 2) <= As[0]:
    ans = As[0] - int(left_stones_e_A0, base = 2)
else:
    ans = As[0] - int(left_stones_l_A0, base = 2)

if 0 <= ans < As[0]:
    print(ans)
else:
    print(-1)


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

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int a[1252];
bool broken[1252];
char buf[1252];

int main(){
	while(true){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		REP(i,n){
			scanf("%s",buf);
			if(buf[0]=='x'){
				broken[i] = true;
			}else{
				broken[i] = false;
				a[i] = atoi(buf);
			}
			int len = strlen(buf);
			fill(buf,buf+len,'\0');
		}
		int ub = 1<<30, lb = -(1<<30);
		REP(i,n)if(broken[i]){
			if(i%2==0){
				// ub
				if(i+1<n && !broken[i+1])ub = min(ub,a[i+1]-1);
				if(i-1>=0&& !broken[i-1])ub = min(ub,a[i-1]-1);
			}else{
				if(i+1<n && !broken[i+1])lb = max(lb,a[i+1]+1);
				if(i-1>=0&& !broken[i-1])lb = max(lb,a[i-1]+1);
			}
		}
		bool ng = false;
		REP(i,n)if(!broken[i]){
			if(i%2==0){
				// smaller
				if(i+1<n && !broken[i+1] && !(a[i]<a[i+1]))ng=true;
				if(i-1>=0&& !broken[i-1] && !(a[i]<a[i-1]))ng=true;
			}else{
				if(i+1<n && !broken[i+1] && !(a[i]>a[i+1]))ng=true;
				if(i-1>=0&& !broken[i-1] && !(a[i]>a[i-1]))ng=true;
			}
		}
		REP(i,n-1)if(broken[i] && broken[i+1])ng = true;
		if(ub<lb || ng)puts("none");
		else if(ub==lb)printf("%d\n",ub);
		else puts("ambiguous");
	}
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c;
  cin >> a >> b >> c;
  cout << (b-a==c-b ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                sc.close();
                boolean ebishu = true;
                int sai = 0;
                while(ebishu){
                        sai++;
                        if(sai * (sai - 1) / 2 < n && sai * (sai + 1) / 2 >= n){
                                ebishu = false;
                        }
                }
                int set = 1;
                n -= sai;
                int[] a = new int[sai];
                boolean yono = true;
                for(int i = sai - 1 ; i > 0 && yono ; i--){
                        if(n > i){
                                a[set] = i;
                                n -= i;
                                set++;
                        }else if(n == i){
                                a[set] = i;
                                n = 0;
                                set++;
                                yono = false;
                        }
                }
                System.out.println(sai);
                for(int i = 1 ; i < set ; i++){
                        System.out.println(a[i]);
                }
        }
}
//難しくない？WAな気しかしない、取り敢えず提出するか

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

int main(int argc, char const* argv[])
{
	int ans = 0;
	string W, T = "", tmp_T;
	cin >> W;
	while (cin >> tmp_T && tmp_T != "END_OF_TEXT") {
		for (int i=0; i<tmp_T.size(); i++) {
			T += tolower(tmp_T[i]);
		}
		if (T == W) {
			ans++;
		}
		T = "";
	}
	/*
	for (int i=0; i<T.size()-W.size()+1; i++) {
		for (int j=0; j<W.size(); j++) {
			cout << W[j] << "" << T[i+j] << endl;
			if (W[j] != T[i+j]) {
				cout << endl;
				break;
			}
			if (j == W.size()-1) {
				ans++;

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


Measured memory_bytes: 1200
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    cin >> n >>m >> k;
    vll a(n),b(m);
    vll sa(n+1),sb(m+1);
    sa[0]=0;
    sb[0]=0;
    REP(i,n){
        cin >> a[i];
        sa[i+1] = sa[i]+a[i];
    }
    REP(i,m){
        cin >> b[i];
        sb[i+1] = sb[i]+b[i];
    }
    ll ans = 0;
    REP(i,n+1){
        if(sa[i]>k){
            break;
        }
        ll t = i;
        ll r = k-sa[i];
        ll ok = 0;
        ll ng = m+1;
        while(abs(ok-ng)>1){
            ll mid = (ok+ng)/2;
            if(sb[mid]<=r){
                ok = mid;
            }else{
                ng = mid;
            }
        }
        t += ok;
        ans = max(ans,t);
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  int i = 0;
  int j = 1;

  while (1) {
    if (j>=B) break;
    j--;
    j += A;
    i++;
  }
  cout<<i<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;



void solve()
{	

    ll n;
    cin>>n;

    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }

    ll start = 1000;

    for(ll i=1;i<n;i++){
        if(a[i]>a[i-1]){
            ll num = start/a[i-1];
            start = start - num*a[i-1] + num*a[i];
        }
    }

    cout<<start;
    

    
}

int main() {

    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 3010;
long long C[MAXN][MAXN];
int main()
{
	int n = 2010;
	for (int i = 0; i <= n; ++ i)
		C[i][0] = 1;
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= i; ++ j)
			C[i][j] = (C[i-1][j-1]+C[i-1][j])%MOD;
	
	int N, K;
	cin >> N >> K;
	for (int i = 1; i <= K; ++ i)
	{
		cout << C[K-1][i-1]*C[N-K+1][i]%MOD << endl;
	}
	return 0;
}

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

public class Main {
    static IO io = new IO();
    public static void main(String[] args) {

        int n[] = new int[10];
        for (int i=0; i<10; i++) n[i] = io.nextInt();
        Arrays.sort(n);
        System.out.println(n[9]);
        System.out.println(n[8]);
        System.out.println(n[7]);

    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        }

        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 24440
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
typedef vector<int> vi;

int main(){
    long long N;
    cin >> N;
    vector<char> alpha(26);
    vector<long long> tmp(1000, 9999);
    string ans;
    rep(i, 26){
        alpha[i] = 'a' + i;
    }

    long long x = N;
    for(int i = 0; x > 0; i++){
        if(x % 26 == 0){
            tmp[i] = 26;
            x--;
        }
        else{
            tmp[i] = (long long)(x % 26);
        }
        if(x == 26) break;
        x /= 26;
        //cout << alpha[tmp[i]-1] << " ";
    }
    
    int i = 0;
    while(tmp[i] != 9999){
        if(alpha[tmp[i]-1] == ' ') continue;
        ans.push_back(alpha[tmp[i]-1]);
        //cout << alpha[tmp[i]-1] << " ";
        i++;
    }
    reverse(ans.begin(), ans.end());

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

Measured memory_bytes: 3624
# 一行に整数ひとつだけ
N , L = gets.chomp.split.map(&:to_i)

# マイナスだけ
if (L + N - 1) < 0
  puts (L..(L + N - 2)).to_a.inject(:+)
# プラスだけ
elsif L > 0
  puts ((L+1)..(L + N - 1)).to_a.inject(:+)
else
  puts ((L)..(L + N - 1)).to_a.inject(:+)
end



Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  if(N==1){
    cout << "Hello World\n";
    return 0;
  }
  ll A, B;
  cin >> A >> B;
  cout << A+B << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N;
    cin >> N;
    int prev = -1, cur;
    vector<int> additional;
    for(size_t i = 0; i < N; i++) {
        cin >> cur;
        if(cur == prev + 1) {
            additional.push_back(prev-1);
        }
        prev = cur;
    }
    int sum = 0;
    for(size_t i = 0; i < N; i++) {
        int b;
        cin >> b;
        sum += b;
    }
    vector<int> C(N);
    for(size_t i = 0; i < N-1; i++) {
        cin >> C[i];
    }
    for(int i: additional){
        sum += C[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <cmath>
#include <queue>

using namespace std;
int main() {
	long long n, m;
	cin >> n >> m;
	if(n == 1 && m == 1){
		cout << 1 << endl;
	}else if(n == 1){
		cout << m-2 << endl;
	}else if(m == 1){
		cout << n-2 << endl;
	}else if(n == 2 || m == 2){
		cout << 0 << endl;
	}else {
		long long ans;
		ans = (m-2) * (n-2);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int32_t main()
{
	string s, t, ans;
    cin >> s >> t;
    int dp[s.size()+1][t.size()+1];
    for(int i = 0; i <= s.size(); i++)
    {
    	for(int j = 0; j <= t.size(); j++)
        {
        	if(i == 0 || j == 0)
            {
              	dp[i][j] = 0;
            	continue;
            }
          	if(s[i-1] == t[j-1])
            	dp[i][j] = dp[i-1][j-1]+1;
          	else
            	dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int i = s.size(), j = t.size();
    while(i > 0 && j > 0)
    {
        if(dp[i][j] == dp[i-1][j])
            i--;
        else if(dp[i][j] == dp[i][j-1])
            j--;
        else
            i--, j--, ans += s[i];
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
  	return 0;
}

Measured memory_bytes: 38828
n,m,x,y = gets.chomp.split.map(&:to_i)
xis = gets.chomp.split.map(&:to_i)
yis = gets.chomp.split.map(&:to_i)
if xis.max+1 > yis.min
  puts "War"
else
  if x<yis.min && y>=xis.max+1
    puts "No War"
  else
    puts "War"
  end
end

Measured memory_bytes: 14384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n, a;
	cin >> n >> a;

	cout << n * n - a << endl;

}


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

int main() {
  
  int N, a, b, c, d;
  cin  >> N;
  a = N/1000, b = (N-1000*a)/100,
  c = (N-1000*a-100*b)/10, d = (N-1000*a-100*b-10*c);

  if ( b != c ) {
      cout << "No" << endl;
  }

  else if ( a != b && c != d) {
    cout << "No" << endl;
  }
  
  else {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
  public static int n;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    dfs("", 'a');
  }

  public static void dfs(String s, char mx) {
    if(s.length() == n) {
      System.out.println(s);
    } else {
      for(char c = 'a'; c <= mx; c++) {
        if(c == mx) {
          dfs(s + String.valueOf(mx), (char)(mx + 1));
        } else {
          dfs(s + String.valueOf(c), mx);
        }
      }
    }
  }
}

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

#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)

using namespace std;
typedef pair<int, int> pii;

ll dp[3001][3001][4];
ll g[3001][3001];
int r, c, k;

ll memo(int row, int col, int items) {
    if (dp[row][col][items] != -1) return dp[row][col][items];

    ll best = pow(-10, 13);
    if (row < r - 1) {
        best = (items < 3) ? g[row][col] + max(best, memo(row + 1, col, 0)) : max(best, memo(row + 1, col, 0));
    }

    if (col < c - 1) {
        best = max(best, memo(row, col + 1, items));
        if (g[row][col] != 0 && items < 3) best = max(best, g[row][col] + memo(row, col + 1, items + 1));
    }

    return dp[row][col][items] = best;
}

int main() {
    fastIO;
    cin >> r >> c >> k;
    memset(g, 0, sizeof(g));
    memset(dp, -1LL, sizeof(dp));

    for (int i = 0; i < k; i++) {
        int ri, ci, ki;
        cin >> ri >> ci >> ki;
        ri--, ci--;
        g[ri][ci] = ki;
    }


    dp[r - 1][c - 1][0] = dp[r - 1][c - 1][1] = dp[r - 1][c - 1][2] = g[r - 1][c - 1];
    dp[r - 1][c - 1][3] = 0;


    cout << memo(0, 0, 0);
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

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

    vector<int> R,G,W;

    rep(i,A) {
        int a;
        cin >> a;
        R.push_back(a);
    }

    rep(i,B) {
        int b;
        cin >> b;
        G.push_back(b);
    }

    rep(i,C) {
        int w;
        cin >> w;
        W.push_back(w);
    }

    sort(R.begin(),R.end());
    reverse(R.begin(),R.end());
    sort(G.begin(),G.end());
    reverse(G.begin(),G.end());
    sort(W.begin(),W.end());
    reverse(W.begin(),W.end());

    vector<int> sa,sb;
    rep(x,X) {
        sa.push_back(R[x]);
    }
    rep(y,Y) {
        sb.push_back(G[y]);
    }

    reverse(sa.begin(),sa.end());
    reverse(sb.begin(),sb.end());

    int idxa,idxb;
    idxa = idxb = 0;

    rep(i,C) {
        int a = sa[idxa];
        int b = sb[idxb];
        int c = W[i];
        
        if (a<c && a<b) {
            sa[idxa] = c;
            idxa++;
            idxa = min(idxa, X-1);
        }
        else if (b<c) {
            sb[idxb] = c;
            idxb++;
            idxb = min(idxb, Y-1);
        }
        else {
            break;
        }
    }

    ll ans = 0;
    rep(i,sa.size()) {
        ll tmp = sa[i];
        ans += tmp;
    }
    rep(i,sb.size()) {
        ll tmp = sb[i];
        ans += tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5500
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n;
	cin >> n;
	int tmp=n, fn=0;
	while(tmp){
		fn += tmp%10;
		tmp /= 10;
	} 
	if(!(n%fn))
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.lang.Math.*

fun main(args:Array<String>) {
	val z = readLine()!!.split(" ").map{ it.toLong() }
	val (a,b,ab) = z.take(3)
	val (x,y) = z.takeLast(2)
	
	listOf(
			2*ab*max(x,y),
			2*ab*min(x,y) + a*(x-min(x,y)) + b*(y-min(x,y)),
			a*x + b*y
	).min().let {println(it)}
}

Measured memory_bytes: 37876
S = input()

toloop = [0 for _ in S]
for i in range(1, len(S)):
    if S[i] == 'L':
        if S[i - 1] == 'L':
            toloop[i] = toloop[i - 1] + 1
        else:
            toloop[i] = 0
for i in range(len(S) - 2, -1, -1):
    if S[i] == 'R':
        if S[i + 1] == 'R':
            toloop[i] = toloop[i + 1] + 1
        else:
            toloop[i] = 0

out = [0 for _ in S]
for i in range(len(S)):
    if S[i] == 'R':
        out[i + toloop[i] + toloop[i] % 2] += 1
    else:
        out[i - toloop[i] - toloop[i] % 2] += 1

print(" ".join(map(str, out)))

Measured memory_bytes: 53044
n, m = map(int, input().split())
graph = {i:[] for i in range(n)}
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

for dst in graph[0]:
    if n-1 in graph[dst]:
        print('POSSIBLE')
        exit()
else:
    print('IMPOSSIBLE')

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli n;
vector<lli> A;

int main(void){
    cin >> n;
    rep(i, n){
        lli tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    lli k = 0;
    rep(i, n){
        if(A.at(i) == k+1) k++;
    }
    if(k == 0) cout << -1 << endl;
    else cout << n-k << endl;
    return 0;
}


Measured memory_bytes: 2420
N, M, Q = map(int, input().split())

class Cell:
    def __init__(self):
        self.value = 0
        self.L = 0
    def __repr__(self):
        return str((self.value, self.L))

pairs = [[Cell() for _ in range(N+1)] for _ in range(N+1)]
for L, R in (map(int, input().split()) for _ in range(M)):
    cell = pairs[L][R]
    cell.value += 1
    cell.L = cell.value

for i in range(N-1, 0, -1):
    for j in range(i+1, N+1):
        cell = pairs[i][j]
        cell.L += pairs[i][j-1].L
        cell.value = cell.L + pairs[i+1][j].value
for p, q in (map(int, input().split()) for _ in range(Q)):
    print(pairs[p][q].value)


Measured memory_bytes: 81116
/*
    2014.07.04 1313~1326
    2014.07.04 1451~
    C language Lecture week 4
*/

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

#define ES_max 32 // Era string max length
    // heisei_2014_12_31
    //     *    1    *    2    *    3    *    4

typedef struct Date {
    int year;
    int month;
    int date;
} Date;

void Year2EraTranslate ( char* out, Date In );
int DateCmp ( Date In1, Date In2 );

// 変えないので高速化の意味でもグローバルで定義しておく
Date Meiji  = { 1868,  9,  8 };
Date Taisho = { 1912,  7, 30 };
Date Showa  = { 1926, 12, 25 };
Date Heisei = { 1989,  1,  8 };

int main (void) {
    
    char erastr[ES_max];
    Date Input;
    
    while (1) {
        
        if ( scanf ( "%d", &Input.year ) == EOF ) {
            break;
        }
//        scanf ( "%d", &Input.year );
        scanf ( "%d", &Input.month );
        scanf ( "%d", &Input.date );
        Year2EraTranslate ( (char *) erastr, Input );
        printf ( "%s", erastr );
        fflush ( stdout );
        
    }
    
    return 0;
    
}

void Year2EraTranslate ( char* out, Date In ) {
    
    if ( DateCmp ( In, Meiji ) == -1 ) {
        sprintf ( (char*) out, "pre-meiji\n" );    // 明治以前
    } else if ( DateCmp ( In, Taisho ) == -1 ) {
        sprintf ( (char*) out, "meiji %d %d %d\n",  ( In.year -  Meiji.year + 1 ), In.month, In.date );    // 明治
    } else if ( DateCmp ( In, Showa ) == -1 ) {
        sprintf ( (char*) out, "taisho %d %d %d\n", ( In.year - Taisho.year + 1 ), In.month, In.date );    // 大正
    } else if ( DateCmp ( In, Heisei ) == -1 ) {
        sprintf ( (char*) out, "showa %d %d %d\n",  ( In.year -  Showa.year + 1 ), In.month, In.date );    // 昭和
    } else {
        sprintf ( (char*) out, "heisei %d %d %d\n", ( In.year - Heisei.year + 1 ), In.month, In.date );    // 平成
    }
    
    return;
    
}

int DateCmp ( Date In1, Date In2 ){
    // Compare Date In1 and In2
    // If In1 < In2 then return -1
    // If In1 = In2 then return 0
    // if In1 > In2 then return 1
    
    if ( In1.year == In2.year ) {
        if ( In1.month == In2.month ) {
            if ( In1.date == In2.date ) {
                return 0;
            } else {
                if ( In1.date < In2.date ) {
                    return -1;
                } else {
                    return 1;
                }
            }
        } else {
            if ( In1.month < In2.month ) {
                return -1;
            } else {
                return 1;
            }
        }
    } else {
        if ( In1.year < In2.year ) {
            return -1;
        } else {
            return 1;
        }
    }
    
}

Measured memory_bytes: 1040
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#define lli long long int
#define pb pushback
#define vec vector

using namespace std;

void dfs(vector <vector <int> >& adjList, vector <bool>& explored, int src);
void bfs(vector <vector <int> >& adjList, vector <bool>& explored, int src);

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

    int n, x, t;
    cin >> n >> x >> t;
    int ans = n / x;
    if (n % x != 0)
        ans++;
    cout << ans * t << endl;
    
    return 0;
}

void dfs(vector <vector <int> >& adjList, vector <bool>& explored, int src)
{
    explored.at(src - 1) = true;
    for (int i = 0, j = adjList.at(src - 1).size(); i < j; i++)
    {
        if (!explored.at(adjList.at(src - 1).at(i) - 1))
        {
            dfs(adjList, explored, adjList.at(src - 1).at(i));
        }
    }
    return;
}

void bfs(vector <vector <int> >& adjList, vector <bool>& explored, int src)
{
    explored.at(src - 1) = true;
    queue <int> q;
    q.push(src);
    while (!q.empty())
    {
        int temp = q.front();
        q.pop();
        for (int i = 0, j = adjList.at(temp - 1).size(); i < j; i++)
        {
            if (!explored.at(adjList.at(temp - 1).at(i) - 1))
            {
                explored.at(adjList.at(temp - 1).at(i) - 1) = true;
                q.push(adjList.at(temp - 1).at(i));
            }
        }
    }
}


Measured memory_bytes: 3608
// inputに入力データ全体が入る
function Main(input) {
    "use strict";
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const input_ = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	const A = parseInt(input_[0], 10);
    const B = parseInt(input_[1], 10);
    const choices = [1,2,3];
    const index = choices.findIndex(x => x!==A && x!== B);
    // 出力
	console.log('%d',choices[index]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC164D
int compare_lli(const void *a, const void *b) {
  long *A=(long long *) a;
  long *B=(long long *) b;
  if(*A > *B) return 1;
  if(*A < *B) return -1;
  return 0;
}
int main(void) {
  long long n, k, i, cou=0, tmp, len, mod=2019, mte=1, sum=0;

  char s[200000];
  scanf(" %s", s);

  for(len=0; s[len] != '\0'; ++len)
    ; //文字数
  long long m[len + 1];

  m[len - 1]=s[len - 1] - 48;
  m[len]=0;

  for(i=len - 2; i >= 0; i--){
    mte=(mte * 10) % mod;
    m[i]=((s[i] - 48) * mte + m[i + 1]) % mod;
  }

  qsort(m, len + 1, sizeof(long long), compare_lli); //sort

  for(i=0; i <= len; i++){
    if(m[i] == m[i + 1]) cou++;
    else{
      if(cou >= 1) sum+=cou * (cou + 1) / 2;
      cou=0;
    }

    //printf("%d\n",m[i]);
  }
  printf("%lld", sum);
}

Measured memory_bytes: 4660
n = int(input())
li = list(map(int,input().split()))
li.sort()

if len(li)%2 == 1:
    print(0)
elif len(li)%2 == 0:
    l = li[len(li)//2-1]
    r = li[len(li)//2]
    print(r-l)

Measured memory_bytes: 14396
n = int(input())
cnt2 = 0
cnt4 = 0
A = list(map(int, input().split()))
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1
odd = n - cnt2 - cnt4
if cnt2 != 0:
    odd += 1

if odd - 1 > cnt4:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 85068
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if (a < b){
        printf("a < b\n");
    }else if(a == b){
        printf("a == b\n");   
    }else{
        printf("a > b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<math.h>
int main(){
    int n,d,a=0;
    double b;
    scanf("%d %d",&n,&d);
    int x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            scanf("%d",&x[i][j]);
        }
    }
    for(int k=0;k<n;k++){
        for(int l=k+1;l<n;l++){
            b=0.0;
            for(int m=0;m<d;m++){
                b+=pow(x[k][m]-x[l][m],2.0);
            }
            if(ceil(sqrt(b))==floor(sqrt(b))){
                a++;
            }
        }
    }
    printf("%d\n",a);
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  int N, M;
  vector<pair<ll, ll>> price;
  ll A, B;

  cin >> N >> M;
  REP(i, N) {
    cin >> A >> B;
    price.push_back(make_pair(A, B));
  }

  sort(price.begin(), price.end());

  ll ans = 0;
  REP(i, N) {
    if (M <= price[i].second) {
      ans += price[i].first * M;
      break;
    } else {
      ans += price[i].first * price[i].second;
      M -= price[i].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int xs,ys;
ll a[2003];
ll b[2003];
bool vis[1009][1009];
int ans[1000004];
// 10 min for problem A : 50
// 15 min for problem B : 55
// 30 min for problem C : 60
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    int n;
    cin>>n;
    if(n%1000==0)
        return cout<<0,0;
    n=n-(1000*(n/1000));
    cout<<1000-n;
}


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

int a[200006];
int sum[200006];
int b[200006];

int main(){
  int n;
  int i,j;
  int m = 0;

  scanf("%d", &n);
  for(i = 1;i <= n;i++){
    scanf("%d", &a[i]);
    sum[i] = b[i] = 0;
  }

  vector <int> ans;

  for(i = n;i >= 1;i--){
    int sum = 0;
    for(j = i;j <= n;j += i){
      sum += b[j];
    }

    if(a[i] == 0){
      if(sum % 2 == 1){
        b[i] = 1;
        ans.push_back(i);
      }
    }

    else {
      if(sum % 2 == 0){
        b[i] = 1;
        ans.push_back(i);
      }
    }
  }

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

  for(i = 0;i < ans.size();i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
long long n,a[200001],q=1,ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		if(a[i]==q)
			++q;
		else
			++ans;
	}
	if(ans!=n)
		cout<<ans;
	else
		cout<<"-1";
	return 0;
}                                  

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
  bool ans = true;

  size_t N;
  std::cin >> N;

  std::vector<std::string> SS(N);

  for (size_t i=0; i<N; i++) {
    std::cin >> SS[i];
  }

  for (auto it = SS.cbegin(); it != SS.cend(); it++) {
    if (it != SS.cbegin())
      if (std::prev(it)->back() != it->front()) {
        ans = false;
        break;
      }

    if (std::find(std::next(it), SS.cend(), *it) != SS.cend()) {
      ans = false;
      break;
    }
  }

  std::cout << (ans ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256