akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> h(n), x(n), y(n);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> h[i];
  ll ans = 0, ansx = 0, ansy = 0;
  for (int gx = 0; gx <= 100; gx++)
    for (int gy = 0; gy <= 100; gy++) {
      ll g = 0;
      for (int i = 0; i < n; i++)
        if (h[i])
          g = max(g, h[i] + abs(x[i] - gx) + abs(y[i] - gy));
      bool ok = true;
      for (int i = 0; i < n; i++) {
        if (max(g - abs(x[i] - gx) - abs(y[i] - gy), 0LL) != h[i]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (ans < g) {
          ans = g;
          ansx = gx;
          ansy = gy;
        }
      }
    }
  cout << ansx << " " << ansy << " " << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;
using ll = long long;

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

    ll A[N], B[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }

    int ans = 0;
    priority_queue<ll> excess;
    ll lack = 0;

    for (int i = 0; i < N; ++i) {
        ll diff = A[i] - B[i];
        if (diff < 0) {
            lack -= diff;
            ++ans;
        } else {
            excess.push(diff);
        }
    }

    while (!excess.empty() && lack > 0) {
        ll d = excess.top();
        excess.pop();
        lack -= d;
        ++ans;
    }

    cout << (lack <= 0 ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 2808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, ans = 0;
		
		n = sc.nextInt();
		
		ans = 800 * n - (n / 15) * 200;
		
		System.out.println(ans);
		
		sc.close();
	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <bitset>
using namespace std;
#define mod 1000000009
int arr[5005],dp[5005],tmp[5005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	dp[0]=1;
	for (int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		for (int j=k;j>=arr[i];j--)
		dp[j]=(dp[j]+dp[j-arr[i]])%mod;
	}
	int ans=n;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<=k;j++)
		tmp[j]=dp[j];
		for (int j=arr[i];j<=k;j++)
		tmp[j]=(tmp[j]-tmp[j-arr[i]]+mod)%mod;
		for (int j=max(k-arr[i],0);j<k;j++)
		{
			if (tmp[j])
			{
				ans--;
				break;
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 384
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {
    vector<vector<int>> vec1(3,vector<int> (10));
    rep(i,3){
        rep(j,10){
            vec1.at(i).at(j) = 0;
        }
    }
    vector<vector<int>> vec2(3,vector<int> (10));
    rep(i,3){
        rep(j,10){
            vec2.at(i).at(j) = 0;
        }
    }
    vector<vector<int>> vec3(3,vector<int> (10));
    rep(i,3){
        rep(j,10){
            vec3.at(i).at(j) = 0;
        }
    }
    vector<vector<int>> vec4(3,vector<int> (10));
    rep(i,3){
        rep(j,10){
            vec4.at(i).at(j) = 0;
        }
    }
    int n;
    read(n);
    rep(i,n){
        int b,f,r,v;
        read(b);
        read(f);
        read(r);
        read(v);
        switch(b){
            case 1:
                vec1.at(f - 1).at(r - 1) += v;
                break;
            case 2:
                vec2.at(f - 1).at(r - 1) += v;
                break;
            case 3:
                vec3.at(f - 1).at(r - 1) += v;
                break;
            case 4:
                vec4.at(f - 1).at(r - 1) += v;
                break;
        }
    }
    rep(i,3){
        rep(j,10){
            print(" ");
            print(vec1.at(i).at(j));
        }
        printn;
    }
    rep(i,20)print("#");
    printn;
    rep(i,3){
        rep(j,10){
            print(" ");
            print(vec2.at(i).at(j));
        }
        printn;
    }
    rep(i,20)print("#");
    printn;
    rep(i,3){
        rep(j,10){
            print(" ");
            print(vec3.at(i).at(j));
        }
        printn;
    }
    rep(i,20)print("#");
    printn;
    rep(i,3){
        rep(j,10){
            print(" ");
            print(vec4.at(i).at(j));
        }
        printn;
    }
}

signed main() {
    solve();
    return 0;
}


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

int main(void) 
{
    int n;
    ll d;
    cin >> n >> d;
    ll ans = 0;
    rep(i,n){
        ll x, y;
        cin >> x >> y;
        long double sum = sqrtl(x*x + y*y);
        if(sum <= d) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
    int A,B,C,D,L,R;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    L=A+B;
    R=C+D;
    if(L>R) {
        printf("Left\n");
    }
    else if(L==R) {
        printf("Balanced\n");
    }
    else {
    printf("Right\n");
    }
    return 0;
}


Measured memory_bytes: 1620
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[10]; 
int main(){
	for(int i=1;i<=5;i++){
		cin>>a[i];
	}
	for(int i=1;i<=5;i++){
		if(a[i]!=i){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
import sys

def main():
    n = int(sys.stdin.readline())
    s_lst = []

    m_default = 101
    min_not_10 = m_default #10の倍数でない数で最小の数
    for i in range(n):
        t = int(sys.stdin.readline())
        if t < min_not_10 and t % 10 != 0:
            min_not_10 = t

        s_lst.append(t)


    max_cand = sum(s_lst)
    if max_cand % 10 != 0:
        print(max_cand)
    else:
        if min_not_10 == m_default:
            print(0)
        else:
            print(max_cand - min_not_10)

    return 0

if __name__ == '__main__':
    sys.exit(main())


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


int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a >= k) cout << a-k << " " << b << endl;
  else if(a+b >= k) cout << 0 << " " << b-(k-a) << endl;
  else cout << 0 << " " << 0 << endl;
  return 0;
}

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

import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = collections.Counter(prime_factorize(N))

ans = 0
for i in c.values():
    for j in range(1,i+1):
        i -= j
        if i >= 0:
            ans += 1
        else:
            break

print(ans)



Measured memory_bytes: 65976
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define int         int64_t

using namespace std;

const int N = int(2e5) + 7;
const int oo = int(1e18) + 7;

int a, b;

int mul(int x, int y) {
    if(x != 0 && oo / x < y) return oo;
    return x * y;
}

int Get(int la, int ra, int lb, int rb) {
   int res = 0; if(la > ra) swap(la, ra); if(lb > rb) swap(lb, rb);
   res = max(mul(la, rb), mul(lb, ra));
   int mid = (la + rb) / 2;
   if(mid <= ra && mid >= la && la + rb - mid >= lb && la + rb - mid <= rb) res = max(res, mul(mid, la + rb - mid));
   if(mid <= rb && mid >= lb && la + rb - mid >= la && la + rb - mid <= ra) res = max(res, mul(mid, la + rb - mid));
   return res;
}

bool Check(int x) {
    if(a > x) return Get(1, x, 1, x) < a * b;
    if(a <= x && b > x) return max(Get(1, a - 1, x - a + 2, x), Get(a + 1, x + 1, 1, x - a + 1)) < a * b;
    int res = 0, l, r;
    if(x - b + 1 < a - 1) {
       l = x - b + 1;
       res = max(res, Get(1, l, x - l + 2, x + 1));
       res = max(res, Get(a + 1, x + 1, 1, x + 1 - a));
       res = max(res, Get(l + 1, a - 1, x + 2 - a, x - l));
    } else {
       l = a - 1, r = b - 1;
       res = max(res, Get(1, l, x - l + 1, x));
       res = max(res, Get(l + 2, x + 1 - b, b + 1, x - l));
       res = max(res, Get(x + 3 - b, x + 1, 1, b - 1));
    }
    return res < a * b;
}

void Solve() {
    cin >> a >> b; if(a > b) swap(a, b);
    if(a == b) {cout << 2 * a - 2 << '\n'; return;}
    int low = 1, mid, high = int(1e18) + 7;
    while(low <= high) {
        mid = (low + high) >> 1;
        if(Check(mid)) low = mid + 1;
        else high = mid - 1;
    }
    cout << high << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    int nTest; cin >> nTest;
    while(nTest --) Solve();
}


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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int k=0;
        while(a>0 && c>0){
            if(k%2==0){
                c-=b;
                k++;
            }
            else{
                a-=d;
                k++;
            }
        }
        if(a<=0)
            cout<<"No";
        else
            cout<<"Yes";
        return 0;
    }


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



int main()
{
    string s;
    cin >> s;
    ll left = 0, right = s.length() - 1;
    ll ans = 0;
    while(left <= right){
        if(s[left] != s[right]) ans++;
        left++;
        right--;
    }
    cout << ans << endl;



}

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

int main() {
  int n; cin >> n;
  vector<int64_t> a(n);
  for (int i = 0; i < n; i++) scanf("%lld" , &a.at(i));
  int64_t max_a, min_a, sum_a;
  max_a = -10000000; min_a = 10000000; sum_a = 0;
  for (int i = 0; i < n; i++) {
    if (max_a < a.at(i)) max_a = a.at(i);
    if (min_a > a.at(i)) min_a = a.at(i);
    sum_a += a.at(i);
  }
  cout << min_a << " " << max_a << " " << sum_a << endl;
}


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

int main(){
    int n = 0;
    char ch[9];
    for (int i = 0; i < 9; i++){
        cin >> ch[i];
    }

    for (int i = 0; i < 3; i++){
        cout << ch[4*i];
    }
    puts("\n");
    
    int flag=0;
    int ans=0;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
typedef struct proces{
  char name[10];
  int count;
  int time;
  }def;

int head,n,tail;
def c[100000];


void enq(def s){
  c[tail]=s;
  
  tail=(tail+1)%100000;

}


def deq(){
  def sd=c[head];
  head=(head+1)%100000;
  
  return sd;
}


int min(int k,int l){
  if(k>l) return l;
  else return k;
}


int main(){
  int tasu,i,q,b,sum=0;
  def type;
  scanf("%d %d",&b,&q);
  for(i=1;i<=b;i++){
    scanf("%s",c[i].name);
    scanf("%d",&c[i].time);
    c[i].count=1;
  }
  head=1;
  tail=b+1;
  while(tail != head){
    type=deq();
    tasu=min(q,type.time);
    type.time=type.time-tasu;
    sum=sum+tasu;
    if(type.time>0){
      enq(type);
    }
    else if(type.count==1){
      
      printf("%s %d\n",type.name,sum);
      type.count=0;
    }
    
  }
  return 0;
}



Measured memory_bytes: 3804
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N = 0, maisu = 0;
	cin >> N >> maisu;
	for (int i = 0; i <= N; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			if (i + j > N)
			{
				continue;
			}
			if (i * 10 + j * 5 + (N - i - j) == (maisu / 1000))
			{
				cout << i << " " << j << " " << N - i - j << endl;
				N = 0;
				break;
			}
		}
	}
	if (N != 0)
	{
		cout << "-1 -1 -1" << endl;
	}
}


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

int n;
int a[2000005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	int tot=0;
	for (int i=1;i<=n;i++)
	{
		if (i%2==1&&a[i]%2==1)  tot++;
	 } 
	
	cout<<tot<<endl;
	
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<vector<int64_t>> p(19,vector<int64_t>(19));
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    int64_t Z=0;
    int M=S.size();
    int ni=0,go=0;
    for(int j=0;j<M;j++){
      if(S[j]=='.'){
        ni=-(M-j-1),go=-(M-j-1);
      }
      else{
        Z*=10;
        Z+=(S[j]-'0');
      }
    }
    while(Z%2==0){
      ni++;
      Z/=2;
    }
    while(Z%5==0){
      go++;
      Z/=5;
    }
    ni+=9,go+=9;
    p[min(18,ni)][min(go,18)]++;
  }
  int64_t A=0;
  for(int i=0;i<19;i++){
    for(int j=0;j<19;j++){
      for(int k=0;k<19;k++){
        for(int l=0;l<19;l++){
          if(i+k>=18&&j+l>=18&&!(i==k&&j==l)){
            A+=p[i][j]*p[k][l];
          }
          else if(i+k>=18&&j+l>=18){
            A+=p[i][j]*(p[i][j]-1);
          }
        }
      }
    }
  }
  A/=2;
  cout<<A<<endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int N;

void  rot(int& a, int& b) {
	int na=b;
	int nb=N-a-1;

	a=na;
	b=nb;
}

int solve(vector<vector<int>>coors) {

	int ans=1e9;
	int same_num = 0;
	for (int i = 0; i<3; ++i)if (coors[0][i] == coors[1][i])same_num++;


	if (same_num == 0) {
		bool flag = true;
		for (int i = 0; i<3; ++i)if (coors[0][i] + coors[1][i] != N - 1)flag = false;

		if (flag) {
			ans = min(ans, 5);
		}
		else {

			int now_x = coors[0][0];
			int now_y = coors[0][1];
			int now_z = coors[0][2];
			for (int i = 0; i < 4; ++i) {
				for (int j = 0; j < 4; ++j) {
					for (int k = 0; k < 4; ++k) {
						int anum = 0;
						anum = (i == 3 ? 1 : i) + (j == 3 ? 1 : j) + (k == 3 ? 1 : k);
						for (int l = 0; l < 3; ++l) {
							anum += abs(coors[0][l] - coors[1][l]);
						}
						ans = min(ans, anum);

						rot(coors[0][2], coors[0][0]);
					}
					rot(coors[0][0], coors[0][1]);
				}
				rot(coors[0][1], coors[0][2]);
			}
		}
	}
	else if (same_num == 1) {
		int same_pos=-1;
		for(int i=0;i<3;++i)if(coors[0][i]==coors[1][i])same_pos=i;

		vector<int>v{ 0,1,2 };
		v.erase(find(v.begin(),v.end(),same_pos));


		for (int i = 0; i < 4; ++i) {
			int anum = 2;
			anum += (i == 3 ? 1 : i) ;
			for (int l = 0; l < 3; ++l) {
				anum += abs(coors[0][l] - coors[1][l]);
			}
			ans = min(ans, anum);
			rot(coors[0][v[0]], coors[0][v[1]]);
		}
	
	}
	else if(same_num==2){
		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				for (int dz = -1; dz <= 1; ++dz) {
					vector<int>ncoor(coors[0]);
					ncoor[0]+=dx;
					ncoor[1]+=dy;
					ncoor[2]+=dz;

					bool ok=true;

					int n_same_num=0;
					for (int i = 0; i < 3; ++i) {
						if(ncoor[i]<0||ncoor[i]>=N)ok=false;

						if(ncoor[i]==coors[1][i])n_same_num++;
					}
					if(n_same_num>=2)ok=false;
					if (ok) {
						int need=abs(dx)+abs(dy)+abs(dz);
						ans = min(ans, need+solve(vector<vector<int>>{ncoor, coors[1]}));
					}

				}
			}
		}
	}
	return ans;
}

int main() {
	int N,M,C;cin>>N>>M>>C;
	vector<int>ls(C);
	for(int i=0;i<C;++i)cin>>ls[i];

	vector<pair<int,int>>ps;
	for (int i = 0; i < N; ++i) {
		int c,w;cin>>c>>w;c--;
		ps.emplace_back(c,w);
	}
	sort(ps.begin(), ps.end(), [](const pair<int, int>&l, const pair<int, int>&r) {return l.second > r.second; });

	int ans=0;

	for (auto p : ps) {
		if (M) {
			if (ls[p.first]) {
				M--;
				ls[p.first]--;
				ans+=p.second;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4192
#include<algorithm>
#include<iostream>

int c[100];

int main()
{
	int a;
	
	while( std::cin >> a ){
		c[a-1]++;
	}
	
	int c_max = 0;
	for( int i = 0; i < 100; i++ ){
		c_max = std::max( c_max, c[i] );
	}
	
	for( int i = 0; i < 100; i++ ){
		if( c[i] == c_max ){
		 	std::cout << i + 1 << std::endl;
		}
	}

 	return 0;
}

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

using namespace std;

void Main()
{
    string s, t;
    cin >> s >> t;
    cout << t << s;
}

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

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

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[5005][5] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}




int main() {

	cin >> N>>a;

	if (a == 1) {
		cout << 0 << endl;
	}
	else {
		cout << N - a << endl;
	}
	return 0;

}


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int l;
vector<ll> v(26, 0);

void init()
{
	string s;
	cin >> s;
	l = s.length();
	rep(i, l) {
		v[s[i] - 'a']++;
	}
}

void solve()
{
	ll res = (ll) l * (l - 1) / 2;
	rep(i, 26) {
		res -= v[i] * (v[i]-1) / 2;
	}
	cout << res + 1 << endl;
}


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

int main() {
    int s; cin >> s;
    int a[1000000] = {0};
    a[s] = 1;
    int b = s;
    int i = 1;
    while(1) {
        ++i;
        if (b % 2 == 0) {
            b = b / 2; 
            a[b] += 1;
            if (a[b] == 2) break;
        } else {
            b = 3 * b + 1;
            a[b] += 1;
            if (a[b] == 2) break;
        }
    }
    cout << i << endl;
}

Measured memory_bytes: 4096
#include <stdio.h>
#define SIZE 200000

int main(void){
	int N, i, j, a[SIZE], sub;
	int max = -1000000000;
	int min = 2000000000;

	scanf("%d",&N);

	for(i = 0; i < N; i++){
		scanf("%d",&a[i]);
		sub = a[i] - min;
		if(a[i] < min) min = a[i];
		if(sub > max) max = sub;
	}
	printf("%d\n", max);

}

Measured memory_bytes: 2632
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
	Scanner scn = new Scanner(System.in);
	String a = scn.next();
      String b = scn.next();
      String h = "H";
      String d = "D";
      int check = 0;
      if(a.equals(h)){
       if(b.equals(d)){
         check=1;
       }
      }
      if(a.equals(d)){
       if(b.equals(h)){
         check=1;
       }
      }
      if(check==1){
        System.out.println("D");
      }else{
        System.out.println("H");
      }
	}
}


Measured memory_bytes: 35632
import sys

class Node:
    def __init__(self,data=None):
        self.data  = data
        self.left  = None
        self.right = None
    
def search(node,x):
    if node is None:
        return 'no'
    elif node.data == x:
        return 'yes'
    elif node.data > x:
        return search(node.left,x)
    else:
        return search(node.right,x)

def insert(node,x):
    if node is None:
        node = Node(x)
    elif node.data == x:
        return node
    elif node.data > x:
        node.left = insert(node.left,x)
    else:
        node.right = insert(node.right,x)
    return node

def search_min(node):
    if node.left is None:
        return node.data
    return search_min(node.left)

def delete_min(node):
    if node.left is None:
        return node.right
    node.left = delete_min(node.left)
    return node

def delete(node,x):
    if node:
        if x == node.data:
            if node.left is None:
                return node.right
            elif node.right is None:
                return node.left
            else:
                node.data = search_min(node.right)
                node.right = delete_min(node.right)
        elif x < node.data:
            node.left = delete(node.left,x)
        else:
            node.right = delete(node.right,x)
    return node

class BST:
    def __init__(self):
        self.root = None

    def insert(self,x):
        if self.root is None:
            self.root = Node(x)
        else:
            self.root = insert(self.root,x)
    
    def search(self,x):
        return search(self.root,x)

    def delete(self,x):
        self.root = delete(self.root,x)

def mid_walk(node):
    if node is None:
        return 
    yield from mid_walk(node.left)    
    yield node.data
    yield from mid_walk(node.right)

def pre_walk(node):
    if node is None:
        return 
    yield node.data
    yield from pre_walk(node.left)
    yield from pre_walk(node.right)

n = int(input())
bt = BST()
for line in sys.stdin:
    if line[:1] == 'i':
        bt.insert(int(line[7:]))
    elif line[:1] == 'f':
        print(bt.search(int(line[5:])))
    elif line[:1] == 'p':
        print(' '+' '.join(map(str,mid_walk(bt.root))))
        print(' '+' '.join(map(str,pre_walk(bt.root))))
    else:
        bt.delete(int(line[7:]))





Measured memory_bytes: 115384
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;

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

int n;
vector<int> x;
vector<int> y;

double d(int i, int j){
	double ans(0);
	double X = x[j] - x[i];
	double Y = y[j] - y[i];
	ans = sqrt(pow(X,2.0) + pow(Y,2.0));
	return ans;
}

int kaijo(int n){
	int ans(1);
	for(int i(n);i>0;i--){
		ans *= i;
	}
	return ans;
}

int main(){
	cin >> n;
	x.resize(n);y.resize(n);
	rep(i,n)cin >> x[i] >> y[i];

	double total(0);
	rep(i,n)rep(j,n) total += d(i,j);

	int kumiawase = kaijo(n) * (n-1) / (n*(n-1)/2);
	kumiawase /= 2;

	double ans = total * kumiawase / kaijo(n);

	cout << std::fixed << std::setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

a,b,c,d = MI()
x,y = c-a,d-b
ANS = ['R']*x + ['U']*y + ['L']*x + ['D']*(y+1) + ['R']*(x+1) + ['U']*(y+1) + ['L'] + ['U'] + ['L']*(x+1) + ['D']*(y+1) + ['R']
print(''.join(ANS))


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

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

  int a, b;
  cin >> a >> b;
  int c = a + b;
  if (c & 1)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << c / 2 << endl;
}


Measured memory_bytes: 256
n=int(input())
l=1
while n>l:
    l*=2
if n==l:
    print("No")
    quit()
print("Yes")
for i in range((n-1)//2):
    t=i*2
    print(1,2+t)
    print(2+t,3+t)
    print(1,3+n+t)
    print(3+n+t,2+n+t)
print(3,1+n)
if n%2==0:
    print(n,(n&-n)+1+n)
    print(2*n,n-(n&-n))

Measured memory_bytes: 5464
#include <iostream>

using namespace std;

int main(){
	int H, W;

	while (true){
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout << "#";
			}
			cout << "\n";
		}
		cout<<"\n";
	}
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int maxi = int(max_element(a, a+3) - a);

    int ans = 0;
    rep(3){
        if(maxi == i) ans += a[i]*10;
        else ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def devide_counter(num):
    devide_count = 0
    while num%2==0:
        num /= 2
        devide_count += 1
    return devide_count

N = int(input())
A = list(map(int, input().split()))

devide_count_list=[]
for a in A:
    devide_count_list.append(devide_counter(a))
    
print(min(devide_count_list))

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

int main(void) {
    string S; cin >> S;
    int ans = 0;
    if(S[0]=='R' && S[1]=='R' && S[2] == 'R') cout << 3 << endl;
    else if(S[0]=='R' && S[1]=='R' && S[2] == 'S') cout << 2 << endl;
    else if(S[0]=='S' && S[1]=='R' && S[2] == 'R') cout << 2 << endl;
    else if(S[0]=='S' && S[1]=='R' && S[2] == 'S') cout << 1 << endl;
    else if(S[0]=='R' && S[1]=='S' && S[2] == 'S') cout << 1 << endl;
    else if(S[0]=='S' && S[1]=='S' && S[2] == 'R') cout << 1 << endl;
    else if(S[0]=='R' && S[1]=='S' && S[2] == 'R') cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int ans=1000000000,n,m,x;
int a[12][12];
int c[12];
int curBooksBought[12];
int skills[12];

void test()
{
    for (int i=0;i<m;++i)
        skills[i]=0;
    int cur=0;
    for (int i=0;i<n;++i)
        if (curBooksBought[i])
        {
            cur+=c[i];
            for (int j=0;j<m;++j)
                skills[j]+=a[i][j];
        }
    for (int i=0;i<m;++i)
        if (x>skills[i])
            return;
    ans=min(ans,cur);
}

void permutations(int cur)
{
    if (cur==n)
    {
        test();
        return;
    }
    curBooksBought[cur]=0;
    permutations(cur+1);
    curBooksBought[cur]=1;
    permutations(cur+1);
    return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m>>x;
    for (int i=0;i<n;++i)
    {
        cin>>c[i];
        for (int j=0;j<m;++j)
            cin>>a[i][j];
    }
    permutations(0);
    if (ans==1000000000)
        cout<<-1;
    else
        cout<<ans;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>

using namespace std;

int main(){

  int n;
  cin >> n;

  string s[n],t[n];

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

  int a[n];

  for(int k=0;k<n;k++){
    int dp[s[k].size()+1][t[k].size()+1];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < s[k].size(); ++i) {
      for (int j = 0; j < t[k].size(); ++j) {
        if (s[k][i] == t[k][j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
      }
    }
    a[k]=dp[s[k].size()][t[k].size()];
  }

  for(int i=0;i<n;i++)cout << a[i] << endl;

}


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

int main() {
    std::string S;

    std::cin >> S;
    if (S == "ABC") {
        std::cout << "ARC" << std::endl;
    } else if (S == "ARC") {
        std::cout << "ABC" << std::endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll r = 0;
    for (int i = 0; i < n; i++) {
        ll k = n - i;
        r += k * (k + 1) / 2;
    }

    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        if (u > v) swap(u, v);

        r -= (ll)(u + 1) * (n - v);
    }

    cout << r << endl;

    //fが頂点数なら簡単 実際は、辺の数だけ減る
    //

    return 0;
}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            Long a = Long.parseLong(in.next());
            Long b = Long.parseLong(in.next());
            Long c = Long.parseLong(in.next());
            Long d = Long.parseLong(in.next());

            Long G = gcd(c, d);
            Long L = c / G * d;
            Long ans1 = b - b / c - b / d + b / L;
            Long ans2 = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / L;

            // 出力
            out.println(ans1 - ans2);

        }

        public static long gcd(long num1, long num2) {
            if (num2 == 0) return num1;
            else return gcd(num2, num1 % num2);
        }

    }
}



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

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

  int ans = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (i & 1) {
      ans += S[i] == 'g';
    } else {
      ans -= S[i] == 'p';
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H;
		int W;
		for (int i = 0; i < 10000; i ++) {
			H = scan.nextInt();
			W = scan.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int h = 0; h < H; h++) {
				for (int w = 0; w < W; w++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    unordered_map<int, unordered_map<int, int>> E;
    REP(m, M){
        scanInt(L); --L;
        scanInt(R); --R;
        scanInt(D);
        E[L][R] = D;
        E[R][L] = -D;
    }
    vector<ll> X(N + 1, LLONG_MIN);
    function<bool(int)> search = [&](int n){
        if (X[n] == LLONG_MIN) X[n] = 0;
        vector<int> nexts;
        for (auto& e : E[n]){
            if (X[e.first] == LLONG_MIN){
                X[e.first] = X[n] + e.second;
                nexts.emplace_back(e.first);
            }else if (X[e.first] != X[n] + e.second){
                return false;
            }
        }
        for (auto& next : nexts){
            if (!search(next)) return false;
        }
        return true;
    };
    REP(n, N){
        if (!search(n)){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<map<int, long long>> mp(n + 1);
  auto rec = [&](auto&& self, int i, int c) -> long long {
    if (c < 0 or c > (n - i + 1) / 2) {
      return -inf<long long>;
    }
    if (i == n) {
      return 0;
    }
    if (i == n - 1) {
      return c ? a.back() : 0;
    }
    if (mp[i].count(c)) {
      return mp[i][c];
    }
    return mp[i][c] = max(a[i] + self(self, i + 2, c - 1), self(self, i + 1, c));
  };
  cout << rec(rec, 0, n / 2) << '\n';
}


Measured memory_bytes: 43760
#include <cstdio>

int main()
{
    char a;
    scanf("%c", &a);
    
    if (a == 'a' or a == 'e' or a == 'i' or a == 'o' or a == 'u')
    {
    	printf("vowel");
	}
	else
	{
		printf("consonant");
    }           
}

Measured memory_bytes: 1648
import itertools


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

Z = []

for count in range(1,int(N)+1):
    Z.append(count)

zyun = itertools.permutations(Z)

abscount = 1
Pcount = 0
Qcount = 0

for cc in zyun:
    if list(cc) == P:
        Pcount = abscount
    if list(cc) == Q:
        Qcount = abscount
    abscount += 1

print(abs(Pcount - Qcount))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,ans = 0;
    cin >> N;
    rep(i,1,N+1){
        if(i % 2 == 0)continue;
        int cnt = 0;
        rep(j,1,i+1)if(i % j == 0)cnt++;
        if(cnt == 8)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;


int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N; cin >> N; // 2以上
    int L; cin >> L;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int num1 = -1;
    rep(i, N-1){
        if(A[i] + A[i+1] >= L){
            num1 = i;
            break;
        }
    }

    if(num1 == -1){
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;

    rep(i, num1){
        cout << i+1 << endl;
    }
    for(int j=N-2; j> num1; j--){
        cout << j+1 << endl;
    }
    cout << num1+1 << endl;
    
    
    return 0;
}


Measured memory_bytes: 1152
def main():
    N = 50
    K = int(input())
    ans = [(K // N) + i for i in range(N)]
    for i in range(K % N):
        for j in range(N):
            ans[j] += N if i == j else -1
    print(N)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> G;
int a[1000100];
int cnt = 0;

void shellInsertion(int* a, int n, int g) {
	for (int i = g; i < n; i++) {
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v) {
			a[j+g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j + g] = v;
	}
}

void shellSort(int* a, int n) {
	int m = 1;
	while (m <= n) {
		G.push_back(m);
		m = 3*m+1;

	}
	
	for (int i = 0; i < G.size(); i++) {
		shellInsertion(a, n, G[G.size() - i-1]);
	}

	cout << G.size() << endl;
	for (int i = 0; i < G.size(); i++) {
		cout << G[G.size()-1-i];
		if (i < m - 1) cout << ' ';
	}
	cout << endl;
}

int main() {


	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	shellSort(a, n);
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << a[i];
		cout << endl;

	}
	

}


Measured memory_bytes: 7032
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		  try(Scanner sc = new Scanner(System.in)) {
			  while(sc.hasNext()) {
				  String str=sc.nextLine();
				  String ans="";
				  for(int i=0; i<str.length(); i++) {
					  char c=(char)((str.charAt(i)-'A'+23)%26+'A');
					  ans += String.valueOf(c);
				  }
				  System.out.println(ans);
			  }
		  }
	}
}



Measured memory_bytes: 29844
N, H = map(int, input().split())
A = [0] * N
B = [0] * N
count = 0
for i in range(N):
    A[i], B[i] = map(int, input().split())
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
maximum_Val = A[0]
for i in B:
    if maximum_Val > i:
        break
    H -= i
    count += 1
    if H <= 0:
        print(count)
        exit(0)
if H % maximum_Val == 0:
    print(count + int(H / maximum_Val))
else:
    print(count + int(H / maximum_Val) + 1)


Measured memory_bytes: 12080
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    int n,m,a[1000],b[1000],x=0,y=0;
    ll z=1, p=1e9+7;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    sort(a, a+n, greater<int>());
    sort(b, b+m, greater<int>());
    if(a[0]!=n*m||b[0]!=n*m){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=1;i<m;i++){
        if(b[i]==b[i-1]){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=n*m;i>0;i--){
        if(y+1<n&&a[y+1]==i)y++;
        if(x+1<m&&b[x+1]==i)x++;

        if(i==a[y]&&i==b[x]){
            continue;
        }
        if(i==a[y]){
            z*=(ll)(x+1);
            z%=p;
            continue;
        }
        if(i==b[x]){
            z*=(ll)(y+1);
            z%=p;
            continue;
        }
        ll w=(ll)(x+1)*(y+1)+i-n*m;
        if(w<=0){
            cout << 0 << endl;
            return 0;
        }
        z*=w%p;
        z%=p;
        //cout<<i<<" : "<<z<<endl;
    }
    cout<<z<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void) {
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, 0, n) {
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i=0; i< n; i++)
using namespace std;


int main() {
    string s1,s2;
    cin >> s1 >> s2;
    cout << s2+s1 << endl;
	return 0;
}

Measured memory_bytes: 256
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=2e5+15;
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

vector<int>adj[N];
int h[N];
ll ans=0;
priority_queue<int,vector<int>,greater<int> >q;
vector<pair<int,int> >L,R;

int main()
{
    Nitroboost;
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int l,r,k;
        
        L.clear(), R.clear();
        
        ans=0;
        for(int i=0;i<n;i++)
        {
            cin>>k>>l>>r;
            if(l>r)
            {
                ans+=r;
                L.push_back({k,l-r});
            }
            else if(r>l && n-k)
            {
                ans+=l;
                R.push_back({n-k,r-l});
            }
            else
                ans+=l;
        }
        
        sort(L.begin(),L.end());
        sort(R.begin(),R.end());
        
    
    for(int i=0;i<L.size();i++)
    {
        if(q.size()<L[i].first)
            q.push(L[i].second);
        else if(L[i].second>q.top())
            {
                q.pop();
                q.push(L[i].second);
            }
    }
    
     while(!q.empty()) ans += q.top(), q.pop();
       
      for(int i=0;i<R.size();i++)
        {
        if(q.size()<R[i].first)
            q.push(R[i].second);
        else if(R[i].second>q.top())
            {
                q.pop();
                q.push(R[i].second);
            }
    }
    
    while(!q.empty()) ans += q.top(), q.pop();
       cout<<ans<<"\n";
    }
}

Measured memory_bytes: 10316
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
ans=0
for i in range(N):
    p = min(A[i],B[i])
    B[i] -= p
    q = min(B[i], A[i+1])
    A[i+1] -=q
    ans = ans + p+q
print(ans)

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

int main() {
    ll n;
    cin >> n;
    ll max_z = -1000000000;
    ll min_z = 1000000000;
    ll max_w = -1000000000;
    ll min_w = 1000000000;
    for (int i = 0; i < n; i++) {
        ll x, y, z, w;
        cin >> x >> y;
        z = x + y;
        w = x - y;
        max_z = max(max_z, z);
        min_z = min(min_z, z);
        max_w = max(max_w, w);
        min_w = min(min_w, w);
    }
    ll ans;
    ans = max(max_z - min_z, max_w - min_w);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556