akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

int n,x;
int a[51];
ll dp[51][51][2501];

ll solve(int ind, int num, int rem){
    if(num == 0){
        if(rem == 0){
            return 1;
        }
        else{
            return 0;
        }
    }
    if(ind > n){
        return 0;
    }
    if(rem < 0){
        return 0;
    }
    if(dp[ind][num][rem] != -1){
        return dp[ind][num][rem];
    }
    dp[ind][num][rem] = solve(ind+1, num, rem) + solve(ind+1, num-1, rem-a[ind]);
    return dp[ind][num][rem];
}

int main(){
    IOS

    cin>>n>>x;
    FOR(i,1,n+1){
        cin>>a[i];
    }
    FOR(i,0,51){
        FOR(j,0,51){
            FOR(k,0,2501){
                dp[i][j][k] = -1;
            }
        }
    }
    ll ans = 0;
    FOR(i,1,n+1){
        ans += solve(1, i, i*x);
    }
    cout<<ans;


    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

Measured memory_bytes: 51072
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = IntArray(n) { sc.nextInt() }

    var aa = a.reduce { acc, i ->
        acc or i
    } ?: 0


    var ret = 0
    var i = 0
    while ((aa and (1 shl i)) != 1 && aa > 0) {
        aa /= 2
        ret++
    }

    println(ret)

}

Measured memory_bytes: 31264
from collections import Counter

N,P=map(int,input().split())

if N == 1:
  print(P)
  exit()
  
if P == 1:
  print(1)
  exit()

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors, upper_divisors[::-1]

def factorize(n):
    out=[]
    i = 2
    while 1:
        if n%i==0:
            out.append(i)
            n //= i
        else:
            i += 1
        if n == 1:break
        if i > int(n**.5+3):
            out.append(n)
            break
    
    return out

F,_ = make_divisors(P)
C = Counter(factorize(P))
for f in reversed(F):
  if (P//f) % f == 0:
    c = Counter(factorize(f))
    ok=1
    for k in c.keys():
      if c[k]*N>C[k]:
        ok=0
        break
    if ok:
      print(f)
      exit()

Measured memory_bytes: 9748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int main(){
    int a,b;
    cin >> a >> b;
  if(a==1 && b!=1){
      cout << "Alice";
  }
  else if(b==1 && a!=1){
      cout << "Bob";
  }
  else if(a>b){
      cout << "Alice";
  }
  else if(b>a){
      cout << "Bob";
  }
  else{
      cout << "Draw";
  }
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[1006];
int main (){
	int n,m;	
	while(~scanf("%d%d",&n,&m)){
	    if(n<m){
	    	int t=0;t=m;m=n;n=t;
		}
		printf("%d",n-m+1);	
	}	 	  
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
	final static char[][] brackets = {{'(', ')'}, {'[', ']'}};
	static Scanner scan = new Scanner(System.in);
	
	Stack<Character> s;
	String input;
	int flag;	//????????????????????????????????°???
	
	Main(){
		s = new Stack<Character>();
		input = null;
		flag = 0;
	}
	
	public static void main(String[] args){
		while( new Main().Main() );
		return;
	}
	
	//???????????¶??????????????????false????????????
	boolean Main(){
		try{
			input = Main.scan.nextLine();
		}catch( NoSuchElementException nsee ){
			System.out.println("Error");
			return false;
		}
		//???????????¶?????§?????????
		if( input.length() == 1 ){ return false; }
		for( int i = 0; i < input.length(); i++ ){
			for( int j = 0; j < brackets.length; j++ ){
				if( input.charAt(i) == brackets[j][0] ){
					s.push(brackets[j][0]);
					break;
				}else if( input.charAt(i) == brackets[j][1] ){
					try{
						if( s.pop() != brackets[j][0] ){
							System.out.println("no");
							return true;
						}
					}catch( EmptyStackException ese ){
						//??????????????¬??§???????????????????????¬??§????????¨????????????
						System.out.println("no");
						return true;
					}
					break;
				}
			}
		}
		if( s.isEmpty() ){
			System.out.println("yes");
		}else{
			System.out.println("no");
		}
		return true;
	}
}

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

#define fori(i,a,b)    for(long long i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;


const int N = 1e5 + 5;
lli md = 1e9 + 7;
lli dp[105][N], a[105], n, k;


void solve(){
    cin>>n>>k;

    fori(i, 1, n)
    cin>>a[i];    

    dp[0][0] = 1;
    vector<int> pref(k+1, 0);

    fori(i, 1, n){
        pref.assign(k+1 ,0);
        pref[0] = dp[i-1][0];


        fori(ki, 1, k){
            pref[ki] = dp[i-1][ki] + pref[ki-1];
            pref[ki] %= md;
        }

        fori(ki, 0, k){
            dp[i][ki] = pref[ki] - (ki-a[i]-1 >= 0? pref[ki-a[i]-1]: 0);
            dp[i][ki] += md;
            dp[i][ki] %= md;
        }
    }

    cout<<dp[n][k];
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 79744
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 9999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int>pi;

/*---------------------------------------------------*/

int main(){
  int n,a[105];
  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {

  def solve(sc: => Scanner): Unit = {
    println(if ((sc.next * 2).contains(sc.next)) ("Yes") else ("No"))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 44932
n,m=map(int,input().split())
l=[input() for i in range(n)]
ml=[input() for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    for h in range(m):
      if ml[h]!=l[i+h][j:j+m]:break
    else:print("Yes");exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	int n; cin>>n;
	string s; cin>>s;
	vector <ll> forward(n), backward(n);
	forward[0] = 0;
	for (int i = 0; i <= n - 2; ++i)
	{
		forward[i + 1] = forward[i];
		if(s[i] == 'W')
			forward[i + 1]++;
	}
	backward[n - 1] = 0;
	for (int i = n - 1; i >= 1; --i)
	{
		backward[i - 1] = backward[i];
		if(s[i] == 'E')
			backward[i - 1]++;
	}
	ll answer = n - 1;
	for (int i = 0; i < n; ++i)
	{
		answer = min(answer, forward[i] + backward[i]);
	}
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 5396
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }

    let s_set = s .into_iter().collect::<std::collections::HashSet<_>>();
    println!("{}", if s_set.contains(&'a') && s_set.contains(&'b') && s_set.contains(&'c') {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll n;
double q[3000][3000];
double p[10000];
int main()
{
    IOS
    cin>>n;
    REP(i,n)
    {
        cin>>p[i+1];
    }
    double prod=1;

    q[0][0]=1;
    FOR(i,1,n+1,1)
    {
        prod*=0;
        q[0][i]=prod;
    }
    prod=1;
    REP(i,n)
    {
        prod*=p[i+1];
        q[i+1][0] = prod;
    }
    FOR(i,1,n+1,1)
    {
        FOR(j,1,i+1,1)
        {
            q[i][j] = p[i]*q[i-1][j] + (1-p[i])*q[i-1][j-1];
        }
    }
    // REP(i,n+1)
    // {
    //     REP(j,n+1)
    //     {
    //         cout<<q[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    double ans = 0;
    REP(i,(n-1)/2+1)
    {
        ans+=q[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 68992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int ki = (N / 2) + (N % 2);

        System.out.println((double)ki / (double)N);
    }
}


Measured memory_bytes: 21844
from math import factorial
n, a, b = map(int, input().split())
V = sorted(map(int, input().split()), reverse=True)

av = sum(V[:a]) / a
print(av)

def comb(m, k):
    ans = 1
    if k == 0:
        return 1
    else:
        for i in range(k):
            ans *= m - i
            ans //= i + 1
        return ans

num = V[a]
m = V.count(num)
k = V[:a].count(num)
#print(m, k, a)
if a != k:
    ans = factorial(m) // (factorial(k) * factorial(m - k))
else:
    #mCi(i:　a=>b)
    ans = 0
    for k in range(a, b+1):
        ans += comb(m, k)
print(ans)


Measured memory_bytes: 63108
#include<cstdio>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>

using namespace std;

typedef pair<int,long long> P;

const long long mod=1000000009;

vector<int> G[100100];
bool used[100100];
int N,M;

int dis[100100];
int base[100100];
int bfs(int v){
	queue<int> que;
	dis[v]=0;
	base[v]=v;
	que.push(v);
	int res=v;
	int cnt=0;
	while(!que.empty()){
		int cur=que.front();
		que.pop();
		cnt++;
		for(int i=0;i<G[cur].size();i++){
			int u=G[cur][i];
			if(used[u]) continue;
			if(base[u]==v&&dis[u]<=dis[cur]+1) continue;
			dis[u]=dis[cur]+1;
			base[u]=v;
			que.push(u);
			if(dis[u]==2){
				res=cur;
			}
		}
	}
	if(cnt==1) return -1;
	return res;
}

P solve(int v){
	int root=bfs(v);
//	printf("solve %d root=%d\n",v,root);
	if(root==-1){
		used[v]=true;
//		printf("end solve %d :1 1\n",v);
		return P(1,1);
	}
	used[root]=true;
	for(int i=0;i<G[root].size();i++){
		if(used[G[root][i]]) continue;
		base[G[root][i]]=-1;
	}
	int num=0;
	long long ways=1;
	for(int i=0;i<G[root].size();i++){
		if(used[G[root][i]]) continue;
		P p=solve(G[root][i]);
		num+=p.first;
		ways*=p.second;
		ways%=mod;
	}
	if(num==1){
		ways++;
		ways%=mod;
	}
//	printf("end solve %d: %d %d\n",v,num,ways);
	return P(num,ways);
}

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<N;i++){
		base[i]=-1;
	}
	int num=0;
	long long ways=1;
	for(int i=0;i<N;i++){
		if(used[i]==false){
			P p=solve(i);
			num+=p.first;
			ways=(ways*p.second)%mod;
		}
	}
	printf("%d\n%lld\n",num,ways);
	return 0;
}

Measured memory_bytes: 7404
const qaq=0.000000000000000001;
var
  n:longint;
  i:longint;
  a,b,x,ans:int64;
begin
  read(n);
  for i:=1 to n do
  begin
    read(a,b);
    if a=b then
    begin
      x:=a-1;
      writeln(x*2);
    end else
    begin
      x:=trunc(sqrt(a*b)+qaq);
      ans:=x*2;
      //writeln(x);
      if x=sqrt(a*b) then dec(ans);
      if x*(x+1)>=a*b then dec(ans);
      if (a<=x)or(b<=x) then dec(ans);
      //if (a=b+1)or(b=a+1) then dec(ans);
      writeln(ans);
    end;
  end;
end.


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

using namespace std;

long long inf=1000000007;

int main(){
	int h,n;
	cin>>h>>n;
	vector<pair<int,int>> m(n);
	for(int i=0;i<n;i++){
		cin>>m.at(i).first>>m.at(i).second;
	}

	vector<int> dp(h+1,inf);
	dp[0]=0;

	for(int i=0;i<h;i++){
		for(int j=0;j<n;j++){
			dp.at(min(i+m.at(j).first,h))=min(dp.at(min(i+m.at(j).first,h)),dp.at(i)+m.at(j).second);
		}
	}

	cout<<dp.at(h)<<endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
};

#[fastout]
fn main() {
    input! {
        mut n: i64,
    }
    let mut ans = String::new();
    while n > 0 {
        n -= 1;
        let b = (n % 26) as u8;
        ans.push((b'a' + b) as char);
        n -= b as i64;
        n /= 26;
    }
    println!("{}", ans.chars().rev().collect::<String>());
}


Measured memory_bytes: 2148
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;

int main()
{
    long long t, i, j, k = 2, h, w, n, ch, ch1, count = 0, prev_left, prev_right, m;
    cin >> n;
    long long* arr = new long long[n];
    for (i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    long long ans = arr[n - 1];
    for (i = 2; i < n; i++){
        if (k == n)
            break;
//        cout << ans << " " << arr[n - i] << " " << n - i << endl;
        ans += arr[n - i];
        k++;
        if (k < n) {
//            cout << ans << " " << arr[n - i] << " " << n - i << endl;
            ans += arr[n - i];
            k++;
        }
        else
            i = n + 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
const int INF = 1e18 + 7;
int a[N], b[N];
int pref[N];
vector <int> pos[N];
signed main() {
    #ifdef HOME
        freopen("input.txt", "r", stdin);
    #else 
        ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    vector <pair <int, int> > c;
    for (int i = 0; i < n; ++i) {
        c.push_back({a[i], i}); c.push_back({b[i], i});
    }   
    sort(c.begin(), c.end());
    for (int i = 0; i < (int)c.size(); ++i) {
        pos[c[i].second].push_back(i);
    }
    for (int i = 0; i < (int)c.size(); ++i) {
        pref[i + 1] = pref[i] + c[i].first;
    }   
    int suma = 0, sumb = 0;
    for (int i = 0; i < n; ++i) {
        suma += a[i];
        sumb += b[i];
    }   
    int ans = min(suma, sumb);
    for (int i = 0; i < n; ++i) {
        int t = c[pos[i][0]].first + c[pos[i][1]].first;
        if (pos[i][0] >= n - 2) {
            ans = min(ans, t + pref[n - 2]);
        }
        else if (pos[i][1] - 1 >= n - 2) {
            ans = min(ans, t + pref[n - 2 + 1] - c[pos[i][0]].first);
        }
        else {
            ans = min(ans, t + pref[n - 2 + 2] - t);
        }   
    }
    cout << ans << '\n'; 
}   

Measured memory_bytes: 15980
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const lines_array = lines[0].split(" ").map(x => Number(x))
  if (lines_array[0] == lines_array[1]) {
    console.log("Yes")   
  } else {
    console.log("No")
  }
});

Measured memory_bytes: 21320
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
// #include <cctype>

#define INF -1

using namespace std;

typedef vector<double> Vector;
typedef valarray<double> Vec_valarr;


double Minkowski(const Vector & x, const Vector & y, int p);
void input(Vec_valarr & vec, int n);
double Minkowski(const Vec_valarr & vec_x, const Vec_valarr & vec_y, double p);


int main()
{





    //method 1
    // int n;
    // cin >> n;

    // Vector x(n), y(n);

    // int i = 0;
    // while (i < n)
    //     cin >> x[i++];

    // i = 0;
    // while (i < n)
    //     cin >> y[i++];

    // int p = 0;
    // while (p++ < 3)
    //     cout << fixed << Minkowski(x, y, p) << endl;
    // cout << Minkowski(x, y, INF) << endl;


    //method 2
    // Vec_valarr vec_x, vec_y;

    // int n;
    // cin >> n;

    // input(vec_x, n);
    // input(vec_y, n);

    // int p = 0;
    // while (p++ < 3)
    //     cout << fixed <<Minkowski(vec_x, vec_y, p) << endl;
    // cout << Minkowski(vec_x, vec_y, INFINITY) << endl;


    //method 3
    Vec_valarr vec;

    int n; 
    cin >> n;
    vec.resize(n);

    int i = -1;
    while (++i < 2*n)
    {
        double temp;
        cin >> temp;
        vec[i%n] = temp - vec[i%n];
    }
    vec = abs(vec);

    double p = 0;
    while (p++ < 3)
        cout << fixed << pow(pow(vec, p).sum(), 1/p) << endl;
    cout << vec.max() << endl;
}


double Minkowski(const Vector & x, const Vector & y, int p)
{
    if (x.size() != y.size())
        return NAN;

    Vector intermediate;
    int i = 0;    
    while (i < x.size())
    {
        intermediate.push_back(abs(x[i]-y[i++]));
    }     


    double distance;

    if (p != INF)
    {
        i = 0;
        double sum = 0;        
        while (i < x.size())
        {
            sum += pow(intermediate[i++], p);            
        }
        distance = pow(sum, 1./p);
    }
    else
    {
        distance = *max_element(intermediate.begin(), intermediate.end());
    }

    return distance;

}



void input(Vec_valarr & vec, int n)
{
    vec.resize(n);

    int i = 0;
    while (i < n)
        cin >> vec[i++];
}

double Minkowski(const Vec_valarr & vec_x, const Vec_valarr & vec_y, double p)
{
    Vec_valarr intermediate;
    intermediate = abs(vec_x-vec_y);
    if (p != INFINITY)
        return pow(pow(intermediate, p).sum(), 1/p);    
    else
        return intermediate.max();
    
}


Measured memory_bytes: 3420
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>

using namespace std;

void pstr_fw(int num, char* str){
	for(int i = 0; i < num; ++i){
		cout << str[i];
	}
}
void pstr_bk(int num, char* str){
	for(int i = num - 1; i >= 0; --i){
		cout << str[i];
	}
}

int main(void){
	int q, t, f;
	char c;
	char s[100000], before[200000], after[200000];
	int rev_num = 0, bef_len = 0, aft_len = 0;

	cin >> s >> q;

	for(int i = 0; i < q; ++i){
		cin >> t;
		if(t == 1){
			++rev_num;
		}else{
			cin >> f >> c;
			if((f + rev_num) % 2 == 1){
				before[bef_len++] = c;
			}else{
				after[aft_len++] = c;
			}
		}
	}

	if(rev_num % 2 == 0){
		pstr_bk(bef_len, before);
		cout << s;
		pstr_fw(aft_len, after);
	}else{
		pstr_bk(aft_len, after);
		int s_len = strlen(s);
		pstr_bk(s_len, s);
		pstr_fw(bef_len, before);
	}
	cout << endl;
}


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

using ll = long long;
using pll = pair<ll, ll>;
 
constexpr ll M = 1e9+7;

const string w = "01+-*()";

constexpr int mi = 0;
constexpr int ma = 1023;

bool isrange(int n) {
    return mi <= n && n <= ma;
}

int expr(string const& s, int& p);
int term(string const& s, int& p);
int factor(string const& s, int& p);
int number(string const& s, int& p);

int expr(string const& s, int& p) {
    int res = term(s, p);
    while(p < s.size() && (s[p] == '+' || s[p] == '-')) {
        if(s[p] == '+') {
            res += term(s, ++p);
        } else if(s[p] == '-') {
            res -= term(s, ++p);
        }
        if(!isrange(res)) {
            throw runtime_error("");
        }
    }
    return res;
}

int term(string const& s, int& p) {
    int res = factor(s, p);
    while(p < s.size() && s[p] == '*') {
        res *= factor(s, ++p);
        if(!isrange(res)) {
            throw runtime_error("");
        }
    }
    return res;
}

int factor(string const& s, int& p) {
    if(isdigit(s[p])) {
        return number(s, p);
    }
    if(s[p] == '-') {
        int res = -factor(s, ++p);
        if(!isrange(res)) {
            throw runtime_error("");
        }
        return res;
    } else if(s[p] == '(') {
        int res = expr(s, ++p);
        if(p < s.size() && s[p] != ')') {
            throw runtime_error("");
        }
        ++p;
        return res;
    } else {
        throw runtime_error("");
    }
}

int number(string const& s, int& p) {
    int res = 0;
    while(p < s.size() && isdigit(s[p])) {
        res <<= 1;
        res |= s[p] == '1';
        ++p;
    }
    if(!isrange(res)) {
        throw runtime_error("");
    }
    return res;
}

bool check(string const& s) {
    stack<int> st;
    vector<vector<bool>> par(s.size(), vector<bool>(s.size()));
    bool ok = true;
    for(int i=0; i<s.size(); ++i) {
        if(s[i] == '(') {
            st.push(i);
        }
        if(s[i] == ')') {
            if(st.empty()) {
                ok = false;
                break;
            }
            if(s[st.top()+1] == '(' && s[i-1] == ')' && par[st.top()+1][i-1]) {
                ok = false;
                break;
            }
            par[st.top()][i] = true;
            bool f = false;
            for(int j=st.top()+1; j<i; ++j) {
                f |= !isdigit(s[j]);
            }
            st.pop();
            ok &= f;
        }
    }
    return st.empty() && ok;
}

int solve(int i, string& s, vector<int> const& lost) {
    int res = -1;
    if(i == lost.size()) {
        try {
            int p = 0;
            if(check(s)) {
                res = expr(s, p);
            }
            return (p == s.size() ? res : -1);
        } catch(...) {
            return -1;
        }
    }
    for(int j=0; j<w.size(); ++j) {
        s[lost[i]] = w[j];
        res = max(res, solve(i+1, s, lost));
    }
    return res;
}

int main() {
    string s;
    cin >> s;
    vector<int> pos;
    for(int i=0; i<s.size(); ++i) {
        if(s[i] == '.') {
            pos.push_back(i);
        }
    }
    cout << solve(0, s, pos) << endl;
}

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

int main(){
    using namespace std;
    unsigned long N, Q;
    cin >> N >> Q;
    vector<vector<unsigned long>> edge(N);
    vector<unsigned long> weight(N);
    for(unsigned long i = 1, a, b; i < N; ++i){
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }
    for(unsigned long i = 0, p, x; i < Q; ++i){
        cin >> p >> x;
        weight[p - 1] += x;
    }
    [rec = [&edge, &weight](auto f, auto now, auto prev) -> void{
        for(const auto& i : edge[now]){
            if(i != prev){
                weight[i] += weight[now];
                f(f, i, now);
            }
        }
    }](auto start){rec(rec, start, start);}(0);
    copy(weight.begin(), weight.end(), ostream_iterator<unsigned long>(cout, " "));
    return 0;
}

Measured memory_bytes: 22528
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        List <String> sList = new LinkedList<>(Arrays.asList(t.split("")));
        List <String> tList = new LinkedList<>(Arrays.asList(s.split("")));
        int flag = 0;
        int n = tList.size();
        for(int i = 0; i < n; i++){
            String a = tList.remove(n-1);
            tList.add(0,a);
            if(tList.equals(sList)){
                flag = 1;
                break;
            }
        }
        if(flag == 1) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>

using namespace std;
int dp[100050]={};
int num(int a){
    if(a<0)return -a;
    else return a;
}
int min1(int a,int b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;
    cin>>n;
    vector<int> h(n+5);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=num(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min1(dp[i-1]+num(h[i]-h[i-1]),dp[i-2]+num(h[i]-h[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
struct Combination {
    m: usize,
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
}

impl Combination {
    fn new(n: usize, m: usize) -> Combination {
        let mut fact = vec![0; n + 1];
        let mut inv_fact = vec![0; n + 1];
        fact[0] = 1;
        for i in 1..=n {
            fact[i] = fact[i - 1] * i % m;
        }
        inv_fact[n] = Self::pow(fact[n], m - 2, m);
        for i in (1..=n).rev() {
            inv_fact[i - 1] = inv_fact[i] * i % m;
        }

        Combination { m, fact, inv_fact }
    }

    fn pow(mut a: usize, mut n: usize, m: usize) -> usize {
        let mut res = 1;
        while n > 0 {
            if n & 1 > 0 {
                res = res * a % m;
            }
            a = a * a % m;
            n >>= 1;
        }
        res
    }
    
    fn c(&self, n: usize, r: usize) -> usize {
        if n < r { return 0; }
        let tmp = self.inv_fact[n - r] * self.inv_fact[r] % self.m;
        self.fact[n] * tmp % self.m
    }
}

fn main() {
    const MOD: usize = 1_000_000_007;

    let k: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let n = s.len();
    let m = k + n;

    let combination = Combination::new(m, MOD);

    let mut ans = 0;
    for i in n..=m {
        let mut res = 1;
        res = res * combination.c(i - 1, n - 1) % MOD;
        res = res * Combination::pow(25, i - n, MOD) % MOD;
        res = res * Combination::pow(26, m - i, MOD) % MOD;
        ans = (ans + res) % MOD;
    }
    println!("{}", ans);
}

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

int main(){
    int price;
    cin >> price;
    if(!price) return 0;
    while(true){
        int a, b, c, d;
        int e, f, g, h;
        int m, n, o, p;
        int change=0;
        int sum = 100;
        cin >> a >> b >> c >> d;
        for(int i=0;i<=a;++i){
            for(int j=0;j<=b;++j){
                for(int k=0;k<=c;++k){
                    for(int l=0;l<=d;++l){
                        if(i*10+j*50+k*100+l*500<price) continue;
                        else{
                            change = i*10+j*50+k*100+l*500-price;
                            h = change/500;
                            change %= 500;
                            g = change/100;
                            change %= 100;
                            f = change/50;
                            change %= 50;
                            e = change/10;
                            if((i&&e)||(j&&f)||(k&&g)||(l&&h)) continue;
                            if(a+b+c+d+e+f+g+h-i-j-k-l<sum){
                                sum = a+b+c+d+e+f+g+h-i-j-k-l;
                                m=i;
                                n=j;
                                o=k;
                                p=l;
                            }
                        }
                    }
                }
            }
        }
        if(m) cout << "10 " << m << endl;
        if(n) cout << "50 " << n << endl;
        if(o) cout << "100 " << o << endl;
        if(p) cout << "500 " << p << endl;
        cin >> price;
        if(!price) break;
        cout << endl;
    }
}

Measured memory_bytes: 1164
N,M=map(int,input().split())
A=[input() for i in range(N)]
B=[input() for i in range(M)]
judge=any([line[j:j+M] for line in A[i:i+M]]==B for i in range(N-M+1) for j in range(N-M+1))
print("Yes" if judge else "No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

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

    string R = N;
    reverse(R.begin(), R.end());

    REP(0, i, N.length()) {
        if (N[i] != R[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = [0] * 3
for i in range(n):
    if a[i] % 4 == 0:
        count[2] += 1
    elif a[i] % 2 == 0:
        count[1] += 1
    else:
        count[0] += 1

ans = False

if count[0] + (count[1] % 2) <= count[2] + 1:
    ans = True

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int arr[100010];
string S[100010];
set<string> words;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int n = s.size();
    for (int i = 0; i < n; ++i)
    {
        if (i + 5 <= n && s.substr(i, 5) == "maerd")
        {
            i += 4;
        }
        else if (i + 5 <= n && s.substr(i, 5) == "esare")
        {
            i += 4;
        }
        else if (i + 7 <= n && s.substr(i, 7) == "remaerd")
        {
            i += 6;
        }
        else if (i + 6 <= n && s.substr(i, 6) == "resare")
        {
            i += 5;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
using namespace std;

char s[200010];
int n, l, r, ans;

int main() {
    scanf("%d%s", &n, s);
    r = strlen(s), r--;
    while (l < r) {
        while (l < r && s[l] == 'R') l++;
        while (l < r && s[r] == 'W') r--;
        if (l < r) ans++, l++, r--;
    }
    printf("%d", ans);
}


Measured memory_bytes: 1924
//  Created by conan1024hao on 2019/11/16.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    string s;
    cin>>s;
    int j=0;
    if(n%2!=0)
        cout<<"No"<<endl;
    else{
        bool abc=1;
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2])
                abc=0;
        }
        if(abc==0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    N%=10;

    switch(N){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;
        case 3:
            cout<<"bon"<<endl;
            break;
    }

    return 0;
}

Measured memory_bytes: 3620
N, A, B = gets.split(' ').map{|n| n.to_i}
total = 0
N.times do |i|
  n = (i + 1).to_s.to_s.split('').map{|n| n.to_i}.inject(:+)
  total += i + 1 if n >= A && n <= B
end
print total

Measured memory_bytes: 2044
//nlrx
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int t=111;t<=999;t+=111)
    {
    	if(t>=n)
    	{
    		cout<<t;
    		return 0;
		}
	}
}
//※ at most 512 KiB
//※ Your source code will be saved as Main.extension.
//I __________win!
//  am going to!

Measured memory_bytes: 3520
#include<iostream>
#include<string>
#include<vector>

int main(){
  std::string s;
  std::cin >> s;
  std::vector<int> result;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '0') result.push_back(0);
    else if(s.at(i) == '1') result.push_back(1);
    else{
      if(result.size() == 0) continue;
      else result.pop_back();
    }
  }
  for(int i = 0; i < result.size(); i++) std::cout << result.at(i);
  std::cout << std::endl;
}

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

inline ll mpow(ll x, ll n, ll mod) {
    ll r = 1;
    while (n > 0) {
        if (n & 1) r = r * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return r;
}

inline ll inv(ll a, ll mod) {
    return mpow(a, mod - 2, mod);
}

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

    int n;
    cin >> n;
    ll mod = 1e9 + 7;
    map<ll, ll> ds;
    vector<ll> a(n);
    rep(i, 0, n) {
        cin >> a[i];
        ll x = a[i];
        map<ll, ll> sub;
        for (ll j = 2; j * j <= x; j++) {
            while (x % j == 0) {
                x /= j;
                sub[j]++;
            }
        }
        if (x != 1) sub[x]++;
        for (auto z : sub) {
            ds[z.first] = max(ds[z.first], sub[z.first]);
        }
    }

    ll l = 1;
    for (auto z : ds) {
        l *= mpow(z.first, z.second, mod);
        l %= mod;
    }
    ll ans = 0;
    rep(i, 0, n) {
        ans += l * inv(a[i], mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())

t = {}
for i in range(1, N + 1):
    t[i] = int(input())

i = 1
result = 1
while True:
    if t[i] == -1:
        print(-1)
        exit()
    if t[i] == 2:
        print(result)
        exit()
    result += 1
    j = t[i]
    t[i] = -1
    i = j

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll k, x; cin >> k >> x;

    rep(i, 2*k-1) cout << x-k+i+1 << " ";
    cout << endl;


    return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int K, X;
  cin >> K >> X;
  int p = max(X - K + 1, -1000000);
  int q = min(X + K - 1,  1000000);
  for (int i = p; i <= q; i++) {
    if (i > p)  cout << " ";
    cout << i;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  string S,T;
  int x = 0;
  cin >> S;
  cin >> T;
  if(S.size() + 1 != T.size()){
    x = 1;
  }
  for(int i = 0;i < S.size();i++){
    if(S.at(i) != T.at(i)){
      x = 1;
    }
  }
  if(x == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> a(n);
        int ave = 0;
        for(int i = 0 ; i < n ; ++i){
            cin >> a[i];
            ave += a[i];
        }
        ave /= n;
        int ans = 0;
        for(int i = 0 ; i < n ; ++i){
            ans += a[i] <= ave;
        }

        cout << ans << endl;
    }
}


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

signed main(){
  
  int n, m, d;
  
  cin>>n>>m>>d;
  
  double ans = 2.0 * ( n - d ) * ( m - 1 ) / ( n * n );
  
  if( d == 0 ) ans /= 2.0;
  
  printf("%.8f\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    ll ans=INT_MAX,diff=0;
    ll n=s.size(),k=t.size();
    for(ll i=0;i<=(n-k);i++)
    {
        diff=0;
        for(ll j=0;j<k;j++)
        {
            if(s[i+j]!=t[j])
            {
                diff++;
            }
        }
        ans=min(ans,diff);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3664
def resolve():
    n = int(input())
    A = list(map(int,input().split()))
    ans = [0]* n
    for i in range(n-1):
        joushi = A[i]
        ans[joushi-1] += 1
    
    for i in range(n):
        print(str(ans[i]))
 
resolve()

Measured memory_bytes: 32220
#include<cstdio>
#include<cstring>
using namespace std;
const long long mod=1e9+7;
char s[105];
int k;
int digit[105];
long long f[105][5];
long long dfs(int pos,int num,bool res){
	if (num>k) return 0;
	if (pos==0&&num==k) return 1;
	if (!res&&f[pos][num]!=-1) return f[pos][num];
	int maxn=res?digit[pos]:9;long long ans=0;
	for (register int i=0;i<=maxn;++i){
		if (i==0) ans=(ans+dfs(pos-1,num,res&&i==maxn))%mod;
		else ans=(ans+dfs(pos-1,num+1,res&&i==maxn))%mod;
	}
	if (!res) f[pos][num]=ans;
	return ans;
}
int main(){
	memset (f,-1,sizeof (f));
	scanf ("%s",s+1);scanf ("%d",&k);
	int len=strlen(s+1);
	int w=len;
	digit[0]=0;
	while (digit[0]<=len){++digit[0];digit[digit[0]]=s[w]-'0';--w;}
	printf ("%lld\n",dfs(digit[0]-1,0,1));
	return 0;
}

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

vector<ll> p(55), a(55);

ll f(ll n, ll x){
    if(n == 1){
        if(x == 0) return 0;
        if(x > 0) return min(x-1, (ll)3);
    } 
    if(x < a[n-1]+2) return f(n-1, x-1);
    if(x == a[n-1] + 2) return p[n-1]+1;
    if(x > a[n-1] + 2){
        return p[n-1]+1 + f(n-1, x - a[n-1] - 2);
    }
    return 0;
}

int main(){
    ll n, x;
    cin >> n >> x;
    p[0] = 1; a[0] = 1;
    rep(i, n + 3){
        p[i+1] = 2*p[i] + 1;
        a[i+1] = 2*a[i] + 3;
    }
    cout << f(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,x;
    bool ok=true;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        if(x%2==0){
            if(x%3!=0 && x%5!=0)
                ok=false;
        }
    }
    if(ok)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}

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

int n,m,v,p,a[100010];

bool calc(int mid,ll cnt=0){
    int x=a[mid]+m;
    if(a[p-1]>x)return false;
    cnt+=(ll)(p-1)*m;
    cnt+=(ll)(n-mid)*m;
    for(int i=p-1; i<=mid-1; ++i){
        cnt+=min(m,max(0,x-a[i]));
    }
    return cnt>=(ll)m*v;
}

int main(){
    cin>>n>>m>>v>>p;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    int l=0,r=n;
    while(r-l>1){
        int mid=(l+r)/2;
        if(calc(mid))l=mid;
        else r=mid;
    }
    //1-indexedに修正
    cout<<l+1<<endl;
}

Measured memory_bytes: 4004