akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static HashMap<String,String> map = new HashMap<>();

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int D = sc.nextInt();
		
		boolean[][] map = new boolean[N][M];
		for(int i = 0; i < N; i++) {
			char[] in = sc.next().toCharArray();
			for(int j = 0; j < M; j++) {
				if(in[j] != '#') map[i][j] = true;
			}
		}
		int ans = 0;
		for(int i = 0; i < N; i++) {
			int cc = 0;
			for(int j = 0; j < M; j++) {
				if(map[i][j]) cc++;
				
				if(!map[i][j] || j == M-1) {
					ans += Math.max(0, cc - D + 1);
					cc = 0;
				}
			}
		}
		for(int i = 0; i < M; i++) {
			int cc = 0;
			for(int j = 0; j < N; j++) {
				if(map[j][i]) cc++;
				
				if(!map[j][i] || j == N-1) {
					ans += Math.max(0, cc - D + 1);
					cc = 0;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27516
//A,Elebereth,Gilthoniel mantae!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring> 
#include<map>
using namespace std;
int main()
{
	int n;cin>>n;if(n/10==9 or n%10==9) cout<<"Yes";else cout<<"No"; 
	return 0;
}

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

typedef pair<int, int> P;

int main() {
    double w,h;
    cin >> w >> h;
    double x,y;
    cin >> x >>y;

    double ans = w*h/2;

    cout << fixed;
    cout << setprecision(10) << ans << ' ';

    if(x==w/2&&y==h/2)cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

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

using namespace std;
const int N=3e3+5;

double a[N];
double dp[N];
int main()
{
    int n,m;
    cin>>n;

    for(int i=1;i<=n;i++){
      cin>>a[i];
    }
    dp[0]=1.0;
    for(int coin=1;coin<=n;++coin){
        for(int head=coin;head>=0;--head){
            dp[head] = ((head==0)?0:dp[head-1])*a[coin] + dp[head]*(1-a[coin]);
        }
    }
    double res=0.0;
    for(int i=1;i<=n;++i){
        if(i > n-i){
            res+=dp[i];
        }
    }
    printf("%.10f\n", res);
    return 0;
}




Measured memory_bytes: 256
from math import gcd
 
def main():
  k = int(input())
  ans = 0
  for a in range(1, k+1):
    for b in range(a, k+1):
      x = gcd(a,b)
      for c in range(b,k+1):
        if a==b and b==c:
          ans += a
        elif a==b or b==c:
          ans += gcd(x,c) * 3
        else:
          ans += gcd(x,c) * 6
  print(ans)
  
  
if __name__ == '__main__':
  main()


Measured memory_bytes: 9188
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
//const int mod=1e9+7;
const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;

// int n,m,x,y,res=0,sz[2*up],par[2*up],ans[2*up];

// int get(int x)
// {
//     return x*(x-1)/2;
// }

// int find(int x)
// {
//     if(par[x]==x)
//         return x;
//     else
//         return par[x]=find(par[x]);
// }

// void merge(int u,int v)
// {
//     x=find(u);
//     y=find(v);
//     if(sz[x]<sz[y])
//         swap(x,y);
//     res-=get(sz[x]);
//     res-=get(sz[y]);
//     sz[x]+=sz[y];
//     res+=get(sz[x]);
//     par[v]=u;
// }

// void solve()
// {
//     cin>>n>>m;
//     vector<pii>q(m+1);
//     vector<pair<int,pii>>e(n);
//     repn(i,1,n)
//     {
//         sz[i]=1;
//         par[i]=i;
//     }
//     repn(i,1,n-1)
//     {
//         cin>>e[i].ss.ff>>e[i].ss.ss>>e[i].ff;
//     }
//     repn(i,1,m)
//     {
//         cin>>q[i].ff;
//         q[i].ss=i;
//     }
//     sort(all(e));
//     sort(all(q));
//     int pos=1;
//     repn(i,1,m)
//     {
//         while(pos<n && e[pos].ff<=q[i].ff)
//         {
//             x=e[pos].ss.ff;
//             y=e[pos].ss.ss;
//             merge(x,y);
//             ++pos;
//         }
//         ans[q[i].ss]=res;
//     }
//     repn(i,1,m)
//     {
//         cout<<ans[i]<<" ";
//     }
//     cout<<endl;
// }


int pre[2*up],a[2*up];
void solve()
{
    int n,k,q;
    cin>>n>>k>>q;
    repn(i,1,q)
    {
        cin>>a[i];
        pre[i]=0;
    }
    pre[0]=0;
    repn(i,1,q)
    {
        pre[1]-=1;
        pre[a[i]]+=1;
        pre[a[i]+1]-=1;
        pre[n+1]+=1;
    }
    repn(i,1,n)
    {
        //cout<<pre[i]<<" "<<pre[i-1]<<endl;
        pre[i]+=pre[i-1];
        if((pre[i]+k)<=0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
}

int32_t main()
{
    int t;
    // memset(prime, true, sizeof(prime)); 
    // sieve();
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int[] count = new int[4];
            for (int i = 0; i < 3; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                count[a]++;
                count[b]++;
            }
            int max = 0;
            for (int i = 0; i < count.length; i++) {
                max = Math.max(max, count[i]);
            }
            System.out.println(max <= 2 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 22484
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    cout << (N * 3 + M) / 2 << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int d1 = N%10;
  int d1000 = (N - N%1000)/1000;
  int d100 = (N - N%100 - d1000*1000)/100;
  int d10 = ((N-d1)%100)/10;
  
  if((d1000 == d100 && d100 == d10) || (d10 == d100 && d1 == d10)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    string s; cin >> s;
    int n = s.size();
    string t = s;
    rep(i, n){
        rep(j, n){
            if(t.erase(i, j) == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
            t = s;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main() {
	int n,cnt{},prev{};
	cin >> n;
	for(int i=0; i<n; i++){
		int h;
		cin >> h;
		if(prev<h) cnt += h-prev;
		prev = h;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
N=int(input())
W=list()

start=list()
end=list()

for i in range(N):
    W.append(input())
    w=W[i]
    w=list(w)
    
    if i!=0:
        start.append( w[0] )

    if i!=(N-1):
        end.append( w.pop() )
        
    w.clear()

Ws=set(W)

if len(W)!=len(Ws) or start!=end:
    print("No")

else :
    print("Yes")    


Measured memory_bytes: 3064
import numpy as np

def rot(theta, vec):
    theta = np.deg2rad(theta)
    affine = np.array([[np.cos(theta), -np.sin(theta)],
    [np.sin(theta), np.cos(theta)]])

    return np.dot(affine, vec)


A,B,H,M = list(map(int, input().split()))

# 1分あたり?
unit_h = 360 / (12 * 60)
unit_m = 360 / 60

h_angle = unit_h * (60 * H + M)
m_angle = unit_m * M

h_vec = np.array([0, A])
m_vec = np.array([0, B])

h_vec = rot(h_angle, h_vec)
m_vec = rot(m_angle, m_vec)

print(np.linalg.norm(h_vec - m_vec, ord=(2)))


Measured memory_bytes: 27272
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
#define MAXN 2000005
lli f[MAXN];

lli powmod(lli a,lli b){
	lli ans = 1ll;
	while(b){
		if(b&1ll) ans = (ans * a)%mod;
		b>>=1;
		a = (a*a) % mod;
	}
	return ans%mod;
}

lli inv(lli a){
	return powmod(a,mod-2)%mod;
}

lli ncr(lli n, lli r){
	return (f[n] * (inv((f[r] * f[n-r])%mod))%mod ) % mod;
}

void pre(){
	f[0] = 1ll;
	for(int i=1; i < MAXN; i++){
		f[i] = (1ll * i * f[i-1]) % mod;
	}
}

int main(){__
	int k;
	pre();
	cin >> k;
	string s;
	cin >> s;
	int n =(int) s.size();
	lli ans = 0ll;
	for(int i=0; i <= k; i++){
		lli res = powmod(26,i) % mod;
		res = (res * powmod(25,k-i)%mod)%mod;
		res = (res * ncr(n + (k-i)-1,n-1)%mod) % mod;
		ans =(ans + res) %mod;
	}
	cout << ans%mod << endl;
	return 0;
}


Measured memory_bytes: 19848
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
vector<set<int>> v;
vector<bool> check; 
int f=0;
void dfs(int x)
{
	check[x]=true;
	f++;
	for(auto i:v[x])
		{
			if(!check[i])
				dfs(i);
		}
}
int main()
{
	fast
	int n,m;
	cin>>n>>m;
	check.resize(n+1);
	v.resize(n+1);
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		// cout<<a<<" "<<b<<endl;
		v[a].insert(b);
		v[b].insert(a);
	}
	// for(int i=1;i<=n;i++)
	// 	{for(auto j:v[i])
	// 		cout<<j<<" ";
	// 		cout<<endl;
	// 	}
	int x=0;
	for(int i=1;i<=n;i++)
	{
		if(!check[i])
		{
			// cout<<i<<endl;
			dfs(i);
			x=max(x,f);
			f=0;
		}
	}
	cout<<x;
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1e9 + 7;
const int Maxn = 3e2 + 10;
const ll Inf = 1e16;

bool is_prime(ll x){
	for(int i = 2; i < x; i++) if(x % i == 0) return false;
	return true;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll ans = 1, res, m;
	for(int i = 2; i <= n; i++){
		if(!is_prime(i)) continue;
		m = n;
		res = 0;
		while(m){
			res += (m / i);
			m /= i;
		}
		ans = (ans * (res + 1)) % Mod;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input 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)*} }; }
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)*} }; }
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, [ $t:tt ]) => { { let len = read_value!($next, usize); (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") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        S: String,
    }
    println!("{}", S.replace("2017","2018"));
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

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

int main()
{
        int cnt = 0, N;
        ll ans = 0;
        cin >> N;
        vector<int> vec(N + 1);
        for (int i = 0; i < N; i++)
        {
                cin >> vec[i];
                if (vec[i] < 0)
                {
                        cnt++;
                }
        }

        if (cnt % 2 == 0)
        {
                for (int i = 0; i < N; i++)
                {
                        ans += abs(vec[i]);
                }
        }
        else
        {
                int res = 1000000000;
                for (int i = 0; i < N; i++)
                {
                        ans += abs(vec[i]);
                        res = min(res, abs(vec[i]));
                }
                ans -= 2 * res;
        }

        cout << ans << endl;

        return 0;
}

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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

const int mod = 1e9 + 7;

string A, B, C;
int dp[55][2];

int solve(int digit, int carry)
{
  if(digit == A.size()) return !carry;
  int &ret = dp[digit][carry];
  if(~ret) return ret;
  ret = 0;
  rep(i, 10) {
    if(digit == A.size()-1 && i == 0) continue;
    if(A[digit]-'0' != i && A[digit] != '?') continue;
    rep(j, 10) {
      if(digit == B.size()-1 && j == 0) continue;
      if(B[digit]-'0' != j && B[digit] != '?') continue;
      if(digit == C.size()-1 && (i + j + carry) % 10 == 0) continue;
      if((i + j + carry) % 10 != C[digit]-'0' && C[digit] != '?') continue;
      ret = (ret + solve(digit+1, (i + j + carry) / 10)) % mod;
    }
  }
  return ret;
}

int main()
{
  while(cin >> A, A != "0") {
    cin >> B >> C;
    reverse(all(A));
    reverse(all(B));
    reverse(all(C));
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3032
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);

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

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

        int count = 0;
        boolean bl;
        for(int i=0; i<n; i++){
            bl = true;
            while(bl == true){
                if(a[i] % 2 == 0){
                    a[i] /= 2;
                    count++;
                }
                else{
                    bl = false;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 33988
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s,t;cin>>s>>t;
    int ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3832
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] % 1000 == 0)
            {
                Console.WriteLine(0);
                return;
            }
            Console.WriteLine(1000-a[0] % 1000);

        }
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
string S;
string T;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>S;
	
	int pos=0,rev=0,revn=0;
	while(K-->0){
		
		if((S[pos]=='A') ^ rev ^ revn) {
			revn^=1;
		}
		else {
			pos++;
			revn = 0;
			rev ^=1;
		}
		if(pos==N) break;
	}
	
	string R;
	if(pos==N) {
		while(R.size()<N) {
			if((N-R.size())%2==1) R+='A';
			else R+='B';
		}
		if(R[0]=='A' && K%2) R[0]='B';
	}
	else {
		int first=1;
		while(pos<N) {
			if(rev ^ ((first==1)&&revn)) {
				R+='A'+'B'-S[pos];
			}
			else {
				R+=S[pos];
			}
			pos++;
			first=0;
		}
		while(R.size()<N) {
			if((N-R.size())%2==1) R+='A';
			else R+='B';
		}
	}
	cout<<R<<endl;
	
	/*
	T=S;
	
	FOR(i,100) {
		int x=0,side=0;
		while(x>=0 && x<N) {
			S[x]='A'+'B'-S[x];
			if(side==0) {
				if(S[x]=='B') x--, side=1;
				else x++;
			}
			else {
				if(S[x]=='B') x++, side=0;
				else x--;
			}
		}
		
		if(T[0]=='A') T[0]='B';
		else {
			T=T.substr(1);
			FORR(c,T) c='A'+'B'-c;
			T+='A';
		}
		
		
		cout<<(i+1)<<"\t"<<S<<endl;
	}
	*/
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main(){
    int N, Y;
    cin >> N >> Y;
    
    bool a = false;

    for (int x=0; x<=N; x++){
        for (int y=0; y<=(N-x); y++){
            int sum;
            sum = 10000 * x + 5000 * y + 1000 * (N-x-y);
            if (sum == Y){
                a = true;
                cout << x << ' ' << y << ' ' << N-x-y << endl;
                break;
            }
        }
        if (a == true){
            break;
        }
    }

    if (a == false){
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////
 
int N, K;
int ans[MAX_N];
 
void solve() {
	cin >> K >> N;
	if(K % 2 == 0) {
		rep(i, 0, N) {
			if(i == 0) cout << K / 2 << " ";
			else cout << K << " ";
		}
		cout << "\n";
	}
	else {
		rep(i, 0, N) ans[i] = (K + 1) / 2;
 
		int at = N - 1;
 
		rep(_, 0, N / 2) {
			if(ans[at] == 0) {
				ans[at - 1]--;
				at--;
				if(ans[at] != 0) {
					while(at + 1 < N) {
						ans[at + 1] = K;
						at++;
					}
				}
			}
			else ans[at]--;
			// debug(vi(ans, ans + N), at);
		}
		rep(i, 0, N) {
			if(ans[i] == 0) break;
			cout << ans[i] << " ";
		}
		cout << "\n";
	}
}
 
uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}
 
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


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

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int mx = k - (a[n - 1] - a[0]);
	rep(i, n - 1) {
		mx = max(mx, a[i + 1] - a[i]);
	}
	cout << k - mx << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a[1000005];
int main()
{
	long long n,cnt=-1e9,sum=0;
	cin>>n;
	for(long long i=0;i<n;i++)
		cin>>a[i];
	cnt=a[0];
	for(long long i=1;i<n;i++)
	{
		if(a[i]>cnt)
			cnt=a[i];
		if(a[i]<cnt)
			sum+=abs(a[i]-cnt);
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;
int H, W;

signed main() {
  cin >> H >> W;
  vector<int> cnt(26);
  rep(i, H) {
    rep(j, W) {
      char a;
      cin >> a;
      cnt[a - 'a']++;
    }
  }
  int g1 = H & W & 1;  // 奇数のグループ(真ん中にある文字)
  int g2 = H % 2 * W / 2 + W % 2 * H / 2;  // 2(mod2)あるグループ
  int c1 = 0, c2 = 0;                      // 1, 2(mod2)のグループ

  for (int i = 0; i < 26; i++) {
    if (cnt[i] & 1) {
      c1++;
    }
    if (cnt[i] & 2) {
      c2++;
    }
  }

  if (c1 <= g1 && c2 <= g2) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   sort(a.begin(),a.end());
   cout<<a[n-1]-a[0];

return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("11");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("136");
            //46
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("100000");
            //90909
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);

        int Answer = 0;
        for (int I = 1; I <= N; I++) {
            if (DeriveKeta(I) % 2 == 1) Answer++;
        }
        Console.WriteLine(Answer);
    }

    static int DeriveKeta(int pInt)
    {
        if (pInt == 0) return 0;
        if (pInt < 10) return 1;
        if (pInt < 100) return 2;
        if (pInt < 1000) return 3;
        if (pInt < 10000) return 4;
        if (pInt < 100000) return 5;
        if (pInt < 1000000) return 6;
        return 7;
    }
}


Measured memory_bytes: 11348
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL calc(vector<pair<LL, LL> > &x) {
    sort(x.begin(), x.end());
    LL pop = 0;
    EACH (e, x) pop += e->second;

    LL cur = 0;
    REP (i, x.size()) {
	cur += x[i].second;
	if (cur * 2 >= pop) {
	    LL center = x[i].first;
	    LL ret = 0;
	    REP (j, x.size()) {
		ret += abs(x[j].first - center) * x[j].second;
	    }

	    return ret;
	}
    }

    assert(false);
}

int N;
LL X[15], Y[15], P[15];

LL base[1<<15];
LL cost[1<<15];

LL dp[16][1<<15];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld%lld%lld", X+i, Y+i, P+i);


    vector<pair<LL, LL> > xs, ys;
    REP (s, 1<<N) {
	
	xs.clear();
	ys.clear();
	LL pop = 0;
	LL sum = 0;
	REP (i, N) if (s>>i&1) {
	    LL d = min(abs(X[i]), abs(Y[i]));
	    sum += P[i] * d;
	    pop += P[i];

	    xs.emplace_back(X[i], P[i]);
	    ys.emplace_back(Y[i], P[i]);
	}
	base[s] = sum;

	if (s == 0) {
	    cost[s] = 0;
	} else {
	    cost[s] = min(calc(xs), calc(ys));
	}
    }

    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;

    REP (k, N) {
	REP (s, 1<<N) {
	    for (int sub=s; ; sub=(sub-1)&s) {
		int r = s ^ sub;
		amin(dp[k+1][s], cost[r] + dp[k][sub]);
		if (sub == 0) break;
	    }
	}
    }
    // rprintf("%lld", cost, cost+(1<<N));

    const int all = (1<<N)-1;
    REP (k, N+1) {
	// rprintf("%lld", dp[k], dp[k]+(1<<N));
	LL ans = 1LL<<60;
	REP (s, 1<<N) {
	    amin(ans, dp[k][s] + base[all^s]);
	}
	printf("%lld\n", ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 8352
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string str;
	cin >> str;
	int N = str.size();
	int ret = N;
	for (int i = 0; i < N-1; i++)
		if (str[i] != str[i + 1]) ret = min(ret, max(i + 1, N - i - 1));
	cout << ret << endl;
}

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

using namespace std;

int main(){

    int money = 0;
    cin >> money;
    int sum = 0;
    cin >> sum;
    bool answer = false;

    for (int i = 0; i <= money; i++) {
        for (int j = 0; j <= money - i; j++) {
            for (int k = 0; k <= money - (i + j); k++) {
                int temp = (k * 10000 + j * 5000 + i * 1000);
                int count = i + j + k;
                if ((sum - temp) == 0 && !answer && count == money) {
                    cout << k << ' ' << j << ' ' << i << endl;
                    answer = true;
                }
            }
        }
    }

    if (!answer) {
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str,num;
        int i;
        char a;
        int sum[] = new int[26];
        str = "";
        while(scan.hasNext()) {
            str += scan.nextLine();
        }
        StringBuilder sb = new StringBuilder();
        for ( i=0; i<str.length(); i++) {
            char c = str.charAt(i);
            if(Character.isUpperCase(c)){
                ++sum[c-65];
            }else if(Character.isLowerCase(c)){
                ++sum[c-97];
            }

        }
        for(i=0;i<26;i++){
            a = (char)(97+i);
            System.out.println(a+" : "+sum[i]);
        }

        scan.close();
    }

}



Measured memory_bytes: 26116
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,l,r,s,i;
  cin>>n;
  s=0;
  for (i=0;i<n;i++) {
    cin>>l>>r;
    s+=r-l+1;
  }
  cout<<s<<endl;
}


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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    if (s[k - 1] == 'A')
    {
        s[k - 1] = 'a';
    }
    else if (s[k - 1] == 'B')
    {
        s[k - 1] = 'b';
    }
    else
    {
        s[k - 1] = 'c';
    }
    cout << s << endl;

    

    return 0;
}


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

int n, w;
ll dp[105][1000000];
ll V[105], W[105];

ll solve(int i, ll p){
  if(i == n || p == 0)
    return 0;
  
  if(dp[i][p] != -1)
    return dp[i][p];
  
  if(W[i] > p)
    return dp[i][p] = solve(i + 1, p);
  
  return dp[i][p] = max(V[i] + solve(i + 1, p - W[i]), solve(i + 1, p));
}

int main()
{
    cin >> n >> w;

    memset(dp, -1, sizeof dp);

    for(int i = 0; i < n; i++)
      cin >> W[i] >> V[i];
    
    cout << solve(0, w) << endl;

    return 0;
}

Measured memory_bytes: 823916
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define lowbit(i) (i&(-i))
using namespace std;
const int maxn = 1e5+5;
int readint(){
	int x=0,f=1;char s=getchar();
	#define sc (s=getchar())
	while(s<'0'||s>'9'){
		if(s=='-')
			f=-1;
		sc;
	}
	while(s>='0'&&s<='9'){
		x=(x<<3)+(x<<1)+(s^48);
		sc;
	}
	#undef sc
	return x*f;
}
vector<int> g[maxn];
int h[maxn];
signed main (){
	int n=readint(),m=readint();
	for(int i=1;i<=n;i++)
		h[i]=readint();
	for(int i=1;i<=m;i++){
		int u=readint(),v=readint();
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		bool flag=0;
		for(int j=0;j<g[i].size();j++){
			int v=g[i][j];
			if(h[v]>=h[i]){
				flag=1;
				break;
			}
		}
		if(flag==0)
			ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 9100
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


        double r = sc.nextDouble();
        double x = Math.PI;
        System.out.printf("%06f",(r *r * x));
        System.out.print(" ");
        System.out.printf("%06f", r * 2 * x);
	}
}



Measured memory_bytes: 28492
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  string s,t; cin >> s >> t;
  char r[26], r2[26];
  rep(i, 0, 26){
    r[i] = -1;
    r2[i] = -1;
  }
  rep(i, 0, s.length()){
    r[s[i]-'a'] = t[i]-'a';
    r2[t[i]-'a'] = s[i]-'a';
  }
  bool isOk = true;
  rep(i, 0, s.length()){
    if(r[s[i]-'a']!=t[i]-'a') isOk = false;
    if(r2[t[i]-'a']!=s[i]-'a') isOk = false;
  }
  if(isOk)  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 998244353;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }


ll fact(ll n){
    if(n==0)return 1;
    else return n*fact(n-1)%MOD;
}
ll calc(ll n,ll k){
    if(k==0)return 1;
    ll m=n*n%MOD;
    if(k%2)return n*calc(m,k/2)%MOD;
    else return calc(m,k/2)%MOD;
}
ll comb(ll n,ll k){
    ll ret=fact(n);
    ret=ret*calc(fact(k),MOD-2)%MOD;
    ret=ret*calc(fact(n-k),MOD-2)%MOD;
    return ret;
}
ll p(ll a,ll b){
    ll ans = 1;
    for(ll i =0;i<b;i++){
        ans *=a;
        ans%=MOD;
    }
    return ans;
}

int main() {
    ll n;
    cin>>n;
    vector<ll> v(n);
    vector<ll> s(n);
    map<ll,ll> m;
    rep(i,n){
        cin>>v[i];
        m[v[i]]++;
    }

    ll ans = 1;
    bool f = true;
    sort(s.begin(),s.end());
    if(m[0]!=1||v[0]!=0)f=false;
    else{
        ll start = -1;
        ll pre = 1;
        for(auto &mm:m){
            start++;
            if(mm.first!=0) {
                if (start != mm.first) {
                    f = false;
                    break;
                } else {
                    ll c = mm.second;

                        ans = ans * p(pre,c);
                        ans%=MOD;

                    pre = c;
                }
            }
        }
    }
    if(f){
        cout<<ans%MOD<<endl;
    }else{
        cout<<0<<endl;
    }





    return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 86400

struct Info{
	int start,end;
	double per_amount;
};

int N;
double L;
Info info[NUM];


bool check(double add_water){

	double Tank = L;

	for(int i = 0; i < N; i++){
		Tank -= (info[i].per_amount-add_water)*(double)(info[i].end-info[i].start);
		Tank = min(L,Tank);
		if(Tank <= 0.0)return false;

		if(i < N-1){
			Tank += add_water*(info[i+1].start-info[i].end);
			Tank = min(Tank,L);
		}
	}

	Tank += add_water*(86400.0-(double)(info[N-1].end));
	Tank = min(L,Tank);

	double first_day = Tank;

	Tank += add_water*info[0].start;
	Tank = min(L,Tank);

	for(int i = 0; i < N; i++){
		Tank -= (info[i].per_amount-add_water)*(double)(info[i].end-info[i].start);
		Tank = min(L,Tank);
		if(Tank <= 0.0)return false;

		if(i < N-1){
			Tank += add_water*(info[i+1].start-info[i].end);
			Tank = min(Tank,L);
		}
	}

	Tank += add_water*(86400.0-(double)(info[N-1].end));
	Tank = min(L,Tank);

	return Tank >= first_day;

}


void func(){

	for(int i = 0; i < N; i++){
		scanf("%d %d %lf",&info[i].start,&info[i].end,&info[i].per_amount);
	}

	double left = 0,right = 1000000.0, m = (left+right)/2,ans = 1000000.0;

	while(right-left > EPS){
		if(check(m)){
			ans  = m;
			right = m-EPS;
		}else{
			left = m+EPS;
		}
		m = (left+right)/2;
	}

	printf("%.10lf\n",ans);
}

int main(){

	while(true){
		scanf("%d %lf",&N,&L);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 4524
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e5 + 9;

char ar[30];
ll dp[mxN];

void process(){
    string s = "abcdefghijklmnopqrstuvwxyz";
    for(int i=1; i <= 26; i++) ar[i] = s[i-1];
}

string calc(ll x){
    if( x == 0  ) return "";
    x--;
    //cout << x << " " << x%26 << " " << string(1,'a'+x%26) << endl;
    return calc(x/26) + string(1, 'a'+x%26);
}


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	process();
	ll n;
	cin >> n;
	cout << calc(n) << endl;
	//cout << string(2,'a') << " " << string(3,'d') << " " << string(3,'a'+2);





}


Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const int p =  856;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}



vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

mt19937 rnd(228);


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n;
    cin>>n;
    vector<int> a(n+1);
    for (int i = 1; i<=n; i++) cin>>a[i];
    vector<int> ans;
    for (int i = n; i>=1; i--)
    {
        int j = i;
        while (j>0&&a[j]!=j) j--;
        if (j==0) {cout<<-1; return 0;}
        ans.push_back(j);
        for (int k = j; k<i; k++) a[k] = a[k+1];
    }
    
    for (int i = n-1; i>=0; i--) cout<<ans[i]<<endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int N = 1e5 + 5;
vector<int> g[N];

vector<int> path;
bool rec(int curr, int prev, int target)
{
  if (curr == target) {
    path.push_back(curr);
    return true;
  }
  each (next, g[curr]) {
    if (next == prev) continue;
    if (rec(next, curr, target)) {
      path.push_back(curr);
      return true;
    }
  }
  return false;
}

int color[N];
void fn(int curr, int prev)
{
  if (color[curr] == 0) color[curr] = color[prev];
  each (next, g[curr]) {
    if (next == prev) continue;
    fn(next, curr);
  }
}

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

  int n;
  while (cin >> n) {
    fill(g, g + N, vector<int>());
    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);
    }

    path.clear();
    rec(0, 0, n - 1);
    reverse(path.begin(), path.end());
    // cout << path << endl;

    fill(color, color + N, 0);

    for (int i = 0; i < path.size(); ++i) {
      if (i < (path.size() + 1) / 2) color[path[i]] = 1;
      else color[path[i]] = 2;
    }
    fn(0, 0);
    fn(n - 1, n - 1);

    // for (int i = 0; i < n; ++i) {
    //   cout << i + 1 << ' ' << color[i] << endl;
    // }    
    
    int x = count(color, color + N, 1);
    int y = count(color, color + N, 2);
    // cout << make_pair(x, y) << endl;
    cout << (x > y ? "Fennec" : "Snuke") << endl;
  }

  return 0;
}


Measured memory_bytes: 12920
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] a) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] check = line.split(" ");
            int val1 = Integer.parseInt(check[0]);
            int val2 = Integer.parseInt(check[1]);
            int sum = val1 + val2;
            String str = String.valueOf(sum);
            System.out.println(str.length());
        }
    }
}

Measured memory_bytes: 24276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w;
    cin>>h>>w;
    
    vector<string> vs(h);
    rep(i,h)cin>>vs[i];
    
    vector<string> ans(h,string(w,' '));
    
    rep(i,h){
        rep(j,w){
            if(vs[i][j]=='#')ans[i][j] = '#';
            else{
                int c = 0;
                for(int dx = -1; dx<=1; dx++){
                    for(int dy=-1; dy<=1;dy++){
                        if(dx==0 && dy==0)continue;
                        int ddy = i+dy;
                        int ddx = j+dx;
                        if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)continue;
                        if(vs[ddy][ddx]=='#')c++;
                    }
                }
                ans[i][j] = '0'+c;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace MF
{
    class Program
    {
        static void Main(string[] args)
        {
            while (int.Parse(Console.ReadLine()) != 0 )
            {
                var c = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                var a = c.Average();
                Console.WriteLine("{0}", Math.Sqrt(c.Select(e => Math.Pow(e - a, 2)).Average()));
            }
        }
    }
}

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	int n;
	cin >> n;
	vpi v[n];
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		for(int j=0;j<a;j++){
			pi a1;
			cin >> a1.ff >> a1.ss;
			a1.ff--;
			v[i].push_back(a1);
		}
	}
	// for(auto row:v){
		// for(auto x:row){
			// cout << x.ff << ' ' << x.ss << '\n';
		// }
	// }
	ll ans=0;
	for(int x=0;x<(1LL<<(n));x++){
		bool ok = true;
		for(int i=0;i<n;i++){
			if(x&(1LL<<i)){
				for(auto y:v[i]){			
					bool a = y.ss;
					bool k = ((x&(1LL<<y.ff))>0);
					if(a!=k)ok = false;
					if(!ok){
						// cout << x? << ' ' << i << ' ';
						break;				
					}
				}
			}
			if(!ok)break;
		}
		if(ok){
			ans = max(ans,(ll)__builtin_popcount(x));
		}
	}
	cout << ans;
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  cout << max(a + b,max(a-b,a*b)) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int v[100005];
int main(){
  int n; cin >> n;
  for(int i = 0, x; i < n; ++i){
    cin >> x;
    v[x]++;
    v[x - 1]++;
    v[x + 1]++;
  }
  int ans = 0;
  for(int i = 1; i < 100005; ++i){
    ans = max(ans, v[i]);
  }
  cout << ans << endl;
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
       for(int j=0; j<n; j++){
          if(i*4+j*7==n){
            cout << "Yes" << endl;
            return 0;
          }
       }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652