akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
 long long a,b,c,d,ans,ans2,p;
cin>>b>>a;
for(int i=0;i<2*b-1;i++){
  
    cout<<a-b+i+1;
  if(i!=2*b-2){
  cout<<" ";
  }
}
  cout<<endl;
  }


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0usize; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = if h <= av.iter().sum() { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N;
    cin>>N;
    vector<vector<int>> A(N,vector<int>(N,-1));
    int tmp;
    REP(i,N){
        REP(j,N-1){
            cin>>tmp;
            tmp--;
            A[i][j]=tmp;
        }
    }
    vector<int> cnt(N,0);
    int ans=0;
    int cnt_match=0;
    int cnt_day=1;
    int aite;
    priority_queue<int> que1,que2;
    REP(i,N) que1.push(i);
    while(cnt_day>0&&cnt_match<(N*(N-1))/2){
        ans++;
        cnt_day=0;
        vector<bool> flag(N,false);
        
        if(que1.empty()){
            while(!que2.empty()){
                int i=que2.top();
                que2.pop();
                aite=A[i][cnt[i]];
                if(aite==-1) continue;
                if(flag[i]||flag[aite]) continue;
                if(A[aite][cnt[aite]]==i){
                    cnt[i]++;
                    cnt[aite]++;
                    cnt_day++;       
                    cnt_match++;
                    flag[i]=true;
                    flag[aite]=true;
                    que1.push(i);
                    que1.push(aite);
                }
            }
        }else if(que2.empty()){
            while(!que1.empty()){
                int i=que1.top();
                que1.pop();
                aite=A[i][cnt[i]];
                if(aite==-1) continue;
                if(flag[i]||flag[aite]) continue;
                if(A[aite][cnt[aite]]==i){
                    cnt[i]++;
                    cnt[aite]++;
                    cnt_day++;       
                    cnt_match++;
                    flag[i]=true;
                    flag[aite]=true;
                    que2.push(i);
                    que2.push(aite);
                }
            }
        }
        
        
        
    }
    if(cnt_day==0) cout<<-1<<endl;
    else cout<<ans<<endl;
    
}

Measured memory_bytes: 4224
n, m, q = map(int, input().split())
a = [[0]*(n+2) for _ in range(n+2)]
for _ in range(m):
    i, j = map(int, input().split())
    a[i][j] += 1
for i in range(1, n+1):
    for j in range(1, n+1):
        a[i][j+1] += a[i][j]
        a[i][j] += a[i-1][j]
for _ in range(q):
    i, j = map(int, input().split())
    print(a[n][j] - a[i-1][j])

Measured memory_bytes: 13392
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
//using ll = long long;
#define ll long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


//N:1e5
const int bucket_size = 512;
struct RAQ {
    // data num, bucket num
    int N, K;
    vector<ll> data;
    vector<ll> bucket_add;

    RAQ(int n) : N(n) {
        K = (N + bucket_size - 1) / bucket_size;
        data.assign(K * bucket_size, 0);
        bucket_add.assign(K, 0);
    }

    //[l, r)
    void add(int s, int t, ll x){
        for(int i=0; i<K; i++){
            int left = i * bucket_size;
            int right = (i + 1) * bucket_size;
            if(t <= left || right <= s) continue;
            if(s <= left && right <= t) bucket_add[i] += x;
            else{
                for(int j=max(s, left); j<min(right, t); j++) data[j] += x;
            }
        }
    }

    //get one of data point
    ll get(int i){
        int k = i / bucket_size;
        return (data[i] + bucket_add[k]);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    RAQ raq(n);
    rep(i, q){
        bool flag;
        cin >> flag;
        if(flag){
            int pos; cin >> pos;
            cout << raq.get(pos) << endl;
        }
        else{
            int s, t, x;
            cin >> s >> t >> x;
            raq.add(s, t+1, x);
        }
    }
}



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

int main() {
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> a(n);
  rep(i,n) cin >> a.at(i);
  vector<int64_t> te;
  int64_t now=a.at(0);
  rep(i,3*n){
    te.push_back(now);
    now=a.at(now-1);
  }
  if(k<=n) cout << te.at(k-1) << endl;
  else{
    int64_t x=te.at(n);
    int64_t di;
    rep(i,n){
      if(x==te.at(n+1+i)){
        di=i+1;
      }
    }
    int64_t y=k%di;
    rep(i,n+1){
      if((n+1+i)%di==y){
        cout << te.at(n+i) << endl;
        break;
      }
    }
  }
      
}

Measured memory_bytes: 13224
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int  main()
{
    int n,m,p=0;
    double d;
    string s;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        cin>>p;
        mp[p]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
}


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

struct UnionFind {
  size_t size_;
  std::vector<int> tree;
  UnionFind(size_t n): size_(n), tree(n, -1) {}
  bool unite(size_t u, size_t v) {
    u = find_root(u);
    v = find_root(v);
    if (u == v) return false;
    if (-tree[u] < -tree[v]) std::swap(u, v);

    tree[u] += tree[v];
    tree[v] = u;
    return true;
  }
  size_t find_root(size_t u) {
    if (tree[u] < 0) return u;
    return (u = find_root(tree[u]));
  }
  bool connected(size_t u, size_t v) {
    return find_root(u) == find_root(v);
  }
  int rank(size_t u) {
    return -tree[find_root(u)];
  }
};

int main() {
  int N, M;
  scanf("%d %d", &N, &M);

  UnionFind uf1(N);

  std::vector<std::pair<int, int>> ab(M);
  for (int i=0; i<M; ++i) {
    scanf("%d %d", &ab[i].first, &ab[i].second);
    --ab[i].first;
    --ab[i].second;
    uf1.unite(ab[i].first, ab[i].second);
  }

  intmax_t mini=std::min(uf1.rank(0), uf1.rank(1));
  intmax_t rest=N-mini;
  intmax_t full=mini*(mini-1)/2+rest*(rest-1)/2;
  printf("%jd\n", full-M);
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {

	int n;
	int y[100005] = {};

	cin >> n;
	bool f = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (n == 1) {
			if (!x )cout << 1 << endl;
			else cout << 0 << endl;
			return 0;
		}
		if (x >= n)f = 1;
		if (n % 2) {
			if (!x)y[x]++;
			else if (x % 2) {
				
					f = 1;					
				

			}
		
			else y[x]++;
			
			
		}
		else {
			if (x % 2==0 ) {
				if (x) {
					f = 1;
				}
			

			}
			else y[x]++;


		}


	}
	for (int i = 0; i <= 100000; i++) {
		if (n % 2) {
			if (i&&y[i]&&i%2)f = 1;
			if (y[0] != 1)f = 1;
			if (y[i] != 2 && i % 2 == 0&&i<=n-1&&i)f = 1;
		
		}
		else {
			if (y[i] && i % 2==0)f = 1;
			//if (y[0] != 1)f = 1;
			if (y[i] != 2 && i % 2&&i<n )f = 1;
		}
	}
	
	if (f) {
		cout << 0 << endl;
		return 0;
	}
	long long r = 1;
	for (int i = 0; i < n / 2; i++) {
		r *= 2;
		r %= 1000000007;
	}
	cout << r<< endl;
	return 0;

}




Measured memory_bytes: 768
import sys
import math
#a,b= map(int,input().split())
N=int(input())
li0= [int(x) for x in input().split()]
li1= [int(x) for x in input().split()]
li2= [int(x) for x in input().split()]
i=total=0
total=sum(li1)

for i in range(N-1):
  if li0[i]==(li0[i+1]-1):
    total+=int(li2[li0[i]-1])


print(total)

Measured memory_bytes: 3064
use proconio::{input, fastout, marker::{Usize1, Chars}};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        cc: (Usize1, Usize1),
        dd: (Usize1, Usize1),
        ss: [Chars; h],
    }
    let dir = vec![
        (0, 1),
        (1, 0),
        (0, -1),
        (-1, 0),
    ];
    let dir_warp = vec![
        (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
        (-1, -2), (-1, -1), (-1, 1), (-1, 2),
        (0, -2), (0, 2),
        (1, -2), (1, -1), (1, 1), (1, 2),
        (2, -2), (2, -1), (2, 0), (2, 1), (2, 2),
    ];

    let mut visited = vec![vec![false; w]; h];
    let mut deque: VecDeque<(isize, isize, usize)> = VecDeque::new();
    let mut warp = None;
    deque.push_back((cc.0 as isize, cc.1 as isize, 0));

    while let Some((x, y, c)) = deque.pop_front() {
        let (x, y) = (x as usize, y as usize);
        if visited[x][y] || ss[x][y] == '#' {
            continue;
        }
        visited[x][y] = true;
        if (x, y) == dd {
            if let Some(warp) = warp.as_mut() {
                *warp = std::cmp::min(*warp, c);
            } else {
                warp = Some(c);
            }
        }
        let (x, y) = (x as isize, y as isize);
        for &(dx, dy) in dir.iter() {
            if x + dx >= 0 && x + dx < h as isize
                && y + dy >= 0 && y + dy < w as isize
            {
                deque.push_front((x+dx, y+dy, c));
            }
        }
        for &(dx, dy) in dir_warp.iter() {
            if x + dx >= 0 && x + dx < h as isize
                && y + dy >= 0 && y + dy < w as isize
            {
                deque.push_back((x+dx, y+dy, c+1));
            }
        }
    }
    if let Some(warp) = warp {
        println!("{}", warp);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 14012
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        int[] T = new int[N];
        int[] A = new int[N];

        for(int i = 0;i<N;i++)
        {
            T[i] = cin.nextInt();
            A[i] = cin.nextInt();
        }

        long now_T = T[0];
        long now_A = A[0];

        for (int i = 1; i < N; i++)
        {
            long pd = Math.Max(prod(now_T, T[i]), prod(now_A, A[i]));
            now_T = T[i] * pd;
            now_A = A[i] * pd;           
        }

        Console.WriteLine(now_T + now_A);
        Console.Read();
    }

    long prod(long x,long y)
    {
        if (x < y) return 1;
        if (x % y == 0) return x / y;
        return x / y + 1;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11220
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	string s, t;cin >> s;
	rep(i, s.size()) {
		if (s[i] == '0') {
			t.push_back('0');
		}
		else if (s[i] == '1') {
			t.push_back('1');
		}
		else if (!t.empty()) {
			t.erase(t.size() - 1);
		}
	}
	cout << t << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool cmp(pii d1, pii d2){
	return d1.second < d2.second;
}

void Main()
{
	int n, k;
	cin >> n >> k;
	vi a(n);  
	vi cnt(n+1,0);
	rep(i,n) {
		cin >> a[i];
		cnt[a[i]]++; 
	}
	vector<pii> data;
	int i = 0;
	while(i <= n){
		if(cnt[i]!=0) data.push_back(pii(i, cnt[i]));
		i++;
	}
	// rep(i,data.size()) cout << data[i].first << ": " << data[i].second << endl;
	stable_sort(all(data), cmp);
	int ans = 0;
	i = 0;
	while(data.size()>k){
		ans += data[i].second;
		i++;
		k++;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 5104
main :: IO ()
main = do
  s <- getLine
  print $ solve s 0

solve :: String -> Int -> Int
solve "" _ = 0
solve (c:cs) n
  | c == 'g' && n == 0 = solve cs (n+1)
  | c == 'g'           = 1 + solve cs (n-1)
  | c == 'p' && n == 0 = -1 + solve cs (n+1)
  | otherwise          = solve cs (n-1)


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int ans=0;
    string A;
    cin>>A;
    for(char ch:A)
        ans += (ch-'0');
    if(ans%9==0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

signed main() {
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3744
def main():
    nvertices, nedges = map(int, input().split())
    adj = [[0] * nvertices for i in range(nvertices)]
    for i in range(nedges):
        u, v, c = map(int, input().split())
        adj[u][v] = c

    ans = 0
    while True:
        parents = bfs(0, nvertices - 1, adj)
        if parents is None:
            break
        v = nvertices - 1
        flow = float('inf')
        while parents[v] != -1:
            u = parents[v]
            flow = min(flow, adj[u][v])
            v = u
        ans += flow
        v = nvertices - 1
        while parents[v] != -1:
            u = parents[v]
            adj[u][v] -= flow
            adj[v][u] += flow
            v = u

    print(ans)


def bfs(s, t, adj):
    nvertices = len(adj)
    visited = [False] * nvertices
    parents = [-1] * nvertices
    visited[s] = True
    que = [s]
    while que:
        u = que.pop(0)
        if u == t:
            return parents
        for v in range(nvertices):
            if not visited[v] and adj[u][v] > 0:
                visited[v] = True
                parents[v] = u
                que.append(v)

    return None


main()

Measured memory_bytes: 7888
from collections import deque

N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


visited = [False] * (N + 1)
visited[1] = True
ans = K * comb(K - 1, len(graph[1])) * fac[len(graph[1])] % MOD  # node 1
q = deque([1])
while q:
    u = q.popleft()
    for v in graph[u]:
        if visited[v]:
            continue

        ans *= comb(K - 2, len(graph[v]) - 1) * fac[len(graph[v]) - 1]
        ans %= MOD
        visited[v] = True
        q.append(v)

print(ans)


Measured memory_bytes: 111680
#15858750
n, m, x = map(int, input().split()) 
a = [list(map(int, input().split())) for i in range(n)]
ans = 12*(10**5) + 1

for j in range(2**n):  
    mlist = [0]*m 
    money = 0
    for k in range(n): 
        if (j >> k) & 1 == 1:
            money += a[k][0]
            for l in range(1, m+1): 
                mlist[l-1] += a[k][l]
    if min(mlist) >= x:
        ans = min(ans, money)
        
if ans == 12*(10**5) + 1 :
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n,k,ans=0;cin>>n>>k;
    while(n--){
        int a;cin>>a;
        ans+=(a>=k);
    }
    cout<<ans;
}

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

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid])
			return 1;
		if (key > A[mid])
			left = mid + 1;
		else if (key < A[mid])
			right = mid;
	}
	return 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	int q, k;
	int sum = 0;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &k);
		if (binarySearch(k))
			sum++;
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 3492
#include <stdio.h>

int main() {
	char a[101];
	scanf("%s", a);
	getchar();
	if(a[1] == 'B'){
		a[1] += 16;
		printf("%s", a);
	}else{
		a[1] -= 16;
		printf("%s", a);
	}

  return 0;
}


Measured memory_bytes: 3204
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	auto count_two = [](ll n){
		ll res = 0 ;
		while((n+1)&1){
			res++ ;
			n >>= 1 ;
		}
		return res ;
	} ;
	ll n ; cin >> n ;
	vll div2(n+10,0) ;
	for(int i=1;i<div2.size();i++) div2.at(i) = div2.at(i-1)+count_two(i) ;
	vll a(n) ;
	for(int i=0;i<n;i++){
		char c ; cin >> c ;
		a.at(i) = c-'0'-1 ;
	}
	ll rem = 0 ;
	for(int i=0;i<n;i++){
		if(a.at(i)&1){
			rem += ((div2.at(n-1)-div2.at(n-1-i)-div2.at(i))==0) ;
		}
	}
//	for(auto i:a) cout << i << " " ; cout << endl ;
//	for(auto i:div2) cout << i << " " ; cout << endl ;
//	cout << rem << endl ;
	if(rem&1){
		cout << 1 << endl ;
		return 0 ;
	}
	ll cnt = 0 ;
	for(int i=0;i<n;i++) if(a.at(i)&1) cnt++ ;
	if(cnt){
		cout << 0 << endl ;
		return 0 ;
	}
	for(int i=0;i<n;i++) a.at(i) >>= 1 ;
	rem = 0 ;
	for(int i=0;i<n;i++){
		if(a.at(i)&1){
			rem += ((div2.at(n-1)-div2.at(n-1-i)-div2.at(i))==0) ;
		}
	}
	cout << (rem&1)*2 << endl ;
}


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

struct Graph
{
    int N;
    struct Edge { int source, target, weight; };
    vector<vector<Edge>> adjacency_list;

    Graph(int N) : N(N), adjacency_list(N) {}

    void add_edge(int a, int b, int w) { adjacency_list[a].push_back({a, b, w}); }

    int distance(int start, int finish)
    {
        auto seen = vector<bool>(N);
        auto distances = vector<int>(N, -1);

        struct State { int v, distance; };
        auto deque = std::deque<State>({{start, 0}});

        while (!deque.empty())
        {
            auto s = deque.front(); deque.pop_front();
            if (seen[s.v]) continue;
            seen[s.v] = true;
            distances[s.v] = s.distance;

            for (const auto e : adjacency_list[s.v])
            {
                const auto next = State{e.target, s.distance + e.weight};
                if (e.weight == 0) deque.push_front(next);
                else deque.push_back(next);
            }
        }

        return distances[finish];
    }
};

struct Subway { int source, target, company; };

int solve(const int N, const vector<Subway>& subways)
{
    auto companies_at = vector<unordered_set<int>>(N);
    for (const auto s : subways)
    {
        companies_at[s.source].insert(s.company);
        companies_at[s.target].insert(s.company);
    }

    auto V = 0;

    auto in_vertices = vector<int>(N), out_vertices = vector<int>(N);
    for (auto i = 0; i < N; i++)
    {
        in_vertices[i] = V++;
        out_vertices[i] = V++;
    }

    auto company_in_vertices = vector<unordered_map<int, int>>(N);
    auto company_out_vertices = vector<unordered_map<int, int>>(N);
    for (auto i = 0; i < N; i++)
    {
        for (const auto c : companies_at[i])
        {
            company_in_vertices[i][c] = V++;
            company_out_vertices[i][c] = V++;
        }
    }

    auto graph = Graph(V);
    for (auto i = 0; i < N; i++)
        graph.add_edge(in_vertices[i], out_vertices[i], 1);

    for (auto i = 0; i < N; i++)
    {
        for (const auto c : companies_at[i])
        {
            graph.add_edge(company_in_vertices[i][c], in_vertices[i], 0);
            graph.add_edge(out_vertices[i], company_out_vertices[i][c], 0);
            graph.add_edge(company_in_vertices[i][c], company_out_vertices[i][c], 0);
        }
    }

    for (const auto s : subways)
    {
        graph.add_edge(company_out_vertices[s.source][s.company], company_in_vertices[s.target][s.company], 0);
        graph.add_edge(company_out_vertices[s.target][s.company], company_in_vertices[s.source][s.company], 0);
    }

    return graph.distance(in_vertices[0], in_vertices[N-1]);
}

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

    int N, M; cin >> N >> M;

    auto subways = vector<Subway>();
    for (auto i = 0; i < M; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        subways.push_back({a, b, c});
    }

    cout << solve(N, subways) << endl;
}


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

using namespace std;

const int N = 200000;
int a[N];
long long b[N];

int main() {
  int n, m, k; scanf("%d %d %d", &n, &m, &k);
  for(int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for(int i = 0; i < m; ++i) {
    int x; scanf("%d", &x);
    b[i] = x;
    if(i > 0) b[i] += b[i - 1];
  }
  int ans = 0;
  for(int i = 0; i <= n && k >= 0; ++i) {
    int d = lower_bound(b, b + m, k) - b;
    if(d < m && b[d] <= k) d++;
    ans = max(ans, i + d);
    if(i < n)
      k -= a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6028
from itertools import accumulate
import sys
input = sys.stdin.readline

class BIT:
    def __init__(self, size):
        self.bit = [0] * (size + 1)
        self.size = size

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.bit[i] += x
            i += i & -i

N, K = map(int, input().split())
a = [int(input()) for _ in range(N)]
cum = list(accumulate([0] + a))
v = [cum[i] - K*i for i in range(N+1)]
vs = list(set(v))
vs.sort()
compress = {vs[i]: i for i in range(len(vs))}
bit = BIT(len(vs))
ans = 0
for i in range(N+1):
    x = compress[v[i]]
    ans += bit.sum(x)
    bit.add(x, 1)
print(ans)

Measured memory_bytes: 86672
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n"
         
    #define int long long 
    #define double long double
         
    #define bp __builtin_popcountll
    #define inf 1e16
    
    const int N=1e5+5; 
    const int M=1e6+6;
    const int MOD=1e9+7;
    void solve()
    {        
    	int k,n;
    	cin>>k>>n;
    	int a[n+1];
    	int pre[n+1]={0};
    	for(int i=1;i<=n;i++)cin>>a[i];
    	int ans=inf;
    	for(int i=1;i<=n;i++){
    		if(i==1)
    		ans=a[n]-a[1];
    		else
    		ans=min(ans,a[n]-a[i]+k-a[n]+a[i-1]);
    	}
    	cout<<ans;
    	
    }

    signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
            solve();
        }
    }
        


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,k; cin >> n >> k;
	vi x(n); rep(i,n) cin >> x[i];
	int ans = INF;
	rep(i,n-k+1){
		int l = i;
		int r = i+k-1;
		ans = min(ans,x[r]-x[l]+min(abs(x[l]),abs(x[r])));
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 4e3 + 20, delta = 2005;
inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
namespace FastIO {
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
};
using namespace FastIO;
int fac[maxn * 2], N, arr[200000 + 10][2], dp[maxn][maxn], invv[maxn * 2];
inline int exgcd(int a, int b, int& x, int& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    int d = exgcd(b, a % b, x, y);
    int tmp = y;
    y = x - a / b * y;
    x = tmp;
    return d;
}
inline int inv(int a, int b)
{
    int x, y;
    exgcd(a, b, x, y);
    return (x + MOD) % MOD;
}
signed main()
{
    //freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    N = read();
    for (ri i = 1; i <= N; ++i) {
        arr[i][0] = read(), arr[i][1] = read(), dp[-arr[i][0] + delta][-arr[i][1] + delta]++;
    }
    for (ri i = -2000 + delta; i <= 2000 + delta; ++i) {
        for (ri j = -2000 + delta; j <= 2000 + delta; ++j) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j] + dp[i][j - 1]) % MOD;
        }
    }
    fac[0] = 1;
    for (ri i = 1; i < maxn * 2; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
    }
    for (ri i = 0; i < maxn * 2; ++i) {
        invv[i] = inv(fac[i], MOD);
    }
    int ans = 0;
    for (ri i = 1; i <= N; ++i) {
        int down = 2 * (arr[i][0] + arr[i][1]), up = 2 * arr[i][0];
        int tmp = fac[down] * invv[down - up] % MOD * invv[up] % MOD;
        ans = (ans + tmp) % MOD;
    }
    int sum = 0;
    for (ri i = 1; i <= N; ++i) {
        sum = (sum + dp[arr[i][0] + delta][arr[i][1] + delta]) % MOD;
    }
    sum = (sum - ans + MOD) % MOD;
    sum = (sum * inv(2, MOD)) % MOD;
    writeln(sum);
    return 0;
}

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

const int N = 2e5+15;

int A[N];
ll pre[N];

ll go(int x,int y,int l,int n,int add1,int add2) {
    if(x+add1==y || l+add2==n) {
        return 1e18;
    }
    ll u = pre[x+add1];
    ll i= pre[y]- pre[x+add1];
    ll q = pre[l+add2] - pre[y];
    ll w = pre[n] - pre[l+add2];
    vector<ll> v;
    v.push_back(u);
    v.push_back(i);
    v.push_back(q);
    v.push_back(w);
    sort(v.begin(),v.end());
    return v.back() - v[0];
}

ll solve2(int n) {
    ll ret = 1e18;
    int pos = 1;
    ll cur = A[1];
    for(int i=2;i<=n-2;++i) {
        while(pos+1<i) {
            ll tmp = cur + A[pos+1];
            if(tmp*2 <= pre[i]){
                cur += A[pos+1];
                ++pos;
            } else {
                break;
            }
        }
        int l = i+1,r = n-1,mid;
        ll remSum = pre[n] - pre[i];
        while(l<r) {
            mid = (l+r+1)/2;
            ll tmp = pre[mid] - pre[i];
            if(tmp*2<=remSum) {
                l = mid;
            } else {
                r = mid-1;
            }
        }
        for(int q=0;q<2;++q) {
            for(int w=0;w<2;++w) {
                ret = min(ret, go(pos,i,l,n,q,w));
            }
        }
    }
    return ret;
}
void solve() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",&A[i]);
        pre[i] = pre[i-1] + A[i];
    }
    ll ret = solve2(n);
    reverse(A+1,A+n+1);
    printf("%lld\n", ret);
}


int main() {
   //freopen("input.txt","r",stdin);
   solve();
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
string s;
int main(){
  cin >> s;
  s = s[0]+1;
  cout << s << endl;
}


Measured memory_bytes: 256
n,d,a = map(int,input().split())
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x:x[0])
x = [0]*n
h = [0]*n
for i in range(n): x[i],h[i] = lst[i]

length = [0]*n
for i in range(n):
    left = i+1
    right = n-1
    while left <= right:
        mid = (left+right)//2
        if x[mid] - x[i] <= 2*d:
            left = mid+1
        else:
            right = mid-1
    length[i] = left-1

d = [0]*n
dmg = 0
idx = 0
ans = 0
for i in range(n):
    while i > length[idx]:
        idx += 1
    h[i] = max(h[i]-dmg+d[idx-1],0)
    cnt = (h[i]+a-1)//a
    ans += cnt
    dmg += cnt*a
    d[i] = dmg

print(ans)

Measured memory_bytes: 96088
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
		
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] chs = sc.next().toCharArray();
			
			if(chs[2] == chs[3] && chs[4] == chs[5]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 21204
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if x%y == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(x)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 1772
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B, C, D; cin >> A >> B >> C >> D;

    string ans;
    if (A + B > C + D) ans = "Left";
    else if (A + B < C + D) ans = "Right";
    else ans = "Balanced";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
class aizu{
    public static int Main(){
        int i,j;
        int[] n = new int[10000];
        string[] str = new string[10000];

        for( ; ; ){
            str = Console.ReadLine().Split(' ');
            for(i=0;i<2;i++)
                n[i] = int.Parse(str[i]);
            if(n[0]+n[1]==0) break;
            for(i=0;i<n[0];i++){
                for(j=0;j<n[1];j++){
                    if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
                        Console.Write("#");
                    else
                        Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }        
        return 0;
    }  
}

Measured memory_bytes: 8848
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;
int main(void){
    vector<int> v;
    int n,k,num;
    long long sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>num;
        v.push_back(num);
    }
    sort(v.begin(),v.end(),greater<int>());
    if(v.size()<=k){
        sum=0;
    }else{
        for(int i=k;i<n;i++){
            sum+=v[i];
        }
    }
    cout<<sum;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int on = 0;
  rep(i,n) cin >> a.at(i);
  rep(i,n) {
    on = a.at(on)-1;
    if(on==1){
      cout << i+1 << endl;
      break;
    }
    if(i==n-1) cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int MY_COM(int n, int k) {
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	int n, m;
	cin >> n >> m;
	int s[10], c[10];
	rep(i, m) {
		cin >> s[i] >> c[i];
		s[i]--;
	}

	if (n == 1) {
		for (int i = 0; i < 10; i++) {
			string now = to_string(i);
			bool fin = true;
			rep(j, m) {
				if (now[s[j]] != c[j]+'0') {
					fin = false;
				}
			}
			if (fin) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
	if (n == 2) {
		for (int i = 10; i < 100; i++) {
			string now = to_string(i);
			bool fin = true;
			rep(j, m) {
				if (now[s[j]] != c[j]+'0') {
					fin = false;
				}
			}
			if (fin) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
	if (n == 3) {
		for (int i = 100; i < 1000; i++) {
			string nows = to_string(i);
			bool fin = true;
			rep(j, m) {
				if (nows[s[j]] != c[j]+'0') {
					fin = false;
				}
			}
			if (fin) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x,y,a,e;

  scanf("%d%d",&x,&y);
  if(y>x){   //x>yとなるようにする。
    a=x;
    x=y;
    y=a;
  }

  e=x%y;
  while(e!=0){ //ユークリッド互除法を用いる。eが０となるまで剰余算を繰り返す。
    x=y;
    y=e;
    e=x%y;
  }

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

  return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll ans = (x/11)*2;
  if(x%11 != 0){
    if(x%11 < 7) ans += 1;
    else ans += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int n = Integer.parseInt(tokens[0]);
		int k = Integer.parseInt(tokens[1]);
		tokens = in.nextLine().split(" ");
		List<Integer> values = new ArrayList<>();
		for (int i = 0; i < n; ++i) {
			values.add(Integer.parseInt(tokens[i]));
		}
		Collections.sort(values);
		// 最小値と同じ値の数を出す
		int minValue = values.get(0);
		int minValueNum = 0;
		for (int i = 1; i < values.size(); ++i) {
			if (values.get(i) > minValue) {
				minValueNum = i;
				break;
			}
		}
		int result;
		if ((values.size() - minValueNum) % (k - 1) == 0) {
			result = (values.size() - minValueNum) / (k - 1);
		} else {
			result = (values.size() - minValueNum) / (k - 1) + 1;
		}
		System.out.println(result);

		in.close();

	}

}

Measured memory_bytes: 49708
# -*- coding: utf-8 -*-

N,X = list(map(int, input().rstrip().split()))
L_list = list(map(int, input().rstrip().split()))
#-----

D=0
ans = len(L_list) + 1

cnt=1
for i in range(N):
    D = D + L_list[i]
    
    if D <= X:
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		long a = sc.nextLong();
		String s = sc.next();
		pw.println((a < 3200) ? "red" : s);
		pw.flush();
	}

	static final FastScanner sc = new FastScanner();
	static final PrintWriter pw = new PrintWriter(System.out);

	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int k; cin >> k;

  set<string> st;
  rep(i, s.size()){
    for(int j=1; j<=k && i+j<=s.size(); j++){
      st.insert(s.substr(i, j));
    }
  }

  auto itr = st.begin();
  if(k>1) rep(i, k-1) ++itr;
  
  cout << *itr << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<Pll> a(N);
  set<Pll> se;
  for(int i = 0; i < N; i++){
    cin >> a.at(i).first >> a.at(i).second;
    se.insert(a.at(i));
  }
  sort(ALL(a));

  if(N==1){
    cout << 1 << endl;
    return 0;
  }

  ll count = 0;
  for(int i = 0; i < N-1; i++){
    ll x = a.at(i).first, y = a.at(i).second;
    for(int t = 1; i+t < N; t++){
      ll p = a.at(i+t).first - x, q = a.at(i+t).second - y;
      ll c = 0;
      for(int j = i; j < N-1; j++){
        ll xx = a.at(j).first, yy = a.at(j).second;
        if(se.count(Pll(xx + p, yy + q))) c++;
      }
      chmax(count, c);
    }
  }
  cout << N-count << endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2 10", "1 100" ].parse.expand.solve == 12 );
	assert( [ "3 10", "100 1 100" ].parse.expand.solve == 23 );
	assert( [ "4 10", "1 2 3 4" ].parse.expand.solve == 10 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nx = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nx[ 1 ], as );
}

auto solve( long x, long[] as )
{
	// 魔法をi回使うと仮定したときに何秒かかるかを計算
	auto ans = long.max;
	auto ms = as.dup;
	for( auto i = 0L; i < ms.length; i++ )
	{
		// 魔法をc回使う ⇒ as[ k - i .. k + 1 ] のどれかを捕まえる ⇒ 魔法をi-c回使う（ 0 <= c <= i ）
		auto t = 0L;
		for( auto k = 0L; k < ms.length; k++ )
		{
			if( 0 <= k - i ) ms[ k ] = min( ms[ k ], as[ k - i ] );
			else             ms[ k ] = min( ms[ k ], as[ k - i + as.length.signed ] );
			t += ms[ k ];
		}
		ans = min( ans, t + x * i );
	}
	return ans;
}


Measured memory_bytes: 2428