akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 30;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int N;
int a[20];

int main(){
    while(std::cin >> N, N){
        REP(i, N){
            std::cin >> a[i];
        }

        int min_diff = INF;
        REP(i, 1<<N){
            int a_sum = 0, b_sum = 0;
            REP(j, N){
                if(i >> j & 1){
                    a_sum += a[j];
                }else{
                    b_sum += a[j];
                }
            }
            min_diff = std::min(min_diff, std::abs(a_sum-b_sum));
        }
    
        std::cout << min_diff << std::endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>
#include<numeric>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, M;
pii A[100100];
vector<pii> eve;
int sum[200200];
int sum2[200200];

signed main() {
    cin >> N >> M;
    int pre;
    cin >> pre;
    --pre;
    int ans = 0;
    rep(i, N - 1) {
        int cur;
        cin >> cur;
        --cur;
        if (pre < cur)A[i] = pii(pre, cur);
        else A[i] = pii(pre, cur + M);
        pre = cur;
        ans += A[i].second - A[i].first;
    }
    rep(i, N - 1) {
        eve.emplace_back(A[i].first, i);
        eve.emplace_back(A[i].second, i);
    }
    sort(eve.begin(), eve.end());

    for (pii e:eve) {
        int p = e.first;
        int i = e.second;
        if (p == A[i].first) {
            sum[p + 2] += 1;
        } else {
            int d = A[i].second - A[i].first;
            sum[p + 1] -= d;
            sum[p + 2] += d - 1;
        }
    }
    rep(i, 2 * M + 5)sum[i + 1] += sum[i];
    rep(i, 2 * M + 5)sum[i + 1] += sum[i];
    rep(i, 2 * M + 5)cerr << sum[i] << endl;
    int maxv = -INF;
    rep(i, M) {
        maxv = max(maxv, sum[i] + sum[i + M]);
    }
    cout << ans - maxv << endl;
    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : \n" << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

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

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

    int N, M, Q; cin >> N >> M >> Q;
    vector<string> S(N); cin >> S;

    vector<vector<int>> vertical(N + 1, vector<int>(M + 1));
    vector<vector<int>> horizontal(N + 1, vector<int>(M + 1));

    rep(y, N) repeat(x, 1, M) {
        vertical[y + 1][x + 1] = vertical[y + 1][x] + (S[y][x - 1] == '1' and S[y][x] == '1');
    }
    rep(x, M + 1) rep(y, N) {
        vertical[y + 1][x] += vertical[y][x];
    }
    // debug(vertical);

    rep(x, M) repeat(y, 1, N) {
        horizontal[y + 1][x + 1] = horizontal[y][x + 1] + (S[y - 1][x] == '1' and S[y][x] == '1');
    }
    rep(y, N + 1) rep(x, M) {
        horizontal[y][x + 1] += horizontal[y][x];
    }
    // debug(horizontal);

    vector<vector<int>> blue(N + 1, vector<int>(M + 1));
    rep(y, N) rep(x, M) {
        blue[y + 1][x + 1] = blue[y + 1][x] + (S[y][x] == '1');
    }
    rep(x, M + 1) rep(y, N) {
        blue[y + 1][x] += blue[y][x];
    }
    
    rep(q, Q) {
        int xs, ys, xe, ye; cin >> ys >> xs >> ye >> xe;
        xs--; ys--;
        // cerr << ys << " " << xs << " " << ye << " " << xe << endl;
        xs++;
        int v = vertical[ye][xe] - vertical[ys][xe] - vertical[ye][xs] + vertical[ys][xs];
        xs--; ys++;
        int h = horizontal[ye][xe] - horizontal[ys][xe] - horizontal[ye][xs] + horizontal[ys][xs];
        ys--;
        int b = blue[ye][xe] - blue[ye][xs] - blue[ys][xe]+ blue[ys][xs];

        cout << b - v - h << endl;
    }

    
    return 0;
}


Measured memory_bytes: 53248
from collections import deque

N,K=map(int,input().split())
P=list(map(int,input().split()))

Ary=deque([])
ans,res,cnt=0,0,0
k=0

for i in range(N):
    cnt+=1
    k=(P[i]+1)/2
    Ary.append(k)
    res+=k
    if cnt<K:
        continue
    if ans<res:
        ans=res
    res-=Ary.popleft()

print(ans)

Measured memory_bytes: 25700
#include <stdio.h>
int main(){

  int scoreA[4],scoreB[4],sumA=0,sumB=0;
  int i;

  for(i = 0; i < 4; i++){

    scanf("%d", &scoreA[i]);
    sumA += scoreA[i];

  }

  for(i = 0; i < 4; i++){

    scanf("%d", &scoreB[i]);
    sumB += scoreB[i];
    
  }

  if(sumA >= sumB){

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

  } else {

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

  }

  return 0;

}
  



  

Measured memory_bytes: 592
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll x,y;
    cin>>x>>y;
    ll p=2*x-y/2;
    ll q=y/2-x;
    if(p>=0&&q>=0&&(p+q==x)&&(2*p+4*q==y))
    cout<<"Yes";
    else
    cout<<"No";
}
    
    
    
    
    
    

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

int main(){
  long n,k;
  cin >> n >> k;
  long p[n],c[n];
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,n)cin >> c[i];
  long ans = -INF;
  long tmp_score[n];
  rep(i,n)tmp_score[i] = 0;
  rep(i,n){
    long tmp_max = -INF, tmp = 0, now = i, iter = 0;
    while(1){
      if((iter>0 && now==i) || iter >= k)break;
      now = p[now];
      tmp += c[now];
      tmp_score[iter] = tmp;
      if(tmp > tmp_max)tmp_max = tmp;
      iter++;
    }
    if(tmp_max > ans)ans = tmp_max;
    if(tmp > 0 && iter < k){
      rep(j,iter){
        long score = tmp_score[j] + tmp*(k/iter - 1);
        if(k%iter >= j+1)score += tmp;
        if(ans < score)ans = score;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
vector<int> v[100];
bool visited[100];
void dfs(int u, int from, int to)
{
    visited[u] = true;
    for(int i = 0; i < v[u].size(); i++)
    {
        int nu = v[u][i];
        if(u == from && nu == to || u == to && nu == from) continue;
        if(not visited[nu]) dfs(nu, from, to);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int A[m + 1], B[m + 1];
    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        A[i] = a;
        B[i] = b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i < m; i++)
    {
        memset(visited, false, sizeof(visited));
        dfs(0, A[i], B[i]);
        bool ok = true;
        for(int u = 0; u < n; u++) if(not visited[u]) ok = false;
        if(not ok) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200007];
int main() {
	int n,a,b,c,d;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	int flag=0;
	int ans=0;
	for(int i=min(a,b)+1; i<max(c,d); ++i) {
		if(s[i]=='#')
			ans++;
		else
			ans=0;
		if(ans==2)
			flag=1;
	}
	if(flag)
		puts("No"),exit(0);
	ans=0;
	if(a<b&&c>d) {
		if(s[d-1]!='.') {
			int tot=0;
			for(int i=b-1; i<d; ++i) {
				if(s[i]=='.')
					ans++;
				else
					ans=0;
				if(ans==3)
					tot=1;
			}
			if(tot)
				puts("Yes"),exit(0);
		} else {
			puts("Yes");
			exit(0);
		}
	} else if(a<b&&c<d||a>b&&c>d)
		puts("Yes"),exit(0);
	else if(a>b&&c<d) {
		if(s[c-1]!='.') {
			int tot=0;
			for(int i=a-1; i<c; ++i) {
				if(s[i]=='.')
					ans++;
				else
					ans=0;
				if(ans==3)
					tot=1;
			}
			if(tot)
				puts("Yes"),exit(0);
		} else
			puts("Yes"),exit(0);
	}
	puts("No");
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll a,b,ans;

	cin >> a >> b;

	if (b%a == 0)
		ans = a + b;
	else
		ans = b - a;

	cout << ans << "\n";
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
money=0
ans=float("INF")

money=a*x+b*y
ans=min(money,ans)
#print(ans)

money=2*min(x,y)*c+(x-min(x,y))*a+(y-min(x,y))*b
ans=min(money,ans)
#print(min(x,y),ans)

money=2*c*max(x,y)
ans=min(money,ans)

print(ans)


Measured memory_bytes: 9092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll int N,A,B;
  cin>>N>>A>>B;
  
  cout<<min(N*A,B)<<endl;
}

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();
		if(n % 2 == 0){
			System.out.println(n/2);
		}else{
			System.out.println( n/ 2 +1);
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    if(K * 2 - 1 <= N) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int a;
  int b;
  int h;
  cin >>a>>b>> h;
  int x=(a+b)*h/2;
  cout << x<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  map<string,string> mp;
  mp["Sunny"] = "Cloudy";
  mp["Cloudy"] = "Rainy";
  mp["Rainy"] = "Sunny";
  cout << mp[s] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


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

	string s;
	ll n;
	cin >> n >> s;

	ll num = 0;

	REP(i, n) {
		string s1 = s.substr(0, i);
		string s2 = s.substr(i, s.size());
		ll count = 0;
		REP(j, 26) {
			//どちらにも文字が見つかったら
			if (s1.find('a' + j) != std::string::npos && s2.find('a' + j) != std::string::npos) {
				count++;
			}
		}
		num = max(num, count);
	}
	
	cout << num << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin>>S>>T;
    int l,k=0;
    l=T.size();
    for(int i=0;i<S.size();i++){
        if(S[i]==T[i])
            k++;
    }
    cout<<k;
}

Measured memory_bytes: 256
s = input()
l = s[:2]
r = s[2:]
yy = [str(i).zfill(2) for i in range(100)]
mm = [str(i).zfill(2) for i in range(1, 13)]

if l in mm and r in mm:
    print("AMBIGUOUS")
elif l in yy and r in mm:
    print("YYMM")
elif l in mm and r in yy:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

static int FindGCD(int x, int y) {
  int a = x;
  int b = y;
  while (b) {
    const int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  int x, y;
  cin >> x >> y;
  cout << FindGCD(x, y) << endl;
  return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,a,n)	for(int i=a;i<n;i++)
int main(){
	int n;
	cin>>n;
	int a[100010];
	int b[100010];
	rep(i,0,n){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	int ans=0;
	rep(i,0,n){
		int s=int(lower_bound(b,b+n,a[i])-b);
		if(i%2==0&&s%2==1)ans++;
	}
	cout<<ans<<endl;
		
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
#define int long long
//#define double long double
signed main() {
	vector<double> p(121, 0.0);
	vector<double> np(121, 0.0);
	vector<double> p2(121, 0.0);
	vector<double> e(121, 0.0);
	while (true) {
		int N, M;
		cin >> N >> M;
		if (N == 0 && M == 0)
			break;
		for (int i = 0; i <= 120; i++) {
			p[i] = 0;
			np[i] = 0;
			p2[i] = 0;
			e[i] = 0;
		}
		p[0] = 1;
		for (int ii = 0; ii < N; ii++) {
			for (int i = 0; i <= 120; i++) {
				np[i] = 0;
			}
			for (int i = 0; i <= 120; i++) {

				for (int j = 1; j <= 6; j++) {
					if (i + j <= 120) {
						np[i + j] += (1.0 / 6.0) * p[i];
					}
				}
			}
			p = np;
		}
		
		for (int i = 0; i <= 120; i++) {
			p2[i] = 0;
			e[i] = 0;
			for (int j = i; j <= 120; j++) {
				p2[i] += p[j];
				e[i] += p[j] * j;
			}
		}
		int m = 1;
		double dp = 3.5 * N;
		double res;
		int cnt = 0;
		while (true) {
			cnt++;
			// cerr<<m<<endl;
			// if(cnt==125)break;
			int a = ((int)dp) + 1LL;
			// cerr<<a << " " << m << endl;
			double A = 1 - p2[a];
			double B = e[a];
			double C = dp - (B / (1 - A));
			double D = B / (1 - A);
			//cerr << m << " " << dp << " " << C << " " << D << endl;
			int ok = (int)1 << 40;
			int ng = 0;
			if (a > 6 * N) {
				res = 6.0 * N;
				break;
			}
			while (ok - ng > (int)1) {
				int mm = (ok + ng) / 2;
				if (pow(A,mm) * C + D >= a) {
					ok = mm;
				}
				else {
					ng = mm;
				}
			}
			//cerr << ok << endl;
			//  cerr<<ok<<endl;
			if (M <= ok + m) {
				res = pow(A, M - m) * C + D;
				break;
			}
			else {
				dp = pow(A, ok) * C + D;
				m += ok;
			}
		}
		cout << fixed << setprecision(10) << res << endl;
	}
}


Measured memory_bytes: 3348
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%2==0)
    {
        cout<<"0.5000000000"<<endl;
    }
    else
    {
        ll s=n/2;
        l ss=n-s;
        l ans=ss/n;
        cout<<fixed<<setprecision(10)<<ans<<endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int a[110];
int n, i, j, k;
stack<int>sta;
signed main() {
	cin >> n;
	for (i = 1; i <= n; ++i)cin >> a[i];
	for (i = 1; i <= n; ++i) {
		if (a[i] > i) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (i = n; i > 0; --i) {
		int temp = 1;
		for (j = i; j > 0; --j) {
			if (a[j] == j)break;
		}
		sta.push(j);
		for (; j < i; ++j)a[j] = a[j + 1];
	}
	while (!sta.empty()) {
		cout << sta.top() << endl;
		sta.pop();
	}
	return 0;
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			List<Doll> dolls = new ArrayList<Doll>();
			dolls.add(new Doll(0, 0));
			for (int i = 0; i < n; i++) {
				dolls.add(new Doll(sc.nextInt(), sc.nextInt()));
			}
			int m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				dolls.add(new Doll(sc.nextInt(), sc.nextInt()));
			}
			int dp[][] = new int[n + m + 1][n + m + 1];
			int ans = 0;
			// dp[i][j] : j個目の人形を内側からi番目に配置したときに作れるマトリョーシカの数。
			Arrays.fill(dp[1], 1);
			for (int i = 1; i < n + m; i++) {
				for (int j = 1; j <= n + m; j++) {
					if (dp[i][j] == 0) {
						dp[i + 1][j] = 0;
					} else {
						int max = 0;
						Doll d1 = dolls.get(j);
						for (int k = 1; k <= n + m; k++) {
							if (j == k)
								continue;
							Doll d2 = dolls.get(k);
							if (d1.h > d2.h && d1.r > d2.r)
								max = Math.max(max, dp[i][k]);
						}
						dp[i + 1][j] = max+1;
						ans = Math.max(ans, max+1);
					}
				}
			}
			// for (int i = 1; i <= n + m; i++) {
			// System.out.println(Arrays.toString(dp[i]));
			// }
			System.out.println(ans);

			// 1行目 一郎君のマトリョーシカの人形の数n（100以下の整数）
			// 2行目 一郎君の第一の人形の情報 h1 r1（整数 整数；半角空白区切り）
			// h1：一郎君の第一の人形の高さ（1,000未満の整数）
			// r1：一郎君の第一の人形の半径（1,000未満の整数）
			// 3行目 一郎君の第二の人形の情報 h2 r2（整数 整数；半角空白区切り）
			// ：
			// n+1行目 一郎君の第nの人形の情報 hn rn（整数 整数；半角空白区切り）
			// n+2行目 二郎君のマトリョーシカの人形の数 m（100以下の整数）
			// n+3行目 二郎君の第一の人形の情報 h1 r1（整数 整数；半角空白区切り）
			// h1：二郎君の第一の人形の高さ（1,000未満の整数）
			// r1：二郎君の第一の人形の半径（1,000未満の整数）
			// n+4行目 二郎君の第二の人形の情報 h2 r2（整数 整数；半角空白区切り）
			// ：
			// n+m+2行目 二郎君の第mの人形の情報 hm rm（整数 整数；半角空白区切り）
			//
			// Output
			//
			// 入力データセットごとに新たなマトリョーシカが含む人形の数k（整数）を出力します。
		}
	}
}

class Doll {
	int h;
	int r;

	Doll(int h, int r) {
		this.h = h;
		this.r = r;
	}
}

Measured memory_bytes: 12000
/*  
    ┬┴┬┴┤(･_├┬┴┬┴ hiding from those WAs
*/

#include <bits/stdc++.h>
using namespace std;

int h, w;
string s[105];
int f[105][105][2];
void ngk(){
    cin >> h >> w;
    for(int i=1;i<=h;i++){
    	cin >> s[i];
    	s[i] = '0' + s[i] + '0';
    }
    for(int i=0;i<=h;i++)
    	for(int j=0;j<=w;j++)
    		f[i][j][0] = f[i][j][1] = (int) 1e9;
    
    if (s[h][w] == '.')
    	f[h][w][0] = 0;
    else
    	f[h][w][1] = 1;
    
    for(int i=h;i>=1;i--){
    	for(int j=w;j>=1;j--){
    		if (i == h && j == w)
    			continue;
    		
    		if (s[i][j] == '.'){
    			if (i < h)
    				f[i][j][0] = min(f[i][j][0], min(f[i+1][j][0], f[i+1][j][1]));
    			if (j < w)
    				f[i][j][0] = min(f[i][j][0], min(f[i][j+1][0], f[i][j+1][1]));
    		}
    		else{
    			if (i < h)
    				f[i][j][1] = min(f[i][j][1], min(f[i+1][j][0] + 1, f[i+1][j][1]));
    			if (j < w)
    				f[i][j][1] = min(f[i][j][1], min(f[i][j+1][0] + 1, f[i][j+1][1]));
    		}
    	}
    }
    
    cout << min(f[1][1][0], f[1][1][1]);
}

int main(int argc, char *argv[]){
    iostream::sync_with_stdio(0);
    int test = 1;
    while(test--){
        ngk();
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> maps(H);
	REP(i, H) cin >> maps[i];
	
	
	int ans = 0;
	REP(i, 1<<H) REP(j, 1<<W) {
		int cur = 0;
		REP(y, H) REP(x, W) if (i >> y & 1 && j >> x & 1) {
			if (maps[y][x] == '#') ++cur;
		}
		if (cur == K) ++ans;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3632
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 998244353;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 3e3 + 10;
int a[N];
int dp[2][N][N];

int n, m;
void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int solve(int first, int pos, int rem) {
  if (rem == 0) return n - pos + 1;
  if (pos == n) return 0;
  int& ret = dp[first][pos][rem];
  if (ret >= 0) return ret;
  ret = 0;
  // no add
  add(ret, solve(first, pos + 1, rem));
  // add
  if (rem >= a[pos]) {
    if (first) {
      add(ret, solve(first, pos + 1, rem - a[pos]));
    } else {
      add(ret, 1LL * solve(true, pos + 1, rem - a[pos]) * (pos + 1) % MOD);
    }
  }
  return ret;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  memset(dp, 255, sizeof(dp));
  int ret = solve(0, 0, m);
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 71296
#include <stdio.h>
int main(void)
{
    int n;
    int f = 0;
    char a;
    scanf("%d",&n);
    (void)getchar(); 
    for(int i=0; i < n; i++){
        scanf(" %c",&a);
        //(void)getchar(); 
        if(a == 'Y'){f = 1;}
    }
    
    if(f == 1){printf("Four\n");}else{printf("Three\n");}
    return 0;
}

Measured memory_bytes: 128
require 'tsort'
require 'set'

n, m = gets.split.map(&:to_i)

class Hash
    include TSort
    alias :tsort_each_node :each_key
    def tsort_each_child(i)
        self[i].each{|j| yield j}
    end
end

orig_graph = {}
(1..n).each { |i| orig_graph[i] = Set.new }
edges = (1..m).map { gets.split.map(&:to_i) }
edges.each { |i, j| orig_graph[j] << i }

gc = {}
dec = orig_graph.strongly_connected_components
dec.each_with_index do |a, i|
    a.each { |j| gc[j] = i }
end

graph = {}
(0..dec.size-1).each {|i| graph[i] = Set.new }
edges.each do |i, j|
    graph[gc[j]] << gc[i] unless gc[i] == gc[j]
end

roots = Set[*graph.keys]
graph.each { |_, children| roots -= children }

def f(graph, i)
    s = 1 + graph[i].map{|j| f(graph, j)}.inject(1, :*)
    s % 1_000_000_007
end

p roots.map{|i| f(graph, i)}.inject(1, :*) % 1_000_000_007

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

typedef long long ll;

int main(){
	string S;
	cin >> S;
	for(int i=1; i<(int)S.size(); i++){
		if(S[i] == S[i-1]){	cout << "Bad"<<endl; return 0;}

	}
	cout << "Good" << endl;

	return 0;
}




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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    string s ;
    cin >> s ;

    s = "." + s ;

    if ( s[3] == s[4] and s[5] == s[6] ) cout << "Yes" ;
    else cout << "No" ;

    line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct Info{
	int x;
	int l;
	Info(int X,int L){
		x=X;l=L;
	}
	bool operator<(const Info &another)const{
		return (x < another.x);
	};
	bool operator>(const Info &another)const{
		return (x > another.x);
	};
};
int main(){
	int N,X,L,sum=1,b=0;
	bool flag;
	vector<Info> info;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>X>>L;
		X+=L;
		L=X-L*2;
		info.push_back(Info(X,L));
	}
	sort(info.begin(),info.end());
	
	for(int i=1;i<N;i++){
		flag = info[i].l>=info[b].x;
		if(flag){
			sum++;
			b=i;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1400
import java.util.*;

class Main {
    public static void main(String[] args) {
        Set<Integer> list = new HashSet<Integer>();

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        for (int i=0;i<N;i++) {
        	list.add(Integer.parseInt(sc.next()));
        }

        System.out.println(list.size());
    }
}

Measured memory_bytes: 21972
using System.Linq;
using System.Collections.Generic;
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = Volume0.IsItARightTriangle();
            System.Diagnostics.Trace.WriteLine(result);
            Console.WriteLine(result);
        }
    }

    public static class Volume0
    {
        public static string IsItARightTriangle()
        {
            var count = int.Parse(Console.ReadLine());
            var result = new List<string>();
            foreach (var i in Enumerable.Range(1, count))
            {
                var inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray();
                if (Math.Pow(inputs[0], 2) == Math.Pow(inputs[1], 2) + Math.Pow(inputs[2], 2))
                {
                    result.Add("YES");
                }
                else
                {
                    result.Add("NO");
                }
                
            }
            return string.Join("\n", result.ToArray());
        }
    }
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] *= 2;
    ll l = 0, r = 1e12;
    auto check = [&](ll m) {
        rep(i, n) {
            m = a[i] - m;
        }
        return m;
    };
    rep(_, 1024) {
        ll m = (l + r) / 2;
        auto x = check(m);
        if(x < m) r = m;
        else l = m;
    }
    rep(i, n) {
        cout << l << (i+1 == n ? '\n' : ' ');
        l = a[i] - l;
    }
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const ll INF = 1e15;
int n, a, b, p;
ll dp[5005], ans = INF;
int main(){
	scanf("%d%d%d", &n, &a, &b);
	rep(i,n){
		scanf("%d", &p);
		ll m = INF;
		rep(j,p){
			m = min(m,dp[j]);
			dp[j] += a;
		}
		dp[p] = m;
		for(int j=p+1; j<=n; j++) dp[j] += b;
	}
	rep(i,n+1) ans = min(ans, dp[i]);
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
N = int(input())
A = [int(e) - 1 for e in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
before = N
result = 0
for i in range(N):
  result += B[A[i]]
  if before + 1 == A[i]:
    result += C[before]
  before = A[i]
print(result)


Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int score(vector<int> const &seq, vector<tuple<int,int,int,int>> const &table) {
  int pt = 0;
  for (auto &&row : table) {
    int a, b, c, d; tie(a,b,c,d) = row;
    if (seq[b] - seq[a] == c) {
      pt += d;
    }
  }
  return pt;
}

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;

  vector<tuple<int,int,int,int>> tab;
  REP(i, Q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    tab.emplace_back(--a, --b, c, d);
  }

  int ans = 0;

  int const F = N + M - 1;
  vector<int> Box(F, 0);
  fill(begin(Box), begin(Box) + N, 1);
  do {
    vector<int> a(N);
    for(int i = 0, t = 0, k = 0; i < F; ++i) {
      (Box[i] ? a[t++] : k) = k + 1;
    }
    chmax(ans, score(a, tab));
  } while (prev_permutation(begin(Box), end(Box)));

  cout << ans << "\n";
  return 0;
}


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

using namespace std;

typedef long long ll;

string S = "POSSIBLE" ; string T = "IMPOSSIBLE";

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

int main(){
  int N; cin >> N; ll K; cin >> K;
    vector<ll> A(N); ll max_res = 0;
  bool flag = false;
  for(int i = 0; i < N; i++){  cin >> A[i];
     if( A[i] == K){ flag = true;} max_res = max( max_res, A[i]);
                            }
   
  if( flag){ cout << S << endl; return 0;}
  if( max_res < K){ cout << T << endl; return 0;}
  
  ll g = A[0];
  
  for(int i = 0; i < N; i++){
    g = GCD(g, A[i]);} // i == 0の場合もOK
  
  if( !( K % g )){ cout<< S << endl;}
  else{ cout << T << endl;}
  return 0;}
  

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

int main(){
    string S;
    cin >> S;
    int zerocount = 0;
    int onecount = 0;
    for(int i = 0; i < S.size(); i++){
        if (S[i] == '0') zerocount++;
        else onecount++;
    }
    cout << 2 * min(zerocount, onecount) << endl;
    return 0;
}

Measured memory_bytes: 512
# D - String Formation
from collections import deque


def main():
    S = input().rstrip()
    Q = int(input())
    queue = deque(S)
    to_beginning, to_end = queue.appendleft, queue.append
    is_reversed = 0
    for _ in range(Q):
        query = input().split()
        if query[0] == "1":
            to_beginning, to_end = to_end, to_beginning
            is_reversed ^= 1
            continue
        com, c = query[1], query[2]
        if com == "1":
            to_beginning(c)
        else:
            to_end(c)
    ans = "".join(queue) if not is_reversed else "".join(reversed(queue))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8564
import sys
sys.setrecursionlimit(10 ** 7)

dct = {"#": 0, ".": 1, "-": 2}


def f(c):
    return dct[c]


h, w = map(int, input().split())
s = [[2] * (w + 2)]
for _ in range(h):
    s.append([2] + list(map(f, input())) + [2])
s.append([2] * (w + 2))

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]


def dfs(col, hh, ww):
    if s[hh][ww] != col:
        return

    cnt[col] += 1
    s[hh][ww] = 2

    for dh, dw in d:
        nh = hh + dh
        nw = ww + dw
        dfs(1-col, nh, nw)


ans = 0
for hi in range(1, h + 1):
    for wi in range(1, w + 1):
        cnt = [0, 0]
        if s[hi][wi] != 2:
            dfs(s[hi][wi], hi, wi)
        ans += cnt[0] * cnt[1]

print(ans)


Measured memory_bytes: 156200
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main(){
    string a;
    ll b;
    cin>>a>>b;
    char ans = '1';
    for(int i=0; i<b; i++){
        if(a[i]!='1'){
            ans=a[i];
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1000000;
const int Mod=998244353;
int n;
#define Maxn 1000010
int A[Maxn],F[Maxn],sum[Maxn],f[Maxn];
int p[Maxn],mo[Maxn],inv[Maxn];
bool vis[Maxn];
inline void Init(){
	mo[1]=1;
	inv[0]=inv[1]=1;
	for(register int i=2;i<=N;++i){
		inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
		if(!vis[i]){p[++p[0]]=i;mo[i]=-1;}
		for(register int j=1;j<=p[0]&&1ll*i*p[j]<=N;++j){
			vis[i*p[j]]=true;
			if(i%p[j]==0){
				mo[i*p[j]]=0;
				break;
			}else mo[i*p[j]]=-mo[i];
		}
	}
}

int main(){
	Init();
	scanf("%d",&n);
	for(register int i=1;i<=n;++i){
		scanf("%d",&A[i]);
		sum[A[i]]=(sum[A[i]]+A[i])%Mod;
	}
	for(register int i=1;i<=N;++i){
	    for(register int j=i;j<=N;j+=i)F[i]=(F[i]+sum[j])%Mod;
		F[i]=1ll*F[i]*F[i]%Mod; 
	}
	int Ans=0;
	for(register int i=1;i<=N;++i){
		for(register int j=i;j<=N;j+=i)
		    if(mo[j/i]==1)f[i]=(f[i]+F[j])%Mod;
		    else if(mo[j/i]==-1)f[i]=(f[i]-F[j]+Mod)%Mod;
	    Ans=(Ans+1ll*f[i]*inv[i])%Mod;  
	}
	for(register int i=1;i<=n;++i)Ans=(Ans-A[i]+Mod)%Mod;
	printf("%d\n",1ll*inv[2]*Ans%Mod);
	return 0;
}

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

#ifdef LOCAL_PC
	#define debug(args...) cout.flush(); fflush(stdout); fprintf(stderr, args)
#else
	#define debug(args...) ; /*  */
#endif
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class num> inline void rd(num &x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
	x = (x << 3) + (x << 1) + c - '0';
	if (neg) x = -x;
}

const int MAXN = 1e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int x, a; cin >> x >> a;
	cout << (x >= a) * 10 << "\n";
	
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = scan.nextInt();
		int m = scan.nextInt();

		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}

		int[] c = new int[m];
		int[] d = new int[m];
		for(int i = 0; i < m; i++){
			c[i] = scan.nextInt();
			d[i] = scan.nextInt();
		}

		int[] min = new int[n];
		for(int i = 0; i < n; i++){
			min[i] = Math.abs(a[i]-c[0]) + Math.abs(b[i]-d[0]);
			int point = 1;
			for(int j = 1; j < m; j++){
				int dis = Math.abs(a[i]-c[j]) + Math.abs(b[i]-d[j]);
				if(min[i] > dis){
					min[i] = dis;
					point = j+1;
				}
			}
			System.out.println(point);
		}
	}
}


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

int main() {
	int N, X[100];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];
	for (int i = 1; i <= N; i++) {
		sort(X, X + i);
		for (int i = 0; i < N; i++) {
			if (i != 0) cout << " ";
			cout << X[i];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3120
import java.util.Scanner;

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

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	}
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	bool result = true;
	while (n--) {
		int a; cin >> a;
		if (a % 2 == 0) {
			if (!(a % 3 == 0 || a % 5 == 0)) result = false;
		}
	}
	if (result) cout << "APPROVED";
	else cout << "DENIED";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int c=1;
    for(i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1]) continue;
        else c++;
    }
    cout<<c<<endl;
    return 0;
}


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

using namespace std;

const int MAXN = 100005;

int n, m;
int bio[MAXN];
vector <int> v[MAXN];
vector <pair <int, int> > sol;

void dfs (int x, int c, int d) {
    sol.push_back(make_pair(c, x));
    bio[x] = 1;
    for (int i=0; i<v[x].size(); i++) {
        int sus = v[x] [i];
        if (!bio[sus]) {
            dfs(sus, c + d, d);
            break;
        }
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(1, 1, 1);
    dfs(1, -1, -1);
    sort(sol.begin(), sol.end());
    cout << sol.size()-1 << endl;
    for (int i=0; i<sol.size(); i++) {
        if (i+1 < sol.size() && sol[i].second == sol[i+1].second) continue;
        cout << sol[i].second << " ";
    }
    return 0;
}


Measured memory_bytes: 13300
s = input()
K = int(input())

Ans = []
for i in range(len(s)):
  for j in range(i + 1, min(i + K + 1, len(s) + 1)):
    t = s[i:j]
    Ans.append(t)

Ans.sort()

L = []
for i in Ans:
  if i not in L:
    K -= 1
    if K == 0:
      print(i)
      exit()
    L.append(i)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007


int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = S[K - 1] - 'A' + 'a';
    cout << S << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int ans=0;
    string S;cin>>S;
    for(int i=1;i<S.size();i++)if(S[i]!=S[i-1])ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9+9;
const int maxv = 310;
int N, G[maxv][maxv], rm[maxv][maxv];

int main()
{
    while (cin >> N) {
        FOR(i,0,N) FOR(j,0,N) 
            cin >> G[i][j], rm[i][j] = 0;
        bool good = true;
        FOR(k,0,N) FOR(i,0,N) FOR(j,0,N) {
            const int d = G[i][k]+G[k][j];
            if (d == G[i][j] && k != i && k != j)
                rm[i][j] = true;
            if (d < G[i][j])
                good = false;
        }
        if (!good)
            cout << -1 << endl;
        else {
            LL ans = 0;
            FOR(i,0,N) FOR(j,i+1,N) if (!rm[i][j])
                ans += G[i][j];
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024