akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int n, d;
vector<vector<int>> c;

bool solve() {
    vector<int> s(n), p(n);
    for (int i = 0; i < n; i++) {
        s[i] = accumulate(c[i].begin(), c[i].end(), 0);
    }
    while (1) {
        int i;
        for (i = 0; i < n; i++) {
            if (c[i].size() == 0) continue;
            s[i] -= c[i].back();
            if (*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()) > d) {
                s[i] += c[i].back();
            } else {
                c[i].pop_back();
                break;
            }
        }
        if (i == n) {
            return *max_element(s.begin(), s.end()) == 0;
        }
    }
}

int main() {
    while (cin >> n >> d && n) {
        c.resize(n);
        for (int i = 0; i < n; i++) {
            int m;
            cin >> m;
            c[i].resize(m);
            for (int j = 0; j < m; j++) {
                cin >> c[i][j];
            }
        }
        cout << (solve() ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
int a[3][105];
int dp[3][105];
void dfs(int x,int y)
{
    if(x==2&&y==n){
        return;
    }
    if(x==1 && dp[1][y]+a[2][y]>=dp[2][y]){
            dp[2][y]=dp[1][y]+a[2][y];
            dfs(2,y);
    }
    if(y+1<=n && dp[x][y]+a[x][y+1]>=dp[x][y+1]){
        dp[x][y+1]=dp[x][y]+a[x][y+1];
        dfs(x,y+1);
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    dp[1][1]=a[1][1];
    dfs(1,1);
    /*for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[2][n];
}


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

int main() {
    int n; scanf("%d", &n);
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) scanf("%d%d", &a[i], &b[i]);
    long long ans = min(accumulate(a.begin(), a.end(), 0LL), accumulate(b.begin(), b.end(), 0LL));
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
        v.emplace_back(a[i], i);
        v.emplace_back(b[i], i);
    }
    sort(v.begin(), v.end());
    vector<vector<int>> pos(n);
    for (int i = 0; i < n + n; ++i) pos[v[i].second].push_back(i);
    vector<long long> pref(n + n + 1, 0);
    for (int i = 0; i < n + n; ++i) pref[i + 1] = pref[i] + v[i].first;
    for (int i = 0; i < n; ++i) {
        assert(pos[i].size() == 2);
        int l = pos[i][0], r = pos[i][1];
        long long res = a[i] + b[i];
        if (l >= n - 2) {
            res += pref[n - 2];
        } else {
            if (r - 1 >= n - 2) res += pref[n - 1] - v[l].first;
            else res = pref[n];
        }
        ans = min(ans, res);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 9584
n=int(input())
for i in range(1,n+1):
    flag=0
    j=i
    while j>=1:
        j,a=divmod(j,10)
        if a==3:
            flag=1
            break
    if i%3==0 or flag==1:
        print(" %d"%i,end="")
print("")


Measured memory_bytes: 5876
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 998244353LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, S; cin >> n >> S;
    vi a(n); for(auto& e : a) cin >> e;

    ll res = 0LL;
    const int M = 3000;
    vll dp(2 * M + 1);
    rep(i, n){
        int x = a[i];

        rrep(j, S, 1){
            dp[j + x] = ADD(dp[j + x], dp[j]);
        }
        dp[x] = ADD(dp[x], i + 1LL);

        res = ADD(res, dp[S]);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll a[200005];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll s = 0;
    int i = 0;
    for(; i < n; i++){
        s += a[i];
        if(s * 2 >= sum) break;
    }
    cout << min(s * 2 - sum, sum - (s - a[i]) * 2) << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <utility>
#include <functional>
#define INF 2e9
#define MAX_V 10000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct edge{
	int to,cap,cost,rev;
	edge(int tt=0,int ca=0,int co=0,int re=0){
		to=tt;
		cap=ca;
		cost=co;
		rev=re;
	}
};

int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int preve[MAX_V],prevv[MAX_V];

void add_edge(int from,int to,int cap,int cost){
	G[from].push_back(edge(to,cap,cost,G[to].size()));
	G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
	ll res=0;
	fill(h,h+V,0);
	while(f>0){
		priority_queue<P,vector<P>,greater<P> > que;
		fill(dist,dist+V,INF);
		dist[s]=0;
		que.push(P(0,s));
		while(que.size()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(dist[v]<p.first)continue;
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
					dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
					prevv[e.to]=v;
					preve[e.to]=i;
					que.push(P(dist[e.to],e.to));
				}
			}
		}
		if(dist[t]==INF)return -1;
		for(int v=0;v<V;v++){
			h[v]+=dist[v];
		}
		int d=f;
		for(int v=t;v!=s;v=prevv[v]){
			d=min(d,G[prevv[v]][preve[v]].cap);
		}
		f-=d;
		res+=d*h[t];
		for(int v=t;v!=s;v=prevv[v]){
			edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return res;
}

struct data{
	int f,t,p;
	data(int ff=0,int tt=0,int pp=0){
		f=ff;
		t=tt;
		p=pp;
	}
};

int n;
data dat[1001];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		V=n*2+4;
		for(int i=0;i<V;i++){
			G[i].clear();
		}
		int res=0;
		int S=n*2,T=n*2+1,s=n*2+2,t=n*2+3;
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&dat[i].f,&dat[i].t,&dat[i].p);
			res+=dat[i].p;
			add_edge(i*2+1,i*2,1,dat[i].p);
			add_edge(S,i*2+1,1,0);
			add_edge(i*2,T,1,0);
		}
		add_edge(S,s,2,0);
		add_edge(t,T,2,0);
		for(int i=0;i<n;i++){
			add_edge(s,i*2,1,0);
			add_edge(i*2+1,t,1,0);
			for(int j=0;j<n;j++){
				if(dat[i].t<dat[j].f){
					add_edge(i*2+1,j*2,1,0);
				}
			}
		}
		printf("%lld\n",res-min_cost_flow(S,T,2+n));
	}
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		
		int[] a = new int[n];
		Arrays.setAll(a, i -> sc.nextInt());
		
		for (int ai : a) {
			int i = 0;
			while (i * ai + 1 <= d) {
				x++;
				i++;
			}
		}
		
		System.out.println(x);
		
		sc.close();
	}
}




Measured memory_bytes: 32356
#include <iostream>
using namespace std;
int main(){
  int n;
  float a[100];
  float x = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; i++) x = x + (1 / a[i]);
  cout << 1/x << endl;
}

Measured memory_bytes: 256
#setで殴る
n,m=map(int,input().split())
s=[set()for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  s[a-1].add(b)
for i in s[0]:
  if n in s[i-1]:print("POSSIBLE");exit()
print("IMPOSSIBLE")

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

int main(){
  int A,T,B;
  cin >>A>>T>>B;
  
  if(A*T<B){
    cout << A*T << endl;
  }
  if(A*T==B){
    cout << B << endl;
  }
  if(A*T>B){
    cout << B << endl;
  }
    
}

Measured memory_bytes: 256
# 行数
N = int(input().strip())

# 2次元配列
grid = []

z = 0
flag = '0'

for i in range(N):
    array = list(map(str, input().strip().split()))
    grid.append(array)

X = input()

for s, t in grid:
    if flag == '1':
        z += int(t)
    if s == X:
        flag = '1'

print(z)

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n),cnt(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		--a[i];
		++cnt[a[i]];
	}
	long long int sm = 0;
	for(int i = 0; i < n; i++){
		sm += (1ll * cnt[i] * (cnt[i] - 1)) / 2;
	}
	for(int i = 0; i < n; i++){
		long long int tmp = 0;
		tmp -= (1ll * cnt[a[i]] * (cnt[a[i]] - 1)) / 2;
		--cnt[a[i]];
		tmp += (1ll * cnt[a[i]] * (cnt[a[i]] - 1)) / 2;
		++cnt[a[i]];
		cout << sm + tmp << "\n";
	}
	return 0;
}


Measured memory_bytes: 4844
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		ans = 0;
		int tmpAns = 0;

		for(int i = 0;i<s.length() ; i++) {
			if(s.charAt(i)=='R') {
				tmpAns++;
			}else {
				if(tmpAns>0) {
					ans = Integer.max(ans, tmpAns);
				}
				tmpAns=0;
			}
		}


		ans = Integer.max(ans, tmpAns);


		System.out.println(ans);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35720
while true do
  s = gets.split()
  n = s[0].to_i
  x = s[1].to_i
  count = 0
  if n == 0 and x == 0
    break
  end
  (1..n-2).each do |i|
    (i+1..n-1).each do |t|
      (t+1..n).each do |c|
        if i + t + c == x
          count += 1
        end
      end
    end
  end
  p count
end

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

using namespace std;

vector<long long int> SO(50),PATY(50);

long long int dfs(long long int level, long long int sou){
    if(level==0){
        return 1;
    }else if(sou==1){
        return 0;
    }else if(sou<=SO[level-1]+1){
        return dfs(level-1,sou-1);
    }else if(sou == SO[level-1]+2){
        return PATY[level-1]+1;
    }else if(sou<=2+2*SO[level-1]){
        return PATY[level-1]+1+dfs(level-1,sou-SO[level-1]-2);
    }else{
        return 2*PATY[level-1]+1;
    }
}

int main(){
    long long int N,X;
    cin >> N >> X;
    SO[0] = 1;
    PATY[0] = 1;

    for(int i=1;i<=50;i++){
        SO[i] = 2*SO[i-1] + 3;
        PATY[i] = 2*PATY[i-1] + 1;
    }

    cout << dfs(N,X) << endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
  int n;
  std::cin >> n;
  std::vector<std::pair<int,int> > balls(n);
  rep(i,n) {
    std::cin >> balls[i].first >> balls[i].second;
  }
  std::map<std::pair<int,int>,int> count;
  rep(i,n) rep(j,i) {
    if(i==j) continue;
    int dx = balls[i].first - balls[j].first;
    int dy = balls[i].second - balls[j].second;
    if(dx<0) {
      dx = -dx;
      dy = -dy;
    }
    else if(dx==0 && dy<0) dy = -dy;
    count[std::make_pair(dx,dy)]++;
  }
  int max = 0;
  for(auto e:count) {
    max = std::max(max,e.second);
  }
  print(n-max);
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int h, w, d; cin >> h >> w >> d;
	vector<pair<int, int>> p(h*w + 1);
	rep(i, 1, h)rep(j, 1, w)
	{
		int a; cin >> a;
		p[a] = { i,j };
	}
	vector<int> sum(h*w + d + 1);
	rep(i, d + 1, h*w)
	{
		sum[i] = sum[i - d] + abs(p[i].first - p[i - d].first) + abs(p[i].second - p[i - d].second);
	}

	int q; cin >> q;
	rep(i, 1, q)
	{
		int l, r; cin >> l >> r;
		int ans = sum[r] - sum[l];
		cout << ans << endl;
	}
}


Measured memory_bytes: 2176
#include <stdio.h>
int main(void){
    int i,x,n;
    scanf("%d",&n);
    for(i=1; i<=n; ++i){
    	x=i;
	if(x%3==0){
		printf(" %d",i);
 	}else{
	do{
		if(x%10==3){
			printf(" %d",i);
			break;
		}else
			x/=10;
	}while(x);
    	}
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 600
<?php
list($n,$k) = fscanf(STDIN, '%d %d');

$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$city = 1;
$city_i = array();
$step = 0;
$city_i[0] = 1;
$visited= array(1=>0);
while (true) {
    $step ++;
    $city_i[$step] = $next = $a[$city_i[$step-1]-1];
    if (isset($visited[$next])) {
        $steps = array($visited[$next], $step - $visited[$next]);
        break;
    }
    $visited[$next] = $step;
    if ($step==$k) {
        break;
    }
    $city=$next;
}

if ($step==$k) {
    echo $next;
} else {
    $step--;
    $m = ($k - $steps[0]) % ($steps[1]) + $steps[0];
    echo $city_i[$m];
}

Measured memory_bytes: 42860
#include <iostream>
#include<math.h>
using namespace std;
bool prime(int x){
    if(x==2)return true;
    else if(x<2||x%2==0)return false;
    else{
        int i=3;
        while(i<=sqrt(x)){
            if(x%i==0)return false;
            i=i+2;
        }
    }return true;
}
int main(){
    int x,n;
    int m=0;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >> x;
        if(prime(x))m++;
    }
    cout << m <<endl;
}


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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

vector<int> G[200005];

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

  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;

  vector<P> blocks;
  rep(i, n+1) {
    while(i < n+1 && s[i] == '1') {
      i++;
    }
    if (i == n+1) break;
    int start = i;
    while(i < n+1 && s[i] == '0') {
      i++;
    }
    int end = i-1;
    blocks.push_back({start, end});
  }
  reverse(blocks.begin(), blocks.end());

  int now = n;
  int nowBlock = 0;
  bool canDo = true;
  vector<int> res;
  while(now > 0) {
    if (s[now] == '1') {
      canDo = false;
      break;
    }
    if (nowBlock == blocks.size() - 1) {
      res.push_back(min(now, m));
      now -= min(now, m);
    } else {
      int next = nowBlock+1;
      while(next < blocks.size() && now - blocks[next].second <= m) next++;
      next--;
      int go = min(m, now - (int)blocks[next].first);
      if (!go) {
        canDo = false;
        break;
      }
      res.push_back(go);
      now -= go;
    }
  }

  if (canDo) {
    reverse(res.begin(), res.end());
    rep(i, res.size()) {
      cout << res[i] << " ";
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 6216
x, y = gets.chomp.split.map(&:to_i)
g1 = [1, 3, 5, 7, 8 ,10, 12]
g2 = [4, 6, 9, 11]

if (g1.include?(x) && g1.include?(y)) || (g2.include?(x) && g2.include?(y))
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
main(){
  double l ;
  cin >> l ;
  double ans ;
  ans = (l/3.0)*(l/3.0)*(l-2.0*l/3.0) ;
  cout << fixed << setprecision(12) << ans ;
  return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int h=sc.nextInt();
        	int w=sc.nextInt();

        	if(h==0&&w==0)break;

        	int dia1=h*h+w*w;

        	int testdai2;
        	int ansh=999,answ=999;
        	int ansmenseki = 9999999;
        	for(int i=1;i<150;i++) {
        		for(int j=i+1;j<150;j++) {
        			testdai2=i*i+j*j;

        			if(dia1<=testdai2) {
        				if(dia1==testdai2&&h>=i)continue;
        				if(testdai2<ansmenseki) {
        				ansh=i;
        				answ=j;
        				ansmenseki=testdai2;
        				}
        			}
        		}
        	}
        	
        	
        	System.out.println(ansh+" "+answ);
        }
	}
}



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

int make_digits(long long int S)
{
	int ans = 753;
	while (S > 99) {
		int tmp = S % 1000;
		int diff = (tmp > 753) ? tmp - 753 : 753 - tmp;
		ans = min(ans, diff);
		S /= 10;
	}
	return ans;
}

int main(void)
{
	long long int S; cin >> S;
	int ans = make_digits(S);

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	deque<int> d;
	rep(i, n){ 
		int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
		if(p == 0) {
			d.push_front(a[i]);
		}else  d[p-1] = a[i];
	}
	int ans = d.size();
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int M=2e3+10;
const int Mod=1e9+7;
int main(){
	int n;
	long long k;
	scanf("%d%lld",&n,&k);
	int a[M];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	long long ans=0;
	long long res=(k+1ll)*k/2%Mod;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){	
				ans=(ans+res)%Mod;
				//cout<<res<<" "<<ans<<endl;
			}
		}
	}
	long long res2=(res-k+Mod)%Mod;
	for(int i=n-1;i>=0;i--){
		for(int j=i-1;j>=0;j--){
			if(a[i]>a[j]){
				ans=(ans+res2)%Mod;
			}
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
int n, m, a[1100][1100];
void solve(int n, int m){
	if(n > m){
		solve(n / 2, m);
		for(int i = 0; i < n / 2; i++)
			for(int j = 0; j < m; j++)
				a[i + n / 2 + 1][j] = a[i][j];
		for(int j = 0; j < m; j++)
			a[n / 2][j] = 0;
		return;
	}
	if(m > n){
		solve(n, m / 2);
		for(int i = 0; i < n; i++)
			for(int j = 0; j < m / 2; j++)
				a[i][j + m / 2 + 1] = a[i][j];
		for(int i = 0; i < n; i++)
			a[i][m / 2] = 0;	
		return;
	}
	if(n == 1){
		a[0][0] = 1;
		return;
	}
	solve(n / 2, m / 2);
	for(int i = 0; i < n / 2; i++)
		for(int j = 0; j < n / 2; j++)
			a[i + n / 2 + 1][j + n / 2 + 1] = a[i][j + n / 2 + 1] = a[i + n / 2 + 1][j] = a[i][j];
	for(int i = 0; i < n; i++)
		a[i][n / 2] = a[n / 2][i] = 0;
	a[n / 2][m / 2] = 1;	
}
int main()
{
	cin >> n >> m;
	solve((1 << n) - 1, (1 << m) - 1);
	for(int i = 0; i < ((1 << n) - 1); i++){
		for(int j = 0; j < ((1 << m) - 1); j++)
			printf("%d", a[i][j]);
		printf("\n");
	}
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
const int MOD = 2019;

int main() {
  int L, R;
  cin >> L >> R;
  if (R - L > MOD) {
    cout << 0 << endl;
  } else {
    int ans = MOD * MOD;
    for (int i=L; i<R; i++) {
      for (int j=i+1; j<=R; j++) {
        int tmp = ((i % MOD) * (j % MOD)) % MOD;
        if (tmp < ans) ans = tmp;
      }
      if (ans == 0) break;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll xpow(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
	{
		ll k = xpow(a, b / 2);
		return k * k;
	}
	if (b % 2 != 0)
		return a * xpow(a, b - 1);
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	fio;
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll s = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		s ^= a[i];
	}
	for (ll i = 0; i < n; i++) {
		ll x = s ^ a[i];
		cout << x << " ";
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int answer=0;
  for(int i=0;i<n;i++){
    if(vec.at(i)==i+1){
      if(i!=n-1){
        swap(vec.at(i),vec.at(i+1));
        }
      else{
        swap(vec.at(i),vec.at(i-1));
        }
      answer++;
      }
    }
  for(int i=0;i<n;i++){
    if(vec.at(i)==i+1){
      if(i!=n-1){
        swap(vec.at(i),vec.at(i+1));
        }
      else{
        swap(vec.at(i),vec.at(i-1));
        }
      answer++;
      }
    }
  cout<<answer<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

char a[1010];

int main(void)
{
	scanf("%s", a);
	
	ll len = strlen(a);
	
	if(a[len - 1] == 's')
	{
		a[len] = 'e';
		a[len + 1] = 's';
	}
	
	else
		a[len] = 's';
	
	printf("%s", a);
	return 0;
}

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

modint dp[100001];
bool b[100001];

signed main() {
  int n,m; cin >> n >> m;
  rep(i,m) {int a; cin >> a; b[a] = true;}
   
  dp[0] = 1;
  if(!b[1]) dp[1] = 1;

  for(int i=2;i<=n;i++){
    if(b[i]) continue;
    dp[i] = dp[i-1] + dp[i-2];
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 1152
input()
n = [int(i) for i in input().split()]
index = 0
count = 0
while index < len(n):
    if n[index] % 2 == 0:
        n[index] /= 2
        n[index] = int(n[index])
        count += 1
    else:
        index += 1
print(count)


Measured memory_bytes: 4148
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

int main() {
  char buf[16];
  scanf("%s", buf);
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;
  t.pop_back();
  if (s == t) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    int n;
    cin >> n;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    Sort(a);
    Reverse(a);
    int h=0,w=0;
    FOR(i,1,n){
        if(a[i]==a[i-1]){
            if(h==0){
                h = a[i];
                a[i]=0;
                a[i-1]=0;
            }
            else{
                w = a[i];
                break;
            }
        }
    }
    cout << h*w << endl;
    return 0;
}


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

int main(){

  int N, ans=0;
  cin >> N;
  int l[N], r[N];
  for(int i=0; i<N; i++){
    cin >> l[i] >> r[i];
    ans += r[i] - l[i] + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
x = gets.chomp.split(" ").map(&:to_i)
y = gets.chomp.split(" ").map(&:to_i)

p1 = 0
p2 = 0
p3 = 0
pi = 0
max = 0
for i in 0..n - 1
    tmp = (x[i] - y[i]).abs
    p1 += tmp
    p2 += tmp ** 2
    p3 += tmp ** 3
    
    if max < tmp
        max = tmp
    end
end

puts p1
puts p2 ** (1/2.0)
puts p3 ** (1/3.0)
puts max


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


int main(){
  ll N,P;
  cin >> N >> P;
  if(N == 1){
    cout << P << endl;
    return 0;
  }
  if(P == 1){
    cout << 1 << endl;
    return 0;
  }
  vector<bool> prime((ll)1e7+2,true);
  prime[0] = false;
  prime[1] = false;
  for(ll i = 0;i < prime.size(); i++){
    if(prime[i]){
      ll x = 2;
      while(x*i < prime.size()){
        prime[x*i] = false;
        x++;
      }
    }
  }
  ll ans = 1;
  ll tmp = P;
  for(ll i = 0;i < prime.size(); i++){
    if(prime[i]){
      ll cnt = 0;
      while(tmp%i == 0){

        cnt++;
        tmp/=i;
      }

      ans *= pow(i,(cnt/N));

    }
  }

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


Measured memory_bytes: 1408
/*input
5
3 3 3 3 3
*/
 
 
#include <bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INTMAX  2147483647
#define INTMIN  -2147483648
#define LLMAX 9223372036854775807
#define LLMIN -9223372036854775808
#define MOD 1000000007
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.1415926535
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr

// cout<<fixed<<setprecision(10)<<(v1+v2+v3)<<endl;
  
struct node{
    ll val;
};


long long int minimum = 100000000000000;

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

struct ct_s_h {long long int cts, cth, index;};

bool compare(long long int a, long long int b) {
	if(gcd(a,b) < minimum)
		return 1;
	else return 0;
}






int main(){
	ll n; cin>>n;
	vll a(n,0);
	rep(i,n)cin>>a[i];
	long long int ans = 0;
	for(int i=1;i<n;i++){
		if(a[i]-a[i-1] < 0){
			ans += (a[i-1]-a[i]);
			a[i] = a[i-1];
		}
	}
	cout<<ans<<endl;
	return 0;	
}















 

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,K; cin>>A>>B>>C>>K;
    if(K%2==0) cout<<A-B<<endl;
    else cout<<B-A<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, i, p, x,v[100000];
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        v[x] = i;
    }
    for(i=1;i<=n;i++)
    {
        cout<<v[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	string s;
	cin >> s;
	string tmp = "No";
    int k = n / 2;
    if(n % 2 == 0 && s.substr(0, k) == s.substr(k, k)) tmp = "Yes";
    cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,k,M=0,m=123;
  for(int i=0;i<5;i++){
    cin>>a;
    M=max(M,a);
    m=min(m,a);
  }
  cin>>k;
  
  cerr<<M<<' '<<m;
  cout<<((M-m>k) ? ":(" : "Yay!");
  return 0;
}


Measured memory_bytes: 256
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(sz(s) >= k + 1){
		cout << s.substr(0, k) + "...";
	}else{
		cout << s;
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <ctype.h>
 
 
int main(){
     
    char ch;
     
    while(1) {
        scanf("%c", &ch);
         
        if(islower(ch)){
            printf("%c",toupper(ch));
        }
        else{
            printf("%c",tolower(ch));
        }
         
        if(ch=='\n') break;
         
    }
    return(0);
}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;
    k--;
    for(int i = 0; i < n; i++){
        if(s[i] != s[k]) s[i] = '*';
    }
    cout << s << endl;
    return 0;
}



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

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

  if (A+B<C+D) {
    cout << "Right" << endl;
  }
  else if(A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  else 	cout<<"Left"<<endl;
  
  return 0;
}

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

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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1) {
        cout << ((a == b) ? 1 : 0) << endl;
        return 0;
    }
    if (n == 2) {
        cout << 1 << endl;
        return 0;
    } else {
        cout << (n - 2) * (b - a) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

//#define int long long
//#define double long double
ll binpow(ll a, ll b, ll m){
	ll res = 1;
	while(b > 0){
		if(b&1) res = res * a % m;
		a = a * a % m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a, ll b){
	return (b==0 ? a : gcd(b,a%b));
}
void solve(){	
	string s;
	cin >> s;
	int n = s.size();
	s = '0' + s;
	if(s[1] == '0' or s[n] == '1'){
		cout << -1 << endl;
		return;
	}
	bool done = false;
	for(int i=1;i <= (n-1)/2;i++){
		if(s[i] != s[n-i]){
			cout << -1 << endl;
			return;
		}
	}

	int last = 1;
	for(int i=1;i<n;i++){
		if(s[i] == '1'){
			cout << last << " " << i+1 << endl;
			last = i+1;
		}
		else{
			cout << last << " " << i+1 << endl;
		}
	}

} 
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t=1;
 	//cin >> t;
  while(t--){
  	solve();
  }
}


Measured memory_bytes: 3752
#include<stdio.h>


void Input(int *in)
{
	scanf("%d", in);
}


int main(void)
{
	int baseX, baseY;
	Input(&baseX);
	Input(&baseY);

	int limit;
	Input(&limit);

	int add;
	Input(&add);

	int use;
	Input(&use);
	
	if (use > limit)
	{
		baseY += (use - limit) * add;
	}

	printf("%d\n", (baseX*=use) > baseY ? baseY : baseX);

	return 0;
}


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

int main(){
  string s;
  cin>>s;
  size_t n=s.length();
  for(int i=0;i<(n-1)/2;i++){
    if(s[i]!=s[(n+2)/2+i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  ll   long long
int main() {
    string s , t ;
    int a , b ;
    string u ;
     cin >> s>>t ;
     cin>>a>>b;
     cin>>u;
     if(u==s)
         a--;
     else
         b--;

     cout<<a<<" "<<b;
    
    return 0;
}

Measured memory_bytes: 256
/*
Wai u read my code xD
*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    for (int i = 0; i < n-2; i++)
    {
        if (s[i]=='A'&& s[i+1]=='B'&& s[i+2]=='C') cnt++;
    }
    nout(cnt);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

string board[3];

bool row(char c)
{
	rep(i, 3) rep(j, 3)
	{
		if(board[i][j] != c) break;
		else if(j == 2) return true;
	}
	
	return false;
}

bool column(char c)
{
	rep(i, 3) rep(j, 3)
	{
		if(board[j][i] != c) break;
		else if(j == 2) return true;
	}
	
	return false;
}

bool diagonal(char c)
{
	rep(i, 3)
	{
		if(board[i][i] != c) break;
		else if(i == 2) return true;
	}
	
	rep(i, 3)
	{
		if(board[2 - i][i] != c) break;
		else if(i == 2) return true;
	}
	
	return false;
}

bool (*pred[3])(char) = {row, column, diagonal};
char ch[2] = {'b', 'w'};

int main()
{
    while(cin >> board[0] && board[0] != "0")
	{
		rep(i, 2) cin >> board[i + 1];
		
		rep(i, 3)
		{
			if(i == 2) cout << "NA" << endl;
			else rep(j, 3) if(pred[j](ch[i]))
			{
				cout << ch[i] << endl;
				goto ng;
			}
		}
		
	ng:;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long T, n;
int main()
{

    cin >> n;
    n--;
    long long sum = 0;
    for (long long l = 1, r = 0; l <= n; l = r + 1)
    {
        r = n / (n / l);
        sum += (r - l + 1) * (n / l);
    }
    cout << sum;
    //system("pause");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    if (n < 0 || n < r) return 0;
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

vector<int> e[100010];
long long ans = 1;

void dfs(int curr, int prev, long long k) {
    if (prev == -1) {
        int t = e[curr].size();
        ans *= combination(k, t+1) * factorial[t+1] % mod;
        ans %= mod;
    } else {
        int t = e[curr].size();
        ans *= combination(k-2, t-1) * factorial[t-1] % mod;
        ans %= mod;
    }
    for (auto &to: e[curr]) {
        if (to == prev) continue;
        dfs(to, curr, k);
    }
}

int main() {
    GetInv(); GetFactorial();
    int n, k; cin >> n >> k;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    dfs(0, -1, k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13952
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> a(n+1,true);
  for(int i = 0;i < m;i++)
  {
    int A;
    cin >> A;
    a[A] = false;
  }
  vector<int> dp;
  for(int i = 0;i <= n;i++)
  {
    dp.push_back(0);
  }
  dp[0] = 1;
  for(int i = 0;i < n;i++)
  {
    for(int j = i+1;j <= min(n,i+2);j++)
    {
      if(a[j])
      {
        dp[j] += dp[i];
        dp[j] %= big;
      }
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1276
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=LI()
count=0
while sum(lis)>0:
    i=0
    state=""
    while i<n:
        if lis[i]>0:
            lis[i]-=1
            state="water"
            #print(1)
        elif lis[i]==0 and state=="water":
            count+=1
            state=""
            #print(2)
        if i==n-1 and state=="water":
            count+=1
            state=""
            #print(3)
        i+=1
print(count)

Measured memory_bytes: 39152
#include<stdio.h>
#include<string.h>

int main()
{
    char str[1005];
    int size;
    scanf("%s",str);
    size=strlen(str);
    if(str[size-1]=='s')
    {
        str[size]='e';
        str[size+1]='s';
        str[size+2]='\0';
    }
    else
    {
        str[size]='s';
        str[size+1]='\0';
    }
    printf("%s",str);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define fread freopen("in.txt","r",stdin)
#define fwrite freopen("out.txt","w",stdout)
#define PI acos(-1.0)
#define Mx 100005
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
   int n, k, s;
   cin >> n >> k >> s;
   for(int i = 1; i <= k; i++)
   {
	 if(n == i)
	 cout << s;
	 else
	 cout << s << " ";
   }
    if(s == 1000000000) s--;
	else s++;
   for(int i = 1; i <= (n - k); i++)
   {
     if(n == i)
	 cout << s;
	 else
	 cout << s << " ";
   }
   cout << '\n';

   return 0;
 }


Measured memory_bytes: 1280