akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MAXN	300005
#define INF	1e9
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct Segment_Tree {
	int maxnum[MAXN * 2], tag[MAXN * 2];
	int lc[MAXN * 2], rc[MAXN * 2];
	int n, size, root;
	int new_node() {
		maxnum[size] = 0;
		tag[size] = 0;
		lc[size] = rc[size] = 0;
		return size++;
	}
	void build(int root, int l, int r) {
		if (l == r) return;
		int mid = (l + r) / 2;
		lc[root] = new_node();
		build(lc[root], l, mid);
		rc[root] = new_node();
		build(rc[root], mid + 1, r);
	}
	void init(int x) {
		n = x;
		size = 0;
		root = new_node();
		build(root, 0, n);
	}
	void pushdown(int x) {
		tag[lc[x]] += tag[x];
		maxnum[lc[x]] += tag[x];
		tag[rc[x]] += tag[x];
		maxnum[rc[x]] += tag[x];
		tag[x] = 0;
	}
	void update(int x) {
		maxnum[x] = max(maxnum[lc[x]], maxnum[rc[x]]);
	}
	void modify(int root, int l, int r, int ql, int qr, int value) {
		if (l == ql && r == qr) {
			tag[root] += value;
			maxnum[root] += value;
			return;
		}
		pushdown(root);
		int mid = (l + r) / 2;
		if (mid >= ql) modify(lc[root], l, mid, ql, min(mid, qr), value);
		if (mid + 1 <= qr) modify(rc[root], mid + 1, r, max(mid + 1, ql), qr, value);
		update(root);
	}
	void modify(int l, int r, int v) {
		if (l <= r) modify(root, 0, n, l, r, v);
	}
	int query() {
		return maxnum[root];
	}
} ST;
struct point {int x, y; };
bool operator < (point a, point b) {return a.y < b.y; }
point a[MAXN];
int w, h, n, ans;
void solve() {
	sort(a + 1, a + n + 1);
	ST.init(n);
	ST.modify(0, 0, w);
	static point q1[MAXN], q2[MAXN];
	int t1 = 0, t2 = 0, mid = w / 2;
	q1[0].y = q2[0].y = -1;
	q1[++t1] = (point) {0, 0};
	q2[++t2] = (point) {w, 0};
	for (int i = 1; i <= n; i++) {
		ans = max(ans, ST.query() + a[i].y);
		if (a[i].x <= mid) {
			while (t1 && a[i].x >= q1[t1].x) {
				ST.modify(q1[t1 - 1].y + 1, q1[t1].y, q1[t1].x - a[i].x);
				t1--;
			}
			q1[++t1] = (point) {a[i].x, i - 1};
		} else {
			while (t2 && a[i].x <= q2[t2].x) {
				ST.modify(q2[t2 - 1].y + 1, q2[t2].y, a[i].x - q2[t2].x);
				t2--;
			}
			q2[++t2] = (point) {a[i].x, i - 1};
		}
		q1[++t1] = (point) {0, i};
		q2[++t2] = (point) {w, i};
		ST.modify(i, i, w - a[i].y);
	}
	ans = max(ans, ST.query() + h);
}
int main() {
	read(w), read(h), read(n);
	for (int i = 1; i <= n; i++)
		read(a[i].x), read(a[i].y);
	ans = max(w, h) + 1;
	solve();
	swap(w, h);
	for (int i = 1; i <= n; i++)
		swap(a[i].x, a[i].y);
	solve();
	cout << ans * 2 << endl;
	return 0;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 4e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int arr[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, k, q;
  cin >> n >> k >> q;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  arr[n] = -1;
  int ans = OO + OO;
  for (int i = 0; i < n; ++i) {
    vector<int> vv, vv2;
    int cnt = 0;
    int lower = arr[i];
    for (int j = 0; j <= n; ++j) {
      if(arr[j] < lower) {
        if(cnt) {
          sort(vv2.begin(), vv2.end());
          for (int i = 0; i < cnt; ++i)
            vv.push_back(vv2[i]);
        }
        vv2.clear();
        cnt = 0;
      } else {
        vv2.push_back(arr[j]);
      }
      if((int)vv2.size() >= k)
        ++cnt;
    }
    if((int)vv.size() < q)
      continue;
    sort(vv.begin(), vv.end());
    ans = min(ans, vv[q - 1] - lower);
  }
  cout << ans;
  return 0;
}


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

int n , m;
vector<vector<int>> adj_List;
vector<bool> visited;
vector<bool> path;

bool bfs(int source,  int dest)
{

vector<int> d(n);
vector<int> p(n);
p[source] = -1;
d[source] = 0 ;

queue<int> q;

q.push(source);
visited[source] = true;
bool reach_node = false;
while(!q.empty())
{

    int v = q.front();
    q.pop();

    for(int u : adj_List[v])
    {
        if(!visited[u])
        {
            q.push(u);
            p[u] = v;
            d[u] = d[v]+1;
        }
        if(dest == u){reach_node=true; break;}
    }
    if(reach_node)break;
}

if(d[dest]==2)return true;
else return false;
}


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

    adj_List = vector<vector<int>>(n);
    visited = vector<bool>(n);


    for(int i = 0 ; i<m ; i++)
    {
        int from, to ; cin>>from>>to;
        adj_List[from-1].push_back(to-1);
    }


    if(bfs(0,n-1))cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

Measured memory_bytes: 128
using System;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            double T = double.Parse(s[0]);
            double X = double.Parse(s[1]);
            Console.WriteLine("{0:0.0000}", T / X);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define NIL -(long long)(1e9)
#define ll long long
// long long n,w;


int h,w;
int main () {
//memset(dp,-1,sizeof(dp));
//freopen("a.in","r",stdin);  freopen("a.out","w",stdout);
cin>>h>>w;
vector<vector<int>> dp(h+1,vector<int>(w+1,0));
vector<vector<char>> map(h+1,vector<char>(w+1));

for (int i = 0; i < h; ++i)
{for (int j = 0; j < w; ++j)
{
	cin>>map[i][j];

}}

for (int i = 0; i < h; ++i)
{if (map[i][0]=='.') dp[i][0]=1;
	else break;
}

for (int i = 0; i < w; ++i)
{	if (map[0][i]=='.'){dp[0][i]=1;}
	else break;
}


for (int i = 1; i < h; ++i){
	for (int j = 1; j < w; ++j){
		if (map[i][j]=='#') continue;
		dp[i][j]= (dp[i-1][j]+dp[i][j-1])%1000000007;

		
	}
		
	}

// for (int i = 0; i < h; ++i){
// 	for (int j = 0; j < w; ++j){
// cout<<dp[i][j]<<" ";
		
// 	}
// 		cout<<endl;
// 	}

cout<<dp[h-1][w-1];






	return 0;
}



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

int main(){
  long N,A,B,i,sum=0,cnt=0;
  cin >> N >> A >> B;
  cnt += (N/(A+B))*A;
  if(N%(A+B)>A)
    cnt += A;
  else
    cnt += N%(A+B);
  cout << cnt;
}


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

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        int[] arr = nextIntArr(n);
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= k; j++) {
                if (i + j < n) {
                    dp[i + j] = Math.min(dp[i + j], Math.abs(arr[i + j] - arr[i]) + dp[i]);
                }
            }
        }
        outln(dp[n - 1]);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 43944
import java.util.Scanner;
public class Main {
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A,B;
		do {
		A = stdIn.nextInt();
		B = stdIn.nextInt();
		}while(A<1||A>100000||B<1||B>100000||A==B);
		
		if(A<B) {
			int t = A;
			A = B;
			B = t;
		}
		long kai = 0;
		int hantei =0;
		/*for(int i=1 ; i<100000 ; i++ ) {
			kai = A*i;
			if(kai%B==0) {
				break;
			}
		}*/
		System.out.println(lcm(A,B));
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<Tuple<int,int>> s = new List<Tuple<int,int>>();
    static decimal result;
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read4();
      Read2();
      Read5();
Tuple<int,int>[] tmp=s.OrderByDescending(x=>x.Item1).ToArray();
      int count=0;
      for(int i=0;i<tmp.Length;i++){
        int multi=0;
        if(tmp[i].Item2<=N-count){
multi=tmp[i].Item2;
        }else{multi=N-count;}
        count+=multi;
              result+=(decimal)tmp[i].Item1*multi;  
      if(count>=N){break;}
      }
                    Console.WriteLine(result.ToString());     
      
    }


    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(Tuple.Create(int.Parse(tmp[i]),1));         }
    }

    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
for(int i=0;i<K;i++){
        string[] tmp = Console.ReadLine().Split(' ');
  s.Add(Tuple.Create(int.Parse(tmp[1]),int.Parse(tmp[0])));
}
    }
}

Measured memory_bytes: 37676
stack = Array.new

d = gets.chomp.split(" ")
d.each { |op|
	case op
	when "+"
		stack << stack.pop + stack.pop
	when "-"
		n = stack.pop
		stack << stack.pop - n
	when "*"
		stack << stack.pop * stack.pop
	else
		stack << op.to_i
	end
}
puts stack[0]

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

ll a[][6]={{},{0,5},{0,6,11}};
			

int main(void)
{
	ll x;
	cin>>x;
	ll ret=0;
	ret+=2*(x/11);
	ret+= (x%11==0)?0:((x%11<=6)?1:2);
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
from  collections import defaultdict


INF=int(1e9+7)


def main():
    Sn = list(open(0).read().split()[1:])
    d = defaultdict(lambda: INF)
    for Si in Sn:
        for i in range(26):
          d[i] = min(d[i], Si.count(chr(ord("a") + i)))
    for i in range(26):
      if d[i] == INF:
          continue
      print(chr(ord("a") + i) * d[i], end="")


main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using LL = long long;
using namespace std;
int main(){
    while(1){
        int N;cin >> N;
        if(N != 0){
            vector<int> vec;
            for(int a = 0;a < N;a++){
                int b;cin >> b;
                vec.push_back(b);
            }
            vector<vector<int>> dp(N+1,vector<int>(N+1,-1));

            std::function<int(int,int)> calc = [&](int l, int r){
                if(dp[l][r] != -1)return dp[l][r];

                if(abs(l - r) <= 1)return 0;

                int ins = 0;

                if(abs(vec.at(l) - vec.at(r-1)) <= 1 && calc(l+1,r-1) == r - l -2){
                    ins = r - l;
                }
                for(int mid = l + 1 ;mid <= r -1 ;mid++){
                    ins = max(ins, calc(l,mid) + calc(mid, r));
                }
                return dp[l][r] = ins;
            };
            calc(0,N);
            cout<<dp[0][N]<<endl;
        }else{
            return 0;
        }
    }
}


Measured memory_bytes: 3284
#include <cstdio>
#include <vector>

int main(){
	int n;
	int self;
	
	while(1){
		scanf("%d" , &n);
		if(n == 0){ break; }
		int ice[10];
		for(int i=0;i<10;i++){
			ice[i] = 0;
		}
		for(int i=0;i<n;i++){
			scanf("%d",&self);
			ice[self]++;
		}
		for(int i=0;i<10;i++){
			if(ice[i] == 0){
				printf("-");
			}else{
				for(int j=0;j<ice[i];j++){
					printf("*");
				}
			}
			printf("\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long int dp[10000000];

int main()
{
    long long int h,i,x,res;
    double y;
    cin>>h;
    if(h==1)
        cout<<1<<endl;
    else if(h==2)
        cout<<3<<endl;
    else
    {
        y=log2(h);
        x=log2(h);
        if(x!=y)
            x=ceil(log2(h));
        else
            x=ceil(log2(h))+1;
        res=powl(2,x);
        cout<<res-1<<endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
typedef long long int lli;
int main() {
  char s[6];
  scanf("%s", &s);

  if(s[2]==s[3] && s[4]==s[5]){
      printf("Yes\n");
  }
  else{
      printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 1644
#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 = 1000000007LL;
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; cin >> n;
    ll C; cin >> C;
    vll x(n), v(n); rep(i, n) cin >> x[i] >> v[i];

    vll sum, rsum;
    rep(_, 2){
        vll& s = _ ? rsum:sum;
        s = vll(n + 1);

        ll cx = 0;
        rep(i, n){
            s[i+1] = s[i] + v[i] - (x[i] - cx);
            cx = x[i];
        }
        rep(i, n){
            chmax(s[i+1], s[i]);
        }

        for(auto& e : x) e = C - e;
        reverse(_all(x));
        reverse(_all(v));
    }

    ll res = max(sum[n], rsum[n]);
    rep(_, 2){
        vll& s  = _ ? rsum:sum;
        vll& rs = _ ? sum:rsum;

        rep(i, n){
            chmax(res, (s[i+1] - x[i]) + rs[n-(i+1)]);
        }

        for(auto& e : x) e = C - e;
        reverse(_all(x));
        reverse(_all(v));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace aoj_graph
{
    class Program
    {
        static void Main()
        {
            string[] ver = Console.ReadLine().Split(' ');
            int v = int.Parse(ver[0]);
            int e = int.Parse(ver[1]);
            int r = int.Parse(ver[2]);
            int[] dist = new int[v];
            int ma = v * 10000;
            bool nega = false;
            for (int i = 0; i < v; ++i)
                dist[i] = ma;

            dist[r] = 0;

            node[] n = new node[e];

            for (int i = 0; i < e; ++i) 
            {
                n[i] = new node();
            }

            List<node>[] l = new List<node>[v];
            for (int i = 0; i < v; ++i) 
            {
                l[i] = new List<node>();
            }

            
            for (int i = 0; i < e; ++i) 
            {
                string[] std = Console.ReadLine().Split(' ');
                int s = int.Parse(std[0]);
                int t = int.Parse(std[1]);
                int d = int.Parse(std[2]);
                n[i].target = t;
                n[i].cost = d;
                l[s].Add(n[i]);
            }

            
            node k = new node();
            k.target = r;
            k.cost = 0;

            for (int i = 0; i < v; ++i) 
            {
                for (int j = 0; j < v; ++j) 
                {
                    foreach (node p in l[j])
                    {
                        if (dist[j] < ma && (dist[p.target] >= ma || dist[j] + p.cost < dist[p.target]))
                        {
                            if (i < v - 1)
                                dist[p.target] = dist[j] + p.cost;
                            else
                            {
                                nega = true;
                                break;
                            }
                        }
                    }
                }
            }
            if (nega)
                Console.WriteLine("NEGATIVE CYCLE");
            else
            {
                foreach (int i in dist)
                {
                    if (i < ma)
                        Console.WriteLine(i.ToString());
                    else
                        Console.WriteLine("INF");
                }
            }

        }
        class node
        {
            public int target;
            public int cost;

        }

    }

}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll sum = 0;
    int n;
    cin >> n;
    vector<ll> a(n+1, 0LL);
    ll cur = 0;
    rep(i,n){
        cin >> a[i];
        sum += llabs(cur - a[i]);
        cur = a[i];
    }
    sum += llabs(cur);
    cur = 0;
    rep(i,n){
        ll ans = sum - llabs(cur - a[i]) - llabs(a[i] - a[i+1]) + llabs(cur - a[i+1]);
        cout << ans << endl;
        cur = a[i];
    }
    return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d, c = 0;
  cin >> l >> r >> d;
  for(int i = l; i <= r; i++) {
    if(i / d * d == i) {
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long a, b, x; cin >> a >> b >> x;
  if (a == 0) cout << b / x + 1 << '\n';
  else cout << b / x - (a - 1) / x << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for B - Cakes and Donuts
	var N int
	fmt.Scanf("%d", &N)

	var flag int = 0
	for i := 0; i <= 25; i++ {
		for j := 0; j <= 14; j++ {
			if N == 4*i+7*j {
				flag = 1
				break
			}
		}
	}

	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int cnt = 0;
int N, M, K;
int main(){
    cin >> N >> K;
    int x[N];
    rep(i, N) cin >> x[i];
    rep(i, N){
        if(K - x[i] > x[i])
            cnt += 2 * x[i];
        else
            cnt += 2 *(K - x[i]);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll s;
lli ans = 0;

vll marge_sort(lli from,lli to){
    if(to - from == 1) return vll{s[from]};
    vll r = marge_sort(from,(from+to)/2);
    vll l = marge_sort((from+to)/2,to);
    r.push_back(1000000000);
    l.push_back(1000000000);
    vll ret;
    for(lli i = from,j=0,k=0;i < to;i++){
        if(r[j] < l[k]) ret.push_back(r[j++]);
        else ret.push_back(l[k++]);
        ans++;
    }
    return ret;
}

int main(){
    cin >> n;
    s = vll(n);
    for(lli i = 0;i < n;i++) cin >> s[i];
    s = marge_sort(0,s.size());
    cout << s[0];
    for(lli i = 1;i < n;i++) cout << " " << s[i];
    cout << endl;
    cout << ans << endl;
    return 0;

}

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

int main(){
    int n;
    string input;
    string output;
    string phone[10] =
    {
        " ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"
    };
    int p;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> input;
        output = "";
        p = input.find('0');
        while(p != string::npos){
            switch(input[0]){
                case '1':
                output += phone[1][(p-1)%5];
                break;
                case '2':
                output += phone[2][(p-1)%3];
                break;
                case '3':
                output += phone[3][(p-1)%3];
                break;
                case '4':
                output += phone[4][(p-1)%3];
                break;
                case '5':
                output += phone[5][(p-1)%3];
                break;
                case '6':
                output += phone[6][(p-1)%3];
                break;
                case '7':
                output += phone[7][(p-1)%4];
                break;
                case '8':
                output += phone[8][(p-1)%3];
                break;
                case '9':
                output += phone[9][(p-1)%4];
                break;
            }
            input.erase(input.begin(), input.begin() + p + 1);
            p = input.find('0');
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 1236
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            Console.WriteLine(s == "ABC" ? "ARC" : "ABC");
        }
    }
}


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

ll a[100010],n;

ll ans(int hugo){
	ll sum=0,ANS=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		if(hugo==-1){
			hugo=1;
			if(sum>=0){
				ANS+=abs(sum)+1;
				sum=-1;
			}
		}
		else if(hugo==1){
			hugo=-1;
			if(sum<=0){
				ANS+=abs(sum)+1;
				sum=1;
			}
		}
	}
	return ANS;
}

int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		a[i]=z;
	}
	cout << min(ans(-1),ans(1));
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int count[] = new int[n];
        for (int i = 1; i < n; i++) {
            String a = s.substring(0, i);
            String b = s.substring(i, n);
            int ac[] = new int[26];
            int bc[] = new int[26];
            for (int j = 0; j < i; j++) {
                ac[a.charAt(j) - 'a'] = 1;
            }
            for (int j = 0; j < n - i; j++) {
                bc[b.charAt(j) - 'a'] = 1;
            }
            for (int j = 0; j < 26; j++) {
                if (ac[j] == 1 && bc[j] == 1) {
                    count[i]++;
                }
            }
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, count[i]);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21972
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(); int b = sc.nextInt();
	if (b >= a) {
      System.out.println(a);
    } else {
      System.out.println(a-1);
    }  
  }
}

Measured memory_bytes: 21844
import math

def comb(n,r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

n, k = list(map(int, input().split()))

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))

Measured memory_bytes: 3316
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class AStillTBD {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int y, m, d;
	    char c;
	    in >> y >> c >> m >> c >> d;
	    out << (m <= 4 ? "Heisei" : "TBD") << '\n';
	}
};


int main() {
	AStillTBD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import math
def f(a,b,x):
	return math.floor(a*x/b) - a*math.floor(x/b)

a,b,n = map(int, input().split())

ans = f(a,b,b-1)
if (n < b):
	ans = f(a,b,n)
	if (ans == 0 and n > 1):
		ans = f(a,b,n-1)
print(ans)





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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	if (A.size() == (size_t)N) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N, X, T;
    cin >> N >> X >> T;

    if (N % X == 0) {
        cout << N / X * T << endl;
    } else {
        cout << (N / X + 1) * T << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

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

    int s[105];
    int sum = 0;
    rep(i,n){
        cin >> s[i];
        sum += s[i];
    }
    sort(s, s + n);

    int d = 0;
    int i = 0;
    while((sum - d) % 10 == 0){
        d = s[i];
        if(i >= n){
            cout << 0 << endl;
            return 0;
        }
        i++;
    }
    cout << sum - d << endl;
}


Measured memory_bytes: 256
import collections

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = collections.Counter(A)
    comb_dict = {}
    for num, freq in c.items():
        comb_dict[num] = freq * (freq-1) // 2
    comb_sum = sum(comb_dict.values())

    ans_dict = {}
    for a in A:
        if a not in ans_dict:
            ans_dict[a] = comb_sum - comb_dict[a] + (c[a] - 1) * (c[a] - 2) // 2
        print(ans_dict[a])


if __name__ == '__main__':
    main()


Measured memory_bytes: 129792
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


ll N, A, B; 
std::vector<ll> h; 

ll binarysearch(ll left, ll right) {
  if ( left >= right ) return left;
  ll mid = (left+right)/2;
  ll Sum = 0; 
  rep(i,N) {
    ll a = h[i] - mid*B;
    if ( a <= 0 ) continue;
    Sum += std::ceil( (double)a / (double)(A-B) );
  }
  //std::cout << left << " ~ " << right << " ? " << mid << " ; " << Sum << std::endl;
  if ( Sum > mid ) return binarysearch(mid+1, right);
  else return binarysearch(left, mid);
}


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> N >> A >> B;
  h.resize(N); rep(i,N) std::cin >> h[i];

  ll hmax = *std::max_element( all(h) );
  ll kmax = hmax/B + 2;

  std::cout << binarysearch(0, kmax) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    int ans=0;
    rep(i,n){
        if(i%2==0 && a.at(i)%2==1) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

int main() {
	int N, W[100], i, sum = 0, avg, sum1 = 0, sum2, min;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &W[i]);
		sum = sum + W[i];
	}
	avg = sum / 2;
	for (i = 0; sum1 < avg && i < N; i++) {
		sum1 = sum1 + W[i];
	}
	sum2 = sum - sum1;
	min = abs(sum1 - sum2);
	sum1 = sum1 - W[i - 1];
	sum2 = sum - sum1;
	if (min > abs(sum1 - sum2)) {
		min = abs(sum1 - sum2);
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	_, s, _ := ReadString(), ReadString(), ReadString()
	fmt.Println("A" + s[:1] + "C")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int l, r, d; cin >> l >> r >> d;

  int ans = 0;
  for(int i = l; i <= r; i++){
    ans += (i % d == 0);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
from collections import defaultdict

N,M = map(int, input().split())
MOD = 10**9+7
# 素因数分解
d = defaultdict(int)
i = 2
while i*i <= M:
    if M % i == 0:
        d[i] += 1
        M //= i
    else:
        i += 1
if M > 1:
    d[M] += 1

# 素因数をN個に分配する方法
def nCr(n,r):
    if n < 0 or r < 0 or n < r: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    
    # 分子のn*(n-1)*...がr個分続くやつ
    numerator = [n-r+k+1 for k in range(r)]
    # 分母：r!=r*(r-1)*...*3*2の要素
    denominator = [k+1 for k in range(r)]
    
    # 分母の要素で割れる部分を割っていく部分
    for p in range(2, r+1):
        # 分母は1,2,3,...rのようになっており、1は意味がないのでスキップした形か
        pivot = denominator[p-1]
        if pivot > 1:
        # 分子のX番目と分母のX-offset番目が共通の約数を持つということだと思う。piv分ずれているのだから、pivの倍数というところか
            offset = (n-r) % p
            for k in range(p-1, r, p):
                # 約分できる要素について割る
                numerator[k - offset]  /= pivot
                denominator[k] /= pivot
            
    ret = 1
    for k in range(r):
        if numerator[k] > 1: ret *= int(numerator[k])
        
    return ret
"""
それぞれの素数についてどの用意分配するか考える
例：2が5個あり、3箇所に分ける（２を受け取らない場所があってもよい）とは
並んでいる５つの２の間にしきりを二つ入れる、のと同じ
なので、5つの２と２つの仕切りの重複順列といえる。
上の例は3H5と表せて、
nHr = (n+r-1)Crとなる
"""
ans = 1
for k in d.keys():
    ans *= nCr((N+d[k]-1), d[k])
    ans %= MOD

print(ans)

Measured memory_bytes: 3316
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int a[N],f[N],n,res;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]),f[i]=(a[i]<=a[i-1]?f[i-1]+1:1);
	fp(i,1,n)cmax(res,f[i]);
	printf("%d\n",res-1);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    int n, m;
    cin >> n >> m;
    string s1 = "";
    string s2 = "";
    for (int i = 1; i <= m; i++)
    {
        s1 += to_string(n);
    }
    for (int i = 1; i <= n; i++)
    {
        s2 += to_string(m);
    }
    cout << min(s1, s2);
}

Measured memory_bytes: 3664
import math
a,b,h,m = map(int,input().split())

h_ang = 0.5* (h*60+m) #度
m_ang = 6.0 * m

ang = math.fabs(h_ang-m_ang)

if ang > 180:
    ang = 360 - ang


if ang <= 90:
    ans = ((a*math.sin(math.radians(ang)))**2 + (b-a*math.cos(math.radians(ang)))**2)**0.5
else:
    ang = 180-ang
    ans = ((a*math.sin(math.radians(ang)))**2 + (b+a*math.cos(math.radians(ang)))**2)**0.5
print(ans)


Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    string pattern = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int slen = s.length();
    int res = 0;
    rep(i, slen){
        if(s[i] != pattern[i])res++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);


signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	ll n; string s; cin >> s; n = s.size();
	if (s[0] == '0' || s[n - 1] == '1') { cout << "-1\n"; return 0; }
	rep2(i, n / 2 - 1) {
		if (s[i] != s[n - i - 2]) { cout << "-1\n"; return 0; }
	}
	queue<ll> que;
	rep(i, n) {
		if (s[i] == '1') { que.push(i + 1); }
	}
	rep2(i, n - 2) {
		if (que.front() == i) { que.pop(); }
		cout << que.front() << ' ' << i << endl;
	}
	cout << n - 1 << ' ' << n << endl;
	return 0;
}

Measured memory_bytes: 4204
n = gets.to_i
arr = []
n.times do
  a = gets.split.map(&:to_i)
  arr << a
end
arr.sort_by! { |_, v| v }
time = 0
check = 0
arr.each do |k, v|
  time += k
  check = 1 unless v >= time
end
if check.zero?
  puts :Yes
else
  puts :No
end

Measured memory_bytes: 22520
#coding: UTF-8
import math
N = int(input())
#print(N)

ans = [0]*10001

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      a = x**2+y**2+z**2+x*y+y*z+z*x
      if a <=10000:
        ans[a] += 1
    
for i in range(1,N+1):
  print(ans[i])

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
int r=0,b=0;
for (int i = 0;i < S.size();i++) {
    if (S.at(i) == '0') r++;
    else b++;
}

int ans = min(r,b);
cout << ans * 2 << endl;


return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll X; cin >> X;
  
  ll res = 0; ll i = 1;
  while(1){
    res += i;
    if( res >= X){
      if( res == X){ cout << i << endl; return 0;}
      else{ cout << i  << endl; return 0;}
    }
    i++;}
  
}
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B, C;
  std::cin >> A >> B >> C;
  if(A > B+C){
    std::cout << 0 << '\n';
  }else{
    std::cout << B+C-A << '\n';
  }
  return 0;
}


Measured memory_bytes: 888
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<time.h>
#include<utility>
#include<vector>
using namespace std;
const long mod = 1000000007;
//以下、グローバル変数

long patty[51]; //レベルNバーガーのパティの数
long burger[51];//レベルNバーガーのパティとバンズの数

void precal() {
	patty[0] = 1; burger[0] = 1;
	for (int i = 1; i <= 50; i++) patty[i] = 2 * patty[i - 1] + 1;
	for (int i = 1; i <= 50; i++) burger[i] = 2 * burger[i - 1] + 3;
}

long solve(long N,long X){//レベルNバーガーの下からX枚のパティの数

    if (X == 0) return 0;
	if (N == 0) return 1;
    
	if (X > burger[N] / 2 + 1) return solve(N - 1, X - burger[N] / 2 - 1) + 1 + patty[N - 1];
	if (X == burger[N] / 2 + 1)return 1 + patty[N - 1];
	if (X < burger[N] / 2 + 1) return solve(N - 1, X - 1);
	if (true) return 0;
}

//--------------------

int main() {

	long N, X; cin >> N >> X;
	precal();

	cout << solve(N, X) << endl;

}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}";return o;}
#define out(args...){vector<string> a_r_g_s=__split(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> __split(const string& s,char c){vector<string>v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T,typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){if(*it==" 1"||*it=="1")cerr<<endl;else cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it, args...);}

void Main() {
  int n = read<int>();

  ll ans = 0;
  vi A(n), B(n);
  rep(i, n) {
    A[i] = read<int>();
    B[i] = read<int>();
  }

  rrep(i, n) {
    int p = (A[i] + ans) % B[i];
    p = (B[i] - p) % B[i];
    ans += p;
    //out(i, p, 1);
  }

  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 1024