akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define diff(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int main(void)
{
    int N, T, E;
    int x[128];
    int i;
    int mini;
    int m_t;

    scanf("%d %d %d", &N, &T, &E);
    for (i = 0; i < N; i++) scanf("%d", x + i);

    m_t = E + 1;
    for (i = 0; i < N; i++){
        int near = 0;

        while (diff(T, x[i] * near) > diff(T, x[i] * (near + 1))) near++;
        if (m_t > diff(T, x[i] * near)){
            mini = i + 1;
            m_t = diff(T, x[i] * near);
        }
    }
    if (m_t == E + 1) puts("-1");
    else printf("%d\n", mini);

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100005
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;


int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(7);

cin>>n;
vector<ll>a(n+1),b(n+1),c(n+1),pref(n+1);
lp(i,n)cin>>a[i+1];
lp(i,n)cin>>b[i+1];
lp(i,n)cin>>c[i+1];
sort(all(a));
sort(all(b));
sort(all(c));
for(int i=1;i<=n;i++){
  ll x = c.end() -upper_bound(all(c),b[i]) ;
  pref[i] = pref[i-1]+x;
}
for(int i=1;i<=n;i++){
  ll x = upper_bound(all(b),a[i])-b.begin();
  if(x<= n)ans+= pref[n]-pref[x-1];
}
cout<<ans;



  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

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

int Sum10(int n);

int main()
{
    // 入力
    int n,i;
    cin >> n >> i;
    cout << (n-i+1) << endl;
    return 0;
}

int Sum10(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        mut a:i64,mut b:i64,k:i64,
    }
    let mut turn = true; // tkhs, 0->aok
    for _ in 0..k {
        if turn {
            if a % 2 == 1 {
                a -= 1;
            }
            b += a / 2;
            a /= 2;
        } else {
            if b % 2 == 1 {
                b -= 1;
            }
            a += b / 2;
            b /= 2;
        }
        turn ^= true;
    }

    println!("{} {}", a, b);
}


Measured memory_bytes: 2172
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    F = [tuple(MI()) for _ in range(N)]
    P = [tuple(MI()) for _ in range(N)]
    TS = 10

    ans = -float("inf")
    s = set()
    for tt in range(1, 2**TS):
        ts_open = [min(1, tt & (1 << i)) for i in range(TS)]
        s.add(tuple(ts_open))
        a = 0
        for i in range(N):
            o = 0
            for j in range(TS):
                if ts_open[j] and F[i][j] == 1: o += 1
            a += P[i][o]
        ans = max(ans, a)
    return ans


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


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

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

  int N; cin >> N;
  string S; cin >> S;

  S.erase(unique(S.begin(), S.end()), S.end());

  int ans = S.size();

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  char a,t;
  cin >> a >> t;
  if (a == 'H') a = 1;
  else if (a == 'D') a = 0;
  if (t == 'H') t = 1;
  else if (t == 'D') t = 0;
  int ans = a + t;
  if (ans == 1) cout << 'D' << endl;
  else cout << 'H' << endl;
} 

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


#define ll long long int
#define pb push_back


int main()
{
  ll n;
  cin>>n;
  vector<ll>v;
  ll psum[300000];
  ll tsum=0;
  
  for(ll i=0;i<n;i++){
    ll temp;
    cin>>temp;
    if(i==0)
      psum[i]=temp;
    else
      psum[i]=psum[i-1]+temp;
  }
  
  tsum=psum[n-1];
  ll mini=INT_MAX;
  
  /*for(ll i=0;i<n;i++)
  cout<<psum[i]<<" ";
  cout<<endl;*/
  for(ll i=0;i<n-1;i++)
  {
    ll val1=psum[i];
    ll val2=tsum-val1;
    ll final=abs(val1-val2);
    
    mini=min(mini,final);
  }
  
  cout<<mini;
  
  
  
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    string S;
    cin >> S;

    if (S == "ARC") cout << "ABC";
    else cout << "ARC";

    return 0;
}


Measured memory_bytes: 3108
import math
[X,K,D] = input().split()
X = int(X)
K = int(K)
D = int(D)
c = 0
N = min(math.floor(abs(X)/D),K)
if abs(abs(X) - N*D) > abs(abs(X) - (N-1)*D) :
    N = N - 1
if abs(X - N*D) < abs(X + N*D):
    Z = X - N*D
else:
    Z = X + N*D

if (K - N) % 2 == 1 :
    if abs(Z + D) < abs(Z - D) :
        Z = Z + D
    else:
        Z = Z - D


print(abs(Z))

Measured memory_bytes: 9076
N=int(input())
A=list(input().split())
if N%2==0:
  B=A[::-1]
  print(' '.join(B[::2])+' ' + ' '.join(A[::2]))
else:
  B=A[::-1]
  A=A[1::2]
  print(' '.join(B[::2])+' ' + ' '.join(A[:]))

Measured memory_bytes: 29508
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	char a[200], b[200];
	scanf("%s", &a);
	scanf("%s", &b);
	if(strlen(a) > strlen(b))
	{
		printf("GREATER\n");
		return 0;
		}
	if(strlen(a) < strlen(b))
	{
		printf("LESS\n");
		return 0;
		}
	if(strlen(a) == strlen(b))
	{
		for(int i = 0; i < strlen(a); i++)
		{
			if(a[i] > b[i])
			{
				printf("GREATER\n");
				return 0;
				}
			if(a[i] < b[i])
			{
				printf("LESS\n");
				return 0;
				}
			}
			printf("EQUAL\n");
			return 0;
		}
}

Measured memory_bytes: 128
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var obj = {};
  
  var r = intShift();
  
  for(var i = 0; i < r; i++){
  	var hoge = strShift();
  	obj.hasOwnProperty(hoge)?obj[hoge]++:obj[hoge]=1;
  }
  
  var b = intShift();
  
  for(var i = 0; i < b; i++){
  	var hoge = strShift();
    obj.hasOwnProperty(hoge)?obj[hoge]--:obj[hoge]=-1;
  }
  
  var o = [0];
  for(var i in obj){
  	o.push(obj[i]);
  }
  return ~~Math.max(...o);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
3
apple
orange
apple
1
grape
`);

Measured memory_bytes: 7500
import Control.Monad
import Data.List
main = do
    n <- readLn
    a <- map read . words <$> getLine
    let ml = take n (scanl (gcd) 0 a)
    let mr = drop 1 (scanr (gcd) 0 a)
    let m = zipWith (gcd) ml mr
    print (maximum m)

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

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

    int s,l,x3,y3,x4,y4;
    s = x2 - x1;
    l = y2 - y1;
    x3 = x2 - l;
    y3 = y2 + s;
    x4 = x1 - l;
    y4 = y1 + s;

    cout << x3 << ' ' <<  y3 << ' ' << x4 << ' ' << y4 << endl;

    return 0;
}

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

int main(){
    int n, t;
    cin >> n >> t;

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    reverse(a.begin(),a.end());

    vector<int> profit;
    long long int maxp = a[0], minp = a[0];// prices
    for(int i=1; i<n; i++){
        if(a[i] < minp) minp = a[i];
        if(a[i] > maxp || i == n-1){
            profit.push_back(maxp - minp);
            maxp = a[i];
            minp = a[i];
        }
    }
    sort(profit.begin(),profit.end());
    int l = profit.size();
    cout << upper_bound(profit.begin(),profit.end(), profit[l-1])
          - lower_bound(profit.begin(),profit.end(), profit[l-1]) << endl;
    return 0;
}

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

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

    vector<int> fn;
    fn.push_back(s);
//    cout << fn[fn.size()-1] << endl;
    bool endflg = false;
    int outcnt = 1;
    while (1) {
        outcnt++;
        if ( fn[fn.size()-1] % 2 == 0 ) {
            fn.push_back(fn[fn.size()-1]/2);
        }
        else {
            fn.push_back(fn[fn.size()-1]*3+1);
        }
        for ( int i = 0; i < fn.size() - 1; i++ ) {
            if ( fn[i] == fn[fn.size()-1] ) {
                endflg = true;
            }
        }
        if ( endflg == true ) {
            break;
        }
    }

    cout << outcnt << endl;

    return 0;
}

Measured memory_bytes: 256
def dc(n):
    return sum(map(int, list(bin(n)[2:])))
def calc(a, b, X):
    if len(X) == 1:
        return [a, b]
    i = 0
    while i not in X or (a & (1<<i)) == (b & (1<<i)):
        i += 1
    j = X[1] if i == X[0] else X[0]
    Y = [x for x in X if x != i]
    return calc(a, a ^ (1<<j), Y) + calc(a ^ (1<<j) ^ (1<<i), b, Y)

N, A, B = map(int, input().split())
if dc(A^B) % 2 == 0:
    print("NO")
else:
    print("YES")
    print(*calc(A, B, list(range(N))))


Measured memory_bytes: 56284
import sys,collections as cl
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[i]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a

n = int(input())

a = l()

ans = 0
l = 0
r = 0
su = 0
for i in range(n):
	while(r < n and (su^a[r]) == (su + a[r])):
		su += a[r]
		r += 1
	ans += r - i
	if r == i:
		r += 1
	else:
		su -= a[i]
print(ans)

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int a,b;
int n;

bool query(int x, int y){
  printf("? %d %d\n",x,y);fflush(stdout);
  char buf[5];
  scanf("%s",buf);
  return buf[0]=='Y';
}

char ans[4252];

int main(){
  scanf("%d%d",&a,&b);
  if(a<=b){
    puts("Impossible"); fflush(stdout);
    return 0;
  }
  n = a+b;
  vi v;
  v.push_back(0);
  FOR(i,1,n){
    if(v.size()==0 || query(v.back(), i)){
      v.push_back(i);
    }else{
      v.pop_back();
    }
  }
  int hon = v.back();
  REP(i,n)ans[i] = query(hon,i) ? '1' : '0';
  printf("! %s\n",ans);fflush(stdout);
  return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >>a>>b;
  if (a%3==0||b%3==0||(a+b)%3==0){
    cout <<"Possible"<<endl;
  }
  else {
    cout <<"Impossible"<<endl;
  }
}

Measured memory_bytes: 256
n,p=map(int,input().split())
l=list(map(int,input().split()))
o=sum(1 for i in l if i%2==1)
e=len(l)-o
if o==0:
  if p==0:print(2**n)
  else:print(0)
else:
  print(2**(n-1))

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args)throws IOException{
    	int a, b, s, l; // s:??¢???, l:??¨?????????
    	InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
        String buf = br.readLine();
        StringTokenizer st = new StringTokenizer(buf," ");
    	a = Integer.parseInt(st.nextToken());
        b = Integer.parseInt(st.nextToken());
    	s = a*b;
    	l = (a + b) * 2;
        System.out.printf("%d %d\n", s, l);
    }
}

Measured memory_bytes: 24580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int main() {
	int n; 
	cin >> n;
	vector<int> move(n+1, 0), a(n+1);
	rep(i, n) {
		int x; cin >> x;
		x--;
		a[i] = x;
	}
	bool can = true;
	int now = 0, cnt = 0;
	move[0] = 1;
	rep(i, n+10) {
		now = a[now];
		cnt++;
		if (now == 1) break; 
		move[now]++;
		if (move[now] > 1) can = false;
	}
	if (can) cout <<cnt << endl;
	else cout << -1 << endl;
	return 0;
}

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

typedef long long ll;
typedef tuple<ll, ll, ll, ll> Tp;
const ll INF = 1ll << 60;

int main()
{
	ll a, b, d;
	
	while (cin >> a >> b >> d, a | b | d){
		Tp res = Tp(INF, INF, INF, INF);
		
		for (ll x = 0; x <= 50000; x++){
			ll ax = a * x;
			
			vector<ll> v = {ax + d, ax - d, d - ax};
			for (ll by : v){
				if (by < 0) continue;
				if (by % b == 0){
					ll y = by / b;
					res = min(res, Tp(x + y, ax + by, x, y));
				}
			}
		}
		
		printf("%lld %lld\n", get<2>(res), get<3>(res));
	}
}

Measured memory_bytes: 1164
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//--------------------------------------------



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




int c[1000000 + 5];
//============================================
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

	//THE WATER WAS DEEP, I DROWNED AND THEN CAME FLOATING UP,DEAD!!


        ll n;
        cin>>n;
        ll arr[n];
        ll ma = -1 ;
        for(int i = 0 ; i < n ; i++)
        {
          ll v ;
          cin>>v;
          arr[i] = v;
          c[v]++;
          ma = max(ma,v);
        }

        ll dp[ma+1]={0};

        for(ll j = ma; j >=1 ; j--)
        {
          ll c_p = 0;
            for(ll k = 1; k*j <= ma ; k++)
                c_p += c[k*j];

            ll co_p = c_p*(c_p-1)/2;
            ll sum = 0;
            for(ll k = 2; k*j <= ma ; k++)
            {
              sum = sum + dp[k*j];
            }

            dp[j] = max(0ll,co_p-sum);
            
        }

        //cout<<dp[1]<<'\n';


        ll tot_pair = n*(n-1)/2;

        if(tot_pair == dp[1])
        {
          cout<<"pairwise coprime";
          return 0;
        }

        ll gc = arr[0];
        for(int i = 1 ; i < n ;i++)
          gc = __gcd(gc , arr[i]);

        if(gc == 1)
        {
          cout<<"setwise coprime";
          return 0;
        }

        cout<<"not coprime";








return 0;
}

Measured memory_bytes: 23124
enc = {}
enc[" "] = "101"
enc["'"] = "000000"
enc[","] = "000011"
enc["-"] = "10010001"
enc["."] = "010001"
enc["?"] = "000001"
enc["A"] = "100101"
enc["B"] = "10011010"
enc["C"] = "0101"
enc["D"] = "0001"
enc["E"] = "110"
enc["F"] = "01001"
enc["G"] = "10011011"
enc["H"] = "010000"
enc["I"] = "0111"
enc["J"] = "10011000"
enc["K"] = "0110"
enc["L"] = "00100"
enc["M"] = "10011001"
enc["N"] = "10011110"
enc["O"] = "00101"
enc["P"] = "111"
enc["Q"] = "10011111"
enc["R"] = "1000"
enc["S"] = "00110"
enc["T"] = "00111"
enc["U"] = "10011100"
enc["V"] = "10011101"
enc["W"] = "000010"
enc["X"] = "10010010"
enc["Y"] = "10010011"
enc["Z"] = "10010000"

decode_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"
dec = {}
decode_chars.split("").each_with_index{|s, i|
  dec[sprintf("%05d", i.to_s(2))] = s
}

readlines.map(&:chomp).each{|line|
  str = ""
  line.split("").each{|c|
    str += enc[c]
  }
  while str.size % 5 != 0
    str += "0"
  end

  (str.size / 5).times{|i|
    print dec[str[i*5,5]]
  }

  puts
}

Measured memory_bytes: 9904
n = int(input())
s = input()
t = s
s += "("
cnt = 0
for i in range(n):
  if s[i] == "(":
    cnt -= 1
  else:
    cnt += 1
  if s[i] == ")" and s[i+1] == "(":
    if cnt > 0:
      t = "("*cnt + t
      cnt = 0
if cnt < 0:
  t += ")"*(-cnt)
print(t)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int a, b, c, d, e, f, g,h,hi,ke;
	scanf("%d %d", &a, &b);
	scanf("%d %d", &c, &d);
	scanf("%d %d %d %d", &e, &f, &g, &h);
	hi = a*e + b*f + a / 10 * g + b / 20 * h;
	ke = c*e + d*f + c / 10 * g + d / 20 * h;
	if (hi == ke)
	{
		printf("even\n");
	}
	else if(hi > ke)
	{
		printf("hiroshi\n");
	}
	else
	{
		printf("kenjiro\n");
	}
	return 0;
}

Measured memory_bytes: 584
from collections import defaultdict
n,m=map(int,input().split())
a=list(map(int,input().split()))
ans=0
d=defaultdict(int)
sum_a=0
d[sum_a]+=1
for i in range(n):
    sum_a+=a[i]
    sum_a%=m
    ans+=d[sum_a]
    d[sum_a]+=1
print(ans)

Measured memory_bytes: 14628
from collections import deque

n,q=map(int,input().split())
tr=[[] for i in range(n)]
for i in range(n-1):
    b,c=map(int,input().split())
    tr[b-1].append(c-1)
    tr[c-1].append(b-1)

a=[0]*n
for i in range(q):
    b,c=map(int,input().split())
    a[b-1]+=c
    
d=deque([0])
f=[0]*n
f[0]=1
while d:
    p=d.pop()
    f[p]=1
    for c in tr[p]:
        if f[c]==1:
            continue
        a[c]+=a[p]
        d.append(c)
print(*a)

Measured memory_bytes: 56148
n=int(input())
m=n-1
a=(n>2)+1
for i in range(2,int(n**.5)+1):
  if m%i<1:a+=(m//i>i)+1
  if n%i<1:
    o=n
    while o%i<1:o//=i
    a+=o%i<2
print(a)

Measured memory_bytes: 3060
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=300005;	

void solve(){
	int n,x,y;
	cin>>n>>x>>y;
	if(y<x){
		swap(x,y);
	}
	vector<int>ans(n);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int dist1=j-i;
			if(i<=x&&j>=y){
				dist1=min(dist1,(x-i)+(j-y)+1);
			}
			else{
				dist1=min(dist1,abs(x-i)+abs(j-y)+1);
			}
			ans[dist1]++;
		}
	}
	for(int i=1;i<=n-1;i++){
		cout<<ans[i]<<'\n';
	}
}


signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //~cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}
 


Measured memory_bytes: 256
ar = input()

k = int(input())

l = len(ar)


DP = [[[-1] * 2 for j in range(103)] for i in range(102)]


def dp(i, j, fl):
    if i == l:
        if j == k:
            return 1
        else:
            return 0

    if DP[i][j][fl] != -1:
        return DP[i][j][fl]

    res = 0

   # print(i,j,fl)
    if fl:
        for p in range(10):

            res += dp(i+1, j + (p != 0) , fl == 1)
    else:
        ko = ord(ar[i]) - ord('0')
        for p in range(ko + 1):

            res += dp(i + 1, j + (p != 0), p < ko)
    DP[i][j][fl] = res
    return res

print(dp(0, 0, 0))


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

const int N = 1 << 18, mod = 998244353, i2 = (mod + 1) / 2;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

inline void FWT(int a[], int len, int type) {
    for (int mid = 2; mid <= len; mid <<= 1)
        for (int i = 0; i < len; i += mid)
            for (int j = i; j < i + (mid >> 1); j++) {
                int t = a[j]; a[j] = (t + a[j + (mid >> 1)]) % mod, a[j + (mid >> 1)] = (t - a[j + (mid >> 1)] + mod) % mod;
                if (!type) a[j] = (LL)a[j] * i2 % mod, a[j + (mid >> 1)] = (LL)a[j + (mid >> 1)] * i2 % mod;
            }
}

int A[N], B[N];

int main() {
    int n, sum = 0; scanf("%d", &n), n = 1 << n;
    for (int i = 0; i < n; i++) scanf("%d", &A[i]), B[i] = mod - 1, sum = (sum + A[i]) % mod;
    sum = Pow(sum, mod - 2);
    for (int i = 0; i < n; i++) A[i] = (LL)A[i] * sum % mod;
    B[0] = n - 1, A[0] = (A[0] + mod - 1) % mod;
    FWT(A, n, 1), FWT(B, n, 1);
    for (int i = 0; i < n; i++) B[i] = (LL)B[i] * Pow(A[i], mod - 2) % mod;
    FWT(B, n, 0);
    for (int i = 0; i < n; i++) printf("%d\n", (B[i] - B[0] + mod) % mod);
}

Measured memory_bytes: 4864
#include<iostream>
#include<string>
using namespace std;
int main (void){

    string s;
    int flg = 0;
    cin >> s;

    for(int i = 0;i < 3;i++){

        if(s[i] == '7'){
            flg = 1;
            break;
        }
    }

    if(flg == 1)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}

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

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

  for (int i=0; i < N; i++){
    string S;
    cin >> S;
    
    if (S == "Y"){
      TF = 1;
      break;
    }
    else{
      TF = 0;
    }
  }
  
  if (TF == 1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 int i=0, ch,a[10] = {0};

 while((ch = getchar()) != EOF){
  a[i] = ch - '0';
  i++;
 }
 int count = i-1, min = 900;

 for(i=0; i<count-2; i++){
  int num = a[i] * 100 + a[i+1] * 10 + a[i+2];
  int a = (753 > num) ? 753-num : num-753;
  if(min > a){
   min = a;
  }
 }
 printf("%d\n", min);
 return 0;
}

Measured memory_bytes: 128
#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)

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

struct edge {
	int to,cost;
	edge(int t,ll 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) {
	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;
}

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

int n;

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

	cin>>n;
	cout<<"ABC"<<n<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		int[][] a = new int[3][3];
		boolean[][] flag = new boolean[3][3];

		Scanner sc = new Scanner(System.in);

		for(int i = 0 ; i < a.length; i++) {
			for(int j = 0; j < a[i].length;j++) {
				a[i][j] = sc.nextInt();
			}
		}

		int n = sc.nextInt();
		int[] b = new int[n];

		for(int i = 0; i < b.length;i++) {
			b[i] = sc.nextInt();
		}

		//inputend

		for(int i = 0 ; i < a.length; i++) {
			for(int j = 0; j < a[i].length;j++) {
				for(int k = 0; k < b.length;k++) {
					if(a[i][j] == b[k])flag[i][j]=true;
				}
			}
		}

		for(int i = 0; i < flag.length;i++) {
			if(flag[0][i] && flag[1][i] && flag[2][i]) {
				System.out.println("Yes");
				return;
			}
		}

		for(int i = 0; i < flag.length;i++) {
			if(flag[i][0]&&flag[i][1]&&flag[i][2]) {
				System.out.println("Yes");
				return;
			}
		}

		if((flag[0][0]&&flag[1][1]&&flag[2][2])||(flag[0][2]&&flag[1][1]&&flag[2][0])) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");
		return;
	}


}


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

int main() {
  int N;
  cin >> N;
  int ans=0;
  for(int C=1; C<N; C++){
    int k=N-C;
    int Q=sqrt(k);
    if(Q*Q==k)
      ans--;
    for (int A=1; A<=Q; A++){
      int d;
      d= k % A;
      if (d==0){
        ans=ans + 2;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
 #include <string.h>
 int main (void){
char s[100];
int len,a,b,c,d,e,f,g=0;
scanf("%s",s);
len = strlen(s);
for(a=0,b=len-1;a<b;a++,b--){
    if(s[a]!=s[b]){
        g=g+1;
        break;
    }
}
for(c=0,d=(len-1)/2-1;c<d;c++,d--){
        if(s[c]!=s[d]){
        g=g+1;
        break;
    }
}
for(e=(len+3)/2-1,f=len-1;e<f;e++,f--){
     if(s[e]!=s[f]){
        g=g+1;
        break;
    }
}
if(g==0){
    printf("Yes");
}else{
    printf("No");
}
 }

Measured memory_bytes: 128
list=input().split(" ")
n=int(list[0])
x=int(list[1])
moji=input()
if moji[x-1]=='A':
    ko='a'
elif moji[x-1]=='B':
    ko='b'
else:
    ko='c'

moji=moji[:x-1]+ko+moji[x:]
print(moji)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include <sstream>
 
using namespace std;
 
bool is_prime(int n){
 
  for(int i=2; i*i<=n; i++)
    if(n%i==0)return false;
  return true;
}
 
string toString(int a){
  ostringstream oss;
  oss << a;
  return oss.str();
}
 
int toInt(string s){
  istringstream iss(s);
  int a;
  iss >> a;
  return a;
}
 
int main(void){
  int n,c;
  string str="",C="";
 
  cin >> n >> c;
 
  for(int i=0;i<n;i++)str+="9";
   
  C=c+'0';
 
  if(c<0 && n>1){
    cout << str << str << endl;
    return 0;
  }

  while(true){
    string rstr=str;
    reverse(rstr.begin(),rstr.end());
     
    string res=str+C+rstr;
    int ans=toInt(res);
 
    if(is_prime(ans)){
      cout << ans << endl;
      return 0;
    }
 
    int tmp=toInt(str);
    tmp--;
    str=toString(tmp);
  }
 
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define pii pair<int, int>
#define fir first
#define sec second
using namespace std;
const int MAXN = 1e5 + 7;
vector<pii>G[MAXN];
int n, dis[MAXN];
bool vis[MAXN];
int dijkstra(int s)
{
    for (int i = 0; i <= n; i++) dis[i] = 1e9, vis[i] = 0;
    priority_queue<pii, vector<pii>, greater<pii>>pq;
    pq.push({dis[s] = 0, s});
    while (pq.size())
    {
        int u = pq.top().sec; pq.pop();
        if (vis[u]) continue; 
        vis[u] = 1;
        for (pii e : G[u])
        {
            int v = e.sec, w = e.fir;
            if (dis[v] > dis[u] + w)
                pq.push({dis[v] = dis[u] + w, v});
        }
    }
    return s + dis[0];
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i < n; i++) 
    {
        if (i % 10 < 9) G[i].emplace_back(1, (i + 1) % n);
        G[i].emplace_back(0, (i * 10) % n);
    }
    int ans = 1e9;
    for (int s = 1; s < 10; s++) ans = min(ans, dijkstra(s)); 
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;

    REP(i,s.size()) {
        string ss = s.substr(i,2);
        if (ss == "OX" || ss == "XO") {
            ans++;
            i++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3348
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> left_x, right_x;
  
  for (int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if(tmp < 0) {
      left_x.insert(left_x.begin(), tmp);
    }else{
      right_x.push_back(tmp);
    }
  }
  int ans = 0;

  if(left_x.empty()){
    ans = abs(right_x[K-1]);
  }else if(right_x.empty()){
    ans = abs(left_x[K-1]);
  }else{
    ans = 300000000;
    for (int i = 0; i < K; i++){
      int p = 0;
      if ((left_x.size() <= K-i-2) || (right_x.size() <= i)) continue;
      
      if (abs(right_x[i]) < abs(left_x[K-i-2])) {
        p = abs(right_x[i]);
      }else{
        p = abs(left_x[K-i-2]);
      }

      int tmp = abs(right_x[i]) + abs(left_x[K-i-2]) + p;
      if (tmp < ans) ans = tmp;      
    }

    if (K <= left_x.size() && ans > abs(left_x[K-1])){
      ans = abs(left_x[K-1]);
    }
    if (K <= right_x.size() && ans > abs(right_x[K-1])){
      ans = abs(right_x[K-1]);
    }
  }
  printf("%d\n",ans);

  
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a ,b,c;
  cin >> a >> b >> c;
  int mi = min(min(a,b),c);
  int ma = max(max(a,b),c);
  cout <<  ( ma * 10 + a + b + c - ma ) ;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int flag = 0;
	while(n)
	{
		if(n%10==7)
		{
			flag = 1;
			break;
		}
		n/=10;
	}
if(flag==1)
	printf("Yes");
else
	printf("No");
	return 0;
}


Measured memory_bytes: 1732
using System;

namespace AtCoder1230_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            var c = Console.ReadLine();
            bool isYubin = true;

            for (int i = 0; i < a; i++)
            {
                if (c[i] < '0' || '9' < c[i])
                {
                    isYubin = false;
                }
            }
            if(c[a] != '-'){
                isYubin = false;
            }

            for (int i = a + 1; i < c.Length; i++)
            {
                if (c[i] < '0' || '9' < c[i])
                {
                    isYubin = false;
                }
            }

            if(c.Length != a+b+1){
                isYubin = false;
            }

            if(isYubin == true){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
int biaoji[3];

int main()
{
	int n;
	int num = 2;
	while(num--)
	{
		cin >> n;
		biaoji[n - 1] = 1;
	}
	for(int i = 0;i < 3;i++){
		if(biaoji[i] == 0){
			cout << i +1 << endl;
			break;
		}
			
	}
	return 0;
}


Measured memory_bytes: 256
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007

int main(){
	int H,W; cin>>H>>W;

	vector<string> grid(H);
	rep(h, H) cin>>grid[h];

	vvi dp(H, vi(W, 0)); // (h,w): count
	queue<pair<int,int>> q; // <h,w>
	dp[0][0] = 1;
	q.push({0,0});

	while(q.size()){
		int h,w; tie(h,w) = q.front(); q.pop();

		// right (h,w+1)=(h,w)+(h-1,w+1)
		if(w+1 < W
		&& grid[h][w+1] == '.'
		&& dp[h][w+1] <= 0){
			dp[h][w+1] = dp[h][w];
			if(0 <= h-1) dp[h][w+1] += dp[h-1][w+1];
			dp[h][w+1] %= MOD;
			q.push({h,w+1});
		}

		// down (h+1,w)=(h,w)+(h+1,w-1)
		if(h+1 < H
		&& grid[h+1][w] == '.'
		&& dp[h+1][w] <= 0){
			dp[h+1][w] = dp[h][w];
			if(0 <= w-1) dp[h+1][w] += dp[h+1][w-1];
			dp[h+1][w] %= MOD;
			q.push({h+1,w});
		}

	}
	cout<< dp[H-1][W-1] <<endl;

	// print ==========================
	cerr<<"===\n";//
	cerr<<"H "<<H<<" W "<<W<<"\n";//
	rep(h,H) cerr<<grid[h]<<"\n";//
	for(auto v:dp){
		for(auto x:v)cerr<<" "<<setw(3)<<x;
		cerr<<"\n";
	}
	// =================================

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll k, a, b, ans = 0;
    cin >> k >> a >> b;
    if ((a + 1) < b) {
        if (k <= (a - 1)) {
            ans = k + 1;
        }
        else {
            ans = (k - (a - 1)) / 2 * (b - a) + a + (k - (a - 1)) % 2;
        }
    }
    else {
        ans = k + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int j,k,l,m,n,o,p,q,s,sum=0;
  rep(i,N){
    j=(i+1)/(10*10*10*10);
    k=i+1-j*10*10*10*10;
    l=k/(10*10*10);
    m=k-l*10*10*10;
    n=m/(10*10);
    o=m-n*10*10;
    p=o/10;
    q=o-p*10;
    s=j+l+n+p+q;
    if(A<=s && s<=B){sum+=i+1;}
  }
  cout << sum << endl;
}






Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    set<string> S;
    for(int i=0; i<N; i++) {
        string s; cin >> s;
        S.emplace(s);
    }
    cout << S.size() << endl;
    return 0;
}


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

#define ran 1234

int n;
int a[ran];
long long s[11];

int main() {
	scanf("%d", &n);
	
	s[0] = s[1] = 0LL;
	int neg = 1;
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		if (a[i]>0) {
			neg = -1;
			s[i%2]+=a[i];
		} else if (neg>0 && a[i] > a[neg]) neg = i;
	}
	
	if (neg>0) {
		cout<<a[neg]<<endl<<n-1<<endl;
		for(int i=n;i>neg;i--) cout<<i<<endl;
		for(int i=1;i<neg;i++) cout<<1<<endl;
		return 0;
	}
	
	long long ans = 0LL;
	vector<int> v(0);
	if (s[0]>s[1]) {
		for(int i=2;i<=n;i+=2) if (a[i]>0) {
			ans+=a[i]; 
			v.push_back(i);
		}
	} else {
		for(int i=1;i<=n;i+=2) if (a[i]>0) {
			ans+=a[i];
			v.push_back(i);
		}
	}
	
	cout<<ans<<endl;
	
	vector<int> op(0);
	for(int i=n;i>v.back();i--) op.push_back(i);
	for(int i=(int)v.size()-1;i>0;i--) {
		int mi = (v[i] + v[i-1])/2, sz = (v[i] - v[i-1])/2;
		for(int j=0;j<sz;j++)
			op.push_back(mi-j);
	}
	for(int i=1;i<v[0];i++) op.push_back(1);
	
	cout<<op.size()<<endl;
	for(int i=0;i<(int)op.size();i++)
		cout<<op[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    d = [(0,1),(0,-1),(1,0),(-1,0)]

    while True:
        w,h = LI()
        if w == 0 and h == 0:
            break

        a = [S() for _ in range(h)]
        b = [[0]*w for _ in range(h)]
        c = [[0]*w for _ in range(h)]
        q = []
        for i in range(h):
            for j in range(w):
                if a[i][j] == 'B':
                    q.append((i,j))
        qi = 0
        f = [[None]*w for _ in range(h)]
        while len(q) > qi:
            i,j = q[qi]
            qi += 1
            for di,dj in d:
                ni = di + i
                nj = dj + j
                if 0 <= ni < h and 0 <= nj < w and f[ni][nj] is None:
                    f[ni][nj] = 1
                    if a[ni][nj] == '.':
                        q.append((ni,nj))
                        b[ni][nj] = 1

        q = []
        for i in range(h):
            for j in range(w):
                if a[i][j] == 'W':
                    q.append((i,j))
        qi = 0
        f = [[None]*w for _ in range(h)]
        while len(q) > qi:
            i,j = q[qi]
            qi += 1
            for di,dj in d:
                ni = di + i
                nj = dj + j
                if 0 <= ni < h and 0 <= nj < w and f[ni][nj] is None:
                    f[ni][nj] = 1
                    if a[ni][nj] == '.':
                        q.append((ni,nj))
                        c[ni][nj] = 1
        bc = wc = 0
        for i in range(h):
            for j in range(w):
                if b[i][j] == 1 and c[i][j] == 0:
                    bc += 1
                elif c[i][j] == 1 and b[i][j] == 0:
                    wc += 1


        rr.append('{} {}'.format(bc,wc))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9288
import qualified Data.Vector         as V
import qualified Data.Vector.Mutable as VM
import Control.Applicative
import Control.Monad.ST
import Control.Monad
import Data.STRef

bubbleSort :: [Int] -> ([Int], Int)
bubbleSort xs = runST $ do
  aVec <- V.thaw $ V.fromList xs
  c <- newSTRef 0
  loop aVec c
  list  <- V.toList <$> V.freeze aVec
  count <- readSTRef c
  return (list, count)
    where
      len = length xs - 1
      loop aVec c = do
        flag <- newSTRef False
        forM_ [len, len - 1 .. 1] $ \j -> do
          v1 <- VM.read aVec j
          v2 <- VM.read aVec (j - 1)
          when (v1 < v2) $ do
            VM.swap aVec j (j - 1)
            writeSTRef flag True
            modifySTRef c (+ 1)
        f <- readSTRef flag
        when f $ loop aVec c

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  let (ys, c) = bubbleSort xs
  putStrLn $ unwords $ map show ys
  print c



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

int main() {
  long long n,k;cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  
  int cnt=1,tmp=k,aa=0;
  vector<int> check(n,0);
  check[0]=1;
  for(long long i=1;i<=k;i++){
    cnt=a[cnt-1];
    if(check[cnt-1]==0) check[cnt-1]=i+1;
    else{
      tmp=i+1-check[cnt-1];
      aa=i-tmp;
      //cout<<tmp<<' '<<cnt<<' '<<aa<<endl;
      break;
    }
  }
  tmp=(k-aa)%tmp;
  for(int i=0;i<tmp;i++){
    cnt=a[cnt-1];
  }
  cout <<cnt<<endl;
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(void){
    int n;cin>>n;
    vector<int>V(n);rep(i,n)cin>>V[i];
    sort(all(V));
    int count=0;
    rep(i,n-1){
        if(V[i]==V[i+1])count++;
    }
    cout<<n-(count+1)/2*2<<endl;
}

Measured memory_bytes: 1024
import string
from collections import Counter

ans = []
dic = {}

for a in string.ascii_lowercase:
    dic[a] = 51

N = int(input())
for _ in range(N):
    S = Counter(input())
    
    for l, c in dic.items():
        if dic[l] > S[l]:
            dic[l] = S[l]

for k, v in dic.items():
    if v != 0:
        ans.append(k * v)

ans.sort()
print("".join(map(str, ans)))

Measured memory_bytes: 39408
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var xkd = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var X = xkd[0]; var K = xkd[1]; var D = xkd[2];

            if (X < 0) X = X * -1;

            if (X / D > K) return X - K * D;

            var min = X % D;

            if (((K - X / D) % 2) == 0) return min;
            else return D - min;
        }
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, C; cin >> N >> C;
    vector<ii> tv[C+1];
    FOR(i,0,N-1){
        int s, t, c; cin >> s >> t >> c;
        tv[c].emplace_back(s,t);
    }

    vector<ii> inv;
    FOR(c,1,C) if (!tv[c].empty()) {
        sort(ALL(tv[c]));
        ii cur = ii(tv[c][0].fi, tv[c][0].fi);
        for (auto& x : tv[c]) {
            if (cur.sc == x.fi) cur.sc = x.sc;
            else inv.push_back(cur), cur = x;
        }
        inv.push_back(cur);
    }

    sort(ALL(inv));
    priority_queue<int,vector<int>,greater<int> > pq;
    for (auto& x : inv) {
        if (!pq.empty() && pq.top() < x.fi) pq.pop();
        pq.push(x.sc);
    }

    cout << SZ(pq);
}



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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(b-a <= 0){
        cout << "delicious" << endl;
    }else if(b-a <= x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	ll ans = 0;
	map<ll, ll> m;
	in(int, N);
	loop(i, N) {
		in(ll, a);
		++m[a];
	}
	for (auto&& p : m) {
		auto f = p.first, s = p.second;
		if (f != s) {
			if (s < f) ans += s;
			else ans += s - f;
		}
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 6272