akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

use std::cmp::Ordering;

#[derive(Clone, Eq, PartialEq)]
struct State {
    x: usize,
    y: usize,
    z: usize,
    cost: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        self.cost.cmp(&other.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        x: usize, y: usize, z: usize, k: usize,
        mut a: [usize; x],
        mut b: [usize; y],
        mut c: [usize; z],
    }
    a.sort_by(|a, b| b.cmp(a));
    b.sort_by(|a, b| b.cmp(a));
    c.sort_by(|a, b| b.cmp(a));

    let mut ab = vec![];
    for i in 0..(min(k, a.len())) {
        for j in 0..(min(k, b.len())) {
            ab.push(a[i] + b[j]);
        }
    }
    ab.sort_by(|a, b| b.cmp(a));

    let mut abc = vec![];

    for i in 0..(min(k, ab.len())) {
        for j in 0..(min(k, c.len())) {
            abc.push(ab[i] + c[j]);
        }
    }
    abc.sort_by(|a, b| b.cmp(a));

    for i in 0..k {
        println!("{}", abc[i]);
    }
}


Measured memory_bytes: 44276
def count1(c):
  cnt = 0
  while c != 0:
    if c % 2 == 1:
      cnt += 1
    c //= 2
  return cnt
n = int(input())
x = input()
y = int(x, 2)
z = list(x).count('1')
l = []
a = y % (z + 1)
if z > 1:
  l2 = []
  b = y % (z - 1)
for i in range(n):
  l.append(pow(2, n - i - 1, z + 1))
  if z > 1:
    l2.append(pow(2, n - i - 1, z - 1))
for i in range(n):
  if x[i] == '0':
    c = a + l[i]
    c %= z + 1
  elif z == 1 and x[i] == '1':
    print(0)
    continue
  else:
    c = b - l2[i]
    c %= z - 1
  cnt = 1
  while c != 0:
    d = count1(c)
    c %= d
    cnt += 1
  print(cnt)

Measured memory_bytes: 27188
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int i = 0;
		int j = 0;
		int count = 0;
		String digital;
		
		for(i=1; i <= N; i++){
			digital = String.valueOf(i);
			j = digital.length();
			if(j%2 != 0){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 28244
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int N;
    int Q;
    cin >> N >> Q;
    queue<pair<string,int> > que;
    for (int i = 0; i < N; ++i) {
        string name;
        int time;
        cin >> name >> time;
        que.push({name, time});
    }

    int cur_time = 0;
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();

        if (cur.second > Q) {
            cur_time += Q;
            cur.second -= Q;
            que.push(cur);
        } else {
            cur_time += cur.second;
            cout << cur.first << " " << cur_time << endl;
        }
    }
	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

string s, t;

bool contain(string x) {
   rep (i, t.size()) {
      if (x[i] == '?') continue;
      if (x[i] != t[i]) return false;
   }
   return true;
}

int main() {
   cin >> s >> t;
   int n = s.size();
   int m = t.size();

   bool ok = false;
   for (int i = n-1; i >= 0; i--) {
      string x = s.substr(i, m);
      // debug2((int)x.size(), m)
      // debug2(x[0], t[0])
      // line()
      if (x.size() == m && contain(x)) {
         ok = true;
         int cnt = 0;
         for (int j = i; j < i+m; j++) {
            s[j] = t[cnt];
            cnt++;
         }
         break;
      }
   }

   rep (i, n) {
      if (s[i] == '?') s[i] = 'a';
   }

   if (ok) {
      cout << s << endl;
   } else {
      puts("UNRESTORABLE");
   }

   return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
prime=[]


def expFactor(n, p): 
    x = p 
    exponent = 0
    while n // x > 0: 
      
        exponent += n // x 
        x *= p 
    return exponent 

ans=1

if(n>=2):
    prime.append(2)
for i in range(3,n+1):
    countt=0
    for j in range (1,int(math.sqrt(i))+1):
        if(i%j==0):
            countt+=1
    if(countt==1):
        prime.append(i)
#print(prime)
for i in prime:
    ans*=(expFactor(n,i)+1)
print(ans%(1000000007))

    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int ob = (mod + 1) >> 1;
int dp[5001][5001];
void add(int &a , int b)
{
	a = a + b >= mod ? a + b - mod : a + b;
}
int mult(int a , int b)
{
	return (a * (LL)b) % mod;
}
int main()
{
	string s;
	int N;
	cin >> N >> s;
	dp[0][0] = 1;
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j <= i; j++)
		{
			add(dp[i + 1][j + 1] , mult(dp[i][j] , 2));

			add(dp[i + 1][max(j - 1 , 0)] , dp[i][j]);
		}
	}
	int ans = dp[N][s.size()];
	for(int i = 0; i < s.size(); i++)
		ans = mult(ans , ob);
	cout << ans;
	//freopen("In.txt" , "r" , stdin);
}




Measured memory_bytes: 96384
#include <stdio.h>

int main (void){
    int K,n1=2,n2=2,anc=0,temp;
    int count1=0,count2=0;
    scanf("%d",&K);
    temp =K;
    while(K>1){
        K = K-2;
        count2++;
    }
   
    K =temp;
    while(K>=1){
        K = K-2;
        count1++;
    }
    anc =count1*count2;
    printf("%d",anc);
    
    
    return 0;

}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF 4e18
using namespace std;
 
typedef tree<ll, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        ll n,i,j,k;
        cin>>n;
        ll ans=0,tp;
        for(i=1;i<n;i++)
        {
            tp=n/i;
            if(n%i==0)tp--;
            ans+=tp;
        }
        cout<<ans<<"\n";
        /*tcitr++;
    }*/
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int n;
vector<pair<int,int> >v[100000];
int c[100000];
void dfs(int vv,int p=-1){
	int u,w;
	for(int i=0;i<v[vv].size();++i){
		u=v[vv][i].first;
		w=v[vv][i].second&1;
		if(u!=p){
			c[u]=c[vv]^w;
			dfs(u,vv);
		}
	}
}
int main(){
	cin>>n;
	int u,vv,w;
	for(int i=0;i<n-1;++i){
		cin>>u>>vv>>w;
		v[u-1].push_back(make_pair(vv-1,w));
		v[vv-1].push_back(make_pair(u-1,w));
	}
	dfs(0);
	for(int i=0;i<n;++i)
		cout<<c[i]<<endl;
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
 
#define ll long long
 
using namespace std;
 
int main()
{
  int a,b;
  cin >> a >> b;
  
  if(a <= 5) cout << "0\n";
  else if(a > 5 && a <= 12) cout << b/2 << "\n";
  else cout << b << "\n";
 
}

Measured memory_bytes: 256
from pprint import pprint

while True:
  w, h = map(int, raw_input().split())

  if w == 0 and h == 0:
    break

  dp = [[[[0] * 2 for x in xrange(2) ] for w_ in xrange(w)] for h_ in xrange(h)]

  dp[0][0][0][1] = 1
  dp[0][0][1][1] = 1

  for x in xrange(w):
    for y in xrange(h):
      if x < w - 1:
        dp[y][x + 1][0][0] += dp[y][x][0][0] + dp[y][x][0][1]
        dp[y][x + 1][0][1] += dp[y][x][1][0]

      if y < h - 1:
        dp[y + 1][x][1][0] += dp[y][x][1][0] + dp[y][x][1][1]
        dp[y + 1][x][1][1] += dp[y][x][0][0]

  ans = sum(sum(a) for a in dp[h - 1][w - 1])
  print ans % 100000

Measured memory_bytes: 11172
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    const double PI=3.14159265358979323846;
    int r;
    cin>>r;
    double ans = 0;
    ans = PI*(double)r*2.0;
    printf("%.14f\n",ans);
    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<memory.h>
using namespace std;
typedef long long ll;
const int Max = 4e5 + 5;

int lst[Max];

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string str;
	int dx = tx - sx, dy = ty - sy;
	for (int i = 1;i <= dx;i++)
	{
		str += "R";
	}
	for (int i = 1;i <= dy;i++)
	{
		str += "U";
	}
	for (int i = 1;i <= dx;i++)
	{
		str += "L";
	}
	for (int i = 1;i <= dy;i++)
	{
		str += "D";
	}
	str += "L";
	for (int i = 1;i <= dy+1;i++)
	{
		str += "U";
	}
	for (int i = 1;i <= dx+1;i++)
	{
		str += "R";
	}
	str += "DR";
	for (int i = 1;i <= dy+1;i++)
	{
		str += "D";
	}
	for (int i = 1;i <= dx+1;i++)
	{
		str += "L";
	}
	str += "U";
	cout << str;
}

Measured memory_bytes: 3080
#!/usr/bin/env python3

def main():
    na = list(map(int, input().split()))
    A, B, K = na[0], na[1], na[2]

    if B - A < 2 * K:
        for i in range(A, B + 1):
            print(i)
    else:
        for i in range(K):
            print(A + i)
        for i in range(K):
            print(B - K + 1 + i)



if __name__ == '__main__':
    main()



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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int N = 200001;
vector<vector<int>> G(N);
int dp[N];

signed main(){

  int n,q; cin >> n >> q;
  for(int i = 0; i < n-1; i++){
    int a,b; cin >> a >> b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for(int i = 0; i < q; i++){
    int p,x; cin >> p >> x;
    p--;
    dp[p] += x;
  }

  vector<int> ans(n,0);
  function< void(int,int) > dfs =
  [&](int u,int pre){
    if(pre == -9) ans[u] = dp[u];
    else ans[u] += dp[u] + ans[pre];
    for(int v : G[u]){
      if(v == pre) continue;
      dfs(v,u);
    }
  };
  dfs(0,-9);

  for(int p : ans){
    cout << p << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 28672
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int n; bool possible = true;
vector<ll> A(1<<20);
vector<int> g[1<<20];

ll dfs(int s, int p) {

    if(g[s].size() == 1) {
        return A[s];
    }

    ll sum = 0, maxm = 0, len = 0;
    for(auto &v: g[s]) {
        if(v == p) continue;

        if(not possible) return 0;
        ll temp = dfs(v, s);
        sum += temp;
        maxm = max(maxm, temp);
        len++;
    }

    if(len == 1) {
        if(maxm != A[s]) {
            possible = false;
            return 0;
        }

        return maxm;
    }

    //sort(help.begin(), help.end());

    ll maxp = 0;
    // find maximum #of pairs in help
    if(sum/2 < maxm) {
        maxp = sum - maxm;
    } else {
        maxp = sum/2;
    }

    ll f = 0, l = maxp, mid = (maxp)/2;
    while(f <= l) {
        ll x = mid;
        ll y = sum-2*mid;

        if(x+y == A[s]) {
            return y;
        }

        if(x+y > A[s]) {
            f = mid+1;
        } else {
            l = mid-1;
        }

        mid = (f+l)/2;
    }

    possible = false;
    return 0;
}

int main() {

    //freopen("input07.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);

    cin>>n; ll u, v;
    rep(i, n) cin>>A[i];

    rep(i, n-1) {
        cin>>u>>v;
        u--;v--;
        g[u].pb(v);
        g[v].pb(u);
    }

    if(n == 2 and A[0] == A[1]) {
        cout<<"YES";return 0;
    }

    if(n == 2 and A[0] != A[1]) {
        cout<<"NO";return 0;
    }

    int start = -1;
    rep(i, n) if(g[i].size() > 1) start = i;
    //debug(start);

    if(dfs(start, -1) != 0) possible = false;

    if(possible) cout<<"YES";
    else cout<<"NO";

    return 0;
}


Measured memory_bytes: 43264
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;
ll lini[10];
ll dp[10][150];
int h, w;
ll f(int x, int y)
{
	if(x == 0 && y == h) return 1;
	if(y == h) return 0;
	if(dp[x][y] != -1) return dp[x][y];
	ll res = 0;
	if(x > 0)
		res += f(x-1, y+1) * lini[max(x-2, 0)] % MOD * lini[max(w - x - 2, 0)] % MOD;
	res %= MOD;
	if(x < w - 1)
		res += f(x + 1, y + 1) * lini[max(x-1, 0)] % MOD * lini[max(w - x - 3, 0)] % MOD;
	res %= MOD;
	res += f(x, y + 1) * lini[max(x-1, 0)] % MOD * lini[max(w - x - 2, 0)] % MOD;
	res %= MOD;
	return dp[x][y] = res;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	lini[0] = 1;
	lini[1] = 2;
	fore(i, 2, 10) lini[i] = lini[i-1] + lini[i-2];
	mem(dp, -1);
	int k;
	cin>>h>>w>>k;
	cout<<f(k-1, 0)<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long int Hnow, Hlast;
    cin >> Hlast;
    Hlast--;

    for(int idx = 1LL; idx < N; idx++) {
        cin >> Hnow;

        if(Hnow > Hlast)
            --Hnow;

        if(Hnow < Hlast) {
            cout << "No" << endl;
            return 0;
        }

        Hlast = Hnow;
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
//マクロ使い方は
/*
fn main () {
fn main() {
    input!{
        n: usize,
        m: usize,
    }
    // solver code...
}
ベクトルは
input!{
    n: usize,
    m: usize,
    mat: [[i32; m]; n],
}
input!{
    cs: chars, // トークンを Vec<char> として読む
}
// 3 4
// ####
// #..#
// .#.#

// こういうやつを Vec<Vec<char>> として読み込むコード
input!{
    h: usize,
    w: usize,
    board: [chars; h],
}
// n m
// f_1 t_1
// f_2 t_2
// ...
// f_m t_m

// こういうグラフを読み込むコード
input!{
    n: usize, // ノード数
    m: usize, // 枝数
    edges: [(usize1, usize1); m], // usize1 は 1-origin to 0-origin変換を行う
}

}
*/
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


//入出力用
use std::io::*;
use std::str::FromStr;

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




 
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut book: String = "book".to_string();
    // println!("{:?}",s.last().unwrap());
    // println!("{:?}",book);
    match s.last().unwrap() {
    	'2' | '4' | '5' | '7' | '9' => book = "hon".to_string(),
    	'0' | '1' | '6' | '8' => book = "pon".to_string(),
    	'3' => book = "bon".to_string(),
    	_ => book = "bon".to_string(),
    }
    // if s.last().unwrap() == '2' | '4' | '5' | '7' | '9' { book = "hon"; }
    // if s.last().unwrap() == '0' | '1' | '6' | '8' { book = "pon"; }
    // if s.last().unwrap() == '3' { book = "bon"; }
    println!("{}", book);
}

















Measured memory_bytes: 2164
import Data.List (nub, sort)
import Control.Monad (replicateM)

import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

mochi
  :: [Int] -> Int
mochi = length . nub . sort

main = do
  n <- cReadLn
  ds <- replicateM n cReadLn
  print $ mochi ds

Measured memory_bytes: 508
package main

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

const (
	yes = "Yes"
	no  = "No"
)

var sc = bufio.NewScanner(os.Stdin)

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

func createPointMap(answerIndexes []int) map[int]int {
	decreaseScoresMap := map[int]int{}
	for _, answer := range answerIndexes {
		decreaseScoresMap[answer-1]++
	}
	return decreaseScoresMap
}

func calculateScore(n, k, q int, scoreMap map[int]int) []string {
	results := make([]string, n)
	for i := 0; i < n; i++ {
		v := scoreMap[i]
		if k-q+v > 0 {
			results[i] = yes
		} else {
			results[i] = no
		}
	}
	return results
}

func doQuiz(n, k, q int, answerIndexes []int) []string {
	m := createPointMap(answerIndexes)

	return calculateScore(n, k, q, m)
}
func main() {
	sc.Split(bufio.ScanWords)

	n, k, q := nextInt(), nextInt(), nextInt()

	answerIndexes := make([]int, q)
	for i := 0; i < q; i++ {
		answerIndexes[i] = nextInt()
	}

	for _, s := range doQuiz(n, k, q, answerIndexes) {
		fmt.Println(s)
	}
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  int count=0;
  cin >> n >> m >> c;
  int b[100000];
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    int a[10000];
    for(int j=0;j<m;j++){
      cin >> a[j];
    }
    int wa=0;
    for(int j=0;j<m;j++){
      wa = wa+b[j]*a[j];
    }
    if(wa+c>0){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll q, a, b, c, d, g, mn;
int main() {
	cin >> q;
	while(q--) {
		cin >> a >> b >> c >> d;
		g = __gcd(b, d);
		mn = a - (a-c-1) / g * g;
		puts(a<b || d<b || mn<b ? "No" : "Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

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

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

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

vector<int> oya(1e5);
vector<int> rnk(1e5, 0);
void init(int n) {
  for (int i = 0; i < n; i++) {
    oya[i] = i;
  }
}
int find(int x) {
  if (oya[x] == x) return x;
  return oya[x] = find(oya[x]);
}
void unite(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    oya[x] = y;
  } else {
    oya[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}
bool same(int x, int y) {
  return find(x) == find(y);
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  init(n);
  vector<int> p(n); for (int i = 0; i < n; i++) {cin >> p[i]; p[i]--;}
  for (int i = 0; i < m; i++) {
    int x, y; cin >> x >> y;
    x--; y--;
    unite(x, y);
  }
  int res = 0;
  for (int i = 0; i < n; i++) res += same(i, p[i]);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 1408
x,y=map(int,input().split()) 
mod=10**9+7
m=int((2*y-x)/3)
n=int((2*x-y)/3)
f=[1]

for i in range(1,10**6):
    f.append(f[-1]*i%mod)

if (x+y)%3!=0 or min(m,n)<0:
    print(0)
else:
    print(f[m+n]*pow(f[m],mod-2,mod)*pow(f[n],mod-2,mod)%mod)         


Measured memory_bytes: 42712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}

const int N = 300300;
char s[N];
int n;
int dp[2][4][3];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	dp[0][0][0] = 1;

	for (int it = 0; it < n; it++) {
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 3; j++)
				dp[1][i][j] = 0;
		
		if (s[it] == '0' || s[it] == '?') {
			for (int x = 0; x < 4; x++)
				for (int y = 0; y < 3; y++) {
					int nx = x;
					int ny = y + 1;
					if (ny > 2) ny -= 2;
					dp[1][nx][ny] = add(dp[1][nx][ny], dp[0][x][y]);
				}
		}
		
		if (s[it] == '1' || s[it] == '?') {
			for (int x = 0; x < 4; x++)
				for (int y = 0; y < 3; y++) {
					int nx = x;
					int ny = y;
					if (ny > 0) {
						ny--;
					} else {
						nx++;
						if (nx > 3) nx = 3;
					}
					dp[1][nx][ny] = add(dp[1][nx][ny], dp[0][x][y]);
				}
		}

		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 3; j++)
				dp[0][i][j] = dp[1][i][j];
	}

	int ans = 0;
	for (int x = 0; x < 4; x++)
		for (int y = 0; y < x; y++)
			ans = add(ans, dp[0][x][y]);
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll sum = 0;
  if(a == b){
    sum++;
  }
  if(b == c){
    sum++;
  }
  if(c == a){
    sum++;
  }
  if(sum == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string,decimal
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
a = LI()
a.sort(reverse=True)

print(sum(a[0::2]) - sum(a[1::2]))

Measured memory_bytes: 21564
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=(ll)(1e18);

ll wei[105];
ll val[105];
ll dp[100005][105]={0};
ll sol[100005][105];
ll n0,w0,v0;
ll knapsack2(ll v,ll i)
{
    if(v<=0) return 0;
    if(i==n0) return INF;
    
    if(sol[v][i])return dp[v][i];
    
    sol[v][i]=1;
    dp[v][i]= min(knapsack2(v,i+1),knapsack2(v-val[i],i+1)+wei[i]);
    return dp[v][i];
}

int main()
{
    ll a,b,c,k,d,e,f,n,mx,t;
    cin>>n>>mx;
    f=0;
    for(int i=0;i<n;i++)
    {
        cin>>wei[i]>>val[i];
        f+=val[i];
    }
    n0=n;
    w0=mx;
    v0=f;
    for(ll v=f;v>=0;v--)
    {
        if(knapsack2(v,0)<=mx)
        {
            a=v;
            break;
        }
    }
    
    cout<<a;
    
    
    
    
    return 0;
}

Measured memory_bytes: 164096
n,k = map(int,input().split())
A = [(1+int(i))/2 for i in input().split()]
Sum = [0 for i in range(n+1)]
for i in range(n):
  Sum[i+1] = Sum[i]+A[i]
ans = 0
#print(Sum)
for i in range(n+1):
  if i+k<n+1:
    ans = max(ans,Sum[i+k]-Sum[i])
print(ans)

Measured memory_bytes: 23524
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

class UnionFind {
public:
    vector<int> par;
    vector<int> rnk;
    vector<ll> siz;
    UnionFind(int N):par(N),rnk(N),siz(N){
        for(int i=0;i<N;i++){
            par[i]=i,rnk[i]=0,siz[i]=1;
        }
    }
    //根
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        int rx=find(x);
        int ry=find(y);
        if (rx==ry) return;
        if(rnk[rx]<rnk[ry]){
            par[rx]=ry;
            siz[ry]+=siz[rx];
            siz[rx]=0;
        }
        else{
            par[ry]=rx;
            siz[rx]+=siz[ry];
            siz[ry]=0;
            if(rnk[rx]==rnk[ry]){
                rnk[rx]++;
            }
        }
    }
    //集合が同じか
    bool same(int x,int y){
        return find(x)==find(y);
    }
    //集合の大きさ
    int size(int x){
        return siz[find(x)];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
    }
    int ans=0;
    rep(i,N){
        chmax(ans,uf.size(i));
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 6364
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>

#define N 3
#define N2 9
using namespace std;

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    printf("ACL");
  }
}

Measured memory_bytes: 3632
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1;
string travel;

void solve () {
	cin >> travel;
	bool n = 0, s = 0, e = 0, w = 0;
	for (int i = 0; i < travel.sz(); i++) {
		n = max(n, (travel[i] == 'N'));
		s = max(s, (travel[i] == 'S'));
		e = max(e, (travel[i] == 'E'));
		w = max(w, (travel[i] == 'W'));
	}
	if (!((n ^ s) + (e ^ w))) cout << "Yes";
	else cout << "No";
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
	
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b && b<c){
	
	    printf("Yes\n");
	
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    #print(*c, sep='\n')
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k]+c[k][j])
    #print(*c, sep='\n')
    cost = 0
    for a in A:
        for aa in a:
            if aa == -1:
                continue
            cost += c[aa][1]
    return cost


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [[int(next(tokens)) for _ in range(9 - 0 + 1)] for _ in range(9 - 0 + 1)]  # type: "List[List[int]]"
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    print(solve(H, W, c, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3316
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int n, a[200001], box[200001];

int main(void) {
    int i, mul=1, sum=0, balls=0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (i = n; i >= 1; i--) {
        mul = i*2;
        sum = 0;
        while (mul <= n) {
            sum += box[mul];
            mul += i;
        }
        if ((a[i] == 0 && (sum%2)==1) ||
            (a[i] == 1 && (sum%2)==0) ) {
            box[i]++;
            balls++;
        }
    }
    cout << balls << endl;
    for (i = 1; i <= n; i++) {
        if (box[i] == 1) cout << i << " ";
    }
    if (balls > 0)
        cout << endl;
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    if(n<105){
        cout << 0 << endl;
    }else if(n<135){
        cout << 1 << endl;
    }else if(n<165){
        cout << 2 << endl;
    }else if(n<189){
        cout << 3 << endl;
    }else if(n<195){
        cout << 4 << endl;
    }else{
        cout << 5 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m;
 	cin >> n>>m;
 	if(m%n==0){
 		cout << m+n << endl;
 	}else{
 		cout << m-n << endl;
 	}
 }

Measured memory_bytes: 256
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

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

//namespace my
namespace my
{
//配列の最大値or最小値を数値で返す関数
template <class T>
T max_element(std::vector<T> vec)
{
    std::sort(vec.begin(), vec.end());
    return vec.at(vec.size() - 1);
}
template <class T>
T min_element(std::vector<T> vec)
{
    std::sort(vec.begin(), vec.end());
    return vec.at(0);
}
} // namespace my

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std名前空間を使用
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート

bool is_second(int *pA);

int main()
{
    int n;
    int count = 0;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    for (int i = 1; i < n - 1; i++){
        int * pA;
        pA = new int;
        pA[0] = vec[i - 1];
        pA[1] = vec[i];
        pA[2] = vec[i + 1];
        if (is_second(pA))
            count++;
        delete pA;
    }
    cout << count << endl;
}

bool is_second(int *pA)
{
    if (pA[1] == max3(pA[0], pA[1], pA[2]))
        return false;
    if (pA[1] == min3(pA[0], pA[1], pA[2]))
        return false;
    else
        return true;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>


using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	ll H, W, K;
	cin >> H >> W >> K;
	vstring S(H);
	for (int i = 0; i < H; i++)
	{
		cin >> S[i];
	}


	vvll ans(H);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			ans[i].emplace_back(-1);
		}
	}

	vvll pos(H);
	for (int h = 0; h < H; h++)
	{
		//pos[h].emplace_back(0);
		for (int w = 0; w < W; w++)
		{
			if (S[h][w] == '#')
			{
				pos[h].emplace_back(w);
			}
		}
		pos[h].emplace_back(W);
	}


	// まずは行をつぶす
	int color = 1;
	for (int h = 0; h < H; h++)
	{
		
		for (int i = 0; i < pos[h].size() - 1; i++)
		{
			int start = pos[h][i];
			int end = pos[h][i + 1];
			if (pos[h][i + 1] == W)
			{
				end = W;
			}

			if (start < end)
			{
				for (int w = start; w < end; w++)
				{
					ans[h][w] = color;
				}

				color++;
			}
		}

		for (int w = W - 1; w > 0; w--)
		{
			if (ans[h][w - 1] == -1)
			{
				ans[h][w - 1] = ans[h][w];
			}
		}

	}


	// 空の行に拡張
	for (int h = 0; h < H - 1; h++)
	{
		if (ans[h + 1][0] == -1)
		{
			for (int w = 0; w < W; w++)
			{
				ans[h + 1][w] = ans[h][w];
			}
		}
	}
	for (int h = H-1; h > 0; h--)
	{
		if (ans[h - 1][0] == -1)
		{
			for (int w = 0; w < W; w++)
			{
				ans[h - 1][w] = ans[h][w];
			}
		}
	}


	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}


}





Measured memory_bytes: 3328
#include <cstdio>

#include <set>
using namespace std;

typedef long long llong;

const int N = 200500;

int Q[N];

int main() {
    set<int> pos;
    int  n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        Q[x] = i;
    }
    pos.insert(-1);
    pos.insert(n);
    llong ans = 0;
    for (int v = 1; v <= n; v++) {
        int p = Q[v];
        auto it = pos.upper_bound(p);
        int r = *it;
        int l = *(--it);
        ans += v * 1ll * (r - p) * 1ll * (p - l);
        pos.insert(p);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 10496
#include<stdio.h>
#include<math.h>
int main(){
  long int a,b,c,d,e;
  scanf("%lu%lu%lu",&a,&b,&c);
  if(a+b>c)
    printf("No\n");
  else{
    d = c-a-b;
    e = 4*a*b;
    if(d*d>e)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	int n = rint;
	int m = rint;
	string s = rstring;

	int x = n;
	int[] ans;
	while(x > 0){
		bool f = 0;
		foreach(i; x - m .. x){
			log("x:", x, "i:", i);
			if(i < 0) continue;
			if(s[i] == '1') continue;
			ans ~= x - i;
			x = i;
			f = 1;
			break;
		}
		if(!f){
			"-1".writeln;
			return;
		}
	}

	int[] ansx;
	foreach_reverse(an; ans) ansx ~= an;
	ansx.map!(to!string).array.join(" ").writeln;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;

    rep(i, 10) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
transit_a = set()
transit_b = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        transit_b.add(b)
    elif b == n:
        transit_a.add(a)

print('POSSIBLE' if len(transit_a & transit_b) else 'IMPOSSIBLE')


Measured memory_bytes: 18892
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

ll n,s;

bool check(ll b,ll t) {
	ll sum=0;
	while (t>0) {
		sum+=t%b;
		t/=b;
	}
	return sum==s;
}

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

	cin>>n>>s;
	if(n<s) {
		cout<<-1<<endl;
		return 0;
	}
	else if(n==s) {
		cout<<n+1<<endl;
		return 0;
	}
	ll i;
	for(i=2;i*i<=n;i++) {
		if(check(i,n)) {
			cout<<i<<endl;
			return 0;
		}
	}
	for(;i>0;i--) {
		if((n-s)%i==0&&check((n-s)/i+1,n)) {
			cout<<(n-s)/i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;

	return 0;
}


Measured memory_bytes: 256
S=input()

S=S[::-1]

count=0
while(count<len(S)):
  if (len(S)-count)<5:
    print('NO')
    exit()
    
  elif S[count]=='e' and S[count+1]=='s' and S[count+2]=='a' and S[count+3]=='r' and S[count+4]=='e':
    count+=5
  elif S[count]=='m' and S[count+1]=='a' and S[count+2]=='e' and S[count+3]=='r' and S[count+4]=='d':
    count+=5
  
  elif (len(S)-count)==5:
    print('NO')
    exit()
  elif S[count]=='r' and S[count+1]=='e' and S[count+2]=='s' and S[count+3]=='a' and S[count+4]=='r' and S[count+5]=='e':
    count+=6
  elif (len(S)-count)==6:
    print('NO')
    exit()
  elif S[count]=='r' and S[count+1]=='e' and S[count+2]=='m' and S[count+3]=='a' and S[count+4]=='e'and S[count+5]=='r' and S[count+6]=='d':
    count+=7
  else:
    print('NO')
    exit()

print('YES')

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

struct Vec {
    int x;
    int y;
};

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    Vec v1 = {x2 - x1, y2 - y1};
    Vec v2 = {-1 * v1.y, v1.x};
    int x3, y3;
    x3 = x2 + v2.x;
    y3 = y2 + v2.y;

    Vec v3 = {-1 * v2.y, v2.x};
    int x4, y4;
    x4 = x3 + v3.x;
    y4 = y3 + v3.y;

    cout << x3 << " " << y3 << " " << x4 << " " << y4;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int H,W,i,j,a;
    while(1)
    {
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)break;
            for(i=0;i<H;i++)
           {
                for(j=0;j<W;j++)
               {
                    if(i==0||i==H-1||j==0||j==W-1)
                    {
                     printf("#");
                    }
                    else
                    {
                      printf(".");
                    }

               }
                    printf("\n");

           }
        printf("\n");
    }

  return 0;
}

Measured memory_bytes: 2604