akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <algorithm>
 
void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}
 
void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
 
int main(){
    int n, c, k; fastin(n); fastin(c); fastin(k);
    int t[n];
    for (int i = 0; i < n; ++i) fastin(t[i]);
 
    std::sort(t, t + n);
 
    int ans = 0;
    int beg = 0;
    while (beg < n){
        int end = beg;
        while (end - beg + 1 < c && t[end + 1] - t[beg] <= k){
            ++end;
            if (end == n - 1) break;
        }
        ++ans; beg = end + 1;
        if (beg == n - 1){
            ++ans; break;
        }
    }
    fastout(ans);
    
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({ a, ex });
    }

    // 最後に残った数について
    if (N != 1) res.push_back({ N, 1 });
    return res;
}

ll ar(ll m)
{
    ll t = 1;
    ll cnt = 0;
    while (m - t >= 0) {
        m -= t;
        t++;
        cnt++;
    }
    return cnt;
}


int main() {
    long long N;
    cin >> N;
    const auto& res = prime_factorize(N);
    Vl RR;
    for (auto p : res) {
        RR.push_back(p.second);
    }
    

    ll ans = 0;
    for (int u : RR) {
        //cout << u << endl;
        ans += ar(u);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct XV {
	int x;
	int v;
	int distance;
};

bool operator<(const XV& left, const XV& right) {
	return abs(left.x - left.v) < abs(right.x - right.v);
}
 
int main() {
	int x, n;
	cin >> x >> n;
	if (n == 0) {
		cout << x << endl;
		return 0;
	}

	vector<XV> v_p; v_p.resize(n);
	int max = x;
	for (int i = 0; i < n; ++i) {
		int input; cin >> input;
		if (abs(x - max) < abs(x - input)) {
			max = input;
		}
		v_p[i] = XV{x, input, abs(x - input)};
	}

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

	int current_idx = 0;
	for (int d = 0; d < abs(x - max) + 2; ++d) {
		const int A = x - d;
		int i = current_idx;
		bool exist = false;
		while (d == v_p[i].distance && i < v_p.size()) {
			if (A == v_p[i].v) exist = true;
			i++;
		}
		if (!exist) {
			cout << A << endl;
			break;
		}

		exist = false;
		const int B = x + d;
		i = current_idx;
		while (d == v_p[i].distance && i < v_p.size()) {
			if (B == v_p[i].v) exist = true;
			i++;
		}
		if (!exist) {
			cout << B << endl;
			break;
		}

		current_idx = i;
	}

	return 0;
}

Measured memory_bytes: 3168
n = input()
n = int(n)
uresisa = 0

if n >= 500:
    q, mod = divmod(n, 500)
    uresisa = uresisa + (q * 1000)
    n = n - (500 * q)

q, mod = divmod(n, 5)
uresisa = uresisa + (q * 5)

print(uresisa)

Measured memory_bytes: 3060
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int,ss_raw()))

X,Y,Z,K = ints_raw()

A = list(map(int, input().split()))
B= list(map(int, input().split()))
C= list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
def main():
    D = []
    for a in A:
        for b in B:
            D.append(a+b)
    D.sort(reverse=True)
    D = D[:K+1]
    E =[]
    for d in D:
        for c in C:
            E.append(d+c)
    E.sort(reverse=True)
    for e in range(K):
        print (E[e])

main()


Measured memory_bytes: 161780
# input
H, W = map(int, input().split())
board = [['.']*W for i in range(H)]
v_board = [[True]*W for i in range(H)]
sign_count = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j]=='#':
            sign_count += 1
        board[i][j] = s[j]

if sign_count==H+W-1:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define _USE_MATH_DEFINES
using namespace std;
int main()
{
ll n;
cin>>n;
ll a[n+1];
ll b[n];
for(ll i=0;i<=n;i++)
{
cin>>a[i];
}
for(ll i=0;i<n;i++)
{
cin>>b[i];
}
ll ans=0;
for(ll i=0;i<n;i++)
{
if(b[i]>a[i])
    {
    ans+=a[i];
    b[i]-=a[i];
    }
else
{
ans+=b[i];
b[i]=0;
}
if(b[i]>a[i+1])
    {
    ans+=a[i+1];
    a[i+1]=0;
    }
else
{
ans+=b[i];
a[i+1]-=b[i];
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 1792
from collections import deque
n = int(input())
A = list( map( int, input().split()))
B = deque()
reverse = 0
for i in range(n):
    if reverse == 0:
        B.append(A[i])
        reverse = 1
    else:
        B.appendleft(A[i])
        reverse = 0
B = list(B)
if reverse == 1:
    B = B[::-1]
print( ' '.join( list( map(str, B))))

Measured memory_bytes: 30660
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

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

  string s;
  cin>>s;

  int ans=s.size();
  for(int j=0;j<26;j++)
    {
      int tmp=0;
      int b=0;
      for(int i=0;i<s.size();i++)
	{
	  if(s[i]-'a'!=j)
	    {
	      b++;
	      tmp=max(tmp,b);
	    }
	  else
	    b=0;
	}
      ans=min(ans,tmp);
    }

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


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int x, y, z, cnt = 0; std::cin >> x >> y >> z;
    x -= z;
    while(true) {
        if (x - (y + z) >= 0) cnt++;
        else break;
        x -= (y + z);
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int insertionSort(int A[], int N);
static const int MAX = 100; 
int main()
{
    int A[MAX],N;
    cin >> N ;
    
    for(int i=0; i<N; i++){
        cin >> A[i];
        if (i>0) cout << " ";
        cout << A[i] ;
    }
    cout << "\n";
    
    insertionSort(A,N);
    return 0;
}
    
int insertionSort(int A[],int N){
    
    for(int i=1; i<N; i++){
        
        int v = A[i];
        int j = i-1;
        
            
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        
        for(int k=0; k<N; k++){
            if(k > 0) cout << " ";
            cout << A[k];
            if(k==N-1) cout << "\n";
            
        }
        
            
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int k, n;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k)ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  li n,a,b; cin >>n >>a >>b;
  if(a>b)swap(a,b);
  if((b-a)%2==0){
    printf("%ld",(b-a)/2);
  }else{
    li ans1=(a+b)/2,ans2=n+1-(a+b+1)/2;
    
    printf("%ld",min(ans1,ans2));

  }

}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a,int b) {

  if(b==0) return a;

  else return gcd(b,a%b);

}

int main() {

  int a,b;

  while(cin >> a >> b) {

    cout << gcd(a,b) << endl;

  }

  return 0;

}

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

int main() {
  string S;
  int N,s=0,sum=0;
  cin >> S;
  N = S.size();
  vector<int> num(N);
  for(int i=0;i<N;i++){
  num[i] = S[i]-'0';
  }

  for(int i=0;i<N;i++){
  sum = sum + num[i];
  }

  for(int i=0;i<N;i++){
   s = s + num[i]*pow(10,N-i-1);
  }



  if(s%sum==0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;cin>>n;
    int a[n],b[n];
    int ind,m=-1;
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    rep(i,n){
        if(a[i]!=b[n-1]){
            cout<<b[n-1]<<endl;
        }
        else{
            cout<<b[n-2]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
int main() {
	int n,x,i,d,l[100];
	scanf("%d", &n);
	scanf("%d", &x);
	for(i=0;i<n;i++) scanf("%d", &l[i]);
	d = 0;
	for (i = 0; i <= n && d<=x; i++) {
		d += l[i];
	}
	printf("%d", i);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int a, b;
  int mask;
};
bool operator<(const ST& a, const ST& b){
  return a.mask < b.mask;
}

#define INF 1000000000
int dp[(1<<12)+5];

int main(){
  int N, M;
  cin >> N >> M;
  vector<ST> v;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    int mask = 0;
    rep(j,b){
      int c;
      cin >> c;
      mask |= 1<<(c-1);
    }
    v.push_back((ST){a,b,mask});
  }
  sort(ALLOF(v));

  rep(i,(1<<12)+5) dp[i] = INF;
  dp[0] = 0;
  rep(i,v.size()){
    rep(j,(1<<N)){
      dp[j | v[i].mask] = min(dp[j | v[i].mask], dp[j] + v[i].a);
    }
  }
  if(dp[(1<<N)-1] == INF) cout << -1 << endl;
  else cout << dp[(1<<N)-1] << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define N 3

using namespace std;
int x[N];

int solve(){
  int m1=min(x[0], min(x[1], x[2]));
  int ans = m1;
  for(int i=0; i<N; ++i) x[i]-=m1;
  int m2 = x[0]>=2*x[1] ? x[1]:x[0]/2;
  ans += m2;
  x[0] -= 2*m2;
  ans += x[0]/3;
  return ans;
}

int main(){
  int q;
  cin >> q;
  for(int i=0; i<q; ++i){
    cin >> x[0] >> x[1] >> x[2];
    cout << solve() << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int A, B;
    string S;
    cin >> A >> B >> S;

    for(int i = 0; i < A+B+1; ++i){
        if(i < A){
            if(S[i] == '-'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(i == A){
            if(S[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(A < i){
            if(S[i] == '-'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, c, ans, b[25], a, tmp;

int main(){
    scanf("%d%d%d", &n, &m, &c);
    for(int i = 0; i < m; i++) scanf("%d", b+i);
    for(int i = 0; i < n; i++){
        tmp = c;
        for(int j = 0; j < m; j++){
            scanf("%d", &a);
            tmp += b[j]*a;
        }
        if(tmp > 0) ans++;
    }
    printf("%d\n", ans);
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> pic(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> pic.at(i).at(j);
    }
  }

  vector<bool> row(H,false);
  vector<bool> col(W,false);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(pic.at(i).at(j) == '#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for(int i=0; i<H; i++){
    if(row.at(i)){
      for(int j=0; j<W; j++){
        if(col.at(j)){
          cout << pic.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MOD 998244353
#define endl '\n'
#define fastio; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

const int N=2e5+5;
ll fact[N];

ll binpow(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}

ll mul(ll a,ll b)
{
    return (a*b)%MOD;
}

ll inv(ll a)
{
    return binpow(a,MOD-2);
}

int main()
{
    fact[0]=1;
    for(int i=1;i<N;i++) fact[i]=mul(fact[i-1],i);

    ll n,m,k;
    cin>>n>>m>>k;

    ll ans=0;
    for(ll p=0;p<=k;p++)
    {
        ll ways=(((m*(mul(mul(fact[n-1],inv(fact[p]))%MOD,inv(fact[n-1-p]))%MOD)%MOD)*(binpow(m-1,n-1-p)%MOD))%MOD)%MOD;
        ans=(ans+ways+MOD)%MOD;
    }
    cout<<ans<<endl;

    return 0;
}




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

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  ll sowa = accumulate(v.begin(), v.end(), 0ll);
  ll mine = *min_element(v.begin(), v.end());

  if (n % 2) {
    if (sowa % 2)
      cout << "First" << endl;
    else
      cout << "Second" << endl;
  } else {
    if (mine % 2 || (sowa - mine) % 2)  // どっちかが奇数
      cout << "First" << endl;
    else
      cout << "Second" << endl;
  }
}



Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  int m = 2*D+1;
  cout << (N+m-1)/m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int solve(string S) {
	if (S.size() == 1)return 0;
	string U = S;
	int F = (int)(U[0] - '0') + (int)(U[1] - '0');
	U = to_string(F) + U.substr(2, U.size() - 2);
	return solve(U) + 1;
}
string T;
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> T; int P = solve(T);
		if (P % 2 == 0)cout << "Audrey wins." << endl;
		if (P % 2 == 1)cout << "Fabre wins." << endl;
	}
	return 0;
}

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

int main(){
    int X,A,B;

    cin>>X>>A>>B;

    if(B<=A)cout<<"delicious"<<"\n";
    else if(B-A<=X)cout<<"safe"<<"\n";
    else cout<<"dangerous"<<"\n";

    return 0;
}


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

int main(){
	int n;
	long a, max=-1000000, min=1000000, sum=0;

    cin >> n;
	for(int i=0; i<n; i++){
		cin >> a;
		if(a>max) max = a;
		if(a<min) min = a;
		sum+=a;
	}

	cout << min << " " << max << " " << sum << endl;
	return 0;
}


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

int main(){
    int a,b,c;
    int count=0;
    cin>>a;
    cin>>b;
    if(a==b) count++;
    cin>>c;
    if(c==a) count++;
    if(c==b) count++;
    if(count==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[float]", u: "List[str]"):
    ret = 0

    for xi, ui in zip(x, u):
        if ui == "JPY":
            ret += xi
        else:
            ret += 380000.0 * xi
    print(ret)


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]"
    u = [str()] * (N)  # type: "List[str]"

    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() { int a; cin >> a; return a; }
char nextChar() { char a; cin >> a; return a; }
double nextDouble() { double a; cin >> a; return a; }
string nextString() { string a; cin >> a; return a; }

template<class T> void inputVector(vector<T>& v, int n) {
	v.resize(n);
	for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int cnt[50][50];

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

	rep(i, n) {
		string s;
		cin >> s;

		rep(j, s.size()) {
			cnt[i][s[j] - 'a']++;
		}
	}

	for (char ch = 'a'; ch <= 'z'; ch++) {
		int num = 100;
		rep(i, n) {
			num = min(num, cnt[i][ch - 'a']);
		}
		rep(i, num) {
			cout << ch;
		}
	}
	cout << endl;

    return 0;
}


Measured memory_bytes: 256
K=io.read()

function gcd(a,b)
    if b ~= 0 then
        return gcd(b, a % b)
    else
        return a
    end
end

X={}
for i=1,K do
    X[i] = {}
end

for i=1,K do
    for j=1,K do
        X[i][j] = gcd(i,j)
    end
end

sum = 0
for i=1,K do
    for j=1,K do
        for k=1, K do
            sum = sum + gcd(X[i][j],k)
        end
    end
end
print(sum)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<int, int> p_ii;

int main() {
  int N, M; cin >> N >> M;
  vector<p_ii> work;
  rep(i,N) {
    int A, B; cin >> A >> B;
    work.push_back(make_pair(A,B));
  }
  sort(work.begin(), work.end(), [](const p_ii &x, const p_ii &y){return x.first<y.first;});

  priority_queue<int> can;
  int result = 0, pos = 0;
  rep(i,M) {
    while(pos!=N&&work[pos].first<=i+1) {
      can.push(work[pos].second);
      pos++;
    }
    if (can.empty()) continue;
    result += can.top();
    can.pop();
  }
  cout << result << endl;
  return 0;
}

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

int main(){
    int m,f,r,sum;
    while(true){
        cin>>m>>f>>r;
        sum=m+f;
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1)cout<<"F\n";
        else if(sum>=80)cout<<"A\n";
        else if(sum>=65&&sum<80)cout<<"B\n";
        else if(sum>=50&&sum<65)cout<<"C\n";
        else if(sum>=30&&sum<50){
            if(r>=50)cout<<"C\n";
            else cout<<"D\n";
        }
        else cout<<"F\n";
    }
    
    return 0;
}


Measured memory_bytes: 3068
#include<iostream>
using namespace std;
int main(){
  int i;
  char s[1000001];
  cin>>s;
  int mx=0;
  for(i=0;s[i];){    
    for(;s[i]&&s[i]!='J';++i);
    int jc=0,oc=0,ic=0;
    for(;s[i]&&s[i]=='J';++i)
      ++jc;
    for(;s[i]&&s[i]=='O';++i)
      ++oc;
    for(;s[i]&&s[i]=='I';++i)
      ++ic;
    if(jc>=oc&&ic>=oc)
      mx=max(mx,oc);
  }
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define maxn 102333
using namespace std;
vector< pair<int, int> > G[maxn];
long long dist[maxn];
int ind[maxn];
int main() {
//	freopen("02.txt", "r", stdin);
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		G[l].push_back(make_pair(r, d));
		++ind[r];
	}
	memset(dist, -1, sizeof dist);
	for(int i = 1; i <= n; ++i) {
		if(dist[i] == -1) {
			if(G[i].empty()) continue; // if without this bugs will occur
			if(ind[i]) continue;
			queue<int> Q;
			dist[i] = 0;
			Q.push(i);
			while(!Q.empty()) {
				int x = Q.front();
				Q.pop();
				for(auto u : G[x]) {
					if(dist[u.first] == -1) {
						dist[u.first] = dist[x] + u.second;
						Q.push(u.first);
					}
				}
			}
		}
	}
	bool valid = true;
	for(int i = 1; i <= n; ++i) {
		for(auto u : G[i]) {
			if(dist[i] + u.second != dist[u.first]) {
				valid = false;
			}
		}
	}
	puts(valid ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 10648
import sys

line = sys.stdin.readline()

num = int(line.split()[0])
x = int(line.split()[1])

line = sys.stdin.readline()

nums = map(int, line.split())

cnt = 0
for i,v in enumerate(nums):
  if i == len(nums)-1:
    break
  if nums[i] + nums[i+1] > x:
    eat = nums[i] + nums[i+1] - x
    if nums[i+1] > eat:
      nums[i+1] -= eat
    else :
      nums[i] = nums[i] - (eat - nums[i+1])
      nums[i+1] = 0
    cnt += eat

print cnt

Measured memory_bytes: 12416
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#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 <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n, k;
	cin >> n >> k;
	int ans  = INF;
	for (int i = n; i > 0; --i) {
		int num = 1;
		for (int j = i; j > 0; --j) {
			num *= 2;
		}	
		for (int j = n - i; j > 0; --j) {
			num += k;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
    return;
}

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



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
// typedef
typedef pair<int, int> P;
typedef tuple<int, int, int> P3;

bool comPair(const P &firstElof, const P &secondElof) {
    return firstElof.second > secondElof.second;
}

int main() {
    int n;
    ll k;
    ll ans = 0;
    cin >> n >> k;

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

    vector<int> minorThanInQ;
    rep(i, n) {
        int c = 0;
        repeat(j, i, n) {
            if (a[i] > a[j]) {
                c++;
            }
        }
        minorThanInQ.push_back(c);
    }

    vector<int> minorThan;
    rep(i, n) {
        int c = 0;
        rep(j, n) {
            if (a[i] > a[j]) {
                c++;
            }
        }
        minorThan.push_back(c);
    }

    ll sum = (((k - 1) * k) / 2) % M;
    rep(i, n) {
        ans += (minorThan[i] * sum) % M;
        ans %= M;
        ans += (minorThanInQ[i] * k) % M;
        ans %= M;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

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

    int n, m;
    cin >> n >> m;
    int ar[n], bad[n] = {};
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> ar[ctr1];
    int a, b;
    for (int ctr2 = 0; ctr2 < m; ++ctr2) {
        cin >> a >> b;
        if (ar[a - 1] <= ar[b - 1])
            bad[a - 1] = 1;
        if (ar[a - 1] >= ar[b - 1])
            bad[b - 1] = 1;
    }
    cout << n - accumulate(bad, bad + n, 0) << '\n';
    return 0;
}


Measured memory_bytes: 4348
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n;cin>>n;
  int MARCH[5];
  rep(i,5)MARCH[i] = 0;
  rep(i,n){
    string tmp;cin>>tmp;
    if(tmp[0] == 'M')MARCH[0]++;
    else if(tmp[0] == 'A')MARCH[1]++;
    else if(tmp[0] == 'R')MARCH[2]++;
    else if(tmp[0] == 'C')MARCH[3]++;
    else if(tmp[0] == 'H')MARCH[4]++;
  }
  long long kekka = 0;
  rep(i,5){
    for(int j = i+1; 5 > j; j++){
      for(int k = j+1; 5 > k; k++){
        kekka+=(long long)MARCH[i]*MARCH[j]*MARCH[k];
      }
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n;
    cin >> n;
    string s;
    while (1) {
        if (n % 2 != 0) { s += '1'; n--;}
        else s += '0';
        n /= -2;
        if (n == 0) break;
    }
    reverse(all(s));
    out(s);
}


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

int main(){
    string s;
    cin >> s;
    vector<bool> use(26, false);
    for (int i = 0; i < (int) s.size(); i++){
        int now = s[i] - 'a';
        if (use[now]) {
            cout << "no\n";
            return 0;
        }
        else use[now] = true;
    }
    cout << "yes\n";
}


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

int main(int argc, char **argv)
{
    int n = 0;
    std::cin >> n;
    std::vector<int> v(n);
    for (auto i = v.begin(); i != v.end(); i++) {
        std::cin >> *i;
    }
    std::vector<int> c(n);
    for (auto i = c.begin(); i != c.end(); i++) {
        std::cin >> *i;
    }
    int max = 0;
    for (int i = 0; i < n; i++) {
        int d = v.at(i) - c.at(i);
        if (d > 0) {
            max += d;
        }
    }
    std::cout << max;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int i = 1;
    int cand = 1;
    for(; i <= 10; i++)
    {
        cand *= 10;
        cout << "? " << cand << endl;
        char ans;
        cin >> ans;
        if(ans == 'N') break;
    }

    if(i == 11)
    {
        // n : 10の階乗のとき
        cand = 1;
        for(int j = 0; j < 10; j++)
        {
            cand *= 10;
            cout << "? " << cand-1 << endl;
            char ans;
            cin >> ans;
            if(ans == 'Y')
            {
                cout << "! " << cand/10 << endl;
                return 0;
            }
        }
    }
    else
    {
        // i:桁数
        int num = 0;
        for(int k = 1; k <= i; k++)
        {
            int cand = 0;
            int d[4] = {8, 4, 2, 1};
            for(int j = 0; j < 4; j++)
            {
                if(cand + d[j] > 9) continue;
                cand += d[j];
                ll query = cand * 1e9 + num * pow(10, 10-(i-k+1));
                query = query / pow(10, k-1) -1;
                cout << "? " << query << endl;
                char ans;
                cin >> ans;
                if(ans == 'Y')
                {
                    cand -= d[j];
                }
            }
            if(k==1 && cand == 0) cand = 1;
            num += cand * pow(10, i-k);
        }
        cout << "! " << num << endl;
        return 0;
    }
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;
string s,s1="1";
int res1=0,res2=0;
int main()
{
    //freopen("C.INP","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> s;
    for (int i=1;i<s.size();i++)
    {
        if (s1[i-1]=='1') s1+="0";
        else s1+="1";
    }
    //cout << s1 << " " << s2 << "\n";
    for (int i=0;s[i];i++)
    {
        if (s1[i]==s[i]) res1++;
        else res2++;
    }
    cout << s.size() - max(res1,res2);
}


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

class Program {
  static void Main() {
    string[] input = Console.ReadLine().Trim().Split(' ');
    int K = int.Parse(input[0]);
    int X = int.Parse(input[1]);
    
    string answer = "";
    for(var i = X - K + 1; i <= X + K - 1; i++) {
      if(answer != "") {
        answer += " ";
      }
      answer += i.ToString();
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  int64_t a,b;
  cin>>n>>a>>b;
  int64_t x=n/(a+b);
  int64_t y=n-x*(a+b);
  int64_t cou;
  if(y<=a){
    cou=y;
  }
  else{
    cou=a;
  }
  cout<<x*a+cou<<endl;
}



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

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	double x[3],y[3],px,py;
	while(cin>>x[0]>>y[0]){
		for(int i=1;i<3;i++)cin>>x[i]>>y[i];
		cin>>px>>py;
		bool ok=true;
		for(int i=0;i<3;i++){
			bool plus=false;
			if(x[(i+1)%3]==x[(i+2)%3]){
				if(x[i]>x[(i+1)%3])plus=true;
			}
			else{
				double a,b;
				a=(x[i]-x[(i+1)%3])*(y[(i+2)%3]-y[(i+1)%3]);
				b=(y[i]-y[(i+1)%3])*(x[(i+2)%3]-x[(i+1)%3]);
				if(a>b)plus=true;
			}
			bool pnt=false;
			if(x[(i+1)%3]==x[(i+2)%3]){
				if(px>x[(i+1)%3])pnt=true;
			}
			else{
				double a,b;
				a=(px-x[(i+1)%3])*(y[(i+2)%3]-y[(i+1)%3]);
				b=(py-y[(i+1)%3])*(x[(i+2)%3]-x[(i+1)%3]);
				if(a>b)pnt=true;
			}
			if(pnt!=plus)ok=false;
		}
		if(ok)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

typedef long long ll;

const ll mod = 998244353;

ll p( ll a, ll b){
  if( b == 0){ return 1LL;}
  if( b == 1){ return a;}
  
  if( b % 2 == 0){ return (p(a,b/2)*p(a,b/2))%mod;}
  else{ return (((p(a,(b-1)/2)*p(a,(b-1)/2))%mod)*a)%mod;}
}
  
  
  
  

int main(){ 
  ll N; cin >> N;
  vector<ll> D(N); 
  
  for(ll i = 0; i < N; i++){ 
    cin >> D[i];
    if( i == 0 && D[0] != 0){ cout << 0 << endl; return 0;}
    if( i > 0 && D[i] == 0){ cout << 0 << endl; return 0;}
        } 
    
  sort(D.begin(),D.end());
  ll head = 0; ll tail = 0;
  vector<ll> d;
  bool flag = true; 
  while( head < N && tail < N){
    if( D[head] != D[tail]){ 
      if( D[tail] - D[head] > 1){ flag = false; break;}
      else{ head++;}
    }
    while( D[head] == D[tail] && tail < N){ tail++;}
    
    if( D[tail]-D[head] > 1 && tail < N){ flag = false; break;}
    
    d.push_back(tail-head);
    
    head = tail;
  }
  
  if( !flag ){ cout << 0 << endl; return 0;}
  
  ll ans = 1LL;
  
  for(ll i = 0; i < d.size()-1; i++){ 
    ans *= p(d[i],d[i+1]); ans %= mod;}
  
  cout << ans <<endl; return 0;
}
  
               
  
  
    
    

Measured memory_bytes: 2168
#include<stdio.h>

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

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define N 100005
#define P 1000000007
using namespace std;
int n,m,f[N],dep[N];
vector<int>a[N];
void dfs(int x,int fa){
	dep[x]=dep[fa]+1;
	int t=0;
	for(int i=0;i<(int)a[x].size();i++){
		int y=a[x][i],res=m;
		if(y==fa)continue;
		t++;
		if(dep[x]>=2)res-=2;
		else res--;
		res-=t-1;
		f[y]=res;
		dfs(y,x);
	}
	
}
signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	f[1]=m;
	dfs(1,0);
	long long ans=1ll;
	for(int i=1;i<=n;i++)ans=ans*f[i]%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
int n;
cin>>n;
vector<int> a(n),b(n),c(n-1,0);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n;i++)cin>>b.at(i);
for(int i=0;i<n-1;i++)cin>>c.at(i);
int ans=0;
ans+=b.at(a.at(0)-1);
int bfo=a.at(0);
for(int i=1;i<n;i++){
    //cout<<ans<<endl;
    ans+=b.at(a.at(i)-1);
    if(a.at(i)-bfo==1)ans+=c.at(bfo-1);
    bfo=a.at(i);
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		String sum = "";
		for(int i = 0 ; i < n ; i++) {
			sum += "" + s.charAt(i) + t.charAt(i);
		}

		sc.close();
		System.out.println(sum);

	}
}



Measured memory_bytes: 39296
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
using namespace std;

int main(){
    long long res=0;
    int N;cin>>N;
    vector<long long>A(N);
    vector<long long>B(N);
    vector<long long>C(N);
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];
    for(int i=0;i<N;i++)cin>>C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    for (int i=0;i<N;i++){
        auto it1=lower_bound(A.begin(),A.end(),B[i]);
        auto it2=upper_bound(C.begin(),C.end(),B[i]);
        long k1=it1-A.begin();
        long k2=C.end()-it2;
        res+=k1*k2;
        
    }
    cout<<res<<endl;
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    map<int, int> a, b;
    rep(i, 0, n / 2)
    {
        int x, y;
        cin >> x >> y;
        a[x]++;
        b[y]++;
    }
    int x1 = -1, y1 = -1;
    //a中心
    for (auto i : a)
    {
        if (a[x1] < i.second)
            x1 = i.first;
    }
    for (auto i : b)
    {
        if (b[y1] <= i.second && i.first != x1)
            y1 = i.first;
    }
    int x2 = -1, y2 = -1;
    for (auto i : b)
    {
        if (b[y2] <= i.second)
            y2 = i.first;
    }
    for (auto i : a)
    {
        if (a[x2] < i.second && i.first != y2)
            x2 = i.first;
    }
    cout << n - max(a[x1] + b[y1], a[x2] + b[y2]) << endl;
}

Measured memory_bytes: 8144
#include<iostream>
#include<string>
#define LL long long
int N;
int sum;
int main() {
	LL N;
	std::cin >> N;
	LL lb = 1;
	LL ub = N;
	while (ub - lb > 1) {
		LL mid = (lb + ub) / 2;
		if ((mid + 1LL)*mid / 2LL>=N) {
			ub = mid;
		}
		else {
			lb = mid;
		}
	}
	for (int i = 1; i <= ub; i++) {
		if (i == (ub + 1) * ub / 2 - N)continue;
		std::cout << i << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

struct Node {
	int key;
	Node* parent, * left, * right;
};

Node* root;

void root_init() {
	root = nullptr;
}

void insert(int k) {
	if (root == nullptr) {
		Node* ins_value = new Node;
		ins_value->key = k;
		ins_value->parent = nullptr;
		ins_value->left = nullptr;
		ins_value->right = nullptr;
		root = ins_value;
		return;
	}
	Node* npntr = nullptr;
	Node* now = root;
	Node* ins_value = new Node;

	ins_value->key = k;
	ins_value->left = nullptr;
	ins_value->right = nullptr;

	while (now != nullptr) {
		npntr = now;
		if ((ins_value->key) < (now->key)) now = now->left;
		else now = now->right;
	}
	ins_value->parent = npntr;
	if ((ins_value->key) < (npntr->key)) npntr->left = ins_value;
	else npntr->right = ins_value;
}

void inorder(Node* u) {
	if (u == nullptr) return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}
void preorder(Node * u) {
	if (u == nullptr) return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
}

void all_delete_node(Node * now) {
	if (now == nullptr) return;
	all_delete_node(now->left);
	all_delete_node(now->right);
	delete now;
}


int main() {
	int size, value;
	string cmd;
	cin >> size;

	for (int i = 0; i < size; i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> value;
			insert(value);
		}
		else if (cmd == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	all_delete_node(root);

	return 0;
}



Measured memory_bytes: 26492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double sum = 0;
		for(int i = 0; i < n; i++){
			double x = sc.nextDouble();
			String u = sc.next();
			if(u.equals("BTC")){
				x *= (double)380000;
			}
			sum += x;
		}
		System.out.println(sum);
	}
}


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

int main() {
  vector<char> a(4);
  for(int i=0;i<4;i++){
    cin>>a.at(i);
  }
  if(a.at(0)==a.at(1)&&a.at(1)==a.at(2)){
    cout<<"Yes"<<endl;
  }
  else if(a.at(1)==a.at(2)&&a.at(2)==a.at(3)){       
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  int a_mid = -1, b_mid = -1;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n % 2 == 0) {
    a_mid = a[n / 2 - 1] + a[n / 2];
    b_mid = b[n / 2 - 1] + b[n / 2];
  } else {
    a_mid = a[n / 2];
    b_mid = b[n / 2];
  }
  cout << b_mid - a_mid + 1 << endl;
  return 0;
}

Measured memory_bytes: 4792
import math

A, B, H, M = map(int, input().split())

# for one minute
A_deg=H*(360/12) + M*(360/12/60)
B_deg=M*(360/60)
deg=abs(A_deg-B_deg)

ans = math.sqrt(
  A**2+
  B**2-
  2*A*B*math.cos(math.radians(deg))
)

print(ans)


Measured memory_bytes: 9420
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	string s;
	cin >> s;
	cout << s + (s.back() == 's' ? "es" : "s") << '\n';

	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int a[51],n,m,nm;
int bol(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n,bol);
	for(int i=1;i<=m;i++){
		nm+=a[i];
	}
	cout<<nm<<endl;
	return 0;
}

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

int a[200010], b[200010];
vector<bool> island1(200010), island2(200010);

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == n) {
			island1[b[i]] = true;
		}
		else if (b[i] == n) {
			island1[a[i]] = true;
		}
		if (a[i] == 1) {
			island2[b[i]] = true;
		}
		else if (b[i] == 1) {
			island2[a[i]] = true;
		}
	}
	for (int i = 0; i < min(island1.size(), island2.size()); i++) {
		if (island1[i] == 1 && island2[i] == 1) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1792
n=int(input())
if(n==2):
  print(0)
  quit()
ans=0
p=[]
for i in range(2,1000001):
  if(i*i>=n):
    break
  if(n%i==0):
    p.append(n//i)
for i in p:
  if(n%(i-1)==n//(i-1)):
    ans+=i-1
print(ans+n-1)

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

int main() {
  int N, K; cin >> N >> K;
  vector<long long> x(N), y(N);
  for (int i = 0; i < N; i++) cin >> x.at(i) >> y.at(i);
  long long ans = 1LL << 62;
  for (int left = 0; left < N; left++) {
    for (int right = 0; right < N; right++) {
      if (left == right) continue;
      if (x.at(left) > x.at(right)) continue;
      for (int up = 0; up < N; up++) {
        for (int down = 0; down < N; down++) {
          if (up == down) continue;
          if (y.at(down) > y.at(up)) continue;
          int cnt = 0;
          for (int i = 0; i < N; i++) {
            if (x.at(i) < x.at(left)) continue;
            if (x.at(i) > x.at(right)) continue;
            if (y.at(i) > y.at(up)) continue;
            if (y.at(i) < y.at(down)) continue;
            cnt++;
          }
          if (cnt >= K) {
            long long width = x.at(right) - x.at(left);
            long long height = y.at(up) - y.at(down);
            ans = min(ans, width * height);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int a[]=new int [6];
		for(int i=0;i<6;i++){
			a[i]=scan.nextInt();
		}
		if(1000<=a[0]+a[1]*5+a[2]*10+a[3]*50+a[4]*100+a[5]*500){
			System.out.println(1);
		}
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 17356
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		ArrayList <PriorityQueue<Integer>> queues = new ArrayList <PriorityQueue<Integer>>();  //PriorityQueueのArrayListを生成
		try (Scanner sc = new Scanner (System.in)){
			int n = sc.nextInt();
			for (int i=0; i<n; i++) {
				queues.add(new PriorityQueue<Integer>(Collections.reverseOrder()));  //n個のPriorityQueueを追加（逆順）
																					//Collectionsの参考：https://qiita.com/p_shiki37/items/3902f4e3adc3aeb382f1
			}
			int times = sc.nextInt();
			for (int i=0; i<times; i++) {
				int query = sc.nextInt();  //命令 0 insert 1 getMax 2 deleteMax
				int que = sc.nextInt();  //何個目のqueue
				switch (query) {
				//insert(t,x)
				case 0:
					int x = sc.nextInt();
					queues.get(que).add(x);
					break;

				//getMax(t)
				case 1:
					if (queues.get(que).size() != 0) { //空じゃなかったら
						System.out.println(queues.get(que).peek());
					}
					break;

				//deleteMax(t)
				case 2:
					if (queues.get(que).size() != 0) { //空じゃなかったら
						queues.get(que).poll();
					}
					break;

				}
			}
		}
	}
}


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

void fnInput(vector<int> &rvnTrg, vector<int> &rvnSch)
{
  int nTrgCnt;
  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];

  int nSchCnt;
  cin >> nSchCnt;

  rvnSch.resize(nSchCnt);
  for (int i = 0; i < nSchCnt; i++)
    cin >> rvnSch[i];
}

void fnBinSch(const vector<int> &cnrvnTrg, const vector<int> &cnrvnSch, int &rnFnd)
{
  for (int i = 0; i < cnrvnSch.size(); i++)
  {
    int nLow  = 0;
    int nHigh = cnrvnTrg.size();
    while (nLow < nHigh)
    {
      int nMid = (nLow + nHigh) / 2;
      if (cnrvnSch[i] == cnrvnTrg[nMid])
      {
        rnFnd++;
        break;
      }
      else if (cnrvnSch[i] < cnrvnTrg[nMid])
        nHigh = nMid;
      else
        nLow  = nMid + 1;
    }
  }
}

void fnResult(int nFnd)
{
  cout << nFnd << endl;
}

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

  vector<int> vnTrg, vnSch;
  int nFnd = 0;

  fnInput(vnTrg, vnSch);
  fnBinSch(vnTrg, vnSch, nFnd);
  fnResult(nFnd);

  return 0;
}

Measured memory_bytes: 1592
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	string s;
	cin >> s;
	s += 'T';
	vector<int> fs[2];
	int d = 0, n = 0, x, y;
	cin >> x >> y;
	for (char c : s)
	{
		if (c == 'F')
		{
			n++;
		}
		else
		{
			fs[d].push_back(n);
			n = 0;
			d ^= 1;
		}
	}
	n = fs[0].size();
	//cout << n << endl;
	set<int> go;
	go.insert(0);
	x -= fs[0][0];
	for (int i = 1; i < n; i++)
	{
		int f = fs[0][i];
		set<int> nx;
		//cout << f << endl;
		for (int d : go)
		{
			nx.insert(d+f);
			nx.insert(d-f);
		}
		swap(go, nx);
	}
	if (go.find(x) == go.end())
	{
		cout << "No" << endl;
		return;
	}
	n = fs[1].size();
	go.clear();
	go.insert(0);
	for (int i = 0; i < n; i++)
	{
		int f = fs[1][i];
		set<int> nx;
		//cout << f << endl;
		for (int d : go)
		{
			nx.insert(d+f);
			nx.insert(d-f);
		}
		swap(go, nx);
	}
	if (go.find(y) == go.end())
	{
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 640