akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> Nums;
    int now = 1;
    int cnt = 0;
    rep(i, n) {
        if(s[i] == (char)('0' + now)) {
            cnt++;
        }
        else {
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if(cnt != 0) {
        Nums.push_back(cnt);
    }

    if(Nums.size() % 2 == 0) {
        Nums.push_back(0);
    }

    int Add = 2*k + 1;
    int ans = 0;
    int left = 0;
    int right = 0;
    int tmp = 0;
    for(int i = 0; i < Nums.size(); i += 2) {
        int Nextleft = i;
        int Nextright = min(i + Add, (int)Nums.size());

        while(Nextleft > left) {
            tmp -= Nums[left];
            left++;
        }

        while(Nextright > right) {
            tmp += Nums[right];
            right++;
        }

        ans = max(tmp, ans);
    }

    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 1020
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        
        int[] w = new int[N+1]; 
        long[] v = new long[N+1]; 
         //i番目の品物を、重さがj-w[i]以下になるように選んだ時の価値の最大値
        long[][] dp = new long[N+1][W+1];
        
        //A:0 B:1 C:2
        for(int i = 0; i < N; i++) {
            w[i+1] = Integer.parseInt(sc.next());
            v[i+1] = Integer.parseInt(sc.next());
        }
        
        long ans = 0;
        

        for(int i = 1; i <= N; i++) {
            for(int j = 0; j <= W; j++) {
                if(j-w[i] >= 0) {
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
                }else  {
                    dp[i][j] = dp[i-1][j];//j-w[i]のときはi番目の品物は使えない
                }
            }
            
        }
        
        ans = dp[N][W];
        
        System.out.println(ans);
    }
    
    public static long max(long a, long b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static int min(int a, int b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


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

    vector<string> v(N);
    REP(i,N){
        cin >> v[i];
    }


    bool ok =true;

    FOR(i,1,N){
        if(v[i][0]!=v[i-1][v[i-1].length()-1]){
            ok = false;
        }
    }
    
    FOR(i,0,N){
        FOR(j,i+1,N){
            if(v[i]==v[j]) ok = false;
        }
    }

    if(ok)PRINT("Yes");
    else PRINT("No");

}



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

int main(){
  
  int q, com, x;
  set<int> S;
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> com;
    
    if(com == 0){
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
    }else if(com == 1){
      cin >> x;
      cout << S.count(x) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 12388
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> h(N);
    for(int i = 0; i < N; i++) cin >> h.at(i);
    sort(h.begin(), h.end());
    
    long long ans = 1000000010;
    for(int i = 0; i < N-K+1; i++) {
        ans = min(ans, h.at(i+K-1) - h.at(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
odd = 0
even4 = 0
for i in A :
    if not i % 4 :
        even4 += 1
    elif i % 2 :
        odd += 1
if (odd <= even4) or (N//2 <= even4) :
    ans = "Yes"
else :
    ans = "No"
print(ans)


Measured memory_bytes: 14252
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, A, B = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
res = 0
xi = 0
xis = []
for i in range(A - 1, B):
  t = 0
  for j in range(i + 1): t += a[j]
  t /= i + 1
  if res < t:
    res = t
    xi = i + 1
    xis = [i + 1]
  elif res == t:
    xis.append(i + 1)
resc = 0
while len(xis):
  xi = xis.pop()
  d = dd(int)
  for x in a: d[x] += 1
  d2 = dd(int)
  for i in range(xi): d2[a[i]] += 1
  #print(d, d2)
  tt = 1
  for k in d2.keys():
    t = 1
    for i in range(d[k], 0, -1):
      if i <= d[k] - d2[k]: break
      t *= i
    for i in range(1, d2[k] + 1): t //= i
  #print(k, t, d[k], d2[k])
    tt *= t
  resc += tt

print(res)
print(resc)

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n, ans = 0;
  cin >> n;
  vector<string> s(n);
  for (ll i = 0; i < n; i++) {
    string t;
    cin >> t;
    sort(t.begin(), t.end());
    s[i] = t;
  }
  
  sort(s.begin(), s.end());
  
  ll cnt = 0;
  string x = s[0];
  for (ll i = 0; i < n; i++) {
    if (s[i] == x) {
      cnt++;
      if (i == n-1) {
        ans += cnt*(cnt-1)/2;
      }
    }
    else {
      ans += cnt*(cnt-1)/2;
      x = s[i];
      cnt = 1;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main()
{
  int n, x;
  int i, j, k;
  int count = 0;
  
  while (1) {
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) break;
    
    count = 0;
    for (i = 1; i <= n; i++) {
      for (j = i + 1; j <= n; j++) {
        for (k = j + 1; k <= n; k++) {
          if (i + j + k == x) {
            count++;
            break;
          }
        }
      }
    }
    printf("%d\n", count);
  }
  return 0;
 }



Measured memory_bytes: 2108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author hamaron
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <climits>

using namespace std;

class EKnapsack2 {
public:
    void solve(std::istream &in, std::ostream &out) {
        int N;
        long W;
        in >> N >> W;
        long long dp[N + 1][N * 1000 + 1];

        for (int i = 0; i < N + 1; i++) {
            for (long j = 0; j < N * 1000 + 1; j++) {
                dp[i][j] = INT_MAX;
            }
        }

        dp[0][0] = 0;
        for (int i = 1; i < N + 1; i++) {
            int w, v;
            in >> w >> v;
            for (long j = 0; j < N * 1000 + 1; j++) {
                if (j - v < 0) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j]);
                }
            }
        }

        int maxValue = -1;
        for (int j = N * 1000; j >= 0; j--) {
            if (dp[N][j] <= W) {
                maxValue = j;
                break;
            }
        }

        out << maxValue;
    }
};


int main() {
	EKnapsack2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    for (int i = 0; i < N; i++)
    {
        cin >> t.at(i);
    }

    int res = 0;
    for (int i = 0; i < N - 1; i++)
    {
        res += min(T, t.at(i + 1) - t.at(i));
    }
    res += T;
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	ll n;
	string s,t;
	cin >> n >> s;

	FOR(i,0,s.size()){
		int x = s[i] - 'A' + n;
		x %= 26;
		s[i] = x+'A';
	}
	cout << s << endl;


}

Measured memory_bytes: 256
def     process(tab, first, end):
    #print(tab)
    #print(first, end)
    total = first
    for i in tab:
        if (i[1] > total):
            return ("No")
        total += i[0]
        if (total < 0):
            return ("No")
    if (total == end):
        return ("Yes")
    return ("No")




N  = int(input())

first = -1
last = -1
clean = 0
tab = []
total = 0
for i in range(N):
    s = input()
    avant = 0
    apres = 0
    for j in s:
        if (j == '('):
            apres += 1
        elif (j == ')'):
            if (apres > 0):
                apres -= 1
            else:
                avant += 1
    if (avant == 0 and apres > 0 and first == -1):
        first = apres
    elif (apres == 0 and avant > 0 and last == -1):
        last = avant
    elif (avant > 0 or apres > 0):
        tab.append((apres - avant, avant, apres, s))
    else:
        clean += 1
    total += avant - apres
if (first == -1 and clean > 0):
    first = 0
    clean -= 1
if (last == -1 and clean > 0):
    last = 0


tab = sorted(tab)
tab = tab[::-1]
if (total == 0 and first > -1 and last > -1):
    res = process(tab, first, last)
else:
    if (total == 0 and N == 1):
        res = "Yes"
    else:
        res = "No"
print(res)


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i=0; i<n; ++i) cin >> a[i];
  int ans;

  while(true){
    bool exist_odd = false;
    for (int i = 0;i<n;i++){
      if(a[i] % 2 !=0 )exist_odd = true; 
    }
    if (exist_odd) break;

    for (int i = 0;i<n;i++) a[i] /= 2;
    ans += 1;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> st(n);
    rep(i, n) {
        cin >> a.at(i);
        st.at(i) = a.at(i);
    }
    sort(all(st));
    rep(i, n) {
        if(a.at(i) == st.at(n - 1))
            cout << st.at(n - 2) << endl;
        else
            cout << st.at(n - 1) << endl;
    }
}


Measured memory_bytes: 4736
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int in[100006];
int main()
{	
 	int n,k;
 	scanf("%d%d",&n,&k);
 	int ans=0x3f3f3f3f;
 	for(int i=1;i<=n;i++)
 	{
 		scanf("%d",&in[i]);
	 }
	 for(int i=k;i<=n;i++)
	 {
	 	ans=min(ans,in[i]-in[i-k+1]+min(abs(in[i]),abs(in[i-k+1])));
	 }
	 cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        int c = 0;
        for (int i = 0; i < N; i++) {
            L[i] = sc.nextInt();
        }
        for (int i = 0; i < N-2; i++) {
            for (int j = i+1; j < N-1; j++) {
                for(int k = j+1; k < N; k++) {
                    if ( L[i] == L[j] || L[j] == L[k] ||L[k] == L[i]) {
                        c = c;
                    } else {
                        if ( L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) {
                            c = c + 1;
                        } else {
                            c = c;
                        }
                    } 
                }
            }
        }
        System.out.println(c);
    }
}

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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll,ll>> d(n);
    for(ll i = 0;i < n;i++){
        cin >> d[i].first >> d[i].second;
    }

    bool f = false;

    for(ll i = 0;i < n - 2;i++){
        if((d[i].first == d[i].second) && (d[i + 1].first == d[i + 1].second) && (d[i + 2].first == d[i + 2].second)){
            f = true;
        }
    }

    if(f){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
const long long md=1e9+7;
long long dp[3010][3010][2];
int main(){
//	freopen("D.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		dp[0][i][0]=1;
	dp[0][0][1]=1;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(j==0){
				(dp[i+1][j][1]+=dp[i][j][1]+dp[i][j][0])%=md;
				(dp[i+1][j+1][1]+=dp[i][j][1]+dp[i][j][0])%=md;
			}
			else if(j==1){
				(dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1])%=md;
				if(j<n)
				{
					(dp[i+1][j][0]+=dp[i][j][0])%=md;
					(dp[i+1][j][1]+=dp[i][j][1])%=md;
					(dp[i+1][j+1][0]+=dp[i][j][0])%=md;
					(dp[i+1][j+1][1]+=dp[i][j][1])%=md;
				}
				(dp[i+1][j-1][1]+=dp[i][j][0]+dp[i][j][1])%=md;
			}
			else if(j==n){
				for(int s=0;s<=1;s++){
					(dp[i+1][j][s]+=dp[i][j][s])%=md;
					(dp[i+1][j-1][s]+=dp[i][j][s])%=md;
				}
			}
			else{
				for(int s=0;s<=1;s++){
					(dp[i+1][j][s]+=dp[i][j][s]*2)%=md;
					(dp[i+1][j+1][s]+=dp[i][j][s])%=md;
					(dp[i+1][j-1][s]+=dp[i][j][s])%=md;
				}
			}
		}
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+dp[m][i][1])%md;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 141440
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a > b)
    cout << "a > b" << endl;
  else if(a == b)
    cout << "a == b" << endl;
  else
    cout << "a < b" << endl;
  return 0;
}



Measured memory_bytes: 3008
#include <iostream>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;


int main(){
  const double pi = 3.141592653589793;
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double c = b*b-2.0*a*b*cos((11.0*m/12.0-5.0*h)*pi/30.0);
  c += a*a;
  c = sqrt(c);
  cout << fixed << setprecision(15) << c << endl;
  return 0;
}


Measured memory_bytes: 4216
#include <cstdio>
#include <string>

using namespace std;

int main(void){
    char taro_tmp[500], hanako_tmp[500];
    string taro, hanako;
    int n, p_taro, p_hanako;
  
    p_taro = p_hanako = 0;

    scanf(" %d", &n);
    
    for (int i = 0; i < n; i++){
        scanf(" %s %s", taro_tmp, hanako_tmp);
        taro = taro_tmp;
        hanako = hanako_tmp;

        if (taro > hanako){
            p_taro += 3;
        }
        else if (taro < hanako){
            p_hanako += 3;
        }
        else if (taro == hanako){
            p_hanako++;
            p_taro++;
        }   
    }
    
    printf("%d %d\n", p_taro, p_hanako);
    
    return 0;
}


Measured memory_bytes: 2860
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007
#define INV_10 299473306
#define INF 1000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int s, w;
	cin >> s >> w;
	cout << ((w>=s) ? ("unsafe\n") : ("safe\n"));
}

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

bool isPrime(int n){
	for(int i = 2; i < n; ++i){
		if(n % i == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;

	vi primeTbl;
	for(int i = 2; i <= 55555; i++)
		if(isPrime(i) && i % 5 == 1) primeTbl.push_back(i);

	rep(i, n){
		cout << primeTbl[i];
		if(i != n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 16384
#define M 128

int cnt[N];

int main()
{
    for(int x=1;x<M;++x)for(int y=1;y<M;++y)for(int z=1;z<M;++z)
    {
        int k = x*x + y*y + z*z + x*y + y*z + z*x;
        if(k<N) ++cnt[k];
    }
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;++i) printf("%d\n", cnt[i]);
    return 0;
}


Measured memory_bytes: 1708
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (auto& v : H)cin >> v;
  sort(begin(H), end(H));
  int64_t ans = 0;
  for (int i = 0; i < N - K; ++i)
    ans += H[i];
  cout << ans << endl;
}

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

#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
// constexpr ll mod = 1e9+7;

struct UnionFind {
  vector<int> data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
  
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int a, int b){
    return find(a) == find(b);
  }
  
  int size(int k) {
    return (-data[find(k)]);
  }
};

struct Edge{
  int a, b;
  long long weight;
  
  Edge(int a, int b, long long weight) : a(a), b(b), weight(weight){}
  bool operator< (const Edge& r) const {
    if(weight != r.weight) return weight < r.weight;
    if(a != r.a) return a < r.a;
    return b < r.b;
  }
};
 
long long kruskal(int V, vector<Edge>& Edges){
  long long ans = 0; // 辺の重みの総和
  int count =0; // 選んだ辺の数
  int E = Edges.size(); // 辺の数
  sort(Edges.begin(), Edges.end());
  UnionFind uf(V);
  for(int i = 0; i < E; ++i){
    int a = Edges[i].a, b = Edges[i].b;
    if(uf.same(a, b)) continue;
    ans += Edges[i].weight;
    uf.unite(a, b);
    ++count;
  }
  return ans;
}

struct vartex{
  int idx, x, y;
  vartex(int idx, int x, int y) : idx(idx), x(x), y(y){};
  vartex(){};
};
bool cmp(vartex l, vartex r){
  return l.x < r.x;
}

bool cmp2(vartex l, vartex r){
  return l.y < r.y;
}
ll cal_cost(vartex a, vartex b){
  return min(abs(a.x-b.x), abs(a.y-b.y));
}

int main(){
  int N;
  cin >> N;
  vector<vartex> xy(N);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    xy[i] = vartex(i, x, y);
  }
  vector<Edge> Edges;
  sort(xy.begin(), xy.end(), &cmp);
  REP(i, N-1){
    Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, cal_cost(xy[i], xy[i+1])));
    // Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, xy[i+1].x - xy[i].x));

  }
  sort(xy.begin(), xy.end(), &cmp2);
  REP(i, N-1){
    Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, cal_cost(xy[i], xy[i+1])));
    // Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, xy[i+1].y - xy[i].y));
  }
  cout << kruskal(N, Edges) << endl;
  return 0;
}


Measured memory_bytes: 7664
N, L = map(int,input().split())
total_taste = N*(L-1)+N*(N+1)/2
min_diff = 10**8
for i in range(1,N+1):
    #print(i)
    apple_taste = L+i-1
    pie_taste = total_taste - apple_taste
    taste_diff = abs(total_taste-pie_taste)
    #print(i,total_taste,pie_taste)
    if taste_diff < min_diff:
        min_diff = taste_diff
        ans = pie_taste
        #print(i,pie_taste)
print(int(ans))

Measured memory_bytes: 3060
#include<stdio.h>

#define N 3000000

int main(){
  int loop;
  int Before[N],After[N],Counter[N];
  int i;

  scanf("%d",&loop);
  for(i=0;i<N+1;i++){
    Counter[i]=0;
  }

  for(i=1;i<loop+1;i++){
    scanf(" %d",&Before[i]);
    Counter[Before[i]]++;
  }
  
  for(i=1;i<N+1;i++){
    Counter[i]=Counter[i]+Counter[i-1];
  }

  for(i=loop;i>=1;i--){
    After[Counter[Before[i]]]=Before[i];
    Counter[Before[i]]--;
  }

  for(i=1;i<loop;i++){
    printf("%d ",After[i]);
  }

  printf("%d\n",After[loop]);
  
  return 0;
}




Measured memory_bytes: 29148
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    N, *A = map(int, read().split())
    A = sorted(A)
    B = []
    val = 0
    for a in A:
        val += a
        B.append(val)

    left = -1
    right = -1
    for i in range(N-1):
        if B[i] * 3 >= B[i+1]:
            if left == -1:
                left = i
                right = i+1
            else:
                right = i+1
        else:
            left, right = -1, -1
    print(right - left + 1)


if __name__ == "__main__":
    run()

Measured memory_bytes: 36216
#include <bits/stdc++.h>
    #define int long long
    using namespace std;
     
    signed main() {
      int n;
      cin >> n;
      vector<int> a(n);
      unordered_map<int, int> m;
      for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[i+1-a[i]]++;
      }
      int ans = 0;
      for (int i = 0; i < n; i++) {
        ans += m[a[i]+i+1];
      }
      cout << ans << endl;
    }

Measured memory_bytes: 19964
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int K;
    scan(K);

    ll ans = 0;

    for (size_t i = 1; i <= K; i++) {
        for (size_t j = 1; j <= K; j++) {
            for (size_t k = 1; k <= K; k++) {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }
    print(ans);

    return 0;
}

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

using namespace std;

#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int N = 1e5+5;

int arr[N],dp[N]={-1};
int n,k;

int f(int ind){
    if(dp[ind]!=-1)
        return dp[ind];
    int ans = INT_MAX;
    for(int i=ind+1;i<min(n,ind+k+1);i++){
        ans = min(ans,abs(arr[ind]-arr[i])+f(i));
    }
    return dp[ind]=ans;
}


void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>arr[i],dp[i]=-1;
    dp[n-1] = 0;
    cout<<f(0)<<endl;
}

int main()
{
    FASTIO
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}




Measured memory_bytes: 10604
a,b,c,d = map(int, input().split())

turn = 0
while a > 0 and c > 0:
  if turn % 2 == 0:
    c -= b
    turn += 1
  else:
    a -= d
    turn += 1
    
if a <= 0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9108
import itertools
from scipy.sparse.csgraph import floyd_warshall

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(M)]

s=[[float('inf') for i in range(N)] for i in range(N)]
for i in range(M):
    a,b,c=l[i]
    s[a-1][b-1]=c
    s[b-1][a-1]=c
for i in range(N):
    s[i][i]=0

s=floyd_warshall(s)
#print(s)
ans=10**9
for i in itertools.permutations(r):
#    print(i)
    temp_ans=0
    for j in range(R-1):
        temp_ans+=s[i[j]-1][i[j+1]-1]
    ans=min(ans,temp_ans)
print(int(ans))

Measured memory_bytes: 32600
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<30;i++){
		if(i*a-i+1>=b){
			cout<<i<<'\n';
			return 0;
		}
	}
	return 0;
}



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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> h(n); rep(i, n) cin >> h[i];

	int ans = 0, cnt = 0;
	for (int i = 0; i < n - 1; ++i) {
		cnt++;
		if (h[i] < h[i + 1])
			cnt = 0;
		ans = max(ans, cnt);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    string s;
    cin>>s;
    deque<char>arr;
	for(int i=0; i<s.size(); i++)
	{
		arr.push_back(s[i]);
	}
	int sit=1;
	int q;
	cin>>q;
	while(q--)
	{
		int num1,num2;
		char ch;
		cin>>num1;
		if(num1==1)
		{
			sit=sit*(-1);
		}
		else
		{
			cin>>num2>>ch;
			if(sit==1)
			{
				if(num2==1)
				 arr.push_front(ch);
				else
				 arr.push_back(ch);
			}
			else
			{
				if(num2==1)
				 arr.push_back(ch);
				else
				 arr.push_front(ch);
			}
		}
	}
	if(sit==1)
	{
		while(!arr.empty())
		{
			char ch=arr.front();
			cout<<ch;
			arr.pop_front();
		}
	}
	else
	{
		while(!arr.empty())
		{
			char ch=arr.back();
			cout<<ch;
			arr.pop_back();
		}
	}
	return 0;   
}

Measured memory_bytes: 3948
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

assist = 0
kill = 0

for i in range(n):
    if assist+b[i] < a[i]:
        kill += assist+b[i]
        assist = 0
    else:
        if assist <= a[i]:
            kill += a[i]
            assist += b[i] - a[i]
        else:
            kill += a[i]
            assist = b[i]

if assist == 0:
    print(kill)
elif assist < a[-1]:
    print(kill + assist)
else:
    print(kill + a[-1])

Measured memory_bytes: 18348
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main(){
  while(true){
    int h, w;
    cin >> h >> w;
    if(h == 0 && w == 0){
      break;
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(i == 0 || i == h - 1){
          if(j != w - 1){
            cout << "#";
          }
          else if(j == w - 1){
            cout << "#" << endl;
          }
        }
        else if(i != 0 && i != h - 1){
          if(j == 0){
            cout << "#";
          }
          else if(j == w - 1){
            cout << "#" << endl;
          }
          else{
            cout << ".";
          }
        }
      }
      if(i == h - 1){
        cout << endl;
      }
    }
  }    
}



Measured memory_bytes: 3084
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	long long int N, V;
	cin >> N >> V;
	
	vector<long long int> v1, v2;
	map<long long int, int> m;
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		v1.push_back(num);
	}
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		for(int j = 0; j < N; j++){
			m[num + v1[j]]++;
		}
	}
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		v2.push_back(num);
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		for(int j = 0; j < N; j++){
			ans += m[V - num - v2[j]];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 128092
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 924844033;
const int N = 20335;
const int K = 700 ;
int ans[K][K], f[N], p[N], pp[N];
vector < int > pr;
map < int, int > used;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 2; i < N; i++){
        if (f[i] == 0) pr.pb(i);
        for (int j = i; j < N; j += i) f[j] = 1;
    }
    int l = 2;
    int r = n + 1;
    for (int i = 1; i <= n; i++){
        if (i % 2){
            p[i] = l;
            l++;
        } else{
            p[i] = r;
            r--;
        }
    }
    l = 100;
    r = n + n + 150;;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if ((i + j) % 2 == 1) continue;
            int d = i - j;
            if (pp[d + n] == 0){
                if (abs(d) % 4 == 2){
                    l++;
                    pp[d + n] = pr[l];
                } else{
                    r--;
                    pp[d + n] = pr[r];
                }
            }
            ans[i][j] = p[j] * pp[d + n];
        }
    }
    int q = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if ((i + j) % 2 == 0) continue;
            int x = 1;
            if (ans[i - 1][j] != 0) x = ans[i - 1][j] * x / __gcd(ans[i - 1][j], x);
            if (ans[i + 1][j] != 0) x = ans[i + 1][j] * x / __gcd(ans[i + 1][j], x);
            if (ans[i][j - 1] != 0) x = ans[i][j - 1] * x / __gcd(ans[i][j - 1], x);
            if (ans[i][j + 1] != 0) x = ans[i][j + 1] * x / __gcd(ans[i][j + 1], x);
            int y = x;
            while(used[y]){
                y += x;
                cnt++;
            }
            ans[i][j] = y + 1;
            if (y < 0){
                cout << y;
                return 0;
            }
            used[x] = 1;
            q = max(q, y);
        }
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


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

#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a)		cerr << #a << ": "; for (int& x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	for (int i = 0; i < (int)s.size(); i++) {
		s[i] = 'A' + (s[i] + n - 'A')%26;
	}
	cout << s << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,K,X,Y,total=0;
    cin >> N >> K >> X >> Y;
    for(int i = 0; i < N; i++){
        if(i<K){
            total+=X;
        }else{
            total+=Y;
        }
    }
    cout << total << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
                             
                            int main(void)
                            {
                             int n,i;
                             long long sum=0;
                              scanf("%d",&n);
                              
                              for(i=1;i<=n;i++)
                              {
                                if(i%3!=0&&i%5!=0)
                                  sum+=i;
                              }
                                
                              printf("%lld",sum);
                              
                              return 0;
                            }

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,h[100],c=0,l=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    l=h[0];
    for(int i=0;i<n;i++)
     {   
         if(l<=h[i])
           { c++;
             l=h[i];
           }
     }
     cout<<c;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, x, y, d[2020][2020];

int main(){
    scanf("%d%d%d", &n, &x, &y);
    --x; --y;
    int ans[n];
    rep(i, n) ans[i] = 0;
    rep(s, n)For(t, s+1, n){
        if(s <= x){
            if(t <= x) d[s][t] = t-s;
            else if(t <= y) d[s][t] = min(t-s, x-s + 1 + y-t);
            else d[s][t] = x-s + 1 + t-y;
        }
        else if(s <= y){
            if(t <= y) d[s][t] = min(t-s, s-x + 1 + y-t);
            else d[s][t] = min(t-s, s-x + 1 + t-y);
        }
        else d[s][t] = t-s;

        ++ans[d[s][t]];
    }
    For(i, 1, n) printf("%d\n", ans[i]);
}

Measured memory_bytes: 15488
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


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

  string pat[4];
  if (S[0] == 'o') {
    pat[0] = "SSS";
    pat[1] = "SWW";
    pat[2] = "WWS";
    pat[3] = "WSW";
  } else {
    pat[0] = "SWS";
    pat[1] = "SSW";
    pat[2] = "WSS";
    pat[3] = "WWW";
  }

  string ans(N, '!');
  REP(i, 4) {
    ans[0] = pat[i][0];
    ans[1] = pat[i][1];
    for (int j = 1; j < N - 1; j++) {
      if (ans[j] == 'S') {
        if (S[j] == 'o') ans[j + 1] = ans[j - 1];
        else ans[j + 1] = (ans[j - 1] == 'S' ? 'W' : 'S');
      } else {
        if (S[j] == 'x') ans[j + 1] = ans[j - 1];
        else ans[j + 1] = (ans[j - 1] == 'S' ? 'W' : 'S');
      }
    }
    if (ans[N - 1] == pat[i][2]) {
      if (S[N - 1] == 'o') {
        if (ans[N - 1] == 'S' && ans[N - 2] != ans[0]) continue;
        else if (ans[N - 1] == 'W' && ans[N - 2] == ans[0]) continue;
      }
      if (S[N - 1] == 'x') {
        if (ans[N - 1] == 'W' && ans[N - 2] != ans[0]) continue;
        else if (ans[N - 1] == 'S' && ans[N - 2] == ans[0]) continue;
      }
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<vector<ll>> G(100010);
vector<ll> memo(100010,-1), dist(100010,1e18), memo2(100010,-1), dist2(100010,1e18);
ll N,u,v;

ll dfs(ll vv){
    for(auto& uu:G[vv]){
        if(memo[uu] != -1) continue;
        memo[uu] = vv;
        dist[uu] = dist[vv] + 1;
        if(uu == v) continue;
        dfs(uu);
    }
    return 0;
}
ll dfs2(ll vv){
    for(auto& uu:G[vv]){
        if(memo2[uu] != -1) continue;
        memo2[uu] = vv;
        dist2[uu] = dist2[vv] + 1;
        dfs2(uu);
    }
    return 0;
}

int main(){
    cin >> N >> u >> v;
    u--;v--;
    ll a,b;
    rep(i,N-1){
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    memo[u] = -2;
    dist[u] = 0;
    dfs(u);
    ll diff = dist[v];
    ll t = v;
    while(t != u){
        dist[t] = 1e18;
        t = memo[t];
    }
    /*
    ll M = 0;
    ll Mt = -1;
    rep(i,N){
        if(dist[i]==1e18) continue;
        if(M < dist[i]){
            M = dist[i];
            Mt = i;
        }
    }*/
    memo2[v] = -2;
    dist2[v] = 0;
    dfs2(v);
    ll M = 0;
    rep(i,N){
        if(dist[i] != 1e18 && dist[i] < dist2[i]){
            cmax(M,dist2[i]);
        }
    }
    /*
    memo = vector<ll>(N,-1);
    dist = vector<ll>(N,1e18);
    dfs(v, -2);*/
    //ll ans = M + diff - 1;
    cout << M - 1 << endl;
}

Measured memory_bytes: 15828
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// 約数を列挙
func divisor(n int) []int {
	ret := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			if i*i != n {
				ret = append(ret, n/i)
			}
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	d := divisor(N)
	sort.Ints(d)

	cnt := 0
	for _, v := range d {
		m := N/v - 1
		if m == 0 {
			continue
		}
		if N/m == N%m {
			cnt += m
		}
	}
	out(cnt)
}


Measured memory_bytes: 896
N =int(input())
scores = [min(int(i)//400, 8) for i in input().split()]
d = [0]*9
for s in scores:
    d[s] = d[s] + 1
lt3200 = [bool(i) for i in d[:8]].count(True)
m = max(1, lt3200)
M = lt3200+d[8]
print('{} {}'.format(m, M))

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += min(A[i], B[i])
    B[i] -= min(A[i], B[i])
    ans += min(A[i+1], B[i])
    A[i+1] -= min(A[i+1], B[i])

print(ans)
    


Measured memory_bytes: 19116
#include <iostream>

using namespace std;

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

  if((a % k == 0) || (b % k == 0)){
    cout << "OK" << endl;
  } else if(b/k > a/k){
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
using System;
using System.Linq;

class C
{
    static void Main()
    {
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var m = long.MaxValue;
        for (var i = a[0]; i < a[1]; i++)
            for (var j = i + 1; j <= a[1]; j++)
            {
                var x = i * j % 2019;
                if (x == 0) { Console.WriteLine(0); return; }
                if (x < m) m = x;
            }
        Console.WriteLine(m);
    }
}


Measured memory_bytes: 13396
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	a.erase(unique(all(a)), a.end());
	printf("%d\n", (int)(a.size() - !(a.size() % 2)));
	
	Please AC;
}

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

using namespace std;
int main(){
	int n;
    cin>>n;
    int f[100][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    int p[100][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>p[i][j];
        }
    }
    int ans=-(1e9+7); 
    for(int i=0;i<(1<<10);i++){
        if(i==0)continue;
        int earn=0;
        for(int j=0;j<n;j++){
            int num=0;
            for(int k=0;k<10;k++){
                if(f[j][k]==1&&(i&(1<<k)))num++;
            }
            earn+=p[j][num];
        }
        ans=max(ans,earn);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long ans,sum,a[100010],b[100010],n,k,l;
int main(){
	int i,j;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i] >> b[i];
		if((k | a[i]) == k){
			ans += b[i];
		}
	}
	for(j=0;j<=30;j++){
		if(k & (1<<j)){
			l = (k - (1<<j))|((1<<j)-1);
			sum = 0;
			for(i=0;i<n;i++){
				if((l | a[i]) == l){
					sum += b[i];
				}
			}
			ans = max(ans,sum);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        if(n>m){
            for(int i=1;i<=n;i++)
            cout<<m;
        }
        else{
            for(int i=1;i<=m;i++)
            cout<<n;
        }
        cout<<endl;
    }
}


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

int main(){
  char s[20];
  scanf("%s", s);
  
  if (s[5] == '1'){
    printf("TBD\n");
    return 0;
  }
  if (s[6] >= '5'){
    printf("TBD\n");
    return 0;
  }
  printf("Heisei\n");
  
  
  
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 110;
int n, a[N];

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

Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
signed main(){
    string s;
    cin >> s;
    long long ans = 0;
    int sz = s.length();
    for(int i = 0; i < sz; i++){
        ans = ans + (s[i] -'0');
        ans = ans % 9;
    }
    if(ans){
        cout << "No" << '\n';
    }
    else{
        cout << "Yes" << '\n';
    }
        
    return 0;
}


Measured memory_bytes: 3716