akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            string s = Console.ReadLine();
            long ans = 0;
            for(var i = 0; i < s.Length; i++)
            {
                for (var j = 1; j <= s.Length - i; j++) 
                {
                    string sub = s.Substring(i, j);
                    bool ok = true;
                    for(var k = 0; k < sub.Length; k++)
                    {
                        ok &= (sub[k] == 'A' || sub[k] == 'C' || sub[k] == 'G' || sub[k] == 'T');
                    }
                    if (ok)
                    {
                        ans = Max(ans, sub.Length);
                    }
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        
        
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long Modulo(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}


Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	long long n;
	cin >> n;
	long long a[100010][3];
	REP(i,n) REP(j,3) cin >> a[i][j];
	
	long long dp[100010][3];
	
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i=1; i<n; ++i){
		dp[i][0]=0; dp[i][1]=0; dp[i][2]=0;
		chmax(dp[i][0], dp[i-1][1]+a[i][0]);
		chmax(dp[i][0], dp[i-1][2]+a[i][0]);
		
		chmax(dp[i][1], dp[i-1][0]+a[i][1]);
		chmax(dp[i][1], dp[i-1][2]+a[i][1]);
		
		chmax(dp[i][2], dp[i-1][0]+a[i][2]);
		chmax(dp[i][2], dp[i-1][1]+a[i][2]);
	}
	
	cout << max(dp[n-1][0],max(dp[n-1][1], dp[n-1][2])) << endl;
	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int64_t k;
    cin >> k;
    int n = S.size();
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        A[i] = S[i] - 'a';
    int m = 26;
    for (auto &a: A){
        if (a == 0)
            continue;
        if (m - a <= k){
            k -= m - a;
            a = 0;
        }
    }
    A[n - 1] += k;
    A[n - 1] %= m;
    for (const auto &a: A)
        cout << char('a' + a);
    cout << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll l = 2, r = 3;
    Rrep(i,N){
        ll nl = (l + a[i] - 1) / a[i], nr = (r - 1) / a[i];
        if(nl > nr) {
            cout<<-1<<endl;
            return 0;
        }else{
            l = nl * a[i];
            r = (nr + 1) * a[i];
        }
    }
    cout<<l<<' '<<r - 1<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int  H, W, N;
    cin >> H >> W >> N;
    vector<pair<int, int>> cs;
    rep(i, N){
        int x, y;
        cin >> y >> x;
        for(int i = max(1, y - 2); i <= min(H - 2, y); i ++){
            for(int j = max(1, x - 2); j <= min(W - 2, x); j ++){
                pair<int, int> c = {j, i};
                cs.push_back(c);
            }
        }
    }

    sort(cs.begin(), cs.end());

    vector<ll> num(10);
    for(int i = 0; i < cs.size(); ){
        int cnt = 1;
        for(ll j = i + 1; j < cs.size(); j ++){
            if(cs[i].first == cs[j].first && cs[i].second == cs[j].second){
                cnt ++;
            }else{
                break;
            }
        }
        num[cnt] ++;
        i += cnt;
    }

    num[0] = 1L * (H - 2) * (W - 2);

    for(int i = 1; i < num.size(); i ++){
        num[0] -= num[i];
    }

    rep(i, num.size()){
        cout << num[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 10476
def main():
    N, W = map(int, input().split())
    Ws = []
    Vs = []
    for _ in range(N):
        w, v = map(int, input().split())
        Ws.append(w)
        Vs.append(v)
    mv = sum(Vs)
    dp = [[float('INF')] * (mv + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(mv + 1):
            if Vs[i] > j:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = min(dp[i][j], dp[i][j - Vs[i]] + Ws[i])
    for j in range(mv, -1, -1):
        if W >= dp[N][j]:
            print(j)
            break


main()


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

int main(){


  vector<int> data(3);
  
  cin>>data.at(0);
  cin>>data.at(1);
  cin>>data.at(2);
  
  sort(data.begin(),data.end());
  
  cout<<data.at(0)*data.at(1)/2<<endl;
  
  
    

  
}
  













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

using namespace std;

typedef long long ll;

int main(){
  int N,K;
  int d[111];
  int a;
  int m[111] = {0};
  cin >> N >> K;
  int i,k;
  for(i=1;i<=K;i++){
    cin >> d[i];
    for(k=1;k<=d[i];k++){
      cin >> a;
      m[a] = 1;
    }
    }
  int ans = N;
  for(i=1;i<=N;i++)
    ans -= m[i];
  cout << ans << endl;
}

Measured memory_bytes: 3632
until (n = $<.gets.to_i).zero?
  buildings = n.times.map {$<.gets.split.map(&:to_i)}
  sg = $<.gets.to_i.times.map {$<.gets.split.map(&:to_i)}
  table = Hash.new {|h, k| h[k] = {}}
  buildings.combination(2) do |a, b|
    ida, xa, ya = a
    idb, xb, yb = b
    dist = (xa - xb) ** 2 + (ya - yb) ** 2
    next if dist > 50 ** 2
    table[ida][idb] = Math.sqrt(dist)
    table[idb][ida] = Math.sqrt(dist)
  end
  h = table.map {|k, v| [k, v.keys]}.to_h
  
  sg.each do |s, g|
    shortest = Hash.new(Float::INFINITY)
    pred = {}
    done = h.keys.map {|k| [k, false]}.to_h
    shortest[s] = 0
    
    loop do
      u = nil
      h.each_key do |node|
        next if done[node]
        u = node if !u or shortest[node] < shortest[u]
      end
      break unless u
      done[u] = true
      
      h[u].each do |v|
        if (a = shortest[u] + table[u][v]) < shortest[v]
          shortest[v] = a
          pred[v] = u
        end
      end
    end
    
    result = if pred[g]
      order = []
      while g
        order.unshift(g)
        g = pred[g]
      end
      order.join(" ")
    else
      "NA"
    end
    puts result
  end
end


Measured memory_bytes: 6932
import math
a, b, x = map(int, input().split())
capacity = a**2 * b

if x > capacity/2:
  nokori = capacity - x
  teihen =  nokori / a * 2 / a
  tan = teihen / a
  degree = math.atan(tan)
  ans = math.degrees(degree)
else:
  teihen =  x / a * 2 / b
  tan = b / teihen
  degree = math.atan(tan)
  ans = math.degrees(degree)

print(ans)

Measured memory_bytes: 3060
//114_c
#include <stdio.h>

typedef long long ll;

ll s,N,ans=0;

ll list(ll n,ll a,ll b,ll c){
    if(n>N)return ans;
    if(a>0&&b>0&&c>0)ans++;
    list(n*10+3,a+1,b,c);
    list(n*10+5,a,b+1,c);
    list(n*10+7,a,b,c+1);
}

int main(void){
    scanf("%lld",&N);
    if(N<357){
        printf("0\n");
        return 0;
    }
    printf("%lld\n",list(0,0,0,0));
    return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		double tall,max,min;
		
		tall = max = min = sc.nextDouble();
		
		while(sc.hasNextDouble()){
			tall = sc.nextDouble();
			if(max < tall) max = tall;
			if(min > tall) min = tall;
		}
		
		System.out.println(max - min);
	}

}

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

using namespace std;


int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M = [int(x) for x in input().strip().split()]
X = sorted([int(x) for x in input().strip().split()])
D = [0] * (M - 1)
d = X[0]
if N >= M:
    print(0)
    exit()

for i, x in enumerate(X[1:]):
    D[i] = x - d
    d = x

print(sum(sorted(D, reverse=True)[(N-1):]))

Measured memory_bytes: 13832
#include <iostream>

using namespace std;

int main(){
    int N;
    cin>>N;
    int P[N];
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    int count=0;
    int PMin[N];
    PMin[0]=P[0];
    for(int i=0;i<N;i++){
        
        if(PMin[i]>=P[i]){
            if(i<N-1)PMin[i+1]=P[i];
            count++;
        }else{
            if(i<N-1)PMin[i+1]=PMin[i];
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int b=0;
	string a;
	cin>>a;
	for (int i=0;i<a.length();i++)
	{
		if (a[i]=='C')
		{
			b=1;
		}
		if (b==1&&a[i]=='F')
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
}

Measured memory_bytes: 256
n, k = map(int, input().split())
nums = list(map(int, input().split()))

ans =  sum(nums[:k])
pre_sum = ans

for i in range(0, len(nums) - k):
    pre_sum -= nums[i]
    pre_sum += nums[i + k]
    ans = max(pre_sum, ans)
print((ans + k) / 2)


Measured memory_bytes: 71792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  char c;
  cin >> c;
  cout << char(c + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int w,n,i;
	int a[31],b[31],suu[31];
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=1;i<=w;i++) suu[i]=i;
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a[i],&b[i]);
	}
	for(i=1;i<=n;i++) swap(suu[a[i]],suu[b[i]]);
	for(i=1;i<=w;i++) printf("%d\n",suu[i]);
	return 0;
}

Measured memory_bytes: 1024
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;


char A[4][4];

int main()
{
	for(int i = 0; i < 3; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> A[i][j];
		}
	}

	cout << A[0][0] << A[1][1] << A[2][2];
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    d = LMIIS()
    sum_r = 0
    for i in range(N):
        for j in range(i+1,N):
            sum_r += d[i] * d[j]
    print(sum_r)


if __name__ == '__main__':
    main()

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

typedef long long ll;
const ll InF = 1e15;
// ll mod = 1000000007;

int solve(int i, int a, int b) {
  return min(a, (b - 100) / (100 * i) + 1 );
}

int main() {
  int d,g;
  cin>>d>>g;
  vector<pair<int,int>> ps(11);
  for (int i = 0; i < d; i++) cin>>ps[i].first>>ps[i].second;
  int ans = 1e9;
  for (int i = 0; i < 1 << d; i++) {
    int res,tmp,res_max;
    bool ok = true;
    res = tmp = 0;
    for (int k = 0; k < d; k++) {
      if ((i >> k) & 1) res += ps[k].first, tmp += ps[k].first * (k + 1) * 100 + ps[k].second;
      else res_max = k;
    }
    if (tmp < g) {
      int res2 = solve(res_max + 1, ps[res_max].first, g - tmp);
      if (res2 == ps[res_max].first) ok = false;
      res += res2;
    }
    if (ok) ans = min(ans, res);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    getline(cin, s);
    stack<int> st;
    int i = 0;
    while(true) {
        if(s[i] == '+') {
            int h = st.top();
            st.pop();
            int hh = st.top();
            st.pop();
            st.push(h+hh);
        } else if(s[i] == '-') {
            int h = st.top();
            st.pop();
            int hh = st.top();
            st.pop();
            st.push(hh-h);
        } else if(s[i] == '*') {
            int h = st.top();
            st.pop();
            int hh = st.top();
            st.pop();
            st.push(h*hh);
        } else {
            int j = 0;
            while(s[i+j] != ' ') {
                j++;
            }
            int x = stoi(s.substr(i, j));
            st.push(x);
            i += j-1;
        }
        if(i != s.size()-1) {
            i += 2;
        } else {
            break;
        }
    }

    cout << st.top() << endl;
}


Measured memory_bytes: 3236
N = int(input())
music = []
for _ in range(N):
    s, t = map(str, input().split())
    music.append([s, int(t)])
number = input()

ans = 0
flag = False
for i in range(N):
    if flag:
        ans += music[i][1]
    elif number == music[i][0]:
        flag = True 

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a>b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(a+w>=b?0:b-(a+w));
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>

using namespace std;

int main() {
	string S;
	cin >> S;
	bool ans = true;
	if (S.length() % 2 == 1) {
		cout << "No";
		return 0;
	}
	for (int i = 0; i < (int)S.length(); i+=2) {
		if (S[i] != 'h' || S[i + 1] != 'i') {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 384
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
check_dict = {}
flag = 0
for i in range(n):
    if a[i] in check_dict:
        flag = 1
        break
    else:
        check_dict[a[i]] = 1

if flag == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 32948
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

ll memo[30];
ll fact(int x) {
	//if (memo[x])return memo[x];
	ll ret = 1;
	for (int i = 1; i <= x; i++)ret *= i;
	//pe(x); print(ret);
	memo[x] = ret;
	return ret;
}
void solve() {
	int N; cin >> N;
	vector<int>v(5);
	REP(i, 5)cin >> v[i];
	VSORT(v);
	int mn = v[0];
	ll ans = 5 + (N + mn - 1) / mn - 1;
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


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

using namespace std;
int N;

int checkVector(const vector<int>& vec1, const vector<int>& vec2) {
	for (int i = 0; i < N;i++) {
		if (vec1[i]+1 != vec2[i]) {
			return 0;
		}

	}
	return 1;
}


int main() {

	cin >> N;

	vector<int> nums(N);
	iota(nums.begin(), nums.end(), 0);

	vector<int> P(N), Q(N);

	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
	}

	int a, b, count = 1;;
	do {
		
		if (checkVector(nums, P)) {
			a = count;
			
		}
		
		if (checkVector(nums, Q)) {
			b = count;
			
		}
		count++;
	} while (next_permutation(nums.begin(), nums.end()));
	
	cout << abs(b - a);




	

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	if regexp.MustCompile(`[A-Z]`).Match([]byte(s)) {
		fmt.Println("A")
	} else {
		fmt.Println("a")
	}
}


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

int main() {
	bool check[6]={false};
	int input;
	
	for(int i=0;i<5;i++){
		cin>>input;
		check[input]=true;
	}
	
	for(int i=0;i<6;i++){
		if(check[i]==false){
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

int main()
{
    int a,b;
    cin >> a >> b;
    double k = (a+b)*0.5;
    if(k==(int)k)
    {
        cout << (int)k << '\n';
    }
    else
    {
        cout << "IMPOSSIBLE\n";
    }
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
a = gets.split.map(&:to_i)

k = 10000
b = []

def counting_sort(a, b, k)
  c = Array.new(k + 1, 0)

  (0...N).each do |i|
    c[a[i]] += 1
  end

  (1..k).each do |i|
    c[i] = c[i] + c[i - 1]
  end

  (0...N).each do |j|
    b[c[a[j]]] = a[j]
    c[a[j]] -= 1
  end
  b.shift
end

counting_sort(a, b, k)
puts b.join(' ')


Measured memory_bytes: 154688
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
  fio();
  int h, w, n;
  cin >> h >> w >> n;
  int a = max(h, w);
  if (n % a == 0) {
    cout << n / a << endl;
  }
  else {
    cout << n / a + 1 << endl;
  }
}

Measured memory_bytes: 764
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main() {
	int N, K; string S;
	cin >> N >> K >> S;
	int cnt = 0;
	rep(i, N-1) if(S[i] == S[i+1]) cnt++;
	cout << min(N-1, cnt + K*2) << endl; 
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int a,b;
  cin>>a>>b;
  int x;
  if(b<10){
    x=10*a+b;
  }else if(b<100){
    x=100*a+b;
  }else{
    x=1000*a+b;
  }
  bool flag=false;
  for(int i=1;i<=1000;i++){
    if(x==i*i){
      flag=true;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

struct Edge{
    ll to;
    ll cost;
    Edge(ll to, ll cost): to(to), cost(cost) {}
    Edge(){}
};

const int N_MAX = 100010;
vector<vector<Edge> > G;
bool visited[N_MAX];
ll x[N_MAX] = {};
bool is_consistent = true;

// 矛盾チェック
void dfs(ll current, ll prev, ll position){
    
    visited[current] = true;
    x[current] = position;

    for(auto edge : G[current]){
        ll next_x = x[current] + edge.cost;
        if(visited[edge.to]){
            // 距離の整合性チェック
            if(x[edge.to]!=next_x){
                is_consistent = false;
            }
            continue;
        }else{
            dfs(edge.to, current, next_x);
        }
    }
    return;
}

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

    // input
    ll N, M;
    cin >> N >> M;

    FOR(i, 0, N_MAX){
        visited[i] = false;
        x[i] = 0;
    }

    G.resize(N+1);

    FOR(i, 0, M){
        ll l, r, d;
        cin >> l >> r >> d;
        
        G[l].push_back(Edge(r, d));
        G[r].push_back(Edge(l, -d));
    }

    FOR(i, 1, N+1){
        if(!visited[i]){
            dfs(i, -1, 0);
        }
    }

    if(is_consistent){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 15744
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
tmp = 0
for a, b in D:
    if a == b:
        cnt += 1
    else:
        cnt = 0
    tmp = max(tmp, cnt) 

if tmp >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
h,w,d = map(int,input().split())

whereA = [[0,0] for _ in range(h*w)]
for i in range(h):
    A = list(map(int,input().split()))
    for j,a in enumerate(A):
        whereA[a-1] = [i,j]

Dsum = [0]*(h*w)
for i in range(h*w):
    Dsum[i] = Dsum[max(i-d,i%d)] + abs(whereA[i][0]-whereA[max(i-d,i%d)][0]) + abs(whereA[i][1]-whereA[max(i-d,i%d)][1])

q = int(input())

for _ in range(q):
    l,r = map(int,input().split())
    print(Dsum[r-1] - Dsum[l-1])


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

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x; return is;
}

typedef long long ll;
/*
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
*/

#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) ((x).begin(), (x).end())
#define dump(x) cout << #x << " = " << (x) << endl

const ll MAX = 2000;
const ll MOD = 1e9+7;

ll fac[MAX+1];
ll finv[MAX+1];

ll extgcd(ll a, ll b, ll &x, ll &y){
    if (b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return g;
}

ll modinv(ll a, ll p){
    ll x, y;
    extgcd(a, p, x, y);
    if (x<0) x += p;
    return x;
}

void nCr_init(){
    fac[0] = 1;
    finv[0] = 1;
    rep(i, MAX){ // i=1->MAX+1 => 0->MAX
        fac[i+1] = fac[i] * (i+1) % MOD;
        finv[i+1] = finv[i] * modinv(i+1, MOD) % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r || n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

/*
long long nCr(long long n, long long r){
    if(n == r || r == 0){
        return 1;
    }
    else if(r == 1){
        return n;
    }
    else{
        return (nCr(n-1,r)+nCr(n-1,r-1))%d;
    }
}
*/

int main(){
    long long n, k;
    cin >> n >> k;
    nCr_init();
    rep(i,k) cout << (nCr(n-k+1,i+1) * nCr(k-1,i)) % MOD << endl;
    return 0;
}

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

int n,m;
int l,r;

int main()
{
	
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		if(!i)
		{
			l=x;
			r=y;
		}
		l=max(l,x);
		r=min(r,y);
	}
	if(l>r) cout<<0;
	else cout<<r-l+1;
	
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],b[MAX],ans;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)b[i]=a[i]=read();
	sort(&b[1],&b[n+1]);
	for(int i=1;i<=n;++i)a[i]=lower_bound(&b[1],&b[n+1],a[i])-b;
	for(int i=1;i<=n;++i)ans+=abs(a[i]-i)&1;
	printf("%d\n",ans>>1);
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 100000;
int N, A[MAX], L[MAX+1], R[MAX+1], tmp, ans;

int GCD(int x, int y) {
    int r = x;
    
    if ( x < y ) {
        x = y;
        y = r; 
    }
    
    while ( r > 0 and y > 0 ) {
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

int main() {
    scanf("%d", &N);
    
    for ( int i = 0; i < N; i++ ) {
        scanf("%d", &A[i]);
    }
    
    L[0] = 0;

    for ( int i = 0; i < N; i++ ) {
        L[i+1] = GCD(L[i], A[i]);
    }

    R[N] = 0;

    for ( int i = N-1; i >= 0; i-- ) {
        R[i] = GCD(R[i+1], A[i]);
    }

    ans = 0;

    for ( int i = 0; i < N; i++ ) {
        tmp = GCD(L[i], R[i+1]);
        ans = max(ans, tmp);
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
const int mod = 1000000007;
 
int main() {
    LL n;
    cin >> n;
    LL k = 0;
    for(LL i = 1;i <= n; i++) {
        // cout << i << endl;
        if(i%15 == 0) {
            continue;
        }
        if(i%3 == 0) {
            continue;
        }
        if(i%5 == 0) {
            continue;
        }
        k += i;
    }
    cout << k << endl;
}


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

using namespace std;
typedef long long ll;

const ll MOD = 998244353;

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

    vector<vector<ll>> dp(x + 1, vector<ll>(512));
    for (int i = 0; i <= x; i++) dp[i][0] = 1;
    for (int i = 0; i < n; i++) {
        vector<vector<ll>> after(x + 1, vector<ll>(512));
        for (int nowNum = 0; nowNum <= x; nowNum++) {
            for (int nowXor = 0; nowXor < 512; nowXor++) {
                after[nowNum][nowXor] += dp[nowNum][nowXor ^ nowNum];
                after[nowNum][nowXor] %= MOD;
            }
        }

        for (int j = 0; j < 512; j++) {
            for (int k = 1; k <= x; k++) {
                after[k][j] += after[k - 1][j];
                after[k][j] %= MOD;
            }
        }

        dp = after;
    }

    cout << dp[x][x] << endl;
    return 0;
}



Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll a;cin>>a;
    ll arr[a],ans=0;
    cin>>arr[0];
    ll max=arr[0];
    //cout<<max;
    for(int i=1;i<a;i++){
        cin>>arr[i];
        if(arr[i]<max){
            ans=ans+max-arr[i];
        }
        else{
            max=arr[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 5156
def ABC162C(a,b):#ユークリッドの互除法
    while b != 0:
        a %= b
        if a == 0:break
        b %= a
    return max(a,b)

n,*x=map(int,open(0).read().split())
p=abs(x[-1]-x[-2])
for i in range(n):
    p=ABC162C(abs(x[i]-x[i+1]),p)
print(p)

Measured memory_bytes: 14052
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int N,D,X[20][20],ans;

int main()
{
	scanf("%d%d",&N,&D);
	for(int i=1;i<=N;i++)
	    for(int j=1;j<=D;j++)
	        scanf("%d",&X[i][j]);
	for(int i=1;i<=N;i++)
	{
		for(int j=i+1;j<=N;j++)
		{
			int sum=0;
			for(int k=1;k<=D;k++)
			    sum=sum+(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			int sum1=sqrt(sum);
			if(sum==sum1*sum1)
			    ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 384
#include <vector>
#include <iostream>
using namespace std;
int N, M, a, b, ct, col[100009]; vector<int> g[100009];
bool dfs(int pos, int x) {
	if (col[pos] == -1) {
		col[pos] = x;
		ct += x;
	}
	else return col[pos] == x;
	bool ret = true;
	for (int i : g[pos]) {
		if (!dfs(i, x ^ 1)) return false;
	}
	return true;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a >> b; a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	fill(col, col + N, -1);
	bool ret = dfs(0, 0);
	if (!ret) cout << 1LL * N * (N - 1) / 2 - M << endl;
	else cout << 1LL * ct * (N - ct) - M << endl;
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=1000005;
const LL INF=1<<30;
const LL p=7+1e9;
const LL NN=50;
LL N;
int main(){
	LL K;
	cin >> K;
	cout << NN << endl;
	LL A=K/50;
	LL B=K%50;
	REP(i,NN){
		if(i) cout << " ";
		cout << (NN-i-1)+A+(B>=i+1); 
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int k, n; cin >> k >> n;
  vector<int> a(n);
  for (int& x: a) cin >> x;
  a.push_back(k + a[0]);
  int best = 0;
  for (int i = 0; i < n; i++) {
    best = max(best, a[i+1] - a[i]);
  }
  cout << (k - best) << endl;

  return 0;
}


Measured memory_bytes: 1792
import math
import bisect
import collections
import itertools
import heapq
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M,K = imn()

for i in range(N+1):
    for j in range(M+1):
        b_cnt = (i*M)+(j*N)-(2*i*j)
        if b_cnt == K:
            print('Yes')
            break
    else:
        continue
    break
else:
    print('No')

Measured memory_bytes: 3380
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n,m,q,ans=0;
vector<int> a(0);
vector<int> b(0);
vector<int> c(0);
vector<int> d(0);
vector<int> suretu(11,0);

void dfs(int x){
    if(x>n){
        int tmp=0;
        for(int i=0;i<q;i++){
            if(suretu[b[i]]-suretu[a[i]]==c[i])tmp+=d[i];
        }
        ans=max(ans,tmp);
    }
    else{
        for(int i=suretu[x-1];i<=m;i++){
            suretu[x]=i;
            dfs(x+1);
        }
    }
}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int A,B,C,D;
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>A>>B>>C>>D;
        a.pb(A);b.pb(B);c.pb(C);d.pb(D);
    }
    suretu[0]=1;
    dfs(1);
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <stdio.h>
 
int main() {
  char ch[250]={0};
  char a[250] ={0};
  int h;
  int i,j,k,l,n,m;
 
 
  while(1){
    i=0;
    while(1){
       
      scanf("%c",&ch[i]);
      if(ch[i] == '\n') {    
    break;
      }
       
      i++;
    }
    
    if ( i == 1 && ch[0] == '-' ) break;
 
    //  printf("%d",i);
     
    scanf("%d",&m);
     
    for(j=0;j<m;j++){
      scanf("%d", &h );
       
      for(k=0;k<i-h;k++) {
    a[k] = ch[h+k];
    //    printf("a[%d] = ch[%d]の%c\n",k ,h+k,ch[h+k]);
      }
      for(k=0;k<h;k++){
    a[i-h+k] = ch[k];
    //   printf("a[%d] = ch[%d]の%c\n",i-h+k,k,ch[k]);
      }
      for(k=0; k<i; k++){
    ch[k] = a[k];
    // printf("ch[%d] = a[%d]の%c\n",k,k,a[k]);
      }
    }
    for(k=0;k<i;k++) {
      printf("%c",ch[k]);
    }
    printf("\n");
      scanf("%c",&ch[0]);
  }
   
   
  return 0;
   
}


Measured memory_bytes: 2072
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
int mod = 1000000007;

class Solution {
public:
    int a(int x) {
        return x + x*x + x*x*x;
    }
};

int main() {
    int a;
    cin >> a;
    Solution zhy;
    cout << zhy.a(a) << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

/*void fill(vvi& seq, vi& cur, int inx, int N, int K) {
    if (inx == N) { return; }

    cur.push_back(0);
    for (cur[inx] = 1; cur[inx] <= K; cur[inx]++) {
        seq.push_back(cur);
        fill(seq, cur, inx + 1, N, K);
    }
    cur.pop_back();
}*/

ll nseq(int K, int L) {
    ll res = 0, tmp = 1;
    for (int l = 1; l <= L; l++) {
        tmp *= K;
        res += tmp;
    }
    return res;
}

void find(int K, int L, ll beat) {
    ll skip = 1 + nseq(K, L - 1);
    cout << (beat / skip) + 1;

    if (beat % skip) {
        cout << " ";
        find(K, L - 1, beat % skip - 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    /*for (int N = 1; N <= 15; N++) {
        const int K = 5;
        //for (int K = 1; K <= 7; K++) {
            vvi seq; vi cur;
            fill(seq, cur, 0, N, K);
            sort(all(seq));

            cout << "K=" << K << " N=" << N << " sz=" << sz(seq) << " ";
            WATCHC(seq[(sz(seq) + 1)/2 - 1]);
        //}
    }*/

    int K, N;
    cin >> K >> N;

    if (K % 2 == 0) {
        cout << K / 2;
        for (int i = 1; i < N; i++)
            cout << " " << K;
        cout << endl;
        return 0;
    }

    if (K == 1) {
        for (int i = 0; i < (N - 1) / 2 + 1; i++) {
            if (i) cout << " ";
            cout << 1;
        }
        cout << endl;
        return 0;
    }

    int tail = 1; ll beat;
    while (true) {
        ll sct = nseq(K, tail);
        beat = (sct + N - tail - 1) / 2 - (N - tail);

        if (beat >= 0) break;
        tail++;
    }

    for (int i = 0; i < N - tail; i++) {
        if (i) cout << " ";
        cout << (K + 1) / 2;
    }

    if (N - tail > 0) cout << " ";
    find(K, tail, beat);

    cout << endl;

    return 0;
}



Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vl x(n), y(m);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> y[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ret = 0;
    ll xwidth = 0;
    for (int i = 0; i < x.size() - 1; ++i) {
        ll temp = (x[i + 1] - x[i]) % MOD;
        temp = temp * (i + 1) * (x.size() - 1 - i) % MOD;
        xwidth = (xwidth + temp) % MOD;
    }
    for (int i = 0; i < y.size() - 1; ++i) {
        ll temp = (xwidth) * (y[i + 1] - y[i]) % MOD;
        temp = temp * (i + 1) * (y.size() - 1 - i) % MOD;
        ret = (ret + temp) % MOD;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
N=int(input())
tmp=input().split(" ")

list=[]
for i in range(N-1):
    list.append(int(tmp[i]))

answer=[0]*N

for i in range(N-1):
    answer[list[i]]+=1
answer.append(0)

for i in range(1,N+1):
    print(answer[i])

Measured memory_bytes: 34044
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    
    if( n > k){
        cout << k * x + (n-k) * y << endl;
    }else{
        cout << n * x << endl;
    }
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    if ((a - b) % 2)
        cout << "Borys" << endl;

    else
        cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(i,n) cin>>s.at(i);
    
    sort(all(s));
    string ans;
    rep(i,n) ans+=s.at(i);
    cout<<ans<<endl;
}


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


int main() {
	string S, T;
	cin >> S >> T;
	size_t n = 0;
	for (size_t i = 0; i < 3; ++i) {
		if (S[i] == T[i]) {
			++n;
		}
	}

	cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	string S;
	int N,K;

	cin >> N >> K >> S;

	//S[K - 1] += 32;

	if(S[K-1]=='A'){
		S[K - 1] = 'a';
	}
	if(S[K-1]=='B'){
		S[K - 1] = 'b';
	}
	if(S[K-1]=='C'){
		S[K - 1] = 'c';
	}

	cout << S << endl;


	return 0;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var st = new int[n];
        for (int i = 0; i < n; i++) st[i] = int.Parse(Console.ReadLine().Trim());
        for (int i = 1; i <= m; i++)
            for (int j = 0; j < n-1; j++)
                if (st[j] % i > st[j + 1] % i) SwapB(st, j);
        foreach (var x in st) Console.WriteLine(x);
    }
    public static void SwapB (int[] st , int a)
    {
        var te = st[a];
        st[a] = st[a + 1];
        st[a+1] = te;
    }
}

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll a, b;
    cin >> a >> b;
    if (a*b <= 0) cout << "Zero" << endl;
    else if (a > 0) cout << "Positive" << endl;
    else {
        if ((a - b) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return;
    }
    N /= 2;
    int ans = 0, p = 5;
    while (N / p > 0) {
        ans += N / p;
        p *= 5;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256