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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }


ll n;
string s;


int main() {
    cout<<fixed<<setprecision(10);

    cin>>n>>s;

    map<string,map<string,ll>> m1;
    ll ans = 0;

    rep(i,(1ll<<n)){
        // cout<<i<<endl;
        string r1 = "";
        string b1 = "";
        rep(j,n){
            if((i>>j)&1){
                r1 += s[j];
            }else{
                b1 += s[j];
            }
        }
        reverse(ALL(b1));
        // cout<<r1<<" : "<<b1<<endl;
        m1[r1][b1]++;
    }


    rep(i,(1ll<<n)){
        string r2 = "";
        string b2 = "";
        rep(j,n){
            if((i>>j)&1){
                r2 += s[n+j];
            }else{
                b2 += s[n+j];
            }
        }
        reverse(ALL(b2));
        ans += m1[b2][r2];
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 119552
def main21():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    kensa = [];
    for j in range(buf[1]):
        strbuf = input("");
        strbufs = strbuf.split();
        kari = [];
        for i in range(2):
            kari.append((int(strbufs[i]))-1);
        kensa.append(kari);
    flag = [];
    kazu = [];
    for i in range(buf[0]):
        flag.append(0);
        kazu.append(1);
    flag[0] = 1;
    for i in range(buf[1]):
        kazu[kensa[i][0]] -= 1;
        kazu[kensa[i][1]] += 1;
        if flag[kensa[i][0]] == 1:
            flag[kensa[i][1]] = 1;
        if kazu[kensa[i][0]] == 0:
            flag[kensa[i][0]] = 0;
    result = 0;
    for i in range(buf[0]):
        if flag[i] == 1:
            result+=1;
    print(result);

if __name__ == '__main__':
    main21()


Measured memory_bytes: 22756
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int N, T, A,min=10000000,ans,x;
	cin >> N >> T >> A;
	REP(i, N) {
		cin >> x;
		x = abs(1000*A - 1000*T + x *6);
		if (x < min) {
			min = x;
			ans = i;
		}
	}
	cout << ans <<endl;
}

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

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

using namespace std;

int main()
{
    char str[128];
    char to[128];
    
    to['['] = ']';
    to['('] = ')';
    
    while (fgets(str, sizeof(str), stdin) != NULL){
        str[strlen(str) - 1] = 0;
        if (str[0] == '.' && str[1] == 0) break;
        
        char st[128];
        int ptr = 0;
        bool ok = true;
        
        for (int i = 0; str[i]; i++){
            if (str[i] == '(' || str[i] == '[') st[ptr++] = str[i];
            else if (str[i] == ')' || str[i] == ']'){
                if (ptr == 0 || to[st[--ptr]] != str[i]){
                    ok = false;
                    break;
                }
            }
        }
        
        printf("%s\n", ok && !ptr ? "yes" : "no");
    }
    
    return (0);
}

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

public class Main {
	public static void main(String[] args) {
		final long Mod = 1000_000_007;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		sc.close();
		int[] a = new int[n+1];
		Arrays.fill(a, 1);
		long res = 1;

		for(int i = 2;i<=n;i++) {
			int t=i;
			for(int j=2;j<=t;j++) {
				while(t%j==0) {
					t/=j;
					a[j]++;
				}
			}
		}
		for(int i=1;i<=n;i++) {
			res = res*a[i];
			while(res>=Mod)res-=Mod;
		}
		System.out.println(res);
	}
}

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def get_sum(a, b, c):
    """ 等差数列の和：(初項a, 末項b, 項数c) """
    return (a+b) * c // 2

def dfs(N, nodes, src):
    """ DFS(木、再帰、重みなし) """

    def rec(u, prev):
        C = Counter()
        for v in nodes[u]:
            if v != prev:
                C[rec(v, u) + 1] += 1
        if not C:
            return 0
        C = sorted(C.items(), reverse=1)
        mx = C[0][0]
        add = C[0][1] - 1
        vacant = 0
        for i, (k, v) in enumerate(C[1:], 1):
            k2, _ = C[i-1]
            vacant += k2 - k - 1
            vacant -= v - 1
            if vacant < 0:
                add += abs(vacant)
                vacant = 0
        return mx + add

    return rec(src, -1)

N = INT()
nodes = [[] for i in range(N)]
for a in range(1, N):
    b = INT()
    b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

print(dfs(N, nodes, 0))


Measured memory_bytes: 164588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

void swap(std::string& str1, std::string& str2)
{
	std::string temp;

	temp = str1;

	str1 = str2;

	str2=temp;
}

int main()
{
	int n=0;

	std::cin >> n;

	for(int i=0; i<n; ++i)
	{
		std::vector<int> a, b;

		std::string stra, strb;

		std::cin >> stra >> strb;

		if(stra.length()<strb.length())
		{
			swap(stra,strb);
		}

		for(size_t i=0; i<stra.length(); ++i)
		{
			a.push_back(stra[stra.length()-1-i]-48);
		}

		for(size_t i=0; i<strb.length(); ++i)
		{
			b.push_back(strb[strb.length()-1-i]-48);
		}

		for(size_t i=0; i<b.size(); ++i)
		{
			a[i] += b[i];
		}

		for(size_t i=0; i<a.size()-1; ++i)
		{
			if(a[i]>=10)
			{
				++a[i+1];

				a[i] %= 10;
			}
		}

		if(a[a.size()-1]>=10)
		{
			a[a.size()-1] %= 10;

			a.push_back(1);
		}
		
		if(a.size()>80)
		{
			std::cout << "overflow";
		}
		else
		{
			for(size_t i=0; i<a.size(); ++i)
			{
				std::cout << a[a.size()-1-i];
			}	
		}

		std::cout << '\n';
	}
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    
    int l[50];
    int i;
    for(i = 0; i < n; i++){
        cin >> l[i];
    }
    
    sort(l, l + n, greater<int>());
    
    int ans = 0;
    for(i = 0; i < k; i++){
        ans += l[i];
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#define LL long long
#define M 100020
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
LL n,m;
vector<LL> p[M];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=sqrt(n*2);
	if(m*(m+1)!=n*2){puts("No");return 0;} puts("Yes");
	m=1; LL now=0;
	while(n>now){
		for(LL i=1;i<=m;i++) p[i].push_back(i+now);
		for(LL i=now+1;i<=now+m;i++) p[m+1].push_back(i);
		now+=m; m++;
	}
	printf("%lld\n",m);
	for(LL i=1;i<=m;i++){
		printf("%lld",p[i].size());
		for(LL k=0;k<p[i].size();k++) printf(" %lld",p[i][k]);
		puts("");
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<int>data(n);
  rep(i,0,n) cin >> data[i];
  sort(data.begin(),data.end());
  rep(i,0,n/2) ans -= 2*data[i];
  rep(i,n/2+1,n) ans += 2*data[i];
  if(n%2 == 1){
    ll ans1 = ans+data[n/2]-data[n/2+1];
    ll ans2 = ans-data[n/2]+data[n/2-1];
    ans = max(ans1,ans2);
  }
  else{
    ans += data[n/2]+data[n/2-1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >> N;
  int a[2][N+1]={0};
  int sum1=0,sum2=0;
  rep(i,N) cin >> a[0][i];
  rep(i,N){
     cin >> a[1][i];
     sum2+=a[1][i];
  }
  int ans = -1;
  for(int i=0;i<N;i++){
    sum1+=a[0][i];
    if(i!=0) sum2-=a[1][i-1];
    ans = max(ans,sum1+sum2);
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> X;
  for (int i=0; i<n; i++) {
    int a, b;
    cin >> a >> b;
    X.push_back(make_pair(b, a));
  }
  sort(X.begin(), X.end());
  long long sum=0;
  for (auto j: X) {
    sum+=j.second;
    if (sum>j.first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 2420
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(2);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    string a, b;
    cin >> a >> b;
    int x, y;
    cin >> x >> y;
    string t;
    cin >> t;
    if(t == a)
    {
        x--;
    }
    else
    {
        y--;
    }
    cout << x << " " << y ;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1
MOD = 2019

"""
gcd(10, 2019) = 1 互いに素
-> 10のmod2019での逆元(1/10)が存在
"""
S = input().rstrip()
s_list = list(map(int, list(S)))[::-1]

counts = [0] * MOD
counts[0] = 1

num, d = 0, 1

for s_element in s_list:
    num += s_element * d
    num %= MOD
    d *= 10
    d %= MOD
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans)


Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int a,b;
        cin>>a>>b;
        cout<<a*b<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


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


Measured memory_bytes: 3636
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<i64>();
    let M = scan.word::<usize>();
    let A = scan.list::<i64>(M);

    let sum = A.iter().sum::<i64>();

    if sum <= N {
        println!("{}", N - sum);
    } else {
        println!("-1");
    }
}


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

int main()
{
  int N;
  scanf("%d", &N);
  int n7 = 0;
  char buf[4];
  fprintf(stderr, "%d\n", N);
  sprintf(buf, "%d", N);
  for (int i=0;i<3;i++)
    if (buf[i] == '7')
      n7++;
  if (n7>0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
ll powmod(ll x, ll y, ll mod)
{
    ll ans = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            ans *= x;
            ans %= mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int p;
    cin >> p;
    vii a(p);
    rep(i, p) cin >> a[i];
    vii All(p+1,0);
    //x-0からx-p+1までかけたものの、x^iの係数
    All[1] = 1;
    repf(i,1,p){
        repr(j,p,0){
            All[j] = (All[j - 1] + p - All[j] * i % p) % p;
        }
    }
    vii b(p);
    rep(i,p){
        if (a[i]==0)
            continue;
        int div = 1;
        vii res(p);
        int bef = 0;
        rep(j,p){
            if (i==j)
                continue;
            div *= (p + i - j);
            div %= p;
        }
        repr(j,p,0){
            res[j - 1] = (All[j] + bef) % p;
            bef = i * res[j - 1] % p;
        }
        div = powmod(div, p - 2, p);
        rep(j,p){
            b[j] += res[j] * div % p;
            b[j] %= p;
        }
    }
    rep(i, p) cout << b[i] << " ";
    cout << ENDL;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  map<string, int> counts;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    counts[s]++;
  }
  cout << "AC" << " x " << counts["AC"] << endl;
  cout << "WA" << " x " << counts["WA"] << endl;
  cout << "TLE" << " x " << counts["TLE"] << endl;
  cout << "RE" << " x " << counts["RE"] << endl;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static int[] Distances(List<int>[] edges, int i)
    {
        int N = edges.Length;
        int[] d = Enumerable.Repeat(int.MaxValue, N).ToArray();
        var q = new Queue<int>();
        d[i] = 0;
        q.Enqueue(i);
        while (q.Count > 0)
        {
            int a = q.Dequeue();
            foreach (int b in edges[a])
            {
                if (d[a] + 1 < d[b])
                {
                    d[b] = d[a] + 1;
                    q.Enqueue(b);
                }
            }
        }
        return d;
    }

    static int Farthest(int[] d)
    {
        int max = 0;
        for (int j = 1; j < d.Length; ++j)
        {
            if (d[j] > d[max]) { max = j; }
        }
        return max;
    }

    static int Solve(List<int>[] edges)
    {
        int N = edges.Length;
        int[] colors = new int[N];
        var q = new Queue<int>();
        colors[0] = 1;
        q.Enqueue(0);
        while (q.Count > 0)
        {
            int i = q.Dequeue();
            foreach (int j in edges[i])
            {
                if (colors[j] == 0)
                {
                    colors[j] = -colors[i];
                    q.Enqueue(j);
                }
                else if (colors[i] == colors[j])
                {
                    return -1;
                }
            }
        }
        return Enumerable.Range(0, N).Max(i => Distances(edges, i).Max()) + 1;
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var edges = new List<int>[N];
        for (int i = 0; i < N; ++i)
        {
            edges[i] = new List<int>();
            string S = Console.ReadLine();
            for (int j = 0; j < N; ++j)
            {
                if (S[j] == '1') { edges[i].Add(j); }
            }
        }
        Console.WriteLine(Solve(edges));
    }
}


Measured memory_bytes: 13524
import math

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

if (a*b)/2 == x/a:
    print(45)
elif (a*b)/2 < x/a:  # 水が溢れる瞬間、水面が底面に達しない
    tmp = 2*(b - x/a**2)
    print(math.degrees(math.atan(tmp/a)))
else:
    tmp = (2*x)/(a*b)
    print(math.degrees(math.atan(b/tmp)))

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std; 
 
int main() { 
        int N; 
        cin >> N; 
        if (N == 3) { 
                cout << "2 5 63" << endl; 
                return 0; 
        } 
        vector<int> a; 
        a.push_back(2); a.push_back(4); 
        a.push_back(3); a.push_back(9); 
        for(int i = 1; i * 6 + 4 <= 30000 && a.size() < N - 1; ++i) { 
                a.push_back(i * 6 + 2); 
                a.push_back(i * 6 + 4); 
        } 
        for(int i = 1; i * 12 + 9 <= 30000 && a.size() < N - 1; ++i) { 
                a.push_back(i * 12 + 3); 
                a.push_back(i * 12 + 9); 
        } 
        for(int i = 6; i <= 30000 && a.size() < N; i += 6) { 
                a.push_back(i); 
        } 
        sort(a.begin(), a.end()); 
        for(int i = 0; i < N; ++i) { 
                cout << a[i] << (i == N - 1 ? "\n" : " "); 
        } 
        return 0; 
} 


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;
int p[5000];
int c[5000];

signed main() {
	int i, j;
	
	cin >> n >> k;
	rep(i, n) { cin >> p[i]; p[i]--; }
	rep(i, n) cin >> c[i];
	
	int ans = -1e+18;
	rep(i, n) {
		int pos = i;
		vector<int> vs;
		
		int score = 0;
		while (true) {
			pos = p[pos];
			score += c[pos];
			vs.push_back(score);
			if (pos == i) break;
		}
		
		int sz = vs.size();
		rep(j, vs.size()) {
			if (j + 1 > k) break;
			int cnt = (k - j - 1) / sz;
			if (score <= 0) {
				ans = max(ans, vs[j]);
			}
			else {
				ans = max(ans, vs[j] + cnt * score);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    S += "*";
    vec L(Q), R(Q);
    REP(i,0,Q) {
        cin >> L[i] >> R[i];
    }

    vec P(N+1, 0);
    ll c = 0, i = 0;
    while(i < N-1) {
        if(S[i] == 'A' && S[i+1] == 'C') {
            P[i+1] = c;
            P[i+2] = c+1;
            ++c;
            i += 2;
        }
        else {
            P[i+1] = c;
            ++i;
        }
    }
    P[N] = c;
    
    REP(i,0,Q) {
        PR(P[R[i]]-P[L[i]]);
    }
    
    
    return 0;
}

/*



*/

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

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (int i=0; i<n; ++i) 
        cin >> a[i];
    long long now = 1000;
    for (int i=1; i<n; ++i) {
        if (a[i] > a[i-1]) {
            now += (now / a[i-1]) * (a[i] - a[i-1]);
        }
    }
    cout << now << endl;
}

Measured memory_bytes: 3552
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	string str;
	cin>>str;
	int l=str.length();
	
	int ans=1;
	char old=str[0];
	for(int i=1;i<l;i++){
		if(old==str[i]){
			i++;
			if(i!=l)ans++;
			old=0;
			//cout<<"double"<<endl;
		}else{
			ans++;
			old=str[i];
			//cout<<str[i]<<endl;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type size_, capacity;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : size_(0), capacity(0), c() {}
	explicit segment_tree(const size_type size)
		: size_(size), capacity(getsize(size_)),
		c(capacity << 1, value_structure::identity()) {}

	bool empty() const { return !size_; }
	size_type size() const { return size_; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + capacity];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += capacity, last += capacity; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < capacity)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - capacity + 1;
	}

	void update(size_type index, const value_type &value) {
		assert(index < size());
		index += capacity;
		c[index] = value;
		while (index >>= 1)
			recalc(index);
	}
};

template <class T> class plus_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return x + y;
	}
	static value_type identity() { return value_type(0); }
	static value_type reverse(const value_type &x) { return x; }
};

#include <iostream>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	int n, q;
	::std::cin >> n >> q;

	segment_tree<plus_monoid<int>, vec_alias> seg(n);

	while (q--) {
		int c, x, y;
		::std::cin >> c >> x >> y;
		if (c)
			::std::cout << seg.fold(x - 1, y) << ::std::endl;
		else
			seg.update(x - 1, seg[x - 1] + y);
	}

	return 0;
}



Measured memory_bytes: 3796
#include<stdio.h>

int F[50];
int fibo(int n){
  if(n==0||n==1)return F[n]=1;
  if(F[n] != -1)return F[n];
  return F[n] = fibo(n-1) + fibo(n-2);
}
int main(){
  int n,i;
  for(i=0;i<50;i++)F[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fibo(n));
}



Measured memory_bytes: 2104
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextLong()
    val A = input.nextLong()
    val B = input.nextLong()
    
    val group = N / (A + B)
    var remain = Math.min(N % (A + B), A)
    
    println(group * A + remain)
  }
}

Measured memory_bytes: 36428
#!/usr/bin/python3

#標準出力からの読み込み

input_1 = input()
n = int(input_1.split(" ")[0])
k = int(input_1.split(" ")[1])

input_array = []
for i in range(k):
    input()
    input_array.append(input().split(" "))

for i in range(len(input_array)):
    for j in range(len(input_array[i])):
        input_array[i][j] = int(input_array[i][j])

#判定ロジック
trick_list = []
for i in range(n):
    trick_list.append(i+1)

for i in range(len(input_array)):
    for j in range(len(input_array[i])):
        try:
            trick_list.remove(input_array[i][j])
        except:
            pass
            
print(len(trick_list))

Measured memory_bytes: 9288
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int ans = 0;
        int cont = 0;
        for (String s:str.split("")){
            if (s.equals("A") || s.equals("C") || s.equals("G") || s.equals("T")){
                cont++;
                if (cont>ans){
                    ans = cont;
                }
            } else {
                cont = 0;
            }
        }
        System.out.println(ans);
    }
}

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

int main(){

    ll N, K;
    cin >> N >> K;
    set<ll>S;
    vector<P>v(N);
    priority_queue<ll, vector<ll>, greater<ll> >R;
    rep(i, N)cin >> v[i].second >> v[i].first;
    sort(v.begin(), v.end(), greater<P>());
    ll sum = 0;
    rep(i, K){
        ll d = v[i].first;
        ll t = v[i].second;
        sum += d;
        if(S.find(t) != S.end())R.push(d);
        S.insert(t);
    }
    ll ans = sum + S.size() * S.size();
    for(ll i = K; i < N; i++){
        ll d = v[i].first;
        ll t = v[i].second;
        if(S.find(t) != S.end())continue;
        if(!R.empty()){
            ll r = R.top();
            R.pop();
            sum -= r;
            sum += d;
            S.insert(t);
        }
        chmax(ans, ll(sum + S.size() * S.size()));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    LL s;cin >> s;
    LL x1,x2=1,x3=0,y1,y2=1000000000,y3=0;
    x1=(s+y2-1)/y2;
    y1 = x1*y2 - s;
    cout << x1 << " " << y1 << " " << x2 << " " <<y2 << " " << x3 << " " << y3 << endl;
    return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int main() {
	string s;
	cin >> s;
	int n = (int) s.length();
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < n; i ++) {
		if (s[i] == 'a') a++;
		if (s[i] == 'b') b++;
		if (s[i] == 'c') c++;
	}
	if (abs(a-b) <= 1 && abs(b-c) <= 1 && abs(c-a) <= 1) puts ("YES");
	else puts ("NO");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	string S;
	cin >> S;

	int white = 0, black = 0;
	vector<int> wlist(N), blist(N);
	for (int i = 0; i < N; i++)
	{
		switch (S[i])
		{
		case '.':
			white++;
			break;
		case '#':
			black++;
			break;
		}

		wlist[i] = white;
		blist[i] = black;
	}

	int ans = min(white, black);
	for (int i = 0; i < N; i++)
	{
		int A = blist[i];
		int B = wlist[N - 1] - wlist[i];

		ans = min(ans, A + B);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a,b;
    cin >> a>>b;

    cout << ((a>8 ||b>8) ? ":(" : "Yay!") << '\n';
    return (0);
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << n * n - m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<double> A(N); cin >> A;

    double ans = 0;

    REP(i,N){
      ans += 1.0 / A[i];
    }

    ans = 1.0 / ans;


    cout << fixed << setprecision(12) << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

map<string,int> m;


int main() {
    
    int t; cin >> t;
    
    while(t--){
        string s; cin>>s;
        m[s]++;
    }
    
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
    
}

Measured memory_bytes: 3628
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
c = 0
S = 0
for a in A:
  S += a % MOD
  S %= MOD
for i in range(N):
    c += (A[i] % MOD) * ((S - A[i] % MOD) % MOD)
    c %= MOD
mod = pow(2, -1, 1000000007)
c = c * mod
c %= MOD
print(int(c))

Measured memory_bytes: 31612
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
#define ll long long

int main()
{
    //freopen("aa_input.txt", "r", stdin);
    string str;
    cin>>str;
    if(str[0]==str[1] || str[1]==str[2] || str[2]==str[3]) cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
    return 0;
}
/*

riaadmorshed@gmail.com

*/

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

void primeFactorize(int n) {
    for (int i = 2;i * i <= n; ++i) {
        while (n % i == 0) {
            n /= i;
            cout << ' ' << i;
        }
    }
    if (n != 1) {
        cout << ' ' << n;
    }
}
int main() {
    int n;
    cin >> n;
    cout << n << ':';
    primeFactorize(n);
    cout << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for(int i=0;i<12;i++){
        if(i==4)cout<<" ";
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		for (int i = 3; i <= a; i++) {
			if (i % 3 == 0 || String.valueOf(i).contains("3"))
				System.out.print(" " + i);
		}
		System.out.println();
	}
}

Measured memory_bytes: 24208
#include <stdio.h>

int main(void) {
	int A, B;
	int i, x;
	scanf("%d%d", &A, &B);
	while (A!=0 || B!=0)
	{
		x=0;
		for (i=A; i<=B; i++)
		{
			if (i%4==0 && (i%100!=0 || i%400==0))
			{
				printf("%d\n", i);
				x=1;
			}
		}
		if (x==0)
		{
			printf("NA\n");
		}
		scanf("%d%d", &A, &B);
		if (A!=0 || B!=0)
		{
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(2000) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

string s;

bool a (bool flag, int x, int y){
    if (flag){
        if (x == 0 || x > 12) return 0;
        return 1;
    }
    else {
        if (y == 0 || y > 12) return 0;
        return 1;
    }
}

int main (){
    cin >> s;
    int cur1 = int(s[0] - '0');
    cur1 = cur1 * 10 + int(s[1] - '0');
    int cur2 = int(s[2] - '0');
    cur2 = cur2 * 10 + int(s[3] - '0');
    if (a(1, cur1, cur2) && a(0, cur1, cur2)) return cout << "AMBIGUOUS\n", 0;
    else if (a(1, cur1, cur2)) return cout << "MMYY\n", 0;
    else if (a(0, cur1, cur2)) return cout << "YYMM\n", 0;
    else return cout << "NA\n", 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define vvi vector<vi>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define tc(i) int test_casesq; cin >> test_casesq; f(i, test_casesq)
#define ync(x, a, b) cout << (x?a:b) << '\n';
#define yn(x) ync(x, "YES", "NO");
#ifndef ONLINE_JUDGE
#define DBG(v) cerr << #v << " = " << (v) << endl;
#else
#define DBG(v) ;
#endif
template <typename T> std::ostream& operator<<(std::ostream &os, std::vector<T> v){os << "["; f(i, sz(v)) os << v[i] << " "; return os << "]";}

using namespace std;

ll INF = (1ll<<61);


ll get(ll x){
	if(x < 0) return x;
	int k = 0;
	while(x > 0){
		ll y = __builtin_popcount(x);
		x = x % y;
		k++;
	}
	return k;
}

ll xp(ll b, ll x, ll m){
	if(x == 0) return 1;
	if(x&1) return (b * xp(b, x-1, m)) % m;
	ll a = xp(b, x/2, m);
	return (a * a) % m;
}

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin >> n;
    string s; cin >> s;
    int y = count(all(s), '1');
    if(y == 0){
    	f(i, n){
    		cout << 1 << '\n';
    	}
    	return 0;
    }
    ll tmp1 = 0, tmp2 = 0;
    vi ans(n);
    f(i, sz(s)){
    	if(y > 1) tmp1 = (2 * tmp1 + (s[i] - '0'))%(y-1);
    	tmp2 = (2 * tmp2 + (s[i] - '0'))%(y+1);
    }
    vi a1(n, tmp1);
    vi a2(n, tmp2);
    f(i, sz(s)){
    	if(s[i] == '1'){
    		if(y > 1) ans[i] = ((y-1) + ((a1[i] - xp(2, n-i-1, y-1))%(y-1)))%(y-1);
    		else ans[i] = -1;
    	}else{
    		ans[i] = ((a2[i] + (xp(2, n-i-1, y+1))%(y+1)) )%(y+1);
    	}
    }
    f(i, n){
    	cout << 1 + get(ans[i]) << "\n";
    }
    return 0;
}







// END


Measured memory_bytes: 8360
n,a,b = map(int,input().split())

#制限なしで全ての花束の作り方
wa = pow(2, n, 10 ** 9 + 7) - 1

#a本の花束の作り方
#val1 = comb(n, a, exact=True)
#val2 = comb(n, b, exact = True)

x = 1
y = 1
for i in range(a):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)
val1 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

x = 1
y = 1
for i in range(b):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)

val2 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

ans = wa - val1 - val2
for i in range(100):
    if ans < 0:
        ans += 10 ** 9 + 7
print(ans)

Measured memory_bytes: 3064
S = input()
T = input()

ans = [0 for i in range(len(S)-len(T)+1)]
for i in range(len(S)-len(T)+1):
    cnt = len(T)
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt -= 1
    ans[i] = cnt
print(min(ans))


Measured memory_bytes: 9056
public class Main {


  private static void solve() {
    int n = ni();
    int k = ni();
    
    System.out.println(n -k + 1);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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


  

int main()
{
	long long int i,j,k,m,n;
	cin>>n;
	long double l=(double)n/(double)3,ans;
	ans=l*l*l;
	cout<<fixed<<setprecision(15)<<ans;
	

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);i++)
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int n;
    cin>>n;
    int ans=n;
    for(int i=0;i<=n;i++){
        int now=0;
        int t=i;
        while(t>0){
            now+=t%6;
            t/=6;
        }
        t=n-i;
        while(t>0){
            now+=t%9;
            t/=9;
        }
        ans=min(ans,now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 100;
static const int MAX_M = 1000;
static const int INFTY = (1<<21);

int n;
int d[MAX_N][MAX_N];
int a[MAX_M], b[MAX_M], c[MAX_M];

void floyd(){
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			if(d[i][k] == INFTY) continue;
			for(int j = 0; j < n; j++){
				if(d[k][j] == INFTY) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main(){
	int m, u, v, cost;
	cin >> n >> m;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			d[i][j] = ((i == j) ? 0 : INFTY);
		}
	}

	for(int i = 0; i < m; i++){
		cin >> u >> v >> cost;
		u--; v--;
		d[u][v] = d[v][u] = cost;
		a[i] = u;
		b[i] = v;
		c[i] = cost;
	}

	floyd();
	//for(int i = 0; i < n; i++){
	//	for(int j = 0; j < n; j++){
	//		cout << d[i][j];
	//		if(j == n - 1) cout << endl;
	//		else cout << " ";
	//	}
	//}

	int ans = m;
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			if(d[j][a[i]] + c[i] == d[j][b[i]]){
				ans--;
				break;
			}
		}
	}

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


Measured memory_bytes: 256