akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;

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

	int h;
	cin >> h;
	int sz = 1 << (h - 1);
	vector<int> p(sz);
	rep(i, sz) {
		cin >> p[i];
		p[i]--;
	}
	vector<vector<ll>> prod(sz, vector<ll>(h - 1));
	rep(i, sz) {
		ll x = i + sz; ll tmp = x;
		rep(j, h - 1) {
			prod[i][j] = tmp;
			x >>= 1;
			tmp *= x; tmp %= mod;
		}
	}
	vector<vector<P>> vec(2 * sz, vector<P>());
	vector<int> lst(2 * sz, -1);
	int bor = 1; int cap = 0;
	rep(i, 2 * sz) {
		if (i >= bor) {
			bor <<= 1;
			cap++;
		}
		int x = 1 << (h - cap);
		x *= (h - 1);
		if (i >= 2) vec[i].reserve(x);
	}
	rep(step, h - 1) {
		for (int i = sz - 1; i >= 0; i--) {
			int x = i + sz; int y = p[i] + sz;
			x >>= step;
			int idx = y;
			rep(j, h - 1) {
				if (lst[idx] == x) {
					vec[idx].back().first += prod[i][step] * prod[p[i]][j];
					vec[idx].back().first %= mod;
				}
				else {
					vec[idx].pb({ prod[i][step] * prod[p[i]][j] % mod,x });
					lst[idx] = x;
				}
				idx >>= 1;
			}
		}
	}
	rep(i, 2 * sz) {
		reverse(all(vec[i]));
		if (i & 1) {
			for (int j = 0; j < vec[i].size(); j++) {
				vec[i][j].second ^= 1;
				if (j > 0 && vec[i][j].second < vec[i][j - 1].second) swap(vec[i][j], vec[i][j - 1]);
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < 2 * sz; i += 2) {
		int x = 0, y = 0;
		while (x < vec[i].size() && y < vec[i + 1].size()) {
			if (vec[i][x].second < vec[i + 1][y].second) x++;
			else if (vec[i][x].second > vec[i + 1][y].second) y++;
			else {
				ans += vec[i][x].first * vec[i + 1][y].first % mod * (i >> 1) % mod * (vec[i][x].second >> 1);
				ans %= mod;
				x++; y++;
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 424372
def main():
    S = input()
    gather = []
    beginR = 0
    state = 'R'
    for i in range(1, len(S)):
        if state == 'R':
            if S[i] == 'R':
                continue
            else:
                endR = i - 1
                beginL = i
                state = 'L'
        else:
            if S[i] == 'R':
                gather.append([beginR, endR, beginL, i-1], )
                beginR = i
                state = 'R'
            else:
                continue
    gather.append([beginR, endR, beginL, i])

    result = []
    for block in gather:
        r = block[:2]
        l = block[2:]
        rnum = r[1] - r[0] + 1
        lnum = l[1] - l[0] + 1

        for _ in range(rnum-1):
            result.append(0)

        if (rnum + lnum) % 2 == 0:
            for _ in range(2):
                result.append((rnum + lnum)//2)
        else:
            if rnum % 2 == 1:
                result.append((rnum + lnum)//2 + 1)
                result.append((rnum + lnum)//2)
            else:
                result.append((rnum + lnum)//2)
                result.append((rnum + lnum)//2 + 1)

        for _ in range(lnum-1):
            result.append(0)

    print(' '.join(map(str, result)))

main()

Measured memory_bytes: 22764
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int f=0;
	for(int i=0;i<250;i++){
		for(int j=0;j<100;j++){
			if(4*i+7*j==n){
				f=1;
				break;
			}
		}
		if(f==1) break;
	}
	if(f==1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

signed main(){
	int n;
	scanf("%lld", &n);
	if(n < 1200)printf("ABC\n");
	else printf("ARC\n");
	return 0;
}


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

using namespace std;

#define ll long long

string S[3];
int cnt[3] = {0};

void solve(){
    bool flag = true;
    int index = 0;
    while(flag){
        if(S[index].size()==0){
            cout << (char)('A'+index) << endl;
            break;
        }
            char buff = S[index].front();
            S[index].erase(S[index].begin());
            index = buff - 'a';
            cnt[index] += 1;
    }
}

int main(){
    cin >> S[0] >> S[1] >> S[2];

    solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int d;
  cin >> d;
  int dsum = 0;
  int dt = d;
  while (dt > 0) {
    dsum += dt % 10;
    dt /= 10;
  }
  if (d % dsum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3536
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static long n, d, ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Long.parseLong(in[0]);
    d = Long.parseLong(in[1]);

    ans = 0;

    for (int i = 0; i < n; i++) {
      in = br.readLine().split(" ");
      long x = Long.parseLong(in[0]);
      long y = Long.parseLong(in[1]);
      if (x * x + y * y <= d * d) {
        ans++;
      }
    }

    br.close();

    out.println(ans);

    out.flush();
  }
}


Measured memory_bytes: 54780
program main
  
  implicit none
  integer(8) :: n, m
  integer(8),allocatable :: a(:)
  
  read(*,*) n, m
  allocate( a(m) )
  read(*,*) a
  

  if ( sum(a) > n ) then
    print*, "-1" 
  else
    print*, n - sum( a ) 
  end if
   
end program main


Measured memory_bytes: 2840
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;

int xx1, yy1, xx2, yy2;
int N;
int X[200010], Y[200010];
int XX[200010], YY[200010];
int n;
int idx[200010];
int Y3[200010];
int memo[200010];
//double Pi = 3.1415926535897932;
//double Pi = 3.1415926535897932384626433832795;
double Pi = 3.141592653589793;

int cmp(const void *aa, const void *bb)
{
	int i1 = *((int *)aa);
	int i2 = *((int *)bb);
	return XX[i1] - XX[i2];
}

int bsrch(int v)
{
	int ll=-1, rr=n;
	int mm;  
    while(ll+1 != rr){  
        mm = (ll+rr)/2;  
        if (memo[mm] < v)  
            ll = mm;  
        else  
            rr = mm;  
    }  
    return rr; 
    /*int ll=0, rr=n;
    int mm;
    while(ll<rr){
    	mm = (ll+rr)/2;
    	if(memo[mm] >= v)
    		rr = mm;
    	else
    		ll = mm+1;
    }
    return ll;*/
}

int calc()
{
	int i;
	for(i=0; i<n; i++)
		memo[i] = 1000000000;
	for(i=0; i<n; i++){
		int w = bsrch(Y3[i]);
		memo[w] = Y3[i];
	}
	return bsrch(1000000000);
}

void solve2()
{
	int i;
	double d=0;
	double res;
	int x1=xx1, y1=yy1, x2=xx2, y2=yy2;
	if(x1==x2){
		for(i=0; i<N; i++){
			if(X[i] == x1 && ( (Y[i]>=y1&&Y[i]<=y2) || (Y[i]>=y2&&Y[i]<=y1) ) )
				break;
		}
		if(i<N){
			d = Pi*10 - 20;
		}
		res = abs(y2-y1);
		res *= 100;
		res += d;
	}
	else{
		for(i=0; i<N; i++){
			if(Y[i] == y1 && ( (X[i]>=x1&&X[i]<=x2) || (X[i]>=x2&&X[i]<=x1) ) )
				break;
		}
		if(i<N){
			d = Pi*10 - 20;
		}
		res = abs(x2-x1);
		res *= 100;
		res += d;	
	}
	printf("%.13f\n", res);
}

void solve()
{
	int i;
	int x1=xx1, y1=yy1, x2=xx2, y2=yy2;
	//if(y1==y2 || x1==x2){
	//	solve2();
	//	return ;
	//}
	n = 0;
	if(y2>=y1 && x2>=x1 || y2<=y1 && x2<=x1){
		if(x2<x1){
			swap(y1, y2);
			swap(x1, x2);
		}
		for(i=0; i<N; i++){
			if(X[i]>=x1 && X[i]<=x2 && Y[i]>=y1 && Y[i]<=y2){
				XX[n] = X[i];
				YY[n] = Y[i];
				n ++;
			}
		}
		for(i=0; i<n; i++)
			idx[i] = i;
		qsort(idx, n, sizeof(int), cmp);
		for(i=0; i<n; i++){
			Y3[i] = YY[idx[i]];
		}
	}
	else{
		if(x2<x1){
			swap(y1, y2);
			swap(x1, x2);
		}
		for(i=0; i<N; i++){
			if(X[i]>=x1 && X[i]<=x2 && Y[i]>=y2 && Y[i]<=y1){
				XX[n] = X[i];
				YY[n] = Y[i];
				n ++;
			}
		}
		for(i=0; i<n; i++)
			idx[i] = i;
		qsort(idx, n, sizeof(int), cmp);
		for(i=0; i<n; i++){
			Y3[i] = YY[idx[i]];
		}
		for(i=0; i<n/2; i++){
			swap(Y3[i], Y3[n-1-i]);
		}
	}
	int cnt = calc();
	double d = Pi*5 - 20;
	d *= cnt;
	double res = (abs(y2-y1)+abs(x2-x1));
	res *= 100;
	res += d;
	if(abs(y2-y1)+1==cnt || abs(x2-x1)+1==cnt){//not abs(x2-x1+1)
		d = Pi*5;
		res += d;
	}
	printf("%.13f\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	Pi = 4*atan(1);
	int i;
	scanf("%d%d%d%d", &xx1, &yy1, &xx2, &yy2);
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d%d", &X[i], &Y[i]);
	}
	solve();
	return 0;
}


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

int gcd(int a, int b) {
  if(a%b==0) return b;
  return gcd(b, a%b);
}

long long divTwoNums(long long num, long long c, long long d){
  long long ans=num;
  ans-=(long long)(num/c+num/d);
  ans+=(long long)(num/(c*d/gcd(c,d)));
  return ans;
}

int main() {
  long long a, b;
  long long c, d;
  cin >> a >> b >> c >> d;
  cout << divTwoNums(b, c, d)-divTwoNums(a-1, c, d) << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>

#define MOD_BY 998244353

int add(int a, int b) {
	return a + b - (a + b >= MOD_BY ? MOD_BY : 0);
}

int sub(int a, int b) {
	return b == 0 ? a : add(a, MOD_BY - b);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int pou(int a, int b) {
	int r = 1;
	while (b > 0) {
		if (b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int inv(int a) {
	return pou(a, MOD_BY - 2);
}

int N, M, K;

int kake[222222], wari[222222];

int nCr(int n, int r) {
	if (r < 0 || n < r) return 0;
	return mul(kake[n], mul(wari[r], wari[n - r]));
}

int kugyu[222222];

int main(void) {
	int i;
	int kotae = 0;
	if (scanf("%d%d%d", &N, &M, &K) != 3) return 1;
	kugyu[0] = 1;
	kugyu[1] = M;
	kake[0] = 1;
	wari[0] = 1;
	kake[1] = 1;
	wari[1] = 1;
	for (i = 2; i <= N; i++) {
		kugyu[i] = mul(kugyu[i - 1], M - 1);
		kake[i] = mul(kake[i - 1], i);
		wari[i] = inv(kake[i]);
	}
	for (i = N - K; i <= N; i++) {
		/* i個のブロックを隣が違う色で塗る */
		int temp = kugyu[i];
		/* i個から重複を許してN-i個選んで、2個にする */
		/* N-i個の○とi-1個の仕切りの順列 */
		/* (N-i) + (i-1) 個のうち、N-i個を○にする */
		int temp2 = nCr((N - i) + (i - 1), N - i);
#if 0
		printf("%d %d %d %d\n", i, temp, temp2, mul(temp, temp2));
#endif
		kotae = add(kotae, mul(temp, temp2));
	}
	printf("%d\n", kotae);
	return 0;
}


Measured memory_bytes: 4088
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
	int a, b;
	
	cin >> a;
	cin >> b;

	if (a*b % 2) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

a, b = map(int, input().split())

soin_a = np.array([], dtype='int')
for i in range(2, int(np.sqrt(a)) + 1):
    if a % i == 0:
        soin_a = np.append(soin_a, i)
        while a % i == 0:
            a //= i
if a != 1:
    soin_a = np.append(soin_a, a)

soin_b = np.array([], dtype='int')
for i in range(2, int(np.sqrt(b)) + 1):
    if b % i == 0:
        soin_b = np.append(soin_b, i)
        while b % i == 0:
            b //= i
if b != 1:
    soin_b = np.append(soin_b, b)

ans = 1
for j in soin_a:
    if soin_b[soin_b == j].size != 0:
        ans += 1

print(ans)

Measured memory_bytes: 12508
import numpy as np

n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))

v=np.array(v)
c=np.array(c)

a=(v-c).tolist()
ans=0
for i in a:
    if(i>0):ans+=i

print(ans)

Measured memory_bytes: 12424
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int s(long long x) {
    int ans = 0;
    while (x) {
        ans += (x % 10);
        x /= 10;
    }
    return ans;
}

int main() {
    int K;
    cin >> K;
    long long x = 1e15;
    vector<long long> ans;
    while (true) {
        bool found = true;
        for (long long i = 1; found; i *= 10) {
            for (int w = 1; w <= 9; w++) {
                long long tmp = x - w * i;
                if (1.0 * tmp / s(tmp) <= 1.0 * x / s(x)) {
                    found = false;
                    x = tmp;
                    break;
                }
            }
        }
        if (x < 1) break;
        ans.push_back(x);
    }

    sort(ans.begin(), ans.end());
    for (int i = 0; i < K; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a>b)swap(a,b);
if(a>c)swap(a,c);
if(b>c)swap(b,c);
printf("%d %d %d\n",a,b,c);
return 0;
}

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

int main(){
    int a, b, c, save;
    cin >> a >> b >> c;

    if (b < a) save = a, a = b, b = save;
    if (c < b) save = b, b = c, c = save;
    if (b < a) save = a, a = b, b = save;

    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100005;
char a[maxn];
int n,ans;
int main(){
    scanf("%s",a+1); n=strlen(a+1);
    ans=n/2;
    for(int i=n/2-1;i>=0;i--){
        if(a[i+1]==a[i+2]&&a[n-i]==a[n-i-1]) ans=i; else break;
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> e(n);
  vector<int> w(n);
  int cnte = 0, cntw = 0;
  for (int i = 0; i < n; i++) {
    if(s[i] == 'E') {
      cnte++;
    } else {
      cntw++;
    }
    e[i] = cnte;
    w[i] = cntw;
  }

  int ans = 1000000;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    if (s[i] == 'W') {
      tmp += w[i] - 1;
    } else {
      tmp += w[i];
    }
    tmp += cnte - e[i];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stdlib.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
//using std::greater;
using std::max;
using std::min;

/*
using lli = long long int;
using ulli = unsigned long long int;
*/

#define INF 999999999;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

string A;

long long int c[27], minus;

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

	cin >> A;
	long long int N = A.size();
	for(int i = 0; i < N; i++){
		c[A[i] - 'a']++;
	}
	for(int i = 0; i < 26; i++){
		minus += c[i] * (c[i] - 1) / 2;
	}

	cout << 1 + N*(N - 1) / 2 - minus;

#ifndef EVEL
	system("pause");
#endif

	return 0;
}

Measured memory_bytes: 780
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;


int main(){
      int n;
    cin>>n;
    string s;
    cin>>s;
    int j=n-1;
    int ans=0;
    rep(i,n){
        if(i>=j) break;
        while(s[i]=='R' and i<j) i++;
        while(s[j]=='W' and i<j) j--;
        if(i<j) ans++;
        j--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            int[] inputs = reader.readIntsSplitByDelimiter(" ");

            System.out.println(inputs[0] - inputs[1] + 1);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;
 
    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }
 
    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }
 
    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }
 
    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }
 
    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);
 
        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
 
        return ints;
    }
 
    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);
 
        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }
 
        return longs;
    }
 
    @Override
    public void close() throws IOException {
        br.close();
    }
}


Measured memory_bytes: 21204
lst = input().split()

N = int(lst[0])
M = int(lst[1])

students = []
checkpoints = []

for i in range(N):
   students.append(input().split())

for i in range(M):
   checkpoints.append(input().split())

def distance(P, Q):
   return abs(int(P[0]) - int(Q[0])) + abs(int(P[1]) - int(Q[1]))

for s in students:
   l1 = [10 ** 10]
   l2 = [0]
   for i in range(M):
      if distance(s, checkpoints[i]) < l1[-1]:
         l1.append(distance(s, checkpoints[i]))
         l2.append(i+1)
   print(l2[-1])

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

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

    // 行列Aの数値受取
    int a[100][100];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    // 行ベクトルの数値受取
    int c[100];
    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }

    // 積の計算
    int result[100];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * c[j];
        }
        result[i] = sum;
        sum = 0;
    }

    // 結果の表示
    for (int i = 0; i < n; i++) {
        cout << result[i] << endl;
    }
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename X>
struct BIT
{
  vector<X> dat;
  int n;

  BIT(int _n){
    n = _n+1;
    dat.assign(n,0);
  }
  
  X sum(int i)
  {
    X s = 0;
    while(i > 0){
      s += dat[i];
      i -= i&(-i);
    }
    return s;
  }

  void add(int i,X x)
  {
    while(i<=n){
      dat[i] += x;
      i += i&(-i);
    }
  }
};

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

  vector<ll> sum(n+1);
  sum[0] = 0;

  rep(i,n){
    sum[i+1] = sum[i]+(a[i]-k);
  }

  map<ll,int> mp;
  rep(i,n+1){
    mp[sum[i]]=1;
  }

  int j=1;
  for(auto& it:mp){
    it.second=j++;
  }

  BIT<ll> bt(n+1);
  ll res=0;
  rep(i,n+1){
    int index=mp[sum[i]];
    res += bt.sum(index);
    bt.add(index,1);
  }

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 17408
#include <iostream>

using namespace std;

int main(){
    int n,m,et,ex;
    cin>>n>>m;
    int c=m,ans=m;
    for(int i=0;i<n;++i){
        cin>>et>>ex;
        c +=et-ex;
        if(c<0){
            ans=0;break;
        }
        ans=max(ans,c);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<vector<int>> graph(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int Ai, Bi;
        cin >> Ai >> Bi;
        graph[Ai - 1].push_back(Bi - 1);
        graph[Bi - 1].push_back(Ai - 1);
    }

    vector<int> stamp(N, -1);

    queue<pair<int, int>> q;
    q.push(pair<int, int>(0, 0));

    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();

        if (stamp[p.first] != -1) {
            continue;
        }

        stamp[p.first] = p.second;

        for (size_t i = 0; i < graph[p.first].size(); i++) {        
            if (stamp[graph[p.first][i]] == -1) {
                q.push(pair<int, int>(graph[p.first][i], p.first));
            }
        }
    }

    bool isComplete = true;
    for (int i = 0; i < N; i++) {
        if (stamp[i] == -1) {
            isComplete = false;
            break;
        }
    }

    if (isComplete) {
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) {
            cout << stamp[i] + 1 << endl;
        }

    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 10272
#include <bits/stdc++.h>
using namespace std;
 
string suite = "SHCD";
 
bool cards[4][13];
 
int main(){
    int N; cin >> N;
    for(int i=0; i<N; i++){
        char s; cin >> s;
        int x; cin >> x; x--;
        cards[suite.find(s)][x] = true;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++) if(!cards[i][j]){
            cout << suite[i] << " " << j+1 << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 3132
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
p = wi()
q = sorted(p)

for i in range(n):
    if p[i] != q[i]:
        tmp += 1

if tmp == 0 or tmp == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 6220
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        mut ab: [(u64, u64); n],
    }
    ab.sort_by_key(|&(a, _)| a);
    let mut ans = 0;
    let mut cnt = 0;
    for (a, b) in ab {
        if cnt < m {
            let get = min(m - cnt, b as usize);
            ans += get * a as usize;
            cnt += get;
        }
    }
    println!("{}", ans);
}


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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == s[i+1])
        {
            cout << "Bad" << endl;
            return 0;
        }
        
        
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;

template<typename T>
inline void chkmax(T& x,T y) { if (y>x) x=y; }
inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100+1;

int n,m;
char s[N][N]; short sum[N][N];
short dp[N][N][N][N];

inline short f(int lx,int ly,int rx,int ry) {
    if (lx>rx) swap(lx,rx); if (ly>ry) swap(ly,ry);
    return sum[rx][ry]-sum[lx-1][ry]-sum[rx][ly-1]+sum[lx-1][ly-1];
}

int main() {
    n=read(),m=read(); int x,y;
    for (re int i=1;i<=n;++i) {
        scanf("%s",s[i]+1);
        for (re int j=1;j<=m;++j) {
            if (s[i][j]=='E') x=i,y=j;
            if (s[i][j]=='o') sum[i][j]=1;
        }
    }
    for (re int i=1;i<=n;++i)
        for (re int j=1;j<=m;++j)
            sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
    for (re int u=x;u;--u)
        for (re int l=y;l;--l)
            for (re int d=x;d<=n;++d)
                for (re int r=y;r<=m;++r) {
                    int U=d-x+1,L=r-y+1,D=n-x+u,R=m-y+l;
                    if (u>U) chkmax(dp[u-1][l][d][r],
                                    (short)(dp[u][l][d][r]+f(u-1,max(l,L),u-1,min(r,R))));
                    if (l>L) chkmax(dp[u][l-1][d][r],
                                    (short)(dp[u][l][d][r]+f(max(u,U),l-1,min(d,D),l-1)));
                    if (d<D) chkmax(dp[u][l][d+1][r],
                                    (short)(dp[u][l][d][r]+f(d+1,max(l,L),d+1,min(r,R))));
                    if (r<R) chkmax(dp[u][l][d][r+1],
                                    (short)(dp[u][l][d][r]+f(max(u,U),r+1,min(d,D),r+1)));
                }
    short ans=0;
    for (re int u=x;u;--u)
        for (re int l=y;l;--l)
            for (re int d=x;d<=n;++d)
                for (re int r=y;r<=m;++r)
                    chkmax(ans,dp[u][l][d][r]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 201088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    class A
    {
        static void Main(string[] args)
        {
           int n = int.Parse(Console.ReadLine());
           
           string s = n.ToString();
           if(s[0]==s[2])
           {
              Console.WriteLine("Yes");
           }else{
              Console.WriteLine("No");
           }
        }
          
    }
}

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

int main(){
  set<int> s;
  for(int i=0;i<3;i++){
    int n;
    cin >> n;
    s.insert(n);
  }
  if(s.size()==2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;

}

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

using namespace std;

#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define int long long
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define MOD 1000000007

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

int n, i;

signed main()
{
    fast_IO;
    int test = 1;
    // cin >> test;
    while(test--)
    {
        cin >> n;
        int a[n];
        for(i = 0; i < n; i++)
            cin >> a[i];
        int cnt = 0;
        for(i = 0; i < n; i++)
        {
            for(int j = i + 1; j < n; j++)
            {
                for(int k = j + 1; k < n; k++)
                {
                    if(a[i] + a[j]  > a[k] and a[i] + a[k]  > a[j] and a[k] + a[j]  > a[i] and a[i] != a[j] and a[j] != a[k] and a[i] != a[k])
                        cnt++;
                }
            }
        }
        cout << cnt << endl;
    } 
    return 0;
}

Measured memory_bytes: 3644
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 3e5+5 ,mod = 1e9+7 ;

int n ,m ,x ,mem[N] ;
bool is[N] ;
int solve(int i){
    if(i>n) return 0;
    if(is[i]) return 0;
    if(i==n) return 1;
    int&ret = mem[i];
    if(~ret) return ret;
    return ret = (solve(i+1) + solve(i+2))%mod ;
}
int main(){
    cin >> n >> m ;
    memset(mem,-1,sizeof mem);
    while(m--){
        scanf("%d",&x);
        is[x] = 1 ;
    }
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 4608
#include <stdio.h>



int main(void){
  
  int n;
  scanf("%d", &n);
  
  int num = 100000;
  int i;
  
  for( i = 0; i < n; i++ ){
    num = (int)(num * 1.05 );
    if( num % 1000 ) num += 1000;
    num /= 1000;
    num *= 1000;
  }
  
  printf("%d\n", num );
  
  return 0;
}

Measured memory_bytes: 592
import math
n , d = map(int, input().split())
x = []
for i in range(n):
    line = list(map(int, input().split()))
    x.append(line)

counter = 0
for i in range(n):
    for j in range(i + 1, n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] - x[j][k]) ** 2
        distance = math.sqrt(distance)
        if distance == int(distance):
            counter += 1
print(counter)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {

 ll N;
  cin >>N;
  ll x=N*(N-1);
  ll y=x/2;
  cout<<y<<endl;
}

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

int main()
{
    int n,temp,f[100]={},p[100][11],c,d,profit=0,max;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<10;j++){
        cin >> temp;
        f[i]=2*f[i]+temp;
        }
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<11;j++)
        cin >> p[i][j];
    for (int i=0;i<n;i++)
    {
        d=1&f[i];
        c=0;
        for (int j=0;j<10;j++)
        {
            c+=(d%2==1);
            d=d/2;
        }
        profit+=p[i][c];
    }
    max=profit;
    for (int a=2;a<1024;a++){
    profit=0;
    for (int i=0;i<n;i++)
    {
        d=a&f[i];
        c=0;
        for (int j=0;j<10;j++)
        {
            c+=(d%2==1);
            d=d/2;
        }
        profit+=p[i][c];
    }
    if (profit>max) max=profit;
    }
    cout << max << endl;
    return 0;
}


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

typedef long long ll;
ll n, m, z, t1[2005],t2[2005],t3[2005], d[1005];
vector<int> a[1005], b[1005];
int main()
{
	ll i,j, k, x, y;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf ("%lld %lld %lld", &t1[i], &t2[i], &t3[i]);
		a[t1[i]].push_back(t2[i]);
		b[t1[i]].push_back(-t3[i]);
	}
	for (i = 2; i <= n; i++) d[i] = 9e15;
	for (i = 0; i < n; i++) {
		for (j = 1; j <= n; j++) {
			for (k =0; k < a[j].size(); k++) {
				x = a[j][k];
				y = b[j][k];
				if (d[x] > d[j] + y) {
					d[x] = d[j] + y;
					if (i == n - 1 && x == n) {
						cout << "inf";
						return 0;
					}
				}
			}
		}
	}
	cout << -d[n];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b){
        if(a%b==0) cout<<0<<endl;
        else cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

type edge struct {
	u, v, w int
}

func main() {
	var l int
	fmt.Scanf("%d", &l)

	n, m := 0, 0
	digits := make([]int, 20)
	for i := 0; i < 20; i++ {
		if (l & (1 << uint(i))) > 0 {
			digits[i] = 1
			n = i + 1
		}
	}

	edges := make([]edge, 0)

	for i := 1; i < n; i++ {
		m++
		addEdge(&edges, i, i+1, 1<<uint(i-1))

		m++
		addEdge(&edges, i, i+1, 0)
	}

	tot := (1 << uint(n-1)) - 1
	for i := 0; i < n-1; i++ {
		if digits[i] == 1 {
			m++
			addEdge(&edges, i+1, n, tot+1)

			tot += (1 << uint(i))
		}
	}

	fmt.Println(n, m)
	for _, ed := range edges {
		fmt.Println(ed.u, ed.v, ed.w)
	}
}

func addEdge(edges *[]edge, a, b, c int) {
	*edges = append(*edges, edge{
		u: a,
		v: b,
		w: c,
	})
}


Measured memory_bytes: 512
H, W = map(int, input().split())
func = (lambda x: 1 if x == "#" else 0)
field = [[func(i) for i in input()] for _ in range(H)]
blackQ = []

for i, wField in enumerate(field):
    for j, w in enumerate(wField):
        if w == 1:
            blackQ.append((i, j))

ans = 0
while(True):
    bQ = []
    for _ in range(len(blackQ)):
        i, j = blackQ.pop()
        if i - 1 >= 0 and field[i-1][j] != 1:
            field[i-1][j] = 1
            bQ.append((i - 1, j))
        if i + 1 <= H - 1 and field[i+1][j] != 1:
            field[i+1][j] = 1
            bQ.append((i + 1, j))
        if j - 1 >= 0 and field[i][j-1] != 1:
            field[i][j-1] = 1
            bQ.append((i, j - 1))
        if j + 1 <= W - 1 and field[i][j + 1] != 1:
            field[i][j+1] = 1
            bQ.append((i, j + 1))

    if len(bQ) == 0:
        break

    ans += 1
    blackQ = bQ

print(ans)



Measured memory_bytes: 116368
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        x = format(i, "b").zfill(h)
        y = format(j, "b").zfill(w)
        for xi in range(h):
            for yi in range(w):
                if x[xi] == "0" and y[yi] == "0":
                    if c[xi][yi] == "#":
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

using namespace std;

int main() {
    int n;
    string s;

    cin >> n >> s;

    vector<int> vec;
    int cont = 1;
    for (int i=1; i<n; i++) {
        if (s[i] != s[i-1]) {
            vec.push_back(cont);
            cont = 1;
        }
        else {
            cont++;
        }
    }
    vec.push_back(cont);

    if (s[0] == '.') vec.erase(vec.begin());
    if (s[n-1] == '#') vec.erase(vec.end()-1);

    int bk = 0, wt = 0, len = vec.size();
    for (int i=1; i<len; i+=2) {
        wt += vec[i];
    }

    //cout << wt << endl;

    int ans = wt;
    for (int i=1; i<len; i+=2) {
        bk += vec[i-1];
        wt -= vec[i];
        ans = min(ans, wt+bk);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main(){
    int n, count = 0;
    cin >> n;
    vector<int> a(n+1);
    rep3(i,1,n) cin >> a.at(i);
    rep3(i,1,n) {
        if(i == a.at(a.at(i))) {
            count++;
        }
    }
    cout << count / 2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	ll l, r;
	cin >> l >> r;
	if(l / 2019 < r / 2019) {
		cout << 0 << endl;
		return 0;
	}
	l %= 2019;
	r %= 2019;
	int ans = INF;
	for(int i = l; i <= r - 1; i++) {
		for (int j = i + 1; j <= r; j++) {
			ans = min((i * j) % 2019, ans);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def a(i)
  return 0 if i < 100 || i > 100000
  r = i - 100 * i.div(100)
  1.upto(i.div(100)) do |n|
    [0, 1, 2, 3, 4, 5].repeated_combination(n) do |c|
      return 1 if r == c.sum
    end
  end
  0
end
p a(gets.to_i)

Measured memory_bytes: 15020
// floyd2.cpp : アプリケーションのエントリ ポイントを定義します。
//

// floyd.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
using namespace std;

int main(){
    int a,b,num,sum = 0,i = 1;
    
    cin >> a >> b;

    num = b - a;

    while (num >=i) {
        sum += i;
        i++;
    }
    sum -= b;

    cout << sum << endl;

    cout << endl;
}

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

int main() {
    ll n,k,s;
    cin>>n>>k>>s;
    for(ll i=1;i<=k;i++)
    cout<<s<<" ";
    for(ll i=k+1;i<=n;i++){
        if(s==1e9)
            cout<<1<<" ";
        else
            cout<<s+1<<" ";
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
const int MAX = 2147483647;
int min(int a, int b) {
	return a < b ? a : b;
}
int getSegTreeSize(int len) {
	if (len == 0)
		return 0;
	int ret, cnt = 0, memo = 1;
	while (memo < len) {
		memo *= 2;
		cnt++;
	}
	ret = 1 << (cnt + 1);
	return ret;
}
class RMQ {
  private:
	int size, length;
	std::vector<int> memo;
	RMQ() {}
	void update(int index) {
		index /= 2;
		if (index == 0)
			return;
		memo[index] = min(memo[index * 2], memo[index * 2 + 1]);
        update(index);
	}
	int get(int left, int right, int node, int node_left, int node_right) {
		if (node_right < left || right < node_left)
			return MAX;
		if (left <= node_left && node_right <= right)
			return memo[node];
		return min(get(left, right, node * 2, node_left, (node_left + node_right) / 2), get(left, right, node * 2 + 1, (node_left + node_right) / 2 + 1, node_right));
	}

  public:
	RMQ(int size) {
		this->size = getSegTreeSize(size) / 2;
		this->length = getSegTreeSize(size);
		memo.resize(this->length);
		fill(memo.begin(), memo.end(), MAX);
	}
	void update(int index, int element) {
		index += length / 2 - 1;
		memo[index] = element;
		update(index);
	}
	int find(int left, int right) {
		return get(left, right, 1, 1, size);
	}
};
int main() {
	int n, q;
	std::cin >> n >> q;
	RMQ segTree(n);
	for (int i = 0; i < q; i++) {
		int com, x, y;
		std::cin >> com >> x >> y;
		if (com == 0)
			segTree.update(x + 1, y);
		else
			std::cout << segTree.find(x + 1, y + 1) << std::endl;
	}
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define endl '\n'
#define M 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

void solve() {
     int n;cin>>n;
     int a[n]={0},b[n]={0};
     ll sm=0;
     for(int i=0;i<n;i++)cin>>a[i];
     for(int i=0;i<n;i++)cin>>b[i];
     for(int i=0;i<n;i++){
         if(a[i]>b[i])sm+=a[i]-b[i];
     }
     cout<<sm<<endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t=1;
  while (t--) {
     solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int n;cin>>n;
int a[n],b[n];
int c[n-1];
rep(i,n)cin >> a[i];
rep(i,n)cin>> b[i];
rep(i,n-1)cin >> c[i];
int sum=0;
rep(i,n){
    sum+=b[a[i]-1];
}
rep(i,n-1){
    if(a[i+1]==a[i]+1)sum+=c[a[i]-1];
}
cout << sum << endl;
}

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

int main(){
  int N,k;
  long long a=0;
  cin >> N >> k;
  vector<int>b(N);
  for(int i=0;i<N;i++){
    cin >> b.at(i);
  }
  sort(b.begin(), b.end());
  for(int i=0;i<N-k;i++){
    a=a+b.at(i);
  }
  cout << a<<endl;
}


Measured memory_bytes: 1024
// Good Integer

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

	if (N[0] == N[1] && N[1] == N[2])
		cout << "Yes" << endl;
	else if (N[1] == N[2] && N[2] == N[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int n=scan.nextInt();
		if(n==0)break;
		int count=0;
		
		while(n!=1)
		    {
			if(n%2==0)n/=2;
			else n=3*n+1;
			count++;
		    }
		System.out.println(count);
	    }
    }
}

Measured memory_bytes: 17188
def factorization(n):
    ans = {}
    i = 2
    while n > 1:
        count = 0
        while n % i == 0:
            n = n // i
            count += 1
        if count != 0:
            ans[i] = count
        i += 1
    return ans


N = int(input())
primes = {}
for n in range(2, N + 1):
    factors = factorization(n)
    for f in factors:
        if f in primes:
            primes[f] += factors[f]
        else:
            primes[f] = factors[f]

ans = 0
# 75
for p in primes:
    if primes[p] >= 74:
        ans += 1

# 25 * 3 and 15 * 5
for p in primes:
    for q in primes:
        if p == q:
            continue
        if primes[p] >= 24 and primes[q] >= 2:
            ans += 1
        if primes[p] >= 14 and primes[q] >= 4:
            ans += 1

# 3 5 5
for p in primes:
    if primes[p] >= 2:
        for q in primes:
            if p != q and primes[q] >= 4:
                for r in primes:
                    if p != r and q != r and primes[r] >= 4 and q < r:
                        ans += 1
print(ans)

Measured memory_bytes: 3188
# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
    # parents
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # find(x)
    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # union(x, y)
    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

import sys
def input():
    return sys.stdin.readline().strip()

n, k, l = map(int, input().split())

road = UnionFind(n)
rail = UnionFind(n)
for _ in range(k):
    p, q = map(int, input().split())
    road.union(p-1, q-1)
for _ in range(l):
    r, s = map(int, input().split())
    rail.union(r-1, s-1)

dic = {}
l = []
for i in range(n):
    tup = (road.find(i), rail.find(i))
    l.append(tup)
    if tup in dic:
        dic[tup] += 1
    else:
        dic[tup] = 1

ans = []
for i in l:
    ans.append(dic[i])

print(' '.join(map(str, ans)))

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

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) a[i] = sc.nextInt();
        sc.close();
        Arrays.sort(a);
        long ans = 0;
        for(int i=0;i<n-k;i++){
            ans += a[i];
        }
        return ans;
    }
}



Measured memory_bytes: 64000
#include<iostream>
#include<algorithm>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define Z 12000
using namespace std;
int d[Z+1];
int main(){
	int n,m,k,r,l;
	while(true){
		cin>>n>>k>>m>>r;
		if(!(n+m+k+r))break;
		rep(i,0,Z)d[i]=0;
		k=1,l=n;
		rep(i,0,Z)d[i]+=k/l,k%=l,k*=10;
		if(m)rep(i,1,n){k=1,l=i*n;rep(j,0,Z)d[j]+=k/l,k%=l,k*=10;}
		for(int i=Z;i>0;i--)d[i-1]+=d[i]/10,d[i]%=10;
		cout<<d[0]<<".";
		rep(i,1,r+1)cout<<d[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128