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

int main()
{
	int sum_a = 0,sum_b = 0;
	char c[100000];
	char a,b;
	gets(c);
	if(strlen(c) < 2) printf("0");
	else{
		for(int i = 0;i < strlen(c);i++){
			if(i % 2 == 0){
				a = '0';
				b = '1';
			}
			else{
				a = '1';
				b = '0';
			}
			if(c[i] != a) sum_a++;
			if(c[i] != b) sum_b++;
		}
		if(sum_a <= sum_b) printf("%d",sum_a);
		else printf("%d",sum_b);
	}
	return 0;
}

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

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

using namespace std;

int main(){
    map<string,int> dp;
    string str = "01234567";

    dp[str] = 0;
    queue<string> bfs;
    bfs.push(str);
    while(!bfs.empty()){
        bool flag = true;
        str = bfs.front();
        bfs.pop();
        int t;
        rep(i,8) if(str[i] == '0') t = i;
        
        if(t>0 && t!=4){
            string tm = str;
            swap(tm[t],tm[t-1]);
            if(dp.find(tm) == dp.end()){
                bfs.push(tm);
                dp[tm] = dp[str] + 1;
            }
        }
        if(t<7 && t!=3){
            string tm = str;
            swap(tm[t],tm[t+1]);
            if(dp.find(tm) == dp.end()){
                bfs.push(tm);
                dp[tm] = dp[str] + 1;
            }
        }
        if(t>3){
            string tm = str;
            swap(tm[t],tm[t-4]);
            if(dp.find(tm) == dp.end()){
                bfs.push(tm);
                dp[tm] = dp[str] + 1;
            }                        
        }
        if(t<4){
            string tm = str;
            swap(tm[t],tm[t+4]);
            if(dp.find(tm) == dp.end()){
                bfs.push(tm);
                dp[tm] = dp[str] + 1;
            }                        
        }
    }
    
    string pz;
    pz.resize(8);
    while(cin>>pz[0]){
        rep(i,7)cin >> pz[i+1];
        cout << dp[pz] << endl;
    }
}


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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    ll ans=0;
    rep(i, 0, n)
    {
        rep(j, 1, 9)
        {
            if (a[i] < j * 400)
            {
                ans++;
                while (a[i] < j * 400)
                {
                    i++;
                }
            }
        }
    }
    if(a[0]<3200)cout << ans << " ";
    else cout << 1 << " ";
    cout << ans + a.end()-lower_bound(all(a),3200) << endl;
}   

Measured memory_bytes: 256
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
if b==0:
  print(a)
else:
  l=list(mi())
  for i in range(100):
    if not(a-i in l):
      print(a-i)
      sys.exit()
    elif not(a+i in l):
      print(a+i)
      sys.exit()

Measured memory_bytes: 9568
import sys
input = sys.stdin.readline

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
def dfs(i, a, b, c):
    if i == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c)
        else:
            return 10 ** 9
    
    res0 = dfs(i+1, a, b, c)
    if a == 0:
        res1 = dfs(i+1, a+L[i], b, c)
    else:
        res1 = dfs(i+1, a+L[i], b, c) + 10
    if b == 0:
        res2 = dfs(i+1, a, b+L[i], c)
    else:
        res2 = dfs(i+1, a, b+L[i], c) + 10
    if c == 0:
        res3 = dfs(i+1, a, b, c+L[i])
    else:
        res3 = dfs(i+1, a, b, c+L[i]) + 10

    return min(res0, res1, res2, res3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
a = [[0 for i in range(100)] for j in range(100)]
b = [[0 for i in range(100)] for j in range(100)]
n, m, l = map(int, input().split())
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = list(map(int, input().split()))
for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k] * b[k][j]
        if j == l-1:
            break
        print(c, end=' ')
    print(c)

Measured memory_bytes: 8564
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################

const int INF = 1001001001;
int dp[50][440][440];

signed main(){
	int n,ma,mb;cin >> n >> ma >> mb;
	rep(i,50)rep(j,440)rep(k,440)dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	rep(i,n){
		int a,b,c;cin >> a >> b >> c;
		rep(j,440)rep(k,440){
			dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
			if(j+a< 440 && k+b < 440)dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b],dp[i][j][k] + c);
		}
	}
	int ret = INF;
	for(int x = 1;x <= 440;x++){
		for(int y = 1;y <= 440;y++){
			// x:y == ma:mb
			
			if(x*mb == y*ma)ret = min(ret,dp[n][x][y]);
		}
	}
	if(ret == INF)ret = -1;
	cout << ret << endl;
	return 0;
}

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


int main() {
    int n,k;
    cin>>n>>k;
    vector<int> vec(n);
    rep(i,n){
        cin>>vec.at(i);

    }
    sort(vec.begin(),vec.end());
    int sum=0;
    rep(i,k){
        sum+=vec.at(i);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<string>
#define llI long long int
using namespace std;

 int main()
 {
     int N,X,T,count=0;
     cin>>N>>X>>T;
     if(N<=X)
     cout<<T;
     else
     {
        while(N>X)
        {
            N=N-X;
            count++;
        }
        cout<<T*(count+1);
         
         
            
     }
     return 0;
 }

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
using namespace std;

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int choise_sort (int n, int a[]){
  int index;
  for (int i=0; i<n-1; i++){
    int min = a[i], num;
    for (int j=i; j<n-1; j++){
      if (a[j+1]<min){
        min = a[j+1];
        num = j+1;
      }
    }
    index = a[i];
    a[i] = min;
    a[num] = index;
  }
}

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

  vector<tuple<string,int,int>> p(n);
  for (int i=0; i<n; i++){
    string s;
    int x;
    cin >> s >> x;
    p.at(i) = make_tuple(s,-x,i+1);
  }

  sort(p.begin(),p.end());
  for (auto elem : p){
    int i;
    tie(ignore,ignore,i) = elem;
    cout << i << endl;
  }
  return 0;
}


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


int main() {
	int N;
	scanf("%d", &N);
	int a;
	long long b[200010] = { 0 };
	int i;
	
	for (i = 2; i < N + 1; i++) {
		scanf("%d", &a);
		
		
				b[a] = b[a] + 1;
			}
		
	for (i = 1; i < N + 1; i++) {
		printf("%d\n", b[i]);

	}
	return 0;
}


Measured memory_bytes: 3292
num = int(input())
string = input()

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c + 64)

return_string = ""
for alphabet in string:
	index = alpha2num(alphabet)

	new_num = index + num
	if new_num % 26 == 0:
		return_string += "Z"
	else:
		return_string += num2alpha(new_num % 26)

print(return_string)

Measured memory_bytes: 3060
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    A.append(int(input()))

point = [K-Q] * N

for i in range(Q):
    point[A[i] - 1] += 1

for j in range(N):
    if point[j] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10448
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <stdlib.h>
#define LL long long
#define num1 200
#define num2 100
#define rep(i,n) for(i=0;i<=(n);i++)
#define rep2(i,k,n) for(i=k;i<=(n);i++)
using namespace std;


int main() {

  LL i,gcd,lcm,A,B,C,D,numBC,numBD,numBCD,numAC,numAD,numACD,ans;
  scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
 	
  //great common divide;
  gcd = __gcd(C,D);
  //least common multiple
  lcm = C*D/gcd;

  //整数B以下のCで割り切れるものの個数
  numBC=B/C;
  //整数B以下のDで割り切れるものの個数
  numBD=B/D;
  //整数B以下の整数CでもDでも割り切れるものの個数
  numBCD=B/lcm;
  
  //整数A-1以下のCで割り切れるものの個数
  numAC=(A-1)/C;
  //整数A-1以下のDで割り切れるものの個数
  numAD=(A-1)/D;
  //整数A-1以下の整数CでもDでも割り切れるものの個数
  numACD=(A-1)/lcm;
  
  //回答
  ans = B-numBC-numBD+numBCD-(A-1-numAC-numAD+numACD);
  
  printf("%lld",ans);
  
}



Measured memory_bytes: 128
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    if (a > b || n == 1 && a != b) {
        OUT(0);
        return 0;
    }

    OUT(1 + (n - 2) * (b - a));
    return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
vote = list(map(int, input().split()))

vote.sort(reverse=True)
popular = vote[0:m]
sum = sum(vote)

yes = True

for win in popular:
    if win < sum / (4*m):
        print('No')
        yes = False
        break


if yes:
    print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int n,a[10],i,b,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<10;i++)a[i]=0;
    for(i=0;i<n;i++){
      scanf("%d",&b);
      a[b]++;
    }
    for(i=0;i<10;i++,puts("")){
      if(a[i]==0)printf("-");
      else{
	for(j=0;j<a[i];j++){
	  printf("*");
	}
      }
    }
  }
  return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int x, a, b;
  cin>>x>>a>>b;
  int y = abs(x - a);
  int z = abs(x - b);
  if(y <= z) cout<<'A'<<endl;
  else cout<<'B'<<endl;
}


Measured memory_bytes: 14080
from math import sqrt
import sys
sys.setrecursionlimit(100000)

def prime(n):
    p = [1 for i in range(n)]
    p[0] = 0
    prime_ = []
    for i in range(2,int(sqrt(n))):
        if p[i-1] == 1:
            for i in range(2*i,n,i):
                p[i-1] = 0
    for i in range(n):
        if p[i] == 1:
            prime_.append(i+1)
    return prime_

prime_ = prime(105000)
sum_prime_ = [0 for i in range(10000)]

def sum_prime(n):
    global sum_prime_
    if n == 1:
        sum_prime_[n-1] = prime_[n-1]
        return sum_prime_[n-1]
    else:
        sum_prime_[n-1] = prime_[n-1] + sum_prime(n-1)
        return sum_prime_[n-1]

sum_prime(10000)

while(1):
    n = int(input())
    if n == 0:
        break
    print(sum_prime_[n-1])



Measured memory_bytes: 15460
#include<stdio.h>
int N, M, T[100], P, X, sum, i;
int main(){
  scanf("%d\n", &N);
  for(i=0; i<N; i++){
    scanf("%d", &T[i]);
    sum+=T[i];
  }
  scanf("%d\n", &M);
  for(i=0; i<M; i++){
    scanf("%d%d", &P, &X);
    printf("%d\n", sum+X-T[P-1]);
  }
}


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

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int s = n*m, t = n*m+1;
	char grid[n+5][m+5];
	mf_graph<int> graph(n*m+2);
	for (int i = 0; i < n; ++i) scanf("%s", grid[i]);
	for (int i = 0, v = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j, ++v) {
			if (grid[i][j] != '#') {
				if ((i+j)&1) graph.add_edge(v, t, 1);
				else {
					graph.add_edge(s, v, 1);
					if (i && grid[i-1][j] == '.') graph.add_edge(v, v-m, 1);
					if (i+1<n && grid[i+1][j] == '.') graph.add_edge(v, v+m, 1);
					if (j && grid[i][j-1] == '.') graph.add_edge(v, v-1, 1);
					if (j+1<m && grid[i][j+1] == '.') graph.add_edge(v, v+1, 1);
				}
			}
		}
	}
	printf("%d\n", graph.flow(s, t));
	auto edges = graph.edges();
	for (auto e : edges) {
		if (e.from != s && e.to != t && e.flow) {
			int i = e.from/m, j = e.from%m, i1 = e.to/m, j1 = e.to%m;
			if (i+1 == i1) {
				grid[i][j] = 'v';
				grid[i1][j1] = '^';
			}
			else if (i-1 == i1) {
				grid[i][j] = '^';
				grid[i1][j1] = 'v';
			}
			else if (j+1 == j1) {
				grid[i][j] = '>';
				grid[i1][j1] = '<';
			}
			else {
				grid[i][j] = '<';
				grid[i1][j1] = '>';
			}
		}
	}
	for (int i = 0; i < n; ++i) printf("%s\n", grid[i]);
}


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pub push_back
#define pob pop_back
#define M 1000000007
#define pii pair<ll,ll>
#define mp make_pair
using namespace std;
vector<pii >p;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,a[1000],x,c=0,ans=0;

    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    x=a[0];
    for(i=0;i<n;i++)
    {
    	if(a[i]!=x)
    	{
    		ans+=c/2;
    		x=a[i];
    		c=0;
    	}
    	c++;
    }
    ans+=c/2;
    cout<<ans;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 2e5 + 10;

vector<int> ver[N << 1];
string s, test;
int psum[N];
int f[N];
ll sumS;

void pop() {
    int n = s.size() - 1;
    s.pop_back();

    int buck = psum[n] + N;
    ver[buck].pop_back();
    sumS -= f[n];
}
void push(char ch) {
    s.push_back(ch);
    int n = s.size() - 1;
    
    psum[n] = psum[n - 1] + (s[n] == '(' ? 1 : -1);
    int buck = psum[n] + N;

    if (!ver[buck].empty() && s[n] == ')') {
        //cout << "Pull from " << ver[buck].back() << endl;
        f[n] = f[ver[buck].back()] + 1;
    }
    else f[n] = 0;
    sumS += f[n];
    ver[buck].push_back(n);
}
int main() {
    cin >> test;

    s = '@';
    ver[N].push_back(0);
    psum[0] = 0;
    sumS = 0;

    for(auto ch : test) {
        if (ch == '-') pop();
        else push(ch);
        cout << sumS << '\n';
    }
}



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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

string S;
int L;
bool c = true;

int main() {
  cin.tie(0);cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>S;
  
  L = S.length();
  
  c &= (S[0]=='A');
  
  int t = 0;
  for_(i, 2, L-1)if(S[i]=='C')t++;
  c &= (t==1);
  
  t = 0;
  rep(i, L)if('a' <= S[i] && S[i] <= 'z')t++;
  
  c &= (t==L-2);
  
  cout<<(c?"AC":"WA")<<endl;
  
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    int i,j,k,l,r,x,y; string s;
    bool exit = false;
    int N;
    cin>>N;
    vector<int> b;
    FOR(i, N){
        cin>>x;
        x -= 1;
        b.push_back(x);
    }
    //FORR(i,b)
    //    cout<<i<<endl;
    bool enable = true;
    vector<int> ret;

    while(b.size() != 0){
        int del_idx = -1;
        for(i=b.size()-1; i>=0;i--){
            if(b[i] == i){
                del_idx = i;
                ret.push_back(i);
                break;
            }
        }
        
        //cout<<del_idx;

        if (del_idx == -1){
            enable = false;
            break;
        }
        b.erase(b.begin() + del_idx);
        
    }
    if(enable){
        reverse(ALL(ret));
        FORR(i,ret){
            cout<<i+1<<endl;
        }
    }else{
        cout<<-1<<endl;
    }

    /*cin>>N;
    vector<ll> V((N+1)*(N+1));
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



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

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

  int count=0;
  for(int i=0;2*i<S.size();++i){
    if(S.at(i)!=S.at(S.size()-i-1)){
      ++count;
    }
  }

  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> s(n); REP (i, n) cin >> s[i];
  int ans = 0;
  REPI (d, 1, n - 1) {
    int acc = 0;
    unordered_map<int, int> cnt;
    for (int x = d; x < n - 1; x += d) {
      if (n - 1 - x - d <= 0) continue;
      if (cnt.count(n - 1 - x)) break;
      cnt[n - 1 - x]++;
      if (cnt.count(x)) break;
      cnt[x]++;
      acc += s[x] + s[n - 1 - x];
      chmax(ans, acc);
    }
  }
  cout << ans << endl;
}


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

#define N 4
#define TRUE 1
#define FALSE 0

int dx[4] = {0,-1,0,1}, dy[4] = {1,0,-1,0}, limit, t[N][N];

void swap(int *a,int *b){
  int tmp = *a;
  *a = *b; *b = tmp;
  return;
}

int getsum(){
  int i, j, sum = 0, x;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(t[i][j] == 0) continue;
      x = t[i][j] -1;
      sum += abs(x/4-i) + abs(x%4-j);
    }
  }
  return sum;
}

int DFS(int depth, int pre, int py, int px){
  int i, tx, ty,h = getsum();
  
  if (h == 0) return TRUE;
  if (depth+h > limit) return FALSE;
  for (i = 0; i < 4; i++){
    if(abs(i-pre) == 2) continue;
    tx=px+dx[i];
    ty=py+dy[i];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    swap(&t[ty][tx],&t[py][px]);
    if(DFS(depth+1,i,ty,tx)) return TRUE;
    swap(&t[ty][tx],&t[py][px]);
  }
  return FALSE;
}

void Solved(int py,int px){
  for(limit = 0;; limit++){
    if(DFS(0,99,py,px)){
      printf("%d\n",limit);
      return;
    }
  }
}

int main()
{
  int i,j,px,py;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      scanf("%d",&t[i][j]);
      if(t[i][j] == 0){
        py = i; px = j;
      }
    }
  }
  Solved(py,px);
  
  return 0;
}




Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll cnt=1;
    ll ans=0;
    rep(i,n){
        if(a[i]==cnt){cnt++; ans++;}
    }
    if(ans>0)cout<<n-ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;
inline int max(const int& a, const int& b){return a > b ? a : b;}

const int MAX = 2e5+10;
int fa[MAX];
int fri[MAX], g[MAX];

int Find(int x){
    if (x == fa[x]) return x;
    return fa[x] = Find(fa[x]);
}

void unite(int x, int y){
    int rx = Find(x);
    int ry = Find(y);
    if (rx == ry) return;
    fa[ry] = rx;
}

int main(){
    for (int i = 0; i < MAX; i++) fa[i] = i;
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++){
        int a, b; scanf("%d%d", &a, &b);
        unite(a, b);
    }
    int t = 0, Mx = 0;
    for (int i = 1; i <= n; i++){
        if (!g[Find(i)]) g[Find(i)] = ++t;
        Mx = max(Mx, ++fri[g[Find(i)]]);
    }
    printf("%d\n", Mx);
    return 0;
}


Measured memory_bytes: 3972
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	long H, W; cin >> H >> W;
	char s[2009][2009]; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) cin >> s[i][j];

	long yoko[2009][2009];
	for (int i = 0; i < H; i++) yoko[i][0] = 0;
	for (int i = 0; i < W; i++) yoko[0][i] = 0;

	for (int i = 1; i <= H; i++) {

		for (int j = 1; j <= W; j++) if (s[i][j] == '#') yoko[i][j] = 0; else yoko[i][j] = yoko[i][j - 1] + 1;

	}

	for (int i = 1; i <= H; i++) {

		for (int j = W - 1; j >= 1; j--) if (s[i][j] == '#') yoko[i][j] = 0; else yoko[i][j] = max(yoko[i][j], yoko[i][j + 1]);

	}

	long tate[2009][2009];
	for (int i = 0; i < W; i++) tate[0][i] = 0;
	for (int i = 0; i < H; i++) tate[i][0] = 0;

	for (int i = 1; i <= W; i++) {

		for (int j = 1; j <= H; j++) if (s[j][i] == '#') tate[j][i] = 0; else tate[j][i] = tate[j - 1][i] + 1;

	}

	for (int i = 1; i <= W; i++) {

		for (int j = H - 1; j >= 1; j--) if (s[j][i] == '#') tate[j][i] = 0; else tate[j][i] = max(tate[j][i], tate[j + 1][i]);

	}

	for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) res = max(res, tate[i][j] + yoko[i][j]);

	cout << res - 1 << endl;
}

Measured memory_bytes: 67200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S,T;
    cin >> S >>T;
    int cnt =0;
    for(int i=0; i<3; i++){
        if(S[i] == T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 123, MOD = 1e9 + 7;
int n, m, cnt[N];
pll a[N], b[N];
map <pll, int> ind;

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = (ll)res * x % MOD;
		}
		x = (ll)x * x % MOD;
		y /= 2;
	}
	return res;
}

void norm(pll & x) {
	if ((x.F > 0 && x.S < 0) || (x.F < 0 && x.S < 0)) {
		x.F *= -1;
		x.S *= -1;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int A = 0, B = 0, bad = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].F >> a[i].S;
		if (a[i].F == 0 && a[i].S == 0) {
			bad++;
		}	else {
			if (a[i].F == 0) {
				A++;
			}	else if (a[i].S == 0) {
				B++;
			}	else {
				ll g = __gcd(abs(a[i].F), abs(a[i].S));
				a[i].F /= g;
				a[i].S /= g;
				norm(a[i]);
				if (ind.count(a[i])) {
					int & x = cnt[ind[a[i]]];
					x = x * 2 % MOD;
				}	else {
					ind[a[i]] = ++m;
					b[m] = a[i];
					cnt[m] = 2;
				}
			}
		}
	}
	A = bp(2, A), B = bp(2, B);
	int ans = (ll)A * B % MOD - (ll)(A - 1) * (B - 1) % MOD + MOD;
	if (ans >= MOD) {
		ans -= MOD;
	}
	ind.clear();
	pll need;
	for (int i = 1; i <= m; i++) {
		need = {-b[i].S, b[i].F};
		norm(need);
		if (ind.count(need)) {
			int j = ind[need];
			int tmp = (ll)cnt[i] * cnt[j] % MOD - (ll)(cnt[i] - 1) * (cnt[j] - 1) % MOD + MOD;
			if (tmp >= MOD) {
				tmp -= MOD;
			}
			ans = (ll)ans * tmp % MOD;
			ans = (ll)ans * bp(cnt[j], MOD - 2) % MOD;
		}	else {
			ans = (ll)ans * cnt[i] % MOD;
		}
		ind[b[i]] = i;
	}
	ans = (ans + bad) % MOD;
	ans = (ans - 1 + MOD) % MOD;
	cout << ans;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int x,y,z;
  x = a+b;
  y = a-b;
  z = a*b;
  cout << max(x,max(y,z)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<utility>
#include<cstring>
#define pb(a)             push_back(a)
#define mp(a,b)           make_pair(a,b)
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define ms(a,b)            memset(a, b, sizeof(a))
#define loop(i,a)          for(int i=1;i<=a;i++)
#define pii                pair <int,int>
#define sl(a)              scanf("%I64d",&a)
#define sll(a,b)           scanf("%I64d %I64d",&a,&b)
#define si(a)              scanf("%d",&a)
#define sii(a,b)           scanf("%d %d",&a,&b)
using namespace std ;
typedef long long ll ;
const ll mod = 1e9+7;
int main()
{
   ll n,temp=0;
   cin >> n ;
   string s ;
   cin >> s ;
   vector < ll > r,g;
   unordered_map < ll ,bool > b;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='R')
       {
           r.pb(i+1);
       }
       else if (s[i]=='G')
       {
           g.pb(i+1);
       }
       else
       {
           b[i+1]=true;
           temp++;
       }
   }
   ll ans = r.size()*g.size()*temp;
   //cout << ans << endl;
   for(auto a : r)
   {
       for(auto x : g)
       {
           int p = (a+x)/2,q = a+x;
           if(q%2==0 && b[p]==true){ans--;}
           if(b[2*x-a]==true){ans--;}
           if(b[2*a-x]==true){ans--;}
       }
   }
   cout << ans << endl;
   return 0 ;
}

Measured memory_bytes: 4088
#include <iostream>
#include <set>
#include <string>

using namespace std;


int main(){
    int n;
    cin >> n;
    int ans[7]={1,2,4,8,16,32,64};
    int i=6;
    for(;n<ans[i];i--){}
    cout <<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define pq priority_queue
#define ll long long
#define MOD 1000000007
#define INF 9999999999
#define F first
#define S second

using namespace std;

typedef pair<int, int> pi;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll n, m, add = 1, ans, A[1010101], Q[1010101];
int main() {
	cin >> n >> m;
	rep(i, m) add *= 2;
	cout << m * 1900 * add + (n - m) * 100 * add << endl;
	return 0;
}

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


long long euclid(long long a, long long b){
	if(a == 0){
		return b;
	}
	return euclid(b % a,a);
}

long long c,d;

int main(){
	cin>>c>>d;
	cout<<c * d /euclid(c,d)<<endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N = int(input())
d = [[0]*9 for _ in range(9)]
for i in range(1,N+1):
    if i < 10:
        thou = i
        on = i
    elif i < 100:
        thou = i // 10
        on = i % 10
    elif i < 1000:
        thou = i // 100
        on = i % 10
    elif i < 10000:
        thou = i //1000
        on = i % 10
    elif i < 100000:
        thou = i //10000
        on = i % 10
    else:
        thou = i // 100000
        on = i % 10
    if on != 0:
        d[thou-1][on-1] += 1
s = 0
for p in range(9):
    for q in range(p,9):
        if p == q:
            s += d[p][q]*d[p][q]
        else:
            s += 2*d[p][q]*d[q][p]
print(s)

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

using namespace std;

int main()
{
    string str;
    cin >> str;
    bool flag = true;

    for (int i = 0; i < str.length(); ++i) {
        if ((str[i] == 'R' && (i+1) % 2 == 0) || (str[i] == 'L' && (i+1) % 2 != 0)) {
            flag = false;
            break;
        }
    }

    cout << (flag ? "Yes" : "No");
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p.at(i);
  
  sort(p.begin(),p.end());
  
  int ans=0;
  
  for(int i=0;i<n-1;i++) ans+=p.at(i);
  
  cout << ans+p.at(n-1)/2 << endl;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  if(y-x*2>=0&&4*x-y>=0&&y%2==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/* Name of the class has to be "Main" only if the class is public. */
class Main {
    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);

        int n = in.nextInt();
        StringBuilder output = new StringBuilder();

        int[][] dp = new int[n][3];
        for (int i = 0; i < n; ++i) {
            String[] s = in.nextLine().split(" ");

            for (int j=0; j<3; ++j) {
                if (i == 0) {
                    if (j == 0)
                        dp[i][j] = toInt(s[0]);
                    else if (j == 1)
                        dp[i][j] = toInt(s[1]);
                    else
                        dp[i][j] = toInt(s[2]);
                } else {
                    for (int k=0; k<3; ++k) {
                        if (j == k) continue;

                        if (j == 0)
                            dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + toInt(s[0]));
                        else if (j == 1)
                            dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + toInt(s[1]));
                        else
                            dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + toInt(s[2]));
                    }
                }
            }
        }

        output.append(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));

        System.out.print(output);
    }

    static int toInt(String c) {
        return Integer.parseInt(c);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 49220
#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: 2100
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;

    ll cnt = N / (A + B);
    cout << A * cnt + min(A, N - cnt * (A + B)) << endl;

    return 0;
}


Measured memory_bytes: 256
/* generated by esotope-bfc */
#include <stdio.h>
#include <stdint.h>
#define GETC() (fflush(stdout), fgetc(stdin))
#define PUTC(c) fputc(c, stdout)
static uint8_t m[30000], *p = m;
int main(void) {
	p[0] = GETC();
	while (p[0]) {
		p[0] = GETC();
		p[0] -= 10;
	}
	p[2] = GETC();
	p[3] = 0;
	p[2] -= 32;
	p[4] = 0;
	p[5] = 0;
	while (p[2]) {
		p[3] += 4;
		p[2] += 8*p[3];
		p[3] = 0;
		p[4] = GETC();
		p[5] += 4;
		p[4] -= 8*p[5];
		p[5] = 0;
		p += 2;
	}
	while (p[0] != 0) p -= 2;
	p[3] = GETC();
	++p[3];
	while (p[3]) {
		--p[3];
		p[5] = GETC();
		++p[5];
		p += 2;
	}
	while (p[-1] != 0) --p;
	while (p[0]) {
		PUTC(p[0]);
		++p;
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

lis = [0]*N

isnextup = [0]*(N-1) # -1:下がる, 0: 同じ, 1:上がる
for day in range(N-1):
    today = A[day]
    tommorow = A[day+1]
    if today < tommorow:
        isnextup[day] = 1
    elif today > tommorow:
        isnextup[day] = -1
        

money = 1000
stock = 0
for day in range(N-1):
    if isnextup[day] == 1:#底値で買う
        price = A[day]
        div, mod = divmod(money, price)
        money -= price * div
        stock += div
    elif isnextup[day] == -1: #天井で売る
        price = A[day]
        money += price * stock
        stock = 0

money += stock*A[-1]
print(money)

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back
#define eb emplace_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int h = in(), w = in(), n = in();
    cout << dup(n, max(h, w)) << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"strconv"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func main() {
	var N, D int
	fmt.Scanf("%d %d\n", &N, &D)
	X := [11][11]int{}
	for i := 0; i < N; i++ {
		for j := 0; j < D; j++ {
			var x int
			fmt.Scan(&x)
			X[i][j] = x
		}
	}
	cnt := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			X1 := X[i]
			X2 := X[j]
			d := 0
			for k := 0; k < D; k++ {
				d1, d2 := X1[k], X2[k]
				d = d + (d1-d2)*(d1-d2)
			}
			_, err := strconv.ParseInt(fmt.Sprint(math.Sqrt(float64(d))), 10, 64)
			if err == nil {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 512
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: a,b

    read*, a,b
    if (mod(a,3)==0 .or. mod(b,3)==0 .or. mod(a+b,3)==0) then
        print'(a)', 'Possible'
    else
        print'(a)', 'Impossible'
    end if
    
end program main

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

A = sorted(X)
m1 = A[ N // 2 - 1]
m2 = A[ N // 2]
for i in range(N):
    if X[i] < m2:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 25624