akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


x=limii()

for i,j in enumerate(x):
    if j==0:
        print(i+1)
        exit()
    







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

int main() {
  int n, l;
  string s;
  vector<string> v;
  cin >> n >> l;
  REP(i, n) {
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  REP(i, n) {
    cout << v[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAX_N=1e5+5;

long long dp[MAX_N][3];

long long data[MAX_N][3];

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=0;j<3;j++)cin>>data[i][j];
  }

  for(int i=1;i<=n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(k==j)continue;
        dp[i][j]=max(dp[i-1][k]+data[i][j],dp[i][j]);
      }
    }
  }
  long long ans=0;
  for(int i=0;i<3;i++)ans=max(ans,dp[n][i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 4992
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut xs: Vec<i128> = sc.vec(n);
    xs.sort();
    let mut a: i128 = 1;
    for &x in xs.iter() {
        a *= x;
        if a > 1_000_000_000_000_000_000 {
            put!(-1);
            return;
        }
    }
    put!(a);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 9380
fun main(args: Array<String>) {
    var (a, b) = readLine()!!.split(" ").map{it.toInt()}
    var sum = 0
    for(i in 1..2){
        if(a >= b){
            sum += a
            a--
        }else{
            sum += b
            b--
        }
    }
    println(sum)
}


Measured memory_bytes: 38000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, q; cin >> n >> q;
	vector<vector<int>> edg(n);
	vector<int> cnt(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		edg[a].push_back(b);
		edg[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		int p, x; cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	deque<int> que;
	que.push_back(0);
	bool vis[200003] = {};
	while (!que.empty()) {
		int pos = que.front();
		que.pop_front();
		vis[pos] = true;

		for (int e : edg[pos]) {
			if (vis[e]) continue;
			cnt[e] += cnt[pos];
			que.push_back(e);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << cnt[i] << " \n"[i == n - 1];
	}
	return 0;
}


Measured memory_bytes: 15732
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,l=0,bit,ans=1,cnt=1,sum=0;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  bit=a[0];
  sum=a[0];
  for(int i=1;i<n;i++){
    bit^=a[i];
    sum+=a[i];
    cnt++;
    if(sum>bit){
      while(sum>bit){
        bit^=a[l];
        sum-=a[l];
        l++;
        cnt--;
      }
    }
    ans+=cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

if k == 1:
    print(1)
    sys.exit(0)

# 場合分けをする必要はなかった
#if k <= n:
#    ans = ((n - k) + 1) / n
#    upper = k - 1
#else:
#    ans = 0
#    upper = n
#for i in range(1, upper + 1):
#    tmp = 1 / n
#    while i < k:
#        tmp *= (1 / 2)
#        i *= 2
#    ans += tmp
ans = 0
for i in range(1, n + 1):
    tmp =  1 / n
    while i < k:
        tmp *= (1 / 2)
        i *= 2
    ans += tmp
print(ans)


Measured memory_bytes: 66312
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=MI()
    u-=1
    v-=1
    tree[u].append([v,w])
    tree[v].append([u,w])
q=deque([[0,0]])
al=[-1 for i in range(n)]
#al[0]=0
col=[0 for i in range(n)]
def dfs(a,b):
    al[a]=0
    col[a]=b
    for x,y in tree[a]:
        if al[x]<0:
            dfs(x,(y+b)%2)
dfs(0,0)
#print(col)
for i in range(n):
    print(str(col[i]))

    
    


Measured memory_bytes: 88176
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); i++)
#define FOREACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios::sync_with_stdio(false);

  int x, y, z, v[4], n, e, a;
  int dx[51], mp[51];

  while(cin >> x >> y >> z && (x > 0 || y > 0 || z > 0)){
    REP(i, x) cin >> v[i];
    REP(i, 51){
      dx[i] = 0;
      mp[i] = 0;
    }
    REP(i, z){
      cin >> n >> e >> a;
      if(e == 1) dx[n] = a;
      else if(e == 2) mp[n] = a;
      else if(e == 3) mp[n] = -a;
      
    }
    double dp[51][5001];
    REP(i, y + 1) REP(j, 100 * y + 1) dp[i][j] = 0.0;
    dp[0][0] = 1.0;
    REP(i, y){
      REP(j, 100 * y + 1){
        if (dp[i][j] == 0) continue;
        REP(k, x){
          if (i + v[k] >= y) {
            dp[y][j] += dp[i][j] / x;
            continue;
          }
          int money = j + mp[i + v[k]];
          if (money < 0) money = 0;
          int pos = i + v[k] + dx[i+v[k]];
          if (pos > y) pos = y;
          dp[pos][money] += dp[i][j] / x;
        }
      }
    }
    double ans = 0.0;
    REP(i, 100 * y + 1){
      ans += dp[y][i] * i;
    }
    cout << (int)ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3188
n,m = map(int,input().split())
adj = [ set() for i in range(n+1) ]
for i in range(m):
    a,b = map(int,input().split())
    adj[a].add(b)
    adj[b].add(a)

x = adj[1].intersection(adj[n])
if len(x) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 67740
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long A = scan.nextLong();
		double B = scan.nextDouble();
		
		BigDecimal a = new BigDecimal(String.valueOf(A));
		BigDecimal b = new BigDecimal(String.valueOf(B));
		BigDecimal multi =a.multiply(b);
		BigDecimal multi1 = multi.setScale(0, BigDecimal.ROUND_DOWN);
		
		System.out.println(multi1);

	}

}


Measured memory_bytes: 37632
//
//  main.cpp
//  pL L - Preparing Boxes
//
//  Created by Hsiu-Fen Chou on 2019/12/20.
//  Copyright © 2019 Hsiu-Fen Chou. All rights reserved.
//

#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
#define TURBO ios_base::sync_with_stdio(0);cin.tie(0);

int main() {
    TURBO
    int N;
    cin >> N;
    int a[N+1], b[N+1];
    
    for (int i=1; i<=N; i++) cin >> a[i];
    
    memset(b, 0, sizeof(b));
    for (int i=N; i>0; i--){
        int cnt = 0;
        for (int j=2*i; j<=N; j+=i){
            if (b[j] == 1) cnt ^= 1;
        }
        if (cnt ^ a[i]) b[i] = 1;
    }
    vector<int> v;
    for (int i=1; i<=N; i++){
        if (b[i]) v.push_back(i);
    }
    cout << v.size() << '\n';
    for (auto i: v) cout << i << ' ';
    cout << '\n';
    
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

ll dis[maxn];
vector<pair<int, ll> > E[maxn];
int flg;
int inq[maxn];
int c[maxn];
queue<int> q;
int n,m;

void spfa() {
    for (int i = 0; i < maxn; i++) dis[i] = 1e18;
    int cnt = 0;
    dis[n] = 0;
    q.push(n);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        inq[u] = 0;
        for (auto i : E[u]) {
            if (dis[i.fi] > dis[u] + i.se) {
                dis[i.fi] = dis[u] + i.se;
                if (!inq[i.fi]) {
                    inq[i.fi] = 1;
                    q.push(i.fi);
                    if (++c[i.fi] > n) {
                        flg = 1;return ;
                    }
                }
            }
        }
    }
}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    cin >> n >>m;
    for (int i = 0; i < m; i++) {
        int u,v,co; cin >> u >>v >>co;
        E[v].pb(pii(u,-co));
    }
    spfa();
    if (flg) {
        puts("inf");
    } else {
        cout << -dis[1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < d; ++j) cin >> x[i][j];

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int norm = 0;
      for (int k = 0; k < d; ++k) {
        int diff = abs(x[i][k] - x[j][k]);
        norm += diff * diff;
      }

      bool flag = false;
      for (int k = 0; k <= norm; ++k) {
        if (k * k == norm) {
          flag = true;
        }
      }
      if (flag) ++ans;
    }
  }
  cout << ans << endl;
}


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

long long  dp[2][100000];
long long  mat[105][2];

int main()
{
    long long n,m;
    long long  w,v;
    cin >> n >> m;
    for (int i=0;i<n;i++){
        cin >> mat[i][0]; //w
        cin >> mat[i][1]; //v
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            if (j+1>=mat[i][0]) dp[1][j]=mat[i][1]+dp[0][j-mat[i][0]];
            //if (i==2) cout << mat[i][1] <<  " " << dp[0][j-mat[i][j]-1] << " " << j << " " << mat[i][j]-1 << endl;
            dp[1][j]=max(dp[0][j], dp[1][j]);
        }
        for (int j=0;j<m;j++) dp[0][j]=dp[1][j];
        //for (int j=0;j<m;j++) cout << dp[0][j] << " ";
        //cout << endl;
    }
    cout << dp[1][m-1];
}


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

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	cout << (e - a <= k ? "Yay!" : ":(");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

aとe以外いらなくね
*/

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        swap(a, b);
    }
    rep(i, b) {
        cout << a;
    }
    cout << endl;
}


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


int main(){
	string s; bool b=true;
	cin>>s;
	
	for(int i = 0 ; i < s.size() ; i++){
		if(i%2==1){
			if(s[i]=='R'){
				b=false;
			}
		}
		else if (i%2==0){
			if(s[i]=='L'){
				b=false;
			}
		}
	}
	if(b){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  string S; cin>>S;
  if(S[0] != 'A') {
    cout << "WA" << endl;
    exit(0);
  }

  int c_cnt = 0;
  int c_pos = 0;
  for(int i = 2; i < (int)S.size() - 1; i++) {
    if(S[i] == 'C') {
      c_cnt++;
      c_pos = i;
    }
  }
  if(c_cnt != 1) {
    cout << "WA" << endl;
    exit(0);
  }

  bool ans = true;
  for(int i = 0; i < (int)S.size(); i++) {
    if(i == 0 || i == c_pos) {
      continue;
    }
    if(S[i] < 'a' || S[i] > 'z') {
      ans = false;
      break;
    }
  }

  string s;
  if(ans) s = "AC";
  else s = "WA";
  cout << s << endl;
}


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

#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++)

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  int ans=x-a;
  while(ans>=b){
    ans-=b;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;




int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define Rep(i,n) REP(i,0,n)
typedef long long ll;


string s;
map<char,int> mp;

int main(){
    cin>>s;
    Rep(i,s.size()){
        mp[s[i]]++;
    }
    bool ok=true;
    Rep(i,s.size()){
        if(mp[s[i]]%2!=0){
            ok=false;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define inf 0x3fffffff
using namespace std;

int n,d[100010],val[100010],f[100010][2],v[100010];
char c[100010];
vector<int> e[100010];
struct edge
{
    int x,y;
}a[100010];

void dfs(int x,int fa)
{
    int cnt=0;
    for (auto y:e[x])
        if (y!=fa)
        {
            dfs(y,x);
            if (f[y][0]>f[x][0]) f[x][1]=f[x][0],f[x][0]=f[y][0];
            else if (f[y][0]>f[x][1]) f[x][1]=f[y][0];
            cnt++;
        }
    if (cnt<=1) f[x][0]+=val[x],f[x][1]=0;
    else
    {
        f[x][1]+=val[x];
        f[x][0]+=val[x];
    }
    //cout<<x<<" "<<f[x][0]<<" "<<f[x][1]<<endl;
}

void dfs2(int x,int fa)
{
    if (fa!=0)
    {
        if (f[fa][0]==f[x][0]+val[fa])
        {
            if (f[fa][1]+val[x]>f[x][0]) f[x][1]=f[x][0],f[x][0]=f[fa][1]+val[x];
            else if (f[fa][1]+val[x]>f[x][1]) f[x][1]=f[fa][1]+val[x];
        }
        else
        {
            if (f[fa][0]+val[x]>f[x][0]) f[x][1]=f[x][0],f[x][0]=f[fa][0]+val[x];
            else if (f[fa][0]+val[x]>f[x][1]) f[x][1]=f[fa][0]+val[x];
        }
    }
//cout<<x<<" "<<fa<<endl;
//        cout<<x<<" "<<f[x][0]<<" "<<f[x][1]<<endl;
    for (auto y:e[x])
        if (y!=fa) dfs2(y,x);
}

int main()
{
    scanf("%d",&n);
    memset(d,0,sizeof(d));
    for (int i=1;i<n;i++)
        scanf("%d%d",&a[i].x,&a[i].y),
        d[a[i].x]++,d[a[i].y]++,
        e[a[i].x].push_back(a[i].y),
        e[a[i].y].push_back(a[i].x);
    scanf("%s",c+1);
    queue<int> q;
    for (int i=1;i<=n;i++)
        if (c[i]=='B'&&d[i]==1) q.push(i);
    while(!q.empty())
    {
        int x=q.front();q.pop();
        v[x]=1;
        for (auto y:e[x])
        {
            d[y]--;
            if (d[y]==1&&c[y]=='B') q.push(y);
        }
    }
    int x,y;
    for (int i=1;i<=n;i++)
        e[i].clear();
    for (int i=1;i<n;i++)
    {
        x=a[i].x,y=a[i].y;
        if (v[x]||v[y]) continue;
        e[x].push_back(y);
        e[y].push_back(x);
        //cout<<x<<" "<<y<<endl;
    }
    int ans=0,root;
    for (int i=1;i<=n;i++)
        if (!v[i])
        {
            ans+=d[i];
            if (d[i]%2==0&&c[i]=='W'||d[i]%2==1&&c[i]=='B') ans++,val[i]=2;
            //cout<<i<<" "<<val[i]<<endl;
            root=i;
        }
    if (ans==1){printf("%lld\n",ans);return 0;}
    dfs(root,0);
    dfs2(root,0);
    int res=0;
    for (int i=1;i<=n;i++)
        res=max(res,f[i][0]);
    printf("%d\n",ans-res);
    return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n; cin >> n;
    vll l(n); rep(i, n) cin >> l[i];

    ll ans=0;
    rep(i, n-2){
        rep2(j, i+1, n-1){
            rep2(k, j+1, n){
                if(l[i]==l[j] || l[i]==l[k] || l[j]==l[k]) continue;
                if(l[i]+l[j]<=l[k] || l[i]+l[k]<=l[j] || l[j]+l[k]<=l[i]) continue;
                ans++;
            }
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
number=int(input())
book=[]
for i in range(0,number):
  book.append(input().split())
for i in range(0,len(book)):
    book[i][1]=int(book[i][1])
    book[i].append(i+1)
book1=sorted(book,key=lambda x: -x[1])
book2=sorted(book1,key=lambda x: x[0])
for i in range(0,len(book2)):
  print(book2[i][2])

Measured memory_bytes: 3064
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x-1]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)


Measured memory_bytes: 4596
#include<cstdio>
#include<string.h>
#include<map>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    string c,d,e;
    while(cin>>c)
    {
        cin>>d;
        scanf("%d%d",&a,&b);
        cin>>e;
        if(e==c)
        {
            a--;
        }
        else if(e==d)
        {

            b--;
        }
          printf("%d %d\n",a,b);
    }

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    A = LI()

    for a in A:
        if a % 2 == 0:
            if a % 3 != 0 and a % 5 != 0:
                print("DENIED")
                exit()

    print("APPROVED")


main()


Measured memory_bytes: 65060
import queue


class Edge:
    def __init__(self, from_v, to_v, cost):
        self.from_v = from_v
        self.to_v = to_v
        self.cost = cost

    def __lt__(self, other):
        return self.cost < other.cost

    def get_from_v(self):
        return self.from_v

    def get_to_v(self):
        return self.to_v

    def get_cost(self):
        return self.cost


class Vertex:
    def __init__(self, cost, id):
        self.cost = cost
        self.id = id

    def __lt__(self, other):
        return self.cost < other.cost

    def get_cost(self):
        return self.cost

    def get_id(self):
        return self.id


class Dijkstra:
    def __init__(self, number_of_vertex):
        # self.edges = []
        self.graf = [[] for _ in range(number_of_vertex)]
        self.number_of_vertex = number_of_vertex
        self.distance = []  # 最短距離
        self.INF = 1145141919810

    def add_edge(self, from_v, to_v, cost):
        # self.edges.append(Edge(from_v, to_v, cost))
        self.graf[from_v].append(Edge(from_v, to_v, cost))

    def compute_shortest_distance(self, start):
        self.distance = [self.INF] * self.number_of_vertex
        self.distance[start] = 0
        que = queue.PriorityQueue()

        que.put(Vertex(0, start))

        while not que.empty():
            top = que.get()
            cost = top.get_cost()
            id = top.get_id()
            if self.distance[id] < cost: continue
            for a_edge in self.graf[id]:
                to_v = a_edge.get_to_v()
                from_v = a_edge.get_from_v()
                prev_cost = self.distance[from_v]
                next_cost = self.distance[to_v]
                if next_cost > prev_cost + a_edge.get_cost():
                    next_cost = prev_cost + a_edge.get_cost()
                    self.distance[to_v] = next_cost
                    que.put(Vertex(next_cost, to_v))


n = int(input())
dij = Dijkstra(n)

for i in range(n):
    tmp = list(map(int, input().split()))
    u = tmp[0]
    k = tmp[1]
    vc = tmp[2:]
    for j in range(k):
        dij.add_edge(u, vc[2 * j], vc[2 * j + 1])

dij.compute_shortest_distance(0)

for i in range(n):
    print(str(i) + " " + str(dij.distance[i]))



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

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const MAX: usize = 1000000;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<usize> = sc.vec(N);
    let mut cnt = vec![0; MAX+1];
    for i in 0..N {
        if cnt[A[i]] != 0 {
            cnt[A[i]] += 1;
            continue;
        }
        for j in (A[i]..=MAX).step_by(A[i]) {
            cnt[j] += 1;
        }
    }
    let mut ans = 0;
    for i in 0..N {
        if cnt[A[i]] < 2 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;
using PP = pair<P, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

struct data{
	llong place;
	llong cost;

	data(){};
	data(llong place, llong cost) :
		place(place),
		cost(cost)
	{}

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};

vector<vector<PP> > edges;
vector<bool> use;

llong Dijkstra(int start){
	priority_queue<data, vector<data>, greater<data> > q;
	vector<P> dis(edges.size(),P(inf,-1));
	dis[start].first = 0;

	q.push(data(start, 0));
	while(q.size()){
		data now = q.top(); q.pop();
		if(dis[now.place].first < now.cost) continue;

		for(int i = 0; i < edges[now.place].size(); i++){
			P edge = edges[now.place][i].first;
			data next(edge.first, now.cost + edge.second);
			if(dis[next.place].first <= next.cost) continue;
			dis[next.place].first = next.cost;
			dis[next.place].second = edges[now.place][i].second;
			q.push(next);
		}
	}

	for(int i = 1; i < edges.size(); i++)
		if(i != start && dis[i].first != inf)
			use[dis[i].second] = true;

	return -1;
}


int main(){
	llong N, M;
	cin >> N >> M;
	edges.resize(N+1);
	use.resize(M);

	int a,b,c;
	for(int i = 0; i < M; i++){
		cin >> a >> b >> c;
		edges[a].push_back(PP(P(b,c),i));
		edges[b].push_back(PP(P(a,c),i));
	}

	for(int i = 1; i <= N; i++)
		Dijkstra(i);

	int ans = 0;
	for(int i = 0; i < M; i++)
		if(use[i] == false)
			ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intAbs(x int) int {
	return int(math.Abs(float64(x)))
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}

	cntPlus, cntZero, cntMinus, absMin := 0, 0, 0, int(math.Pow10(10))
	for i := 0; i < N; i++ {
		if A[i] > 0 {
			cntPlus++
			absMin = intMin(absMin, intAbs(A[i]))
		} else if A[i] == 0 {
			cntZero++
		} else {
			cntMinus++
			absMin = intMin(absMin, intAbs(A[i]))
		}
	}

	ans := 0
	for _, a := range A {
		ans += intAbs(a)
	}
	if cntZero == 0 && cntMinus%2 == 1 {
		ans -= 2 * absMin
	}

	fmt.Println(ans)
}


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

typedef long long llong;

int main(int argc, const char * argv[]) {
    llong N;
    llong moving_counts[6];
    
    cin >> N >> moving_counts[0] >> moving_counts[1] >> moving_counts[2] >> moving_counts[3] >> moving_counts[4];
    
    llong min = 1000000000000000;
    for (int i = 0; i < 5; i++) {
        if (min > moving_counts[i]) {
            min = moving_counts[i];
        }
    }
    
    cout << (llong)ceill((long double)N / (long double)min) + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1000000000")
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<cassert>
#include<ctime>
#include<unordered_map>
#include<cmath>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld;
//////////////////////

int a, b;


void solve(){
	if(a <= 0 && 0 <= b){
		printf("Zero\n");
		return;
	}
	
	int q = 0;
	if(a < 0) q = min(b, -1) - a + 1;
	if(q % 2 == 1){
		printf("Negative\n");
		return;
	}

	printf("Positive\n");
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

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

	solve();



	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toLong() }

    fun f(h: Long, w: Long): Long {
        var ans = Long.MAX_VALUE
        for (h1 in 1 until h) {
            val h2 = h - h1

            if (h2 >= 2) {
                val a = listOf(h1 * w, (h2 / 2) * w, (h2 - h2 / 2) * w)
                ans = Math.min(ans, a.max()!! - a.min()!!)
            }

            val a = listOf(h1 * w, h2 * (w / 2), h2 * (w - w / 2))
            ans = Math.min(ans, a.max()!! - a.min()!!)
        }
        return ans
    }

    println(Math.min(f(h, w), f(w, h)))
}


Measured memory_bytes: 50336
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    int S;
    cin >> S;
    
    int h,m,s;
    
    h = S/3600;
    m = S%3600/60;
    s = S - 3600*h - 60*m;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
    
}



Measured memory_bytes: 3120
/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-16 18:05:13
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1e5 + 5;
const int ha = 1e9 + 7;
int x[MAXN],y[MAXN];
int n,m;
P a[MAXN];
int N;
std::vector<int> S;
int f[MAXN];

struct BIT{
    #define lowbit(x) ((x)&(-(x)))
    int tree[MAXN];

    inline void add(int pos,int d){
        while(pos < MAXN){
            (tree[pos] += d) %= ha;
            pos += lowbit(pos);
        }
    }

    inline int query(int pos){
        int res = 0;
        while(pos){
            (res += tree[pos]) %= ha;
            pos -= lowbit(pos);
        }
        return res;
    }
}bit;

inline bool cmp(P x,P y){
    return x.fi == y.fi ? x.se > y.se : x.fi < y.fi;// 同列不得转移
}

int main(){
    scanf("%d%d",&n,&m);
    FOR(i,1,n) scanf("%d",x+i);
    FOR(i,1,m) scanf("%d",y+i);
    std::sort(x+1,x+n+1);std::sort(y+1,y+m+1);
    FOR(i,1,n){
        if(x[i] <= y[1] || x[i] >= y[m]) continue;
        int p = std::lower_bound(y+1,y+m+1,x[i]) - y;
        if(x[i] == y[p]) continue;
        a[++N] = MP(x[i]-y[p-1],y[p]-x[i]);
    }
    std::sort(a+1,a+N+1,cmp);
    FOR(i,1,N) S.pb(a[i].se);
    std::sort(all(S));
    S.erase(std::unique(all(S)),S.end());
    FOR(i,1,N) a[i].se = std::lower_bound(all(S),a[i].se)-S.begin() + 2;
    f[0] = 1;
    N = std::unique(a+1,a+N+1)-a-1;
//    FOR(i,1,N) printf("%d %d\n",a[i].fi,a[i].se);
    FOR(i,1,N){
        f[i] = bit.query(a[i].se-1)+1;f[i] %= ha;
        DEBUG(f[i]);
        bit.add(a[i].se,f[i]);
    }
    int ans = 0;
    FOR(i,0,N) (ans += f[i]) %= ha;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d;
int n,i;
int main (){
	scanf ("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	ll del=abs(a-b),n1=c,n2=d-c;
	for (i=0;i<=n-1;i++)
	{ll x1=2*i-n+1;
	ll d=del-c*x1;
	if (n2==0)
	{if (d==0) 
	{puts("YES");
	return 0;
	}
	}
	else
	{ll minn=n2*(n-1-i);minn*=(-1);
	ll maxn=n2*i;
	if (d>=minn&&d<=maxn)
	{puts("YES");return 0;}
	}
	}
	printf ("NO\n");
	return 0;
}
	

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int MSB1(long long x) { int d = 0; while ((1LL << d) <= x) d++; return d; }

int main() {
    int n; cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for (auto &ai: a) cin >> ai, cnt[ai]++;
    sort(a.rbegin(), a.rend());
    int ans = 0;
    for (int val: a) if (cnt[val]) {
        cnt[val]--;
        int rem = (1 << MSB1(val)) - val;
        if (cnt[rem]) ans++, cnt[rem]--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19712
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	s = list(input())
	N = len(s)
	judge = "Yes"
	if s[0] == "0":
		judge = "No"
	if s[N - 1] == "1":
		judge = "No"
	for i in range(N - 2):
		if s[i] != s[N - 2 - i]:
			judge = "No"
	if judge == "No":
		print(-1)
		return

	c = 1
	d = N
	for i in range(N - 1):
		if s[i] == "1":
			print(c, c + 1)
			c += 1
		else:
			print(c, d)
			d -= 1

if __name__ == '__main__':
	main()

Measured memory_bytes: 51448
package main

import (
	"fmt"
)

func main() {
	var s string
	var i int
	fmt.Scanln(&s)
	if s[0] == '1' {
		i++
	}
	if s[1] == '1' {
		i++
	}
	if s[2] == '1' {
		i++
	}
	fmt.Println(i)
	return
}


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

using namespace std;
int n;
vector<vector<int>> t;

bool check(int a,int b){
    int w=0,l=0;
    for(int j=0;j<n;j++){
        if(t[a][j]==1)w++;
        if(t[a][j]==-1)l++;
    }
    if(w>(n-1)/2||l>(n-1)/2) {
        return false;
    }
    w=0,l=0;
    for(int j=0;j<n;j++){
        if(t[b][j]==1)w++;
        if(t[b][j]==-1)l++;
    }
    if(w>(n-1)/2||l>(n-1)/2) {
        return false;
    }
    return true;
}

int dfs(int x,int y){
    int ans=0;

    if(t[x][y]!=0){
        if(check(x,y)) {
            if (x == n-1 && y == n - 2) {
                return 1;
            }else{
                if(y+1==x){
                    ans+=dfs(x+1,0);
                }else{
                    ans+=dfs(x,y+1);
                }
            }
            return ans;
        }else{
            return 0;
        }
    }else{
        t[x][y]=1;
        t[y][x]=-1;
        bool f=check(x,y);
        if(f){
            if(x==n-1&&y==n-2){
                t[x][y]=0;
                t[y][x]=0;
                return 1;
            }else{
                if(y+1==x){
                    ans+=dfs(x+1,0);
                }else{
                    ans+=dfs(x,y+1);
                }
            }
        }
        t[x][y]=-1;
        t[y][x]=1;
        f=check(x,y);
        if(f){
            if(x==n-1&&y==n-2){
                t[x][y]=0;
                t[y][x]=0;
                return 1;
            }else{
                if(y+1==x){
                    ans+=dfs(x+1,0);
                }else{
                    ans+=dfs(x,y+1);
                }
            }
        }
        t[x][y]=0;
        t[y][x]=0;
    }

    return ans;
}

int main() {
    while(1){
        int m;
        cin >> n;
        if(n==0){
            break;
        }
        cin>> m;
        t.clear();
        t.resize(n,vector<int>(n,0));
        for(int i=0;i<m;i++){
            int x,y;
            cin >> x >> y;
            x--;y--;
            t[x][y]=1;
            t[y][x]=-1;
        }
        int ans=dfs(1,0);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        String result = "No";
        if ( (Math.abs(a-c) <= d) || (Math.abs(a-b) <= d && Math.abs(b-c) <= d) ) result = "Yes";
        System.out.println(result);
    }
}


Measured memory_bytes: 35672
#include<stdio.h>

int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	int l[n];
	for(int i = 0; i < n; i++){
		scanf("%d", l+i);
	}
	int bound[105];
	bound[0] = 0;
	int ans = 1;
	for(int i = 0; i < n; i++){
		bound[i+1] = bound[i] + l[i];
		if(bound[i+1] <= x) ans++;
	}
	printf("%d\n", ans);
} 


Measured memory_bytes: 1720
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0
for t in T:
    left, right = 0, n - 1
    while left <= right:
        mid = (left + right) // 2
        if S[mid] == t:
            ans += 1
            break
        elif S[mid] < t:
            left = mid + 1
        else:
            right = mid - 1

print(ans)


Measured memory_bytes: 16708
h,w=map(int,input().split())
a=[]
for i in range(h):
    k=input()
    if k!="."*w:
        a.append(k)
l=len(a)
#print(a)
ans=[[] for i in range(l)]
for i in range(w):
    for j in range(l):
        if a[j][i]=="#":
            for k in range(l):
                ans[k].append(a[k][i])
            break
for i in range(l):
    print("".join(ans[i]))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    vector<int> nums;
    rep(i,N){
        int x;cin>>x;
        if(i%2){
            nums.insert(nums.begin(),x);
        }else{
            nums.push_back(x);
        }
    }
    
    if(N%2) reverse(all(nums));
    rep(i,N){
        if(i)cout<<" ";
        cout<<nums[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
#include<tuple>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define fi first
#define se second
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}



ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

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

Measured memory_bytes: 256