akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();

            double res = 0;
            for (int n = 0; n < N; n++) {
                res += (1.0 / N) * count(n + 1, K);
            }
            System.out.println(res);
        }
    }

    private static double count(int i, int k) {
        double prob = 1;
        for (int j = i; j < k; j *= 2) {
            prob *= 0.5;
        }
        return prob;
    }

}


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

int main(){
	long long int n,a,b,s,q,r=0;
  	cin>>n>>a>>b;
  	s=a+b;
  	q=n/s;
  	r+=(q*a);
  	if(n%s){
      if(n%s<a)
        r+=(n%s);
      else
        r+=a;
    }
  	cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

int main() {
	vector<string> ans;
	ans.push_back("a");
	int n; cin >> n;
	while (--n) {
		vector<string> tmp;
		for (auto s : ans) {
			char maxc = 0;
			for (auto c : s) maxc = max(maxc, c);
			for (char c = 'a'; c <= maxc + 1; ++c) tmp.push_back(s + c);
		}
		ans = tmp;
	}
	for (auto s : ans) printf("%s\n", s.c_str());

	return 0;
}

Measured memory_bytes: 10908
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K, S;
  cin >> N >> K >> S;
  vector<ll> ans(N);
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    if (cnt < K)
      ans[i] = S;
    else if (S < 1000000000)
      ans[i] = S + 1;
    else
      ans[i] = S - 1;
    cnt++;
  }
  cout << ans[0];
  for (int i = 1; i < N; i++) {
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}

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

using Lint=long long;

int main()
{
   int N,W; cin>>N>>W;
   vector<int> w(N),v(N);
   for(int i=0;i<N;i++) cin>>w[i]>>v[i];

   vector<vector<Lint>> dp(N+1,vector<Lint>(W+1,-1));
   dp[0][0]=0;
   for(int i=0;i<N;i++) for(int j=0;j<=W;j++) if(dp[i][j]!=-1){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j+w[i]<=W){
         dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
      }
   }
   cout<<*max_element(dp[N].begin(),dp[N].end())<<endl;
   return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repl(i, a, b) for (ll i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = b; i >= (a); --i)
#define repdl(i, a, b) for (ll i = b; i >= (a); --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1'000'000'007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  int x;cin >> x;
  cout << !x << endl;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

int main(int argc, char* argv[]) {
  int N, M;
  std::cin >> N >> M;
  if (N >= M) {
    std::cout << "0" << std::endl;
    return 0;
  }
  std::vector<int> Xs(M);
  for (auto&& X : Xs) {
    std::cin >> X;
  }
  std::sort(Xs.begin(), Xs.end());
  std::vector<int> Ls(M - 1);
  for (int i = 0; i + 1 < M; i++) {
    Ls[i] = Xs[i + 1] - Xs[i];
  }
  std::sort(Ls.begin(), Ls.end(), std::greater<int>());
  int sum_l = 0;
  for (int i = 0; i < N - 1; i++) {
    sum_l += Ls[i];
  }
  std::cout << (Xs[M - 1] - Xs[0]) - sum_l << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll m1,d1,m2,d2;cin>>m1>>d1>>m2>>d2;
    if(m1 == m2) cout << 0 << ednl;
    else cout << 1 << endl;
}


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

int main() {
    string s;  cin >> s;
    map<char, int> mp;
    for (int i = 0; i < 4; ++i) ++mp[s[i]];
    cout << (mp.size() == 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
N,M,Q=map(int,input().split())
terms=[list(map(int,input().split())) for i in range(Q)]
def dfs(nums,length,min_lim):
    ans=0
    if length==N:
        ans_2=0
        for a,b,c,d in terms:
            if nums[b-1]-nums[a-1]==c:
                ans_2+=d
        return ans_2
    else:
        for i in range(min_lim,M+1):
            new_nums=nums+[i]
            ans_2=dfs(new_nums,length+1,i)
            ans=max(ans,ans_2)
    return ans
print(dfs([],0,1))

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

const int MAX_N = 100010;

const int inf = 2147483647;
int dat[MAX_N * 4];
int n;

void init(int n_){
    n = 1;
    while(n < n_) n *= 2; // 2のn乗に切り上げる
    // 全て inf で初期化したいとき
    for(int i = 0; i < n*2; i++){
        dat[i] = inf;
    }
    // 配列 a の要素で初期化したいとき
    // for(int i = n; i < n+n; i++){
    //     dat[i] = a[i-n];
    // }
    // for(int i=n-1; i>=1; i--){
    //     dat[i] = min(dat[i*2], dat[i*2+1]);
    // }
}

void update(int i, int x){
    i += n;
    dat[i] = x;
    while(i > 0){
        dat[i/2] = min(dat[i], dat[i^1]);
        i /= 2;
    }
}

int find(int a, int b, int i, int l, int r){
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return dat[i];
    return min(find(a,b,i*2,l,(l+r)/2), find(a,b,i*2+1,(l+r)/2,r));
}

int find(int a, int b){
    return find(a,b,1,0,n);
}

int main(){
    int n, q;
    while(cin >> n >> q){
        init(n);
        for(int i = 0; i < q; i++){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                update(x,y);
            } else {
                cout << find(x,y+1) << endl;
            }
        }
    }
}

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

int main() {
    std::string s;
    std::cin >> s;
    
    const auto find_A = s.find('A');
    const auto find_Z = s.rfind('Z');
    const auto ret = find_Z - find_A + 1;

    std::cout << ret << std::endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);

  int K, N, A;

  std::cin >> N >> K;

  std::map<int, int> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    map[A] ++;
  }

  if (map.size() <= K) {
    std::cout << 0 << std::endl;
  }
  else {

    std::vector<int> a;

    for (const auto& kv : map)
      a.push_back(kv.second);

    std::sort(ALL(a));

    std::cout << std::accumulate(std::begin(a), std::end(a) - K, 0LL) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int mi = 3000,mx=0;
	int x;
	for(int i=0;i<N;++i){
		cin >> x;
		if(mi > x) mi=x;
		if(mx < x) mx=x;
	}
	cout << mx-mi << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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 (b<a) { a=b; return 1; } return 0; }

int main() {
  int N, M; cin >> N >> M;
  vector<int> H(N); rep (i, N) cin >> H.at(i);
  vector<int> a(M); 
  vector<int> b(M); 
  rep (i, M) {
    cin >> a.at(i) >> b.at(i);
    a.at(i) --;
    b.at(i) --;
  }

  bool flag[N];
  rep (i, N) flag[i] = true;

  rep (i, M) {
    int ha = H[a[i]];
    int hb = H[b[i]];
  
    if (ha <= hb) {
      flag[a[i]] = false;
    }
    if (hb <= ha)
      flag[b[i]] = false;
  }

  

  int ans = 0;
  rep (i, N) {
    if (flag[i])
      ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4588
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    _ = II()
    a = LI()

    ans = []
    all_xor = 0
    for _a in a:
        all_xor ^= _a

    for _a in a:
        ans.append(all_xor ^ _a)
    print(*ans, sep=" ")


main()


Measured memory_bytes: 118736
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		StringBuilder[] ans = new StringBuilder[1000];
		int index = 0;

		while( n != 0 ){
			String[][] data = new String[n][2];
			for(int i = 0; i < n; i++){
				data[i][0] = stdIn.next();
				data[i][1] = stdIn.next();
			}
		
			int x = stdIn.nextInt();
			for(int i = 0; i < x; i++){
				String s = stdIn.next();
				for(int j = 0; j < n; j++){
					if( s.equals(data[j][0]) ){
						s = new String(data[j][1]);
						break;
					}
				}
				if( i == 0 ){
					ans[index] = new StringBuilder(s);
				} else {
					ans[index].append(s);
				}
			
			}
			index++;
			n = stdIn.nextInt();
		}
		for(int i = 0; i < index; i++){
			System.out.println(ans[i].toString());
		}
	}
}

Measured memory_bytes: 13000
from math import sqrt
M = 10**6
p = [1]*(M+1)
p[0] = p[1] = 0
for x in range(2, int(sqrt(M))+1):
    if p[x]:
        for y in range(x*x, M+1, x):
            p[y] = 0

x = int(input())

for i in range(M):
   if p[x+i] == 1:
      print(x+i)
      import sys
      sys.exit()

Measured memory_bytes: 10868
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define KKK 1000000007
#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;

long long flag;
long long n;
long long ans;
long long kakub[100005];
long long kakua[100005];
long long a[100005];
long long b[100005];
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		if(i==0)kakua[i]=a[i];
		else if(a[i-1]<a[i])kakua[i]=a[i];
	}
	rep(i,n)cin>>b[i];
	rep(i,n)
	{
		if(i==n-1)kakub[i]=b[i];
		else if(b[i]>b[i+1])kakub[i]=b[i];
	}
	rep(i,n)
	{
		if(kakua[i]!=0)
		{
			if(kakua[i]>b[i])flag=1;
		}
		if(kakub[i]!=0)
		{
			if(kakub[i]>a[i])flag=1;
		}
	}
	if(flag)
	{
		cout<<0<<endl;
		return 0;
	}
	ans=1;
	rep(i,n)
	{
		if(kakua[i]!=0||kakub[i]!=0)continue;
		ans*=min(a[i],b[i]);
		ans%=KKK;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

    vector<pair<ll,int>> fs;
    for (ll i = 2; i*i <= n; i++) {
        int x = 0;
        while(n%i == 0) {
            n /= i;
            ++x;
        }
        fs.emplace_back(i,x);
    }
    if (n != 1) fs.emplace_back(n,1);

    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            b++;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19768
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;
 
int main() {
  ll n, k, m;
  ll x[100005];

  cin >> n >> k;
 
  for (int i = 0; i < n; i++) {
    cin >> x[i];
 }

 ll ans = 1e18;
 
  for (int i = 0; i < n-k+1; i++) {
    ll l = x[i], r = x[i+k-1];
    if (r * l < 0) {
      r = abs(r); l = abs(l);
      m = min(r, l) * 2 + max(r, l);
    } else {
      r = abs(r); l = abs(l);
      m = max(r, l);
    }
    ans = min(ans, m);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int selectionsort(int *,int);

int main(){
  int n,count,A[100],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
    count=selectionsort(A,n);
  for(j=0;j<n;j++){
    printf("%d",A[j]);
    if(j==n-1)
      printf("\n");
    else
      printf(" ");
  }
  printf("%d\n",count);
  return 0;
}

int selectionsort(int *A,int x){
  int i,j,minj,z,count=0;
  for(i=0;i<x-1;i++){
    minj=i;
    for(j=i;j<x;j++){
      if(A[j]<A[minj])
	minj=j;
    }
    z=A[i];
    A[i]=A[minj];
    A[minj]=z;
    if(i!=minj)
      count++;
  }
  return count;
}



Measured memory_bytes: 2076
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int gcd(int a, int b){
  int r,tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;

  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;

}


int main(void){

  int N,M;
  scanf("%d %d", &N, &M);

  char S[N+1],T[M+1];
  scanf("%s", S);
  scanf("%s", T);

  int g = gcd(N,M);
  long long p = ((long long)N)*((long long)M);

  for(int i=0; i<g; i++){
    if(S[i*N/g]!=T[i*M/g]){
      printf("-1\n");
      return 0;
    }
  }

  printf("%lld\n", p/((long long)g));

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int l,a,b,c,d,p=0,q=0;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	while(a>0){
		a=a-c;
		p++;
	}
	while(b>0){
		b=b-d;
		q++;
	}
	if(p-q>0){
		l=l-p;
	}else{
		l=l-q;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main() {
  int q, x;
  char com[20];
  // 標準ライブラリよりlist を使用
  list<int> v;
  scanf("%d", &q);
  for ( int i = 0; i < q; i++ ) {
    scanf("%s", &com);
    if ( com[0] == 'i' ) {  // insert
      scanf("%d", &x);
      v.push_front(x);
    } else if ( com[6] == 'L' ) {  // deleteLast
      v.pop_back();
    } else if ( com[6] == 'F' ) {  // deleteFirst
      v.pop_front();
    } else if ( com[0] == 'd' ) {  // delete
      scanf("%d", &x);
      for ( list<int>::iterator it = v.begin(); it != v.end(); it++ )
        if ( *it == x ) {
          v.erase(it);
          break;
        }
    }
  }
  int i = 0;
  for ( list<int>::iterator it = v.begin(); it != v.end(); it++ ) {
    if ( i++ ) printf(" ");
    printf("%d", *it);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 33984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC075
{
    class Widespread
    {
        static public void Main()
        {
            var nab = ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = nab[0]; var a = nab[1]; var b = nab[2];
            var healthes = new int[n].Select(i => int.Parse(ReadLine().Trim())).ToArray();
            var max = healthes.Max();
            Func<int, bool> func = (count => IsWinnable(a, b, healthes, count));
            var res = BinSearch(func, max / a, max / b + 1);
            WriteLine(res);
        }
        static bool IsWinnable(int a, int b, int[] monster, int count)
        {
            return monster.Where(h => h > b * count).Select(h => (h - b * count - 1LL) / (a - b) + 1).Sum() <= count;
        }
        static int BinSearch(Func<int, bool> func, int from, int to)
        {
            if (from >= to) return from;
            else {
                var mid = to - (to - from + 1) / 2;
                if (func(mid)) return BinSearch(func, from, mid);
                else return BinSearch(func, mid + 1, to);
            }
        }
    }
}


Measured memory_bytes: 19164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, k, s;
        cin>>n>>k>>s;
        ll m = 1e9;
        rep(i, k)   cout<<s<<" ";
        rep(i, n-k) cout<<(s+1)%m<<" ";
    }
}

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

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll h, n; cin >> h >> n;
  vll a(n);

  rep(i, n) cin >> a[i];
  ll sum = accumulate(all(a),0LL);

  if (sum >= h) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


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


int main() {
  int h, w; cin >> h >> w;

  set<pair<int, int>> S, T;
  rep(i, w) S.emplace(i, 0);
  rep(i, w) T.emplace(0, i);

  rep(k, h) {
    int a, b; cin >> a >> b;
    --a;

    auto l = S.lower_bound({a, -1});
    auto r = S.lower_bound({b, -1});

    int x = w;
    while (l != r) {
      auto [i, j] = *l;
      x = min(x, j-i+b);
      l = S.erase(l);
      T.erase({j, i});
    }

    if (x < w && b < w) S.emplace(b, x);
    if (x < w && b < w) T.emplace(x, b);

    int ans = -1;
    if (!T.empty()) ans = k+1 + T.begin()->first;
    cout << ans << '\n';
  }
}


Measured memory_bytes: 22360
//  Created by conan1024hao in 2019.
//  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>
#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 pb push_back
#define mp make_pair
#define eb emplace_back
#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 siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
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};
char dir[4]={'u','l','d','r'};
ll cmp1(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(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>c(n-1),s(n-1),f(n-1);
    for(int i=0;i<n-1;i++)
        cin>>c[i]>>s[i]>>f[i];
    vector<int>ans(n);
    ans[n-1]=0;
    for(int i=0;i<n-1;i++){
        int t=s[i];
        t+=c[i];
        for(int j=i+1;j<n-1;j++){
            int tmp=s[j];
            while(t>tmp)
                tmp+=f[j];
            t=tmp;
            t+=c[j];
        }
        ans[i]=t;
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int h, w;
  char s[59][59];
  int dx[5] = {-1, 0, 1, 0};
  int dy[5] = {0, -1, 0, 1};
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  bool ans=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        bool tmp=true;
        for(int k=0;k<4;k++){
          int nxx = j+dx[k], nxy = i+dy[k];
          if(0<=nxx&&nxx<w && 0<=nxy&&nxy<h && s[nxy][nxx]=='#'){
            tmp=false;
            break;
          }
        }
        if(tmp){
          ans=false;
          break;
        }
      }
    }
    if(!ans)break;
  }
  cout << (ans?"Yes": "No") << endl;
}

Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;
int main() {

	int a, b, s;
	cin >> a >> b;
	s = ((a + b) % 2 == 0) ? (a + b) / 2 : (a + b) / 2 + 1;
	cout << s << endl;





	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[3000];
double f[3000][3000];
int main()
{
	int n,i,j;
	double ans=0;
	scanf("%d",&n);
	f[0][0]=1;
	f[0][1]=0;
	for(i=1;i<=n;i++)
	{
		scanf("%lf",&a[i]);
		f[i][0]=f[i-1][0]*(1-a[i]);
	}
	for(i=1;i<=n;i++)
	{	
		for(j=1;j<=i;j++)
		{
			f[i][j]=f[i-1][j]*(1-a[i])+f[i-1][j-1]*a[i];
		}
	}
	for(i=n/2+1;i<=n;i++)
		ans+=f[n][i];
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 68864
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int n,x[200005];
	vector<int> v;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i<=n;i++){
		v.push_back(x[i]);
	}
	sort(v.begin(),v.end());
	int k=n/2;
	for(int tim=1;tim<=n;tim++){
		if(v[n-k-1]>=x[tim]){
			cout<<v[n-k]<<endl;
		}else{
			cout<<v[n-k-1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;

typedef double D;
typedef complex<D> P;
D pi=acos(-1);
void FFT(vector<P>& a,int N,double t){
	for(int m=N;m>=2;m/=2){
		int mh=m/2;
		rep(i,mh){
			P w=polar(1.0,t*i);
			for(int j=i;j<N;j+=m){
				int k=j+mh;
				P x=a[j]-a[k];
				a[j]+=a[k];
				a[k]=w*x;
			}
		}
		t*=2;
	}
	int i=0;
	rep1(j,N-2){
		for(int k=N/2;k>(i^=k);k/=2);
		if(j<i) swap(a[i],a[j]);
	}
}
vector<P> conv(vector<P> a,vector<P> b){
	int n=a.size()+b.size();
	int N=1;
	while(N<n) N*=2;
	a.resize(N);
	b.resize(N);
	FFT(a,N,2*pi/N);
	FFT(b,N,2*pi/N);
	rep(i,N) a[i]*=b[i];
	FFT(a,N,-2*pi/N);
	rep(i,N) a[i]/=N;
	return a;
}
inline long long fix(P x){
	return round(x.real());
}
int main(){
	int N;
	cin>>N;
	vector<P> A(N*N*2),B;
	rep(i,N) rep(j,N){
		cin>>A[i*2*N+j];
	}
	B=A;
	reverse(all(B));
	auto C=conv(A,B);
	vector<long long> mp(1<<21);
	rep(i,N) for(int j=-N+1;j<=N-1;j++){
		if(i==0&&j<=0) continue;
		mp[i*i+j*j]+=fix(C[2*N*N-1-i*2*N+j]);
	}
	rep(i,N) rep(j,N){
		int x=fix(A[i*2*N+j]);
		mp[0]+=x*(x-1)/2;
	}
	long long sum=0;
	double ave=0;
	rep(i,N*N*2){
		if(mp[i]==0) continue;
		ave+=sqrt(i)*mp[i];
		sum+=mp[i];
	}
	printf("%.12f\n",ave/sum);
	int c=0;
	rep(i,N*N*2){
		if(mp[i]==0) continue;
		printf("%d %lld\n",i,mp[i]);
		c++;
		if(c==10000) break;
	}
}

Measured memory_bytes: 232336
package main

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

type shop struct {
	PRICE int
	STOCK int
}

type shops []shop

func (s shops) Len() int {
	return len(s)
}

func (s shops) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s shops) Less(i, j int) bool {
	return s[i].PRICE < s[j].PRICE
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var s shops = make([]shop, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		s[i].PRICE, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		s[i].STOCK, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(s)

	count := 0
	sum := 0
	for i := 0; i < n; i++ {
		if v := count + s[i].STOCK; v >= m {
			sum += s[i].PRICE * (m - count)
			break
		} else {
			count = v
			sum += s[i].PRICE * s[i].STOCK
		}
	}
	fmt.Println(sum)
}


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

int main(){
 	int n,d,x,tmp;
	cin >>n >> d>>x;
   	int count=x;
  	
 	for(int i = 0; i< n;i++) {	
      cin >> tmp;
  		count += 1 + (d-1)/tmp;
    }
  	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<string>
 
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
const int INF = 100000000;
const double EPS = 0.0000001;
typedef pair<int,int> P;


int modi[26];
int toInt(string ss) {
	int res=0;

	rep(i,ss.size()) {
		if(2<=ss[i]-'0'&&ss[i]-'0'<=9) {
			res += ((ss[i]-'0')*(modi[ss[i+1]-'a']));
			i++;
		}
		else {
			res += modi[ss[i]-'a'];
		}
	}
	return res;
}

string toMCXI(int dec) {
	string res = "";

	int ary[]={1000,100,10,1};
	string ss = "mcxi";
	rep(i,4) {
		int p = dec/ary[i];
		int q = dec%ary[i];
		//printf("[debug]%d,%d,%d,%d\n",dec,ary[3-i],p,q);
		if(p==0) {

		}
		else if(p==1) {
			res+=ss[i];
		}
		else {
			char tmp = p+'0';
			res+=tmp;
			res+=ss[i];
		}
		dec=q;
	}
	return res;
}

int n;
void solve() {
	//"m"，"c"，"x"，"i"
	modi['i'-'a'] = 1;
	modi['x'-'a'] = 10;
	modi['c'-'a'] = 100;
	modi['m'-'a'] = 1000;

	rep(i,n) {
		string ss1,ss2;
		cin>>ss1>>ss2;
		ss1 = "1"+ss1;
		ss2 = "1"+ss2;
		int add = toInt(ss1)+toInt(ss2);
		//printf("%d,%d,%d\n",toInt(ss1),toInt(ss2),add);
		cout<<toMCXI(add)<<endl;

	}
}

int main() {
	
	while (cin>>n)
	{
		if(!n) return 0;
		solve();
	}

	return 0;
}

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

typedef long long ll;
const ll INF = 1e18;
vector<ll> dp; // dp[mask] - maximum score possible for the subset mask
vector<ll> score; // score[mask] - total score of a given mask

void solve(int idx, vector<int> &not_taken, ll score_so_far, int mask, int group) {
    if (idx == not_taken.size()) {
        dp[mask] = max(dp[mask], score_so_far + score[group]);
        return;
    }

    solve(idx+1, not_taken, score_so_far, mask, group);
    solve(idx+1, not_taken, score_so_far, mask ^ (1 << not_taken[idx]), group ^ (1 << not_taken[idx]));
}

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

    vector<vector<int>> a(n, vector<int>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }

    score.resize(1 << n);

    for (int mask = 0; mask < (1<<n); ++mask) {
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                for (int j = i+1; j < n; ++j) {
                    if (mask & (1 << j)) {
                        score[mask] += a[i][j];
                    }
                }
            }
        }
    }

    dp.resize(1 << n, -INF);
    dp[0] = 0;

    for (int mask = 0; mask < (1<<n); ++mask) {
        vector<int> not_taken;
        for (int i = 0; i < n; ++i) {
            if (!(mask & (1<<i)))
                not_taken.push_back(i);
        }

        solve(0, not_taken, dp[mask], mask, 0);
    }

    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

long N;
vector<long> A;
// 回答用
vector<long> A2;

void solve();

int main() {
  cin >> N;
  A.resize(N);
  A2.resize(N);
  for (int i = 0; i < N; i++) {
    long input;
    cin >> input;
    A[i] = input;
    A2[i] = input;
  }
  solve();
}

// 数列中の Ai を除く N−1 個の要素のうちの最大の値を求めよ。
void solve() {
  // 全体図: もし最大値ならば2番目, それ以外なら最大値を返す

  // 最大値を求める
  sort(A.begin(), A.end());
  long maxVal = A[N - 1];
  // 二番目に大きい値を求める
  long secondMaxVal = A[N - 2];

  for (int i = 0; i < N; i++) {
    if (A2[i] == maxVal) {
      cout << secondMaxVal << endl;
    } else {
      cout << maxVal << endl;
    }
  }
}


Measured memory_bytes: 4736
#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)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int h, w, m;
    cin >> h >> w >> m;
    vector<int> row(h), col(w);
    set<pair<int, int>> st;
    rep(i, m) {
        int y, x;
        cin >> y >> x;
        y--; x--;
        row[y]++;
        col[x]++;
        st.emplace(y, x);
    }
    int row_max = *max_element(row.begin(), row.end());
    int col_max = *max_element(col.begin(), col.end());

    vector<int> row_max_idx, col_max_idx;
    rep(i, h) if (row[i] == row_max) row_max_idx.push_back(i);
    rep(j, w) if (col[j] == col_max) col_max_idx.push_back(j);

    for (int i = 0; i < row_max_idx.size(); ++i) {
        for (int j = 0; j < col_max_idx.size(); ++j) {
            if (!st.count({row_max_idx[i], col_max_idx[j]})) {
                cout << row_max + col_max << '\n';
                return 0;
            }
        }
    }
    cout << row_max + col_max - 1 << '\n';
}


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

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

    int i = 0;
    int j = s.length() - 1;

    while(s[i] != 'A') {
        ++i;
    }
    while(s[j] != 'Z') {
        --j;
    }
    
    cout << j - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

 
struct LazySegmentTree {
private:
    int n;
    vector<LL> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<LL> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, LL x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
 
    LL find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return -1;
        if(a <= l && r <= b) return node[k];
        LL vl = find(a, b, 2*k+1, l, (l+r)/2);
        LL vr = find(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


int main(){
    int N;cin >> N;
    vector<LL> h(N),a(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    LazySegmentTree seg( vector<LL> (N+1,0) );
    for (int i = 0; i < N; i++) {
        seg.update(h[i],h[i]+1,seg.find(0,h[i])+a[i]);        
    }
    cout << seg.find(0,N+1) << endl;
    return 0;
}



Measured memory_bytes: 13184
# coding:utf-8
# Round-robin scheduling

def main():
    n, q = map(int, input().split())
    process = []
    finished = []
    counter = 0
    for _ in range(n):
        name, time = input().split()
        process.append((name, int(time)))

    while len(process)  > 0:
        name, time = process.pop(0)
        temp_q = q

        while True:
            
            if time <= 0:
                finished.append((name, counter))
                break

            # q????????§??????????¶????????????£???????????????
            # time?????´??°??????process???????°?????§???? 
            if temp_q <= 0:
                process.append((name, time))
                break
            
            time -= 1
            temp_q -= 1
            counter += 1
    
    for name, time in finished:
        print(name, time)

if __name__ == "__main__":
    main()

Measured memory_bytes: 15908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int N = 999999;
		boolean[] primes = new boolean[N + 1];
		int[] counts = new int[N + 1];

		for (int i = 2; i < N / 2 + 1; i++) {
			if (!primes[i]) {
				for (int j = 2; j < N / i + 1; j++) {
					if (!primes[i * j]) {
						primes[i * j] = true;
					}
				}
			}
		}
		int count = 0;
		for (int i = 2; i < N + 1; i++) {
			if (!primes[i]) {
				count++;
			}
			counts[i] = count;
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			System.out.println(counts[Integer.parseInt(line)]);
		}
	}
}

Measured memory_bytes: 26820
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

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

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

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

/*signed*/int main() {
    int N; cin >> N;
    vector <int> H (N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        bool flag = true;
        for (int j = 0; j < i; ++j) {
            if (H[j] > H[i]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main() {
	
	int n,x;
	int w[100000];
	
	cin >> n >> x;
	for(int i=0; i!=n; i++){
		cin >> w[i];
	}
	
	int d;
	
	qsort(w , n , sizeof(int) , int_sort);
	
	int a,gcd,r;
	
	gcd = abs(x - w[0]);
	
	for(int i=0; i!=n; i++){
		if(i != 0){
			if((w[i] - w[i-1]) % gcd != 0){
				a = w[i] - w[i-1];
				if(a < gcd){
					r = a;
					a = gcd;
					gcd = r;
				}
				r = a % gcd;
				while(r!=0){
					a = gcd;
					gcd = r;
					r = a % gcd;
				}
			}
		}
	}
	
	cout << gcd << '\n';
	
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vector<pair<pair<int,int>,int>> vec;
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        vec.push_back({{a,b},c});
    }
    vector<pair<pair<int,int>,int>> vec2;
    int num=n/2;
    if (n==1){
        if (vec[0].fi.fi*mb==vec[0].fi.se*ma)cout<<vec[0].se<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    for (int i=0;i<(1<<num);i++){
        bitset<20> s(i);
        int sa=0,sb=0,sc=0;
        rep(j,num){
            if (s.test(j)){
                sa+=vec[j].fi.fi;
                sb+=vec[j].fi.se;
                sc+=vec[j].se;
            }
        }
        vec2.push_back({{sa,sb},sc});
    }
    int num2=n-num;
    vvi d(201,vi(201,10000));
    for (int i=0;i<(1<<num2);i++){
        bitset<20> s(i);
        int sa=0,sb=0,sc=0;
        rep(j,num2){
            if (s.test(j)){
                sa+=vec[j+num].fi.fi;
                sb+=vec[j+num].fi.se;
                sc+=vec[j+num].se;
            }
        }
        d[sa][sb]=min(d[sa][sb],sc);
    }
    int ans=100000;
    for (auto p:vec2){
        int a=p.fi.fi,c=p.fi.se;
        int r=c%mb;
        int dd;
        if (r==0)dd=-mb;
        else dd=-r;
        while(1){
            dd+=mb;
            if (dd>200)break;
            int b=ma*(c+dd)/mb-a;
            if (b<0)continue;
            else if (a==0 && b==0 && c==0 && dd==0)continue;
            else if (b>200)break;
            else if (d[b][dd]==10000)continue;
            else ans=min(ans,d[b][dd]+p.se);
        }
    }
    if (ans==100000)cout<<-1<<endl;
    else cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 14576
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using namespace std;

int i,j,k;

int main(){
    long n;
    cin>>n;
    long ans[n];
    for(i=1;i<=n;i++){
        ans[i]=0;
    }
    long a[n];
    REP(i,n-1){
        cin>>a[i];
        ans[a[i]]++;
    }
    for(i=1;i<=n;i++){
        cout<<ans[i]<<'\n';
    }
    
    
    
    

}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
string s[10010];
int h,w;
int main() {
cin>>h>>w;
for(int i=0;i<h;i++) {
	cin>>s[i];
}
for(int i=0;i<w+2;i++) {
	cout<<"#";
}
for(int i=0;i<h;i++) {
	cout<<endl<<"#"<<s[i]<<"#";
}
cout<<endl;
for(int i=0;i<w+2;i++) {
	cout<<"#";
}
}


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

int main(){
    int n, l; cin >> n >> l;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];

    for(int i=0;i<n-1;i++){
        if(l<=a[i]+a[i+1]){
            cout << "Possible" << endl;

            for(int j=1;j<=i;j++) cout << j << endl;
            for(int j=n-1;i+1<j;j--) cout << j << endl;

            cout << i + 1 << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 1664
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
public static class P {
  public static void Main() {
    int n = int.Parse(Console.ReadLine());
    var s = Console.ReadLine();
    Console.WriteLine(s.Length - s.Zip(s.Skip(1), (x, y) => x == y ? 1 : 0).Sum());
  }
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if(line == null){
				break;
			}
			String[] splitedLine = line.split(" ");
			
			Map<String,List<Integer>> wordsInfo = new HashMap<>();
			for(int i = 0 ; i < splitedLine.length ; i++ ){
				if(wordsInfo.containsKey(splitedLine[i])){
					List<Integer> tmplist = wordsInfo.get(splitedLine[i]);
					Integer tmpInt = tmplist.get(0);
					tmplist.set(0, ++tmpInt);
				}else{
					List<Integer> tmplist = new ArrayList<>();
					tmplist.add(1);
					wordsInfo.put(splitedLine[i], tmplist);
				}
			}
			
			String maxLengthWord = "";
			String mostFrequentWord = "";
			int maxCount = 0;
			
			for(String word : wordsInfo.keySet()){
				
				if(word.length() > maxLengthWord.length()){
					maxLengthWord = word;
				}
				
				if(wordsInfo.get(word).get(0) > maxCount){
					maxCount = wordsInfo.get(word).get(0);
					mostFrequentWord = word;
				}
			}
			
			System.out.println(mostFrequentWord + " " + maxLengthWord);
		}
	}

}

Measured memory_bytes: 23988
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int a[];
		int b[];
		int maxNumber;
		boolean flag;

		n = sc.nextInt();
		a = new int[10];
		b = new int[10];
		for (int i = 0; i < n; i++) {
			maxNumber = -1;
			flag = true;
			for (int j = 0; j < 10; j++) {
				a[j] = sc.nextInt();
				b[j] = 0;
				if (maxNumber < a[j]) {
					maxNumber = a[j];
					b[j] = 1;
				}
			}
			maxNumber = -1;
			for (int j = 0; j < 10 && flag; j++) {
				if (b[j] == 0) {
					if (maxNumber < a[j]) {
						maxNumber = a[j];
					} else {
						flag = false;
					}
				}
			}
			if (flag) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 12000