akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n;cin>>n;
  string s;cin>>s;
  int shiro[n];
  if(s[0]=='.'){
    shiro[0] = 1;
  }else{
    shiro[0] = 0;
  }
  for(int i=1;i<n;i++){
    if(s[i]=='.'){
      shiro[i] = shiro[i-1] + 1;
    }else{
      shiro[i] = shiro[i-1];
    }
  }

  int  ans = n/2;
  for(int i=1;i<n;i++){
    ans = min(ans,i-shiro[i-1] + shiro[n-1] - shiro[i-1]);
  }
  if(shiro[n-1]==n||shiro[n-1]==0){
    ans = 0;
  }

  cout<<ans<<endl;

 

  return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int H, W; cin >> H >> W;
	map<char, int> cnt;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char a; cin >> a;
			cnt[a]++;
		}
	}

	int four = 0, two = 0, one = 0;
	for (auto x : cnt) {
		if (x.second % 4 == 0)four++;
		else if (x.second % 2 == 0)two++;
		else one++;
	}

	bool flag = true;
	if (H % 2 == 0 && W % 2 == 0) {
		if (two >= 1 || one >= 1)flag = false;
	}
	if (H % 2 == 0 && W % 2 == 1) {
		if (two > H/2 || one >= 1)flag = false;
	}
	if (H % 2 == 1 && W % 2 == 0) {
		if (two > W/2 || one >= 1)flag = false;
	}
	if (H % 2 == 1 && W % 2 == 1) {
		if (two > (H+W)/2-1 || one >= 2)flag = false;
	}

	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3584
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 2e5 + 5;

int N, M;
Pii A[MAXN];

void input()
{
    read(N); read(M);
    for (int i = 1; i <= N; ++i) {
        read(A[i].x); read(A[i].y);
    }
}

void solve()
{
    std::priority_queue<int, vector<int>, std::greater<int>> q;
    vector<int> list;

    std::sort(A + 1, A + N + 1);
    int ans1 = 0;
    for (int i = 1; i <= N; ++i) {
        q.push(A[i].y);
        if (++ans1 > A[i].x) {
            --ans1;
            list.push_back(q.top());
            q.pop();
        }
    }

    std::sort(ALL(list), std::greater<int>());
    int ans2 = 0;
    for (int i = 0; i < SZ(list) && ans1 + ans2 < M; ++i) {
        ans2 += (ans2 < M - list[i] + 1);
    }
    int ans = N - ans1 - ans2;

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

int main()
{
#ifdef __DEBUG
    freopen("F.in", "r", stdin);
    freopen("F.out", "w", stdout);
#endif

    input();
    solve();
}

// 人生自古谁无死？留取丹心照汗青。
//     -- 文天祥《过零丁洋》


Measured memory_bytes: 3320
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
ll dat[100000];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%lld", &dat[i]);
	int ans = -1, tmp = 0;
	for (;;)
	{
		int cnt = 0, t = 0;
		for (int i = 0; i < num; i++)cnt += (dat[i] % 2 == 0), t += (dat[i] == 1);
		if (cnt % 2 == 1)ans = tmp;
		else if (cnt != num - 1 || t>0)ans = 1 ^ tmp;
		else
		{
			ll g = dat[0] / 2 * 2;
			for (int i = 0; i < num; i++)g = gcd(dat[i] / 2 * 2, g);
			for (int i = 0; i < num; i++)dat[i] /= g;
		}
		if (ans != -1)break;
		tmp = 1 ^ tmp;
	}
	printf(ans ? "Second\n" : "First\n");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int64 n;
    cin >> n;
    if (n % 2 == 1){
        ctn(0);
        return 0;
    }
    int64 rs = 0;
    for (int64 i = 5; i <=n; i*=5){
        rs+= n / (i * 2);
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=sc.I;
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			var a=Gp5(s[0],s[1],s[2],s[3],e[0],e[1]);
			sb.Append(a.Item1+(a.Item1-e[0])).Append(" ").Append(a.Item2+(a.Item2-e[1])).Append("\n");
		}
		Console.Write(sb);
	}
	static Tuple<double,double> Gp5(double p1x,double p1y,double p2x,double p2y,double p0x,double p0y){
		double rx=p0x,ry=p0y;
		if(p1x==p2x){rx=p1x;}
		else if(p1y==p2y){ry=p1y;}
		else{
			double m1=(p2y-p1y)/(p2x-p1x),b1=p1y-(m1*p1x),m2=-1.0/m1,b2=p0y-(m2*p0x);
			rx=(b2-b1)/(m1-m2);
			ry=(b2*m1-b1*m2)/(m1-m2);
		}
		return Tuple.Create(rx,ry);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

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

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  
  if(b <= a+w && a <= b+w) {
    eprintf("1\n");
    cout << 0 <<endl;
    return 0;
  }
  else if(b+w < a) {
    eprintf("2\n");
    cout << a - (b + w) << endl;
    return 0;
  }
  else {
    eprintf("3\n");
    cout << b - (a + w) << endl;
    return 0;
  }

  return 0;
}


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

void vprint(vector<ll> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i];
  }
  cout << endl;
}

int main() {
  ll N, K;
  ll sum = 0;
  cin >> N >> K;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];

  sort(H.begin(), H.end());//小さい順

  rep(i, K) H.pop_back();

  if (H.size() == 0) {
    cout << 0 << endl;
  }
  else {
    rep(i, N - K) sum += H[i];
    
    cout << sum << endl;
  }
  return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int MOD = 998244353;

int brut(int x, int n) {
    int orig = x;

    int res = 0;
    do {
        if (x % 2 == 0) {
            x /= 2;
            x += 1<<(n-1);
        } else {
            x /= 2;
        }
        res++;
    } while (res < 1000 && x != orig);

    if (x == orig)
        return res;
    return 0;
}

int32_t main() {
    ios_base::sync_with_stdio(0);

    int n;
    string s;

    cin >> n;
    cin >> s;

    int l = s.length();

    vector<int> c(n + 1);

    for (int i = 1; i <= n; i += 2) {
        if (n % i != 0) {
            continue;
        }

        int k = n / i;

        int cnt = 0;

        for (int i = 0; i < k; ++i) {
            cnt = (2 * cnt + (s[i] - '0')) % MOD;
        }

        string t = s;
        for (int i = k; i < n; ++i) {
            t[i] = '1' - t[i - k] + '0';
        }

        if (t <= s) {
            cnt = (cnt + 1) % MOD;
        }

        c[k] = cnt;
        //cerr << "k " << k << " " << c[k] << "\n";
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 2 * i; j <= n; j += i) {
            if ((n % j) > 0 || ((n / j) % 2) == 0) {
                continue;
            }
            c[j] = (c[j] - c[i] + MOD) % MOD;
        }
    }

    for (int i = 1; i <= n; ++i) {
        //cerr << "new " << i << " " << c[i] << "\n";
    }

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        if (n % i != 0) {
            continue;
        }
        res = (res + 2 * i % MOD * c[i]) % MOD;
    }

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

Measured memory_bytes: 2324
#[cfg(test)]
#[macro_use]
extern crate contest;

use std::fmt::Debug;
use std::io::{self, Bytes, Read, Stdin, StdinLock};
use std::str::{self, FromStr};

fn main() {
    let stdin = io::stdin();
    let mut sc = StdinScanner::new(&stdin);
    let n = sc.next();
    println!("{}", solve(sc.vec(n)).map(|v| v as i32).unwrap_or(-1));
}


fn solve(a: Vec<usize>) -> Option<usize> {
    let mut result = 0;
    let mut visited = vec![false; a.len()];
    let mut current = 0;

    while current != 1 {
        if visited[current] {
            return None;
        } else {
            visited[current] = true;
            current = a[current] - 1;
            result += 1;
        }
    }
    Some(result)
}


#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        assert_eq_in_time!(1000, "", "");
    }
}


struct StdinScanner<'a> {
    buf: Vec<u8>,
    bytes: Bytes<StdinLock<'a>>,
}


#[allow(dead_code)]
impl<'a> StdinScanner<'a> {
    fn new(stdin: &'a Stdin) -> Self {
        StdinScanner {
            buf: Vec::with_capacity(256),
            bytes: stdin.lock().bytes(),
        }
    }

    fn next<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut c = self.bytes.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = self.bytes.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = self.bytes.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
        where <A as FromStr>::Err: Debug,
              <B as FromStr>::Err: Debug
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
        where <A as FromStr>::Err: Debug,
              <B as FromStr>::Err: Debug,
              <C as FromStr>::Err: Debug
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


trait PrintYn {
    fn print_yn(self, yes: &str, no: &str);
}

impl PrintYn for bool {
    fn print_yn(self, yes: &str, no: &str) {
        println!("{}", if self { yes } else { no });
    }
}


Measured memory_bytes: 4476
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = new char[s.length()];
    int count1 = 0;
    int count2 = 0;

    for (int i = 0; i < s.length(); i++) {
      c[i] = s.charAt(i);
    }

    if (c[0] != 'A') {
      System.out.println("WA");
      return;
    }

    for (int i = 2; i < c.length-1; i++) {
      if (c[i] == 'C') {
        count1++;
      }
    }

    for (int i = 0; i < c.length; i++) {
      if (c[i] >= 'A' && c[i] <= 'Z'){
        count2++;
      }
    }


    if (count1 == 1 && count2 == 2) {
      System.out.println("AC");
    } else {
      System.out.println("WA");
    }
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
   //B問題
   int n;
   cin>>n;
   vector<int> v(n),c(n),cost(n);
   for(int i=0;i<n;i++){
       cin>>v[i];
   }
   for(int i=0;i<n;i++){
       cin>>c[i];
   }
   for(int i=0;i<n;i++){
       cost[i]=v[i]-c[i];
   }
   sort(cost.begin(),cost.end());
   int ans=0;
   for(int i=n-1;i>=0;i--){
       if(cost[i]<=0){
           break;
       }
       ans+=cost[i];
   }
   cout<<ans<<endl;

    /*D問題
    int n;
    cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ll sum=0;
    for(int i=0;i<n-1;i++){
        if(v[i]<0){
            v[i]=-v[i];
            v[i+1]=-v[i+1];
        }
        sum+=v[i];
    }
    if(v[n-1]>=0){
        sum+=v[n-1];
        cout<<sum<<endl;
    }else{
        sum+=v[n-1];
        ll ans=sum;
        for(int i=n-2;i>=0;i--){
            v[i+1]=-v[i+1];
            sum+=2*v[i+1];
            v[i]=-v[i];
            sum+=2*v[i];
            ans=max(ans,sum);
        }
        cout<<ans<<endl;
    }
    */
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<char>> maze(N+2, vector<char>(M+2));
  
  rep(i,N){
    rep(j,N){
      cin>>maze[i+1][j+1];
    }
  }
  rep(i,N){
    rep(j,M){
      if(i==0||i==N+1||j==0||j==M+1){
        maze[i][j]='.';
      }
    }
  }
  bool ch=true;
  rep2(i,1,N+1){
    rep2(j,1,M+1){
      if(maze[i][j]=='#'&&maze[i-1][j]=='.'&&maze[i][j-1]=='.'&&maze[i+1][j]=='.'&&maze[i][j+1]=='.'){
        ch=false;
      }
    }
  }
  
  
 if(ch){
   cout<<"Yes"<<endl;
 }
  else{
    cout<<"No"<<endl;
  }
}



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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  ll n, k;
  cin >> n >> k;
  ll now = 1;
  REP(i, n) {
    if(k <= now) now += k;
    else now *= 2;
  }
  cout << now << endl;

  return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

d = (a + b) - 2 * c

sep = a * x + b * y

ab_x = 2 * x * c
ab_y = 2 * y * c
sum = 0

if d < 0:
    print(sep)
    exit()
elif x > y:
    sum = a * (x - y) + ab_y
    if sum > ab_x:
        print(ab_x)
    else:
        print(sum)
else:
    sum = b * (y - x) + ab_x
    if sum > ab_y:
        print(ab_y)
    else:
        print(sum)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define nl endl
#define inf 1e18
#define cases ll t;cin>>t;while(t--)
#define BLOCK 500
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;



int main()
{
    
    fast
    ll n,W;
    cin>>n>>W;
    vll dp(W+1);
    //dp[i]= max value cosidering i weight so far
    f(i,n)
    {
        ll w,v;
        cin>>w>>v;
        for(ll wused=W-w;wused>=0;wused--)
        {
            dp[wused+w]=max(dp[wused+w],dp[wused]+v);
        }

    }

    cout<<dp[W];


    

       
    return 0;
    
}



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

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (int i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vii vector<int>
#define vvl vector<vector<ll>>
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;
ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ceel(ll a,ll b){if(a%b==0) return a/b;else return a/b+1;}


#define MAX_SIZE 1005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
            for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
    for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}
        


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};



//---------VIPUL SHARMA----------\\


void solve(){
    ll n,cnt=0;
    cin>>n;
    fi(i,0,n){
        ll x,y;
        cin>>x>>y;
        if(x==y)cnt++;
        else cnt=0;
        if(cnt>=3){
            cout<<"Yes"<<nl;
            return;
        }
    }
    cout<<"No";

}



int main(){
    //vector<int> primes;
    //Sieve(primes);

    fast
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }
    
    return 0;
}










Measured memory_bytes: 3608
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut bc: Vec<(usize, usize)> = Vec::new();

    for i in 0..n {
        let a: usize = read();
        bc.push((1, a));
    }

    for i in 0..m {
        let b: usize = read();
        let c: usize = read();
        
        bc.push((b, c));
    }

    bc.sort_by_key(|&(_, b)| b);
    let mut cnt = 0;
    let mut ans = 0;
    for i in (0..(n+m)).rev() {
        let (b, c) = bc[i];
        if cnt + b >= n {
            ans += (n - cnt) * c;
            break;
        } else {
            cnt += b;
            ans += b * c;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
    bool p[101]; memset(p, false, sizeof p);
    int x, n, _p;
    scanf("%d%d", &x, &n);
    for (int i=0; i<n; ++i){
        scanf("%d", &_p);
        p[_p] = true;
    }
    vector<int> arr;
    if (x > 100 || x < 1){
        printf("%d", x);
        return 0;
    }
    if (x == 1){
        if (p[1]) printf("0");
        else printf("1");
        return 0;
    }
    for (int i=0; i<=100; ++i){
        if (!p[i]) arr.push_back(i);
    }
    arr.push_back(101);
    int lo = 0, hi = arr.size(), ans = 0, mid;
    while (lo <= hi){
        mid = (lo + hi) / 2;
        if (arr[mid] >= x){
            ans = mid;
            hi = mid - 1;
        }
        else{
            lo = mid + 1;
        }
    }
    //arr[ans] is the first element such that arr[ans] >= x
    if (arr[ans] - x < x - arr[ans - 1]){
        printf("%d", arr[ans]);
    }
    else{
        printf("%d", arr[ans-1]);
    }
    return 0;
}


Measured memory_bytes: 3796
def main():

    N, T = map(int, input().split())
    A = list(map(int, input().split()))

    if N == 1: return 0

    min_v = A[0]
    max_d = float('-inf')
    for i in range(1, N):
        if A[i] - min_v > max_d:
             max_d = A[i] - min_v
        if A[i] < min_v:
            min_v =  A[i]

    d = set()
    d.add(A[0])
    ans = 0
    for i in range(1, N):
        if A[i] - max_d in d: ans += 1
        d.add(A[i])
    return ans



if __name__ == '__main__':
    print(main())


Measured memory_bytes: 64624
#include <bits/stdc++.h>
using ll = double;
using namespace std;
int main()
{
    ll n,k; cin >> n >> k;
    vector < ll > rm(n);
    for(ll i = 0; i < n; i++)
    {
        cin >> rm[i];
    }
    ll d = accumulate(rm.begin(),rm.end(),0);
    ll cnt = 0;
    double x = d / (4 * k);
    for(ll i = 0; i < n; i++)
    {
        if(rm[i] >= x)
        {
            cnt++;
        }
    }
    //cout << cnt << '\n';
    if(cnt >= k)
        cout << "Yes\n";
    if(cnt < k)
        cout << "No\n";
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
a = ['#' + input() +  '#' for _ in range(h)]
b = ['#' * (w + 2)] * 2
r = 0
for i in range(1, h + 1):
  for j in range(1, w + 1):
    if a[i - 1][j] == '.':
      b[1: -2] = map(list, a)
      q = deque()
      b[i][j] = 0
      q.append((i, j))
      while(q):
        i, j = q.popleft()
        r = max(r, b[i][j])
        d = 0
        for i1 in range(i - 1, i + 2):
          for j1 in range(j - d, j + 2, 2):                
            if b[i1][j1] == '.':
              b[i1][j1] = b[i][j] + 1
              q.append((i1, j1))
          d ^= 1
print(r)


Measured memory_bytes: 3316
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  r, c, a, b; 
    cin >> r >> c >> a >> b ; 
    for (int i=0;i<r;i++){
        for (int j=0;j<c;j++){
            if ((i<b and j<a) or (i>=b and j>=a)) cout << 1 ;
          	else cout << 0 ;
        }
      	cout << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3636
//                             In The Name Of Allah
//                             	Mohammad Hosseini
//                                     185
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3100, OO = 724249387, T = (1 << 20) + 10, M = 998244353, P = 6151, SQ = 280, lg = 24;
typedef pair <int, int> pii;
int dp[N][N];

int32_t main() {
 	use_fast;
	int a, b, n, m;
	cin >> a >> b >> n >> m;
	dp[a][b] = 1;
	for(int i = a; i <= n; i++) for(int j = b; j <= m; j++) if(i != a || b != j)
			dp[i][j] = ((dp[i - 1][j] + dp[i][j - 1] + (i - 1) * dp[i][j - 1] + (j - 1) * dp[i - 1][j])% M - (i - 1) * (j - 1) % M * dp[i - 1][j - 1] % M) % M;
	cout << (dp[n][m] + M) % M << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


Measured memory_bytes: 76200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define outl2(x,y) cout<< (x) << ' ' << (y) << '\n'
using pii = pair<int,int>;
using ll = long long;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
static constexpr int INF = 0x3f3f3f3f;

int N, X;
int a[100010];

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

    cin >> N >> X;

    int M = N+1;

    rep(i, N) {
        cin >> a[i];
    }
    a[N] = X;

    sort(a, a+M);

    int g = __gcd(abs(a[1]-a[0]), abs(a[1]-a[0]));
    for(int i=2; i < M; ++i) {
        g = __gcd(g, abs(a[i] - a[i-1]));
    }

    outl(g);

    return 0;
}



Measured memory_bytes: 640
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    int a[100100];
    cin >> n;
    rep(i, n) cin >> a[i];

    int ans[100100];
    rep(i, n) {
        ans[a[i] - 1] = i + 1;
    }

    rep(i, n - 1) cout << ans[i] << ' '; cout << ans[n - 1] << '\n';


    return 0;
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll par[100010],ranki[100010]; 

void init(int n){
  fr(i,n){
    par[i]=i;
    ranki[i]=0;
  }
}

int find(int x){
  if(par[x]==x) return x;
  else return par[x]=find(par[x]);
}
 
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ranki[x]<ranki[y]) par[x]=y;
  else par[y]=x;
  if(ranki[x]==ranki[y]) ranki[x]++;
}
 
bool same(int x,int y){
  return find(x)==find(y);
}

struct edge{
  ll dm,cd,ct;
  bool operator<(const edge& right) const{
    return ct<right.ct;
  }
};
vector<edge> edges;

int main(){
  ll n,x,y;
  vector<pair<P,ll>> px,py;
  cin>>n;
  fr(i,n){
    cin>>x>>y;
    px.pb(mp(mp(x,y),i));
    py.pb(mp(mp(y,x),i));
  }
  sort(px.begin(),px.end());
  sort(py.begin(),py.end());
  fr(i,n-1){
    edges.pb((edge){px[i].sd,px[i+1].sd,min(abs(px[i].ft.ft-px[i+1].ft.ft),abs(px[i].ft.sd-px[i+1].ft.sd))});
    edges.pb((edge){py[i].sd,py[i+1].sd,min(abs(py[i].ft.ft-py[i+1].ft.ft),abs(py[i].ft.sd-py[i+1].ft.sd))});
  }
  init(n);
  ll ans=0,cnt=0;
  sort(edges.begin(),edges.end());
  for(auto it=edges.begin();cnt<n-1;it++){
    edge e=*it;
    if(same(e.dm,e.cd)) continue;
    unit(e.dm,e.cd);
    ans+=e.ct;
    cnt++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 13860
X=int(input())
if 1<= X <= 99 or 106<= X <=199 or 211<= X <= 299 or 316<= X <=399 or 421<= X <= 499 or 526<= X <=599 or 631<= X <= 699 or 736<= X <=799 or 841<= X <= 899 or 946<= X <=999 or 1051<= X <= 1099 or 1156<= X <=1199 or 1261<= X <= 1299 or 1366<= X <=1399 or 1471<= X <= 1499or 1576<= X <= 1599 or 1681<= X <=1699 or 1786<= X <= 1799 or 1891<= X <=1899 or 1996<= X <= 1999:
    print(0)
else:
    print(1)

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<string> w(n); rep(i, n) cin >> w[i];
    set<string> s;
    s.insert(w[0]);
    for (int i = 1; i < n; ++i) {
        if (w[i-1][(int)w[i-1].size()-1] != w[i][0] || s.count(w[i])) {
            cout << "No" << endl;
            return 0;
        } else {
            s.insert(w[i]);
        }
    } 
    cout << "Yes" << endl;
    return 0;
}


    


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	set<char> st(s.begin(), s.end());
	cout << (st.find('9')==st.end() ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
n k
1000
 */

int n,k;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

int main(){
  cin >> n >> k;
  cout << k*pow(k-1, n-1) << endl;

  return 0;
}


Measured memory_bytes: 256
# 駅１、２、３
# 管理状況はAAB,ABA、BBA,BBBなど、長さ３の文字列で表される
# AとBの駅の間にはバスを運行することにした
# バスが運行することになる組み合わせが存在するかどうか判定し、yes,noで出力
s = input('')
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
       int n;cin>>n;
       int a[n];rep(i,n)cin>>a[i];
       int ans[n];
       int x=0;
       rep(i,n)x=x^a[i];
       rep(i,n){
       		ans[i]=x^a[i];
       }
       rep(i,n)cout<<ans[i]<<" ";
    }   
    timecalculater();
    return 0;   
} 

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s;
    cin >> s;
    ll n = s.size();

    if(s[n - 1] == '1' or s[0] == '0') {
        cout << -1 << en;
        return;
    }
    REP(i, n - 1) {
        if(s[i] != s[n - 2 - i]) {
            cout << -1 << en;
            return;
        }
    }

    ll pre = 1;
    vec<P> es;
    rep(now, 2, n + 1) {
        es.push_back({pre, now});
        if(s[now - 2] == '1')
            pre = now;
    }

    for(auto [a, b] : es) {
        cout << a << " " << b << en;
    }
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t) { solve(); }*/

    return 0;
}


Measured memory_bytes: 5476
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
 vector<int> A(5) ; rep(i,5) cin>>A[i] ;
 int ans=-1 ;
 rep(i,5){
   if(A[i]==0){
    ans=i+1 ;
    break ;
   }
 }
cout<< ans <<endl ;
  return 0;
  }

Measured memory_bytes: 3568
#include<iostream>
using namespace std;
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >>n;
    for (int i = 1;i <= n;i++){
        if(i % 3 == 0) cout << " " <<i;
        else if (i % 10 == 3) cout << " " <<i;
        else if ((i/10) % 10 == 3) cout << " " <<i;
        else if ((i/100) % 10 == 3) cout << " " <<i;
        else if ((i/1000) % 10 == 3) cout << " " <<i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}






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


  ll N, A, B; cin >> N >> A >> B;
  vector<ll> v;

  rep(i,N){
    ll inp; cin >> inp;
    v.pb(inp);
  }
  sort(rall(v));

  
  ld sum = 0.0;
  rep(i,A)sum += v[i];
  cout << fixed << setprecision(16) << sum/(ld)A << endl; 
  ll al = 0;
  ll ch = 0;
  rep(i,N)if(v[i] == v[A-1]) al++;
  rep(i,A)if(v[i] == v[A-1]) ch++;


  ll C[55][55];
  rep(i,55) C[i][0] = 1;
  rep(i,55) C[i][i] = 1;
  
  for(ll i = 2; i <= N ; i++){
    for(ll j = 1; j < i; j++){
      C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }

  if(v[0] == v[A-1]){
    ll ans = 0;
    for(ll i = A; i<= min(B,al); i++){
      ans += C[al][i];
    }
    cout << ans << endl;

    return 0;
  }
  
  
    


  
  cout << C[al][ch] << endl;
  
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#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;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

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


int n, k, h, ans=0;

void solve()
{
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> h;
        if (h>=k) ans++;
    }nout(ans);
}

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

Measured memory_bytes: 3604
n, *A = map(int, open(0).read().split())
if n % 2:
    d = {i:2 for i in range(0, n, 2)}
    d[0] -= 1
else:
    d = {i:2 for i in range(1, n, 2)}
for a in A:
    if a in d:
        d[a] -= 1
    else:
        print(0)
        exit()

if any(d.values()):
    print(0)
else:
    print(pow(2, n//2, 10**9 + 7))

Measured memory_bytes: 14436
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int a,b,x;
    cin>>a>>b>>x;
    double v=a*a*b,s;
    const double k=360/(2*3.141592653589793);
    double ans,c;
    if(x>v/2){
        s=v-x;
        double l=2*s/(a*a);
        c=l/a;
    }else{
        s=x;
        double l=2*s/(a*b);
        c=b/l;
    }
    printf("%.10lf\n",atan(c)*k);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <vector>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int a, b, c;
    int count = 0;
    cin >> a >> b >> c;
    for(int i = a ; i < b + 1 ; i++) {
        if(c % i == 0) count++;
    }
    cout << count << endl;
    return 0;
}

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

const int N=510;
int a[N*N],X[N],n;
int c[N],cnt[N];
int pos[N][N],num[N];

bool cmp(const int &x,const int &y){return X[x]<X[y];}

bool check()
{
    for(int i=1;i<=n*n;i++)
        pos[a[i]][++num[a[i]]]=i;
    for(int i=1;i<=n;i++)
        if(pos[i][i]!=X[i]) return 0;
    return 1;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",X+i);
    for(int i=1;i<=n;i++) c[i]=i,a[X[i]]=i;
    sort(c+1,c+1+n,cmp);
    for(int i=1;i<=n;i++) cnt[i]=i-1;
    for(int i=1;i<=n*n;i++)
    {
        if(a[i]) continue;
        for(int j=1;j<=n;j++)
            if(cnt[c[j]]){a[i]=c[j];cnt[c[j]]--;break;}
    }
    for(int i=1;i<=n;i++) cnt[i]=n-i;
    for(int i=n*n;i>=1;i--)
    {
        if(a[i]) continue;
        for(int j=n;j>=1;j--)
            if(cnt[c[j]]){a[i]=c[j];cnt[c[j]]--;break;}
    }
    if(check())
    {
        puts("Yes");
        for(int i=1;i<=n*n;i++)
            printf("%d ",a[i]);
    }
    else puts("No");
    return 0;
}

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

int main(void)
{
    long int n;
    long int k;
    long int h,i,j;
    long int a,b,c;
    long int dis;
 

    scanf("%ld%ld",&k,&n);

   long int max=0;

   scanf("%ld%ld",&a,&b);

   dis = b-a;
   max= dis;

   for(int i=0;i<n-2;i++){
       scanf("%ld",&c);
       dis = c-b;
       b=c;
       if(dis>max)
        max=dis;
   }

   dis = a+k-c;

   if(dis>max)
    max=dis;

    printf("%ld",k-max);


	return 0;
}


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

int main() {

    int X, Y;
    cin >> X >> Y;

    string ans = "No";

    rep(i, X + 1) {
        if (i * 2 + (X - i) * 4 == Y)
        {
            ans = "Yes";
            break;
        }
            
    };

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572