akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static int N,A,B,C,X;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		for(;;){
			N=sc.nextInt();
			A=sc.nextInt();
			B=sc.nextInt();
			C=sc.nextInt();
			X=sc.nextInt();
			if(N+A+B+C+X==0)break;
			int[] y = new int[N];
			for(int i=0;i<N;i++){
				y[i]=sc.nextInt();
			}
			int xx=X;
			int cnt=0;
			int now=0;
			for(;cnt<=10000;){
//				System.out.println(N+" "+now);
				if(xx==y[now]){
					now++;
				}
				if(now==N)break;
				xx=(A*xx+B)%C;
				cnt++;

			}
			if(cnt==10001){
				System.out.println(-1);
			}
			else{
				System.out.println(cnt);
			}
		}
	}

}

Measured memory_bytes: 31656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int>a(n), b(n), c(m), d(m);
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++)cin >> c[i] >> d[i];
	vector<int>dist(n,1e9);
	vector<int>ans(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (dist[i] > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				dist[i] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans[i] = j;
			}
		}
		cout << ans[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll i;
    ll ans=1;
    ll a[26];
    for(i=0;i<26;i++){
      a[i]=1;
    }
    for(i=0;i<n;i++){
      a[s[i]-97]+=1;
    }
    for(i=0;i<26;i++){
      ans=(ans*a[i])%1000000007;
    }
    ans=(ans-1)%1000000007;
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n,x,a[101],ans,sum;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>x;
	for (int i=0;i<n;++i) cin>>a[i];
	ans=1;
	for (int i=0;i<n;++i)
	{
		sum+=a[i];
		if (sum>x) break;
		++ans;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    double L; cin >> L;

    cout << fixed << setprecision(14) << L*L*L/27.0 << endl;
    return 0;
    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
L=[-1]*n
for i in range(m):
    s,c = map(int,input().split())
    s-=1
    if s>n-1: 
        continue
    if L[s] ==-1 and s<=n-1:
        L[s] = c

    else:
        if L[s]!=c:
            print(-1)
            sys.exit()
    if L[0]==0 and n>1:
        print(-1)
        sys.exit()
if len(L)==1 and L[0]==-1:
    L[0]=0
elif L[0]==-1:
    L[0]=1
for i in range(n):
    if L[i]==-1:
        L[i]=0
print("".join(map(str,L)))
        






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

int q;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> q;
	while(q){
		long long a, b, r, e;
		cin >> a >> b;
      
		e = 1LL * a * b;
		r = sqrt(e);

		cout << 2 * r - (1 + ((1LL * r * r == e && r != a) + (1LL * r * (r + 1) >= e))) << '\n';
		q--;
	}	
}



Measured memory_bytes: 256
class BinaryTree {
  constructor(n) {
    this.nodes = [];
    for (let i = 0; i < n; i++) this.nodes[i] = {id: i + 1, parentId: -1, leftId: -1, rightId: -1}
  }

  get root() { return this.nodes.find(n => n.parentId === -1); }

  find(id) { return this.nodes[id - 1] || {}; }

  printByPostorder() {
    let str = '';
    const postorder = (id) => {
      if (id === -1) return;
      let n = this.find(id);
      postorder(n.leftId);
      postorder(n.rightId);
      str += `${id} `;
    };
    postorder(this.root.id);
    console.log(str.substr(0, str.length - 1));
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const preOrder = lines.shift().split(' ').map(Number);
  const inOrder = lines.shift().split(' ').map(Number);

  let tree = makeTree(preOrder, inOrder);
  tree.printByPostorder();
})();

function makeTree(preOrder, inOrder) {
  let tree = new BinaryTree(preOrder.length);
  const innerMakeTree = (p, i) => {
    let midId = p[0];
    let midIdx = i.indexOf(midId);
    if (midIdx === -1) return;
    if (midIdx > 0) {
      tree.find(midId).leftId = p[1];
      tree.find(p[1]).parentId = midId;
      innerMakeTree(p.slice(1, midIdx + 1), i.slice(0, midIdx))
    }
    if (midIdx < i.length - 1) {
      tree.find(midId).rightId = p[midIdx + 1];
      tree.find(p[midIdx + 1]).parentId = midId;
      innerMakeTree(p.slice(midIdx + 1), i.slice(midIdx + 1))
    }
  }
  innerMakeTree(preOrder, inOrder);
  return tree;
}



Measured memory_bytes: 15408
#include<bits/stdc++.h>
using namespace std;
int min(vector<int> a, int n){
    int ret=a.at(0);
    for(int i=1;i<n;i++){
        if(a.at(i)<ret) ret=a.at(i);
    }
    return ret;
}
int max(vector<int> a, int n){
    int ret=a.at(0);
    for(int i=1;i<n;i++){
        if(a.at(i)>ret) ret=a.at(i);
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    cout<< max(a,n)-min(a,n)<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void solve();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int q=1;//cin>>q;
    while(q--){
        solve();
    }
    return 0;
}
void solve(){
int n;cin>>n;
if(n==1)
cout<<0<<endl;
else
cout<<1<<endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0;i < n;i++){
    cin >> h[i];
  }
  int ans = 0;
  
  int c = 0;
  for (int i = 0;i < n-1;i++){
    if (h[i] >= h[i+1]){
      c++;
    }
    else{
      ans = max(ans,c);
      c = 0;
    }
  }
  ans = max(ans,c);
  
  cout << ans << endl;
}

Measured memory_bytes: 3656
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 100000000)

	s := scanText()
	n := len(s)
	p := 0
	for _, e := range s {
		if e == 'p' {
			p++
		}
	}

	fmt.Println(n/2-p)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2005;
int n,sz[N];ll ans=1e18,f[N],g[N];
char s[N];vector<int>G[N];
void dfs(int x,int p)
{
	sz[x]=s[x]=='1';g[x]=0;ll mx=0,sum=0;
	for(int i=0;i<G[x].size();i++)if(G[x][i]!=p)
	{
		int y=G[x][i];dfs(y,x);sz[x]+=sz[y];
		g[y]+=sz[y];g[x]+=g[y];f[y]+=sz[y];
		if(f[y]>=f[mx])sum+=g[mx],mx=y;else sum+=g[y];
	}
	if(sum>=f[mx])f[x]=(sum-f[mx])&1;else f[x]=f[mx]-sum;
}
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),G[u].push_back(v),G[v].push_back(u);
	for(int i=1;i<=n;i++){dfs(i,0);if(!f[i])ans=min(ans,g[i]);}
	printf("%d\n",ans==1e18?-1:ans/2);return 0;
}

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, a[220000], b[220000],dp[200000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Seg {
	LL n;
	vector<LL>node, lazy;
	Seg(LL n_) {
		n = 1; while (n < n_)n *= 2;
		node.resize(n * 2 - 1);
		lazy.resize(n * 2 - 1);
		rep(i, n)node[n + i - 1] = 0;
		Rrep(i, n - 2)node[i] = max(node[i * 2 + 1], node[i * 2 + 2]);
		//区間最小などの時
		//rep(i, n * 2 - 1)lazy[i] = -1;
	}
	void update(LL i, LL x) {
		i = i + n - 1;
		node[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			node[i] = max(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}
	LL find(LL l, LL r) {
		return find(0, 0, n - 1, l, r);
	}
	LL find(LL i, LL a, LL b, LL l, LL r) {
		if (b< l || r < a)return 0;
		if (l <= a && b <= r)return node[i];
		return max(find(i * 2 + 1, a, (a + b) / 2, l, r), find(i * 2 + 2, (a + b + 1) / 2, b, l, r));
	}


};
Seg seg(200000);
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	//dp[i][h] : i番目まででhを超えない最大の価値
	rep(i, n) {
		dp[a[i]] = max(dp[a[i]], seg.find(0, a[i] - 1) + b[i]);
		seg.update(a[i], dp[a[i]]);
	}
	cout << seg.find(0, n ) << endl;
	return 0;
}


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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N, M;
int s[5], c[5];

bool check(int a) {
    vector<int> d;
    rep(i, N) {
        d.PB(a % 10);
        a /= 10;
    }

    reverse(all(d));

    rep(i, M) {
        if (d[s[i]] != c[i]) {
            return false;
        }
    }

    return true;
}

signed main()
{
    cin >> N >> M;

    rep(i, M) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    if (N == 1) {
        rep(i, 10) {
            if (check(i)) {
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
        return 0;
    }

    // N > 1
    int s = 1;
    rep(i, N) s *= 10;

    for (int i = s/10; i < s; ++i) {
        if (check(i)) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

using namespace std;
using namespace atcoder;
using ll = long long;

const ll X = 1'000'000'000;
ll n, k;
ll a[50][50];

mcf_graph<ll, ll> g;

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

    g = mcf_graph<ll, ll>(2 * n + 2);

    int s = 2 * n, t = 2 * n + 1;

    g.add_edge(s, t, n * k, X);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
            g.add_edge(i, n + j, 1, X - a[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        g.add_edge(s, i, k, 0);
        g.add_edge(n + i, t, k, 0);
    }

    ll total = n * k * X - g.flow(s, t, n * k).second;

    vector<string> ans(n, string(n, '.'));

    for (auto [from, to, cap, flow, cost] : g.edges()) {
        if (from != s and to != t and flow != 0) {
            //cout << from << " " << to << " " << flow << endl;
            ans[from][to - n] = 'X';
        }
    }

    cout << total << endl;
    for (auto s : ans) {
        cout << s << endl;
    }
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    cin >>n;
    vector<int> a(n);
    rep(i,n) scanf(" %d", &a[i]);

    ll ans=0;
    rep(i,n)
    {
        //i同士
        ans += a[i]/2;
        a[i] -= (a[i]/2)*2;
        if(i<n-1)
        {
            //iとi+1
            if(a[i]==1 && a[i+1]>0)
            {
                ans+=1;
                --a[i];
                --a[i+1];
            }
        }
    }
    ans+=a[n-1]/2;

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


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int[] num=new int[a];
		for(int i=0;i<a;++i){
			num[i]=sc.nextInt();
		}
		int[] dp=new int[a];
		dp[0]=num[0];
		int length=1;
		for(int i=1;i<a;++i){
			if(dp[length-1]<num[i]){
				dp[length++]=num[i];
			} else {
				int len=Arrays.binarySearch(dp,0,length-1,num[i]);
				if(len<=0){
					if(len!=0){
						len=(-1*len)-1;
					}
						dp[len]=num[i];
				}
			}
		}
		System.out.println(length);
	}
}

Measured memory_bytes: 69752
#include<stdio.h>

int main()
{
  int w,h,n;

  scanf("%d %d %d",&w,&h,&n);

  int t[101][101]={};
  int x,y,a;
  int i,j,k;
  int ans=0;

  for (k=1;k<=n;k++) {
    scanf("%d %d %d",&x,&y,&a);
    if (a==1) {
      for (i=0;i<x;i++) {
	for (j=0;j<h;j++) {
	  t[i][j]=1;
	}
      }
    } else if (a==2) {
      for (i=x;i<w;i++) {
	for (j=0;j<h;j++) {
	  t[i][j]=1;
	}
      }
    } else if (a==3) {
      for (i=0;i<w;i++) {
	for (j=0;j<y;j++) {
	  t[i][j]=1;
	}
      }
    } else {
      for (i=0;i<w;i++) {
	for (j=y;j<h;j++) {
	  t[i][j]=1;
	}
      }
    }
  }

  for (i=0;i<w;i++) {
    for (j=0;j<h;j++) {
      if (t[i][j]==0) {
	ans++;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

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

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H, W, N;
    int a[100100];

    cin >> H >> W >> N;

    reps(i, 1, N) {
        cin >> a[i];
    }

    int mat[105][105];
    int nowColor = 1;
    int paintCount = 0;
    int dx = 1;

    rep(i, H) {
        const int begin = (dx > 0) ? 0 : W-1;
        const int end = (dx > 0) ? W : -1;
        for(int j = begin; j != end; j += dx) {
            mat[i][j] = nowColor;
            if (++paintCount >= a[nowColor]) paintCount = 0, ++nowColor;
        }
        dx = -dx;
    }

    rep(i, H) {
        printContainer(mat[i], mat[i] + W) << endl;
    }


    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
using std::swap;

int main() {
	int K, X;
	cin >> K >> X;
	for (int i = X - K + 1; i < X + K; i++)cout << i<<" ";
	return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int x = cin.Int();
			int max = n * 2  - 1;
			if (x == 1 || x == max) {
				Console.WriteLine("No");
			} else {
				if (n == 2) {
					StringBuilder sb = new StringBuilder();
					sb.AppendLine("Yes");
					for (int i = 0; i < max; i++) {
						sb.AppendLine((i + 1).ToString());
					}

					Console.WriteLine(sb.ToString());
				} else {
					List<string> ss = new List<string>();
					ss.Add("Yes");
					var nums = Enumerable.Range(1, max).ToList();
					if (x == 2) {
						nums.RemoveAt(x + 1);
						nums.RemoveAt(x);
						nums.RemoveAt(x - 1);
						nums.RemoveAt(x - 2);

						for (int i = 0; i < n - 2; i++) {
							ss.Add(nums[i].ToString());
						}

						ss.Add((x + 1).ToString());
						ss.Add((x).ToString());
						ss.Add((x - 1).ToString());
						ss.Add((x + 2).ToString());

						for (int i = n - 2; i < max - 4; i++) {
							ss.Add(nums[i].ToString());
						}
					} else {
						nums.RemoveAt(x);
						nums.RemoveAt(x - 1);
						nums.RemoveAt(x - 2);
						nums.RemoveAt(x - 3);

						for (int i = 0; i < n - 2; i++) {
							ss.Add(nums[i].ToString());
						}

						ss.Add((x - 1).ToString());
						ss.Add((x).ToString());
						ss.Add((x + 1).ToString());
						ss.Add((x - 2).ToString());

						for (int i = n - 2; i < max - 4; i++) {
							ss.Add(nums[i].ToString());
						}
					}

					Console.WriteLine(string.Join("\n", ss));
				}
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll a,b,c,k; cin>>a>>b>>c>>k;

    ll ans = min(a,k) - max(0ll, k-a-b);
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3648
fn main() {
    let n = read::<u32>();
    let a = read::<u32>();
    println!("{}", n * n - a);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
"use strict";

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0].split(" ")[0]);
  let x = parseInt(arg[0].split(" ")[1]);
  let a = new Array(N);
  let tmp = arg[1].split(" ");
  let sum =0;
  for(let i=0;i<N;i++){
	  a[i]=parseInt(tmp[i]);
	sum+=a[i];
  }
  let num=x;
  a.sort(function(a,b){return a-b});
  
  let ans = 0;
  
  for(let i=0;i<N;i++){
	  if(x>=a[i]){
		ans++;
		x-=a[i];
	  }else{
		  break;
	  }
  }
  
  if(num>sum){
	  ans=N-1;
  }
  console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
static const int M = 200000+5;
int cnt[M],A[M];
int interval[M];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&A[i]);
	for(int i=1;i<=n;++i)++cnt[A[i]];
	for(int i=1;i<=n;++i){
		for(int j=max(1,i-cnt[i]+1);j<=i;++j)++interval[j];
	}
	int ans=0;
	for(int i=1;i<=n;++i)if(!interval[i])++ans;
	for(int i=1,pos,x;i<=m;++i){
		scanf("%d%d",&pos,&x);
		//--cnt[A[pos]]
		if(A[pos]-cnt[A[pos]]+1>=1){
			--interval[A[pos]-cnt[A[pos]]+1];
			if(!interval[A[pos]-cnt[A[pos]]+1])++ans;
		}
		--cnt[A[pos]];
		A[pos]=x;
		++cnt[x];
		if(x-cnt[x]+1>=1){
			if(!interval[x-cnt[x]+1])--ans;
			++interval[x-cnt[x]+1];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
    int a[50];
    int i,max,n,k,sum=0,j;
    scanf("%d%d",&n,&k);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(a[i]<a[j])
            {
                max=a[i];
                a[i]=a[j];
                a[j]=max;
            }
        }
    }
    for(i=0; i<k; i++)
    {
        sum=sum+a[i];
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define ll long long

using namespace std;

signed main() {
	ll K;
	cin >> K;
	int n = 50;
	ll a[n];
  ll nn = K / n;
	ll t = K % n;
	for (int i = 0; i < n; ++i) {
    a[i] = n - 1 + nn;
		if (i < t) {
			a[i] += n - t + 1;
		} else {
			a[i] -= t;
		}
	}
	cout << n << endl;
	for (int j = 0; j < n; ++j) {
    if (j != 0) {
			cout << " ";
		}
		cout << a[j];
	}
	cout << endl;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

cand = p[0:X] + q[0:Y] + r

cand.sort(reverse=True)

ans = sum(cand[0:X+Y])
print(ans)


Measured memory_bytes: 101744
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,count,res=0,sum=0;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	vector<int> v[n+1];
	for(int j=1;j<=m;j++)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	for(int i=1;i<=n;i++)
	{
		count=0;
		if(v[i].size()==0)
		{
			sum++;
			continue;
		}
		else
		{
			for(int j=0;j<v[i].size();j++)
			{
				if(a[i-1]>a[v[i][j]-1])
			    count++;
			    else
			    break;
			}
			if(count==v[i].size())
			res++;
		}
	}
	
	
	cout<<res+sum;
}

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

int main(){
    string s;
    cin>>s;
    s[5]=' ',s[13]=' ';
    cout<<s<<endl;
    
    }

Measured memory_bytes: 256
import sys 
import statistics
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = []
B = []
for _ in range(N):
  a,b = map(int,readline().split())
  A.append(a)
  B.append(b)
median_A = statistics.median(A)
median_B = statistics.median(B)
if N % 2 == 1:
  print(median_B-median_A+1)
else:
  print(int((median_B-median_A)*2)+1)

Measured memory_bytes: 28608
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// HP - 取得
	long long llHP;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld", &llHP);

	// 攻撃回数 - 取得
	long long llACnt = 0;
	long long llMCnt = 1;
	while (llHP > 0) {
		llACnt += llMCnt;
		llMCnt *= 2;
		llHP /= 2;
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llACnt);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, l; cin >> n >> l;
  int minl = l;
  int maxl = l + n - 1;

  int eat = 0;
  if (maxl <= 0) eat = maxl;
  else if (minl >= 0) eat = minl;

  cout << (minl + maxl) * (maxl - minl + 1) / 2 - eat << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=3000,M=3000;
int n,m;
char a[N+5],b[M+5];
int dp[N+1][M+1],pa[N+1][M+1];
int main()
{
	int n,m;
	cin>>a+1>>b+1;
	n=strlen(a+1);m=strlen(b+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=dp[i-1][j];
			pa[i][j]=1;
			if(dp[i][j-1]>dp[i][j])
				dp[i][j]=dp[i][j-1],pa[i][j]=2;
			if(a[i]==b[j]&&dp[i-1][j-1]+1>dp[i][j])
				dp[i][j]=dp[i-1][j-1]+1,pa[i][j]=3;
		}
	int nowi=n,nowj=m;
	string ans; 
	while(nowi&&nowj)
		if(pa[nowi][nowj]==1)
			nowi--;
		else 
			if(pa[nowi][nowj]==2)
				nowj--;
		else 
			ans+=a[nowi],nowi--,nowj--;
	for(int i=ans.size()-1;~i;i--)
		putchar(ans[i]);
	return 0;
}

Measured memory_bytes: 70656
package main

import (
	"fmt"
)

// var scanner = bufio.NewScanner(os.Stdin)

func main() {
	// scanner.Split(bufio.ScanWords)

	var n int
	fmt.Scan(&n)
	// n := nextInt()
	a := make([]int, n)
	for i := range a {
		// a[i] = nextInt()
		fmt.Scan(&a[i])
	}

	sumList := make([]int, n)
	for i, v := range a {
		if i == 0 {
			sumList[0] = v
		} else {
			sumList[i] = sumList[i-1] + v
		}
	}

	var min int
	for i := 0; i < n-1; i++ {
		x := sumList[i]
		y := sumList[n-1] - sumList[i]
		diff := abs(x - y)
		if i == 0 {
			min = diff
		} else {
			if diff < min {
				min = diff
			}
		}
	}

	fmt.Println(min)
}

// func next() string {
// 	scanner.Scan()
// 	return scanner.Text()
// }

// func nextInt() int {
// 	i, err := strconv.Atoi(next())
// 	if err != nil {
// 		fmt.Println(err)
// 	}
// 	return i
// }

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 6656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int ans = Integer.MAX_VALUE;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st.nextToken());
        long k = Long.parseLong(st.nextToken());

        int[] arr = new int[n];
        st = new StringTokenizer(br.readLine());

        for (int i=0; i<n; i++)
            arr[i] = Integer.parseInt(st.nextToken());

        List<Integer> lst = new ArrayList<>();
        HashSet<Integer> vis = new HashSet<>();
        lst.add(1);
        vis.add(1);
        int i=0;
        int cycleStart = -1;
        for (; i<k; i++){
            int next = arr[lst.get(lst.size()-1)-1];
            if (vis.contains(next)){
                cycleStart = next;
                break;
            }
            vis.add(next);
            lst.add(next);
        }
        if (i==k){
            System.out.println(lst.get(lst.size()-1));
        }
        else{
            int j=0;
            for (; j<lst.size(); j++){
                if (lst.get(j)==cycleStart)
                    break;
                k--;
            }
            List<Integer> newLst = lst.subList(j,lst.size());
            System.out.println(newLst.get((int)(k%newLst.size())));
        }

    }
}


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

int main() {
    string S;

    cin >> S;
    
    int sum = 0;
    for (int i = 0; i < (S.size() / 2); i++) {
        if (S.at(i) != S.at(S.size() - 1 -i)) {
            sum++;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

int main()
{
    // input
    long X;
    scanf( "%ld", &X );

    // process
    int year;
    long money = 100;
    for ( year = 1; ; year++ ) {
        money = (long)(1.01*money);
        if ( money >= X ) {
            break;
        }
    }

    // output
    printf( "%d\n", year );

    return 0;
}


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

using namespace std;
int N,R,p,c;

int main() {
	while (cin >> N >> R && N) 
	{
		//		cout << N <<  " " << R << endl;
		int M[N];
		for (int i = 0; i < N; ++i)
		{
			M[i] = N-i;
		}
		//for (int i = 0; i < N; ++i)
		//{
		//	cout << M[i] << endl;
		//}
		for (int i = 0; i < R; ++i)
		{
			cin >> p >> c;
			rotate(M,M+p-1,M+p+c-1);
		//			cout << p << " " << c << endl;
		}
		cout << M[0] << endl;
	}
}


Measured memory_bytes: 3136
#include<iostream>
#define maxn 105
#define maxg 100005

using namespace std;

int W[maxn], P[maxn];
long long Optim[maxg];

int main() {


	int N, G;
	cin>>N>>G;

	for (int i = 1; i <= N; ++i) {
		cin>>W[i]>>P[i];
	}

	Optim[0] = 0;
	long long sol = 0;

	for( int i = 1; i <= N; ++i)
		for( int j = G - W[i]; j >= 0; --j) {
			if( Optim[j+W[i]] < Optim[j] + P[i] )
			{
				Optim[j+W[i]] = Optim[j] + P[i];
				if( Optim[j+W[i]] > sol)
					sol = Optim[j+W[i]];
			}
		}
	cout<<sol;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

int ball[100005],type[100005];

int main()
{
    IOS();
    int n,m,a,b,p=0,nw=1;
    cin >> n >> m;
    for(int i=1;i<=n;++i)
        ball[i]=1;
    while(m--)
    {
        cin >> a >> b;
        if(!p)
            if(a!=nw&&b!=nw)
                --ball[a],++ball[b];
            else if(b==nw)
                p=1,--ball[a],++ball[b],type[b]=1;
            else if(ball[b]==0)
                --ball[a],++ball[b],nw=b;
            else
                p=1,--ball[a],++ball[b],type[b]=1;
        else if(!type[a])
            --ball[a],++ball[b];
        else if(ball[a]==1)
            --ball[a],++ball[b],type[a]=0,type[b]=1;
        else 
            --ball[a],++ball[b],type[b]=1;
    }
    cout << count(type+1,type+n+1,1) << "\n";
}

Measured memory_bytes: 1024
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,m=MI()
    h = LI()
    d = dict()
    for i in range(1,n+1):
        d[i]=[]
    for i in range(m):
        a,b=MI()
        d[a].append(b)
        d[b].append(a)
    # print(d)
    c=0
    for i in d:
        x = h[i-1]
        f=0
        for j in d[i]:
            if h[j-1]>=x:
                f=1
                break
        if f==0:
            c+=1
    print(c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38764
#include <stdio.h>

int main()
{	
	char s[100001];
	scanf("%s", s);
	
	int i, n;
	for (n = 0; s[n] != 0; n++);
	for (i = 0; i < n / 2; i++) if (s[i] != s[n-i-2]) break;
	if (i < n / 2 || s[0] == '0' || s[n-1] == '1') {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int r = 2;
	printf("1 2\n");
	for (i = 1; i < n - 1; i++) {
		printf("%d %d\n", r, i + 2);
		if (s[i] == '1') r = i + 2; 
	}
	fflush(stdout);
	return 0;
}

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

int main(){
    long long n,k,ans=1;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        if(i==0)ans *= k;
        else ans *= (k-1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a,b,num[12] = {0,1,0,2,0,2,0,0,2,0,2,0};
	cin >> a >> b;a--;b--;
	if(num[a] == num[b]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, C;
  map<int, int> ma;
  cin >> A >> B >> C;
  ma[A]++;
  ma[B]++;
  ma[C]++;
  if (ma[5] == 2 && ma[7] == 1) {
    print("YES");
  } else {
    print("NO");
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define vec1(V,T,a) vector<T> V (a)
#define vec2(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define vec3(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  int n, k;
  cin >> n >> k;
  cin >> s;
  if (s[k-1] < 'a') s[k-1] = s[k-1] - 'A' + 'a';
  cout << s << endl;
  return 0;
}


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


void solve(long long r){
    cout << r * r << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        l_vec: [usize; n]
    }

    let mut ans = 0;

    for com in l_vec.iter().combinations(3) {
        let a = com[0];
        let b = com[1];
        let c = com[2];

        if a == b || b == c || c == a {
            continue;
        }

        if a + b > *c && b + c > *a && c + a > *b {
            ans += 1;
        }
    }

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

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2212
#include<bits/stdc++.h>
#define N 65
using namespace std;
int n,K,ans,a[N],r[N],b[N],s0[N],s1[N],s2[N],dp[N][N][N*N];
int main() 
{
	scanf("%d%d",&n,&K);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=K;i++)
		scanf("%d",&r[i]);
	for (int i=1;i<=K;i++)
		scanf("%d",&b[i]);
	sort(a+1,a+n+1,greater<int>());
	sort(r+1,r+K+1,greater<int>());
	sort(b+1,b+K+1,greater<int>());
	for (int i=1;i<=n;i++)
		s0[i]=s0[i-1]+a[i];
	for (int i=1;i<=K;i++)
	{
		s1[i]=s1[i-1]+r[i];
		s2[i]=s2[i-1]+b[i];
	}
	/*if (s0[n]>s1[K]+s2[K])
	{
		puts("-1");
		return 0;
	}*/
	for (int i=0;i<=K;i++)
		for (int j=0;j<=K;j++)
			for (int k=0;k<=s0[n];k++)
				dp[i][j][k]=-12345679;
	dp[0][0][0]=0;
	ans=-1;
	for (int i=0;i<=K;i++)
		for (int j=0;j<=min(K,n-i);j++)
			for (int k=0;k<=s0[i+j];k++)
			{
				if (i&&k>=a[i+j])
					dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-a[i+j]]+min(a[i+j],r[i]));
				if (j)
					dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]+min(a[i+j],b[j]));
				if (i+j==n&&s1[K]>=k&&s2[K]>=s0[n]-k)
					ans=max(ans,dp[i][j][k]);
			}
	if (s0[n]>s1[K]+s2[K])
		printf("%d\n",-1); else
		printf("%d\n",(ans==-1)?-1:(s0[n]-ans));
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	vector<int> v(N + 1, -1);
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		v[p[i]] = i;
	}

	int len = 1;
	int tmp = 1;
	for (int i = 2; i <= N; ++i) {
		if (v[i - 1] < v[i]) {
			++tmp;
		} else {
			len = max(len, tmp);
			tmp = 1;
		}
	}
	len = max(len, tmp);

	int res = N - len;
	cout << res << endl;

	return 0;
}


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

long long int l,r;
long long int mn = 0x3f3f3f3f;

int main(){
    cin>>l>>r;
    if(r - l >= 2019)
        cout<<0<<endl;
    else if(r - l == 1)
        cout<<(l * r)%2019<<endl;
    else{
        for(long long int i = l ; i < r ; i++){
            for(long long int j = i + 1 ; j <= r ; j++){
                mn = min(mn,((i%2019)*(j%2019))%2019);
            }
        }
        cout<<mn<<endl;
    }
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll A, B, C, D;

ll GCD(ll M, ll m){
  if (M < m) swap(M, m);
  while (M % m != 0){
    M = M % m;
    swap(M, m);
  }
  return m;
}
bool Solve(){
  if (A < B) return false;
  if (B > D) return false;
  if (B <= C) return true;

  ll G = GCD(B, D);
  if (B - G + (A % G) > C) return false;
  else return true;
}

int main(){
  ll T; cin >> T;

  for (int i = 0; i < T; i++){
    cin >> A >> B >> C >> D;
    if (Solve() == false) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  

  return 0;
}

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

int main(void) {
	int a, b, n, m = 0;
	int c[5];
	cin >> n >> a >> b;
	if (n == 10000) {
		if (a == 1)m += 10000;
		n--;
	}
	for (int i = 1; i <= n; i++) {
		c[0] = i / 1000;
		c[1] = (i - (c[0] * 1000)) / 100;
		c[2] = (i - (c[0] * 1000) - (c[1] * 100)) / 10;
		c[3] = i % 10;

		if (c[0] + c[1] + c[2] + c[3] >= a && c[0] + c[1] + c[2] + c[3] <= b)m += i;

	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
n.times do |i|
	v = a[i]
	j = i - 1
	while j >= 0 && a[j] > v
		a[j+1] = a[j]
		j -= 1
	end
	a[j+1] = v
	puts a.join(" ")
end

Measured memory_bytes: 8880
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    if(N % 2 == 1){
        print("No");
    }else{
        string s1 = S.substr(0,N/2);
        if(s1 + s1 == S){
            print("Yes");
        }else{
            print("No");
        }
    }

    

}

Measured memory_bytes: 256