akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e6;
//------------------------------------------------------------
ll A,B,N;
void solve() {
  cin>>A>>B>>N;

  ll x = min(B-1, N);

  print(floor(A*x/B)-A*floor(x/B));

  return;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    if(A + B > 2*C)
    {
        int n = min(X, Y);
        ans += n * 2*C;
        X -= n;
        Y -= n;
    }
    ans += min(A, 2*C) * X;
    ans += min(B, 2*C) * Y;
    cout << ans << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,j,n,x;
    
        cin>>n;
        cout<<(n)+(n*n)+(n*n*n);

    
}



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

void push(int x);
int pop(void);

int top, S[1000];
  
int main(){
  int a, b;
  char s[1000000];

  top = 0;
  
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    } else{
      push(atoi(s));
    }
  }
  
  printf("%d\n", pop());
  
  return 0;
}

void push(int x){
  if(top >= 999  ) printf("OverFllow\n");
  S[++top] = x;
}

int pop(){
  if(top == 0) printf("UnderFllow\n");
  top--;
  return S[top+1];
}

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

typedef unsigned long long ull;
typedef long long ll;

#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
  ll K;
  ll a[50];

  cin >> K;

  ll t = (ll)(K/50);

  cout << 50 << endl;
  rep(i,50)
  {
    a[i] = i-K%50;
    if(a[i]<0)
      a[i]+=51;
    cout << a[i]+t << " ";
  }

  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define H 128
#define W 17
#define INF 1e4
using namespace std;
int h,w;
string str[H];

/*
  short mem[H][W][1<<W];
  bool used[H][W][1<<W];
  int dfs(int y,int x,int bit,int p,int u){
  if( y == h ) return 0;
  if(p+(w-x) < str[y].size()) return -INF;
  if( x == w ) {
  if(p < (int)str[y].size()) return -INF;
  return dfs(y+1,0,bit,0,0);
  }

  if(used[y][x][bit]) return mem[y][x][bit];
  used[y][x][bit] = 1;
  int a=0,b=0;

  //?????????????????????
  int abit = bit & (~(1<<x));
  a = dfs(y,x+1,abit,p,u+(bit>>x&1));
  
  //???????????????
  int bbit = bit | (1<<x);
  if(p<(int)str[y].size()){
  int score = 0;
  score += 2*((bit>>x&1)&&(str[y][p]==str[y-1][u]));
  score += 2*(x>=1&&(bit>>(x-1)&1)&&str[y][p]==str[y][p-1]);
  b = score+dfs(y,x+1,bbit,p+1,u+(bit>>x&1));
  }
  return mem[y][x][bit]=max(a,b);
  }
*/


int Max(int &a,int b){return a=max(a,b);}

int dp[2][W][1<<W];
int A[W][1<<W],B[W][1<<W];
void mkAB(int x,int bit){
  int sum = __builtin_popcount(bit);
  int cnt = 0;
  for(int i=0;i<x;i++)cnt+=(bit>>i&1);
  A[x][bit] = cnt;
  B[x][bit] = sum - cnt;
}

int DP(){
  for(int i=0;i<W;i++)
    for(int j=0;j<(1<<W);j++)mkAB(i,j);

  memset(dp,-1,sizeof(dp));
  dp[0][0][0] = 0;
  int res = 0;
  for(int i=0;i<h;i++){
    int idx = i%2;
    for(int j=0;j<w;j++){
      for(int bit=0;bit<(1<<w);bit++){
        if(dp[idx][j][bit]==-1)continue;
        int p = A[j][bit];
        int u = i? str[i-1].size()-B[j][bit]:0;
        if(p+(w-j) < str[i].size()) continue;

        //use space
        int abit = bit & (~(1<<j));
        Max(dp[idx][j+1][abit],dp[idx][j][bit]);
        

        //use character
        if(p>=(int)str[i].size())continue;
        int bbit = bit | (1<<j);
        int score = 0;
        score += 2*((bit>>j&1)&&(str[i][p]==str[i-1][u]));
        score += 2*(j>=1&&(bit>>(j-1)&1)&&str[i][p]==str[i][p-1]);
        Max(dp[idx][j+1][bbit],dp[idx][j][bit]+score);
      }
    }
    for(int bit=0;bit<(1<<w);bit++){
      if(__builtin_popcount(bit) != str[i].size())continue;
      Max(dp[!idx][0][bit],dp[idx][w][bit]);
      Max(res,dp[idx][w][bit]);
    }
  }
  return res;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++) cin>>str[i];
  //  cout<<dfs(0,0,0,0,0)<<endl;
  cout<<DP()<<endl;
  return 0;
}

Measured memory_bytes: 37972
#include<stdio.h>
#define MAX 101
#define LARGE 10000001
  int i,j,n,count=0,v,c,c1,v1;
int main(void)
{
 
  int graph[MAX][MAX],col[MAX],d[MAX],pi[MAX],min,number;
  
  for(i = 0; i < MAX; i++){
  
    for(j = 0; j < MAX; j++)
      graph[i][j] = -1;
  
  }
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
  
    scanf("%d%d",&v,&c);
  
    for(j = 0; j < c; j++){
      scanf("%d%d",&v1,&c1);
      graph[v][v1] = c1;
    }
  
  }
   
  for(i = 0; i < n; i++){
  
    col[i] = 0;
    pi[i] = -1;
    d[i] = LARGE;
  
  }
  
  d[0] = 0;
   
  while(1){
  
    min = LARGE;
  
    for(i = 0; i < n; i++){
  
      if(col[i] != 2 && d[i] < min){
        min = d[i];
        number = i;
      }
  
    }
  
    if(min == LARGE)break;
  
    col[number] = 2;
  
    for(i = 0; i < n; i++){
  
      if(col[i] != 2&&graph[number][i] != -1  && (graph[number][i]+d[number])< d[i]){
    pi[i] = number;
    d[i] = graph[number][i] + d[number];
    col[i] = 1;
      }
  
    }
  
  }
  
  for(i = 0; i < n; i++)printf("%d %d\n",i,d[i]);
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  int D, T, S;
  cin >> D >> T >> S;
  if( (D+S-1)/S <= T ) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3620
def main():
    s = input()
    pre = ''
    start = False
    count = 0
    for c in s:
        if not start and c == 'R':
            start = True
            count = 1
        if start and c == 'R' == pre:
            count += 1
        pre = c
    print(count)


if __name__ == '__main__':
    main()


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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy\n";
	else if (s == "Cloudy")
		cout << "Rainy\n";
	else if (s == "Rainy")
		cout << "Sunny\n";

}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define NUM 1000000007
typedef long long ll;

ll multiply(ll p, ll q) {
    return ((p % NUM) * (q % NUM)) % NUM;
}
// p^q
ll pow(ll p, ll q) {
    if (q == 0) return 1;
    else if (q == 1) return (p % NUM);
    else if (q == 2) return multiply(p, p);
    if (q % 2 == 0) {
        ll r = pow(p, q/2);
        return multiply(r, r);
    } else {
        return multiply(p, pow(p, q-1));
    }
}

int main(void) {
    ll m, n;
    cin >> m >> n;
    cout << pow(m, n) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s;   cin >> s;
    ll res=0;
    rep(i, s.size()){
        res += (s[i]-'0');
        ll tmp = res, sum=0;
        while(0<tmp){
            sum += tmp%10;
            tmp /= 10;
        }
        res = sum;
    }
    if(res%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a;
  cin >> a;
 
  if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }  
}

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

int main(){
	ll n,a,b;cin>>n>>a>>b;
	if(a > b){
		cout << 0 << endl;
		return 0;
	}
	if (n == 1){
		if(a != b){
			cout << 0 << endl;
		}
		else{
			cout << 1 << endl;
		}
		return 0;
	}
	else{
		ll base = a + b;
		ll mini = base + (n - 2) * a;
		ll maxim = base + (n - 2) * b;
		cout << maxim - mini + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = []
h = list(map(int, input().split()))

def l_r(lis):
    l = 0
    r = 0
    for i in range(len(lis)):
        if lis[i] > 0:
            l = i
            break
    if l == len(lis)-1:
        r = l
    else:
        for i in range(l+1,len(lis)):
            if lis[i] <= 0:
                r = i
                break
            else:
                r = len(lis)-1
    return l,r

if h == []:
    print(0)
else:
    counta = 0
    while True:
        if all([x<=0 for x in h]):
            break
        else:
            l,r = l_r(h)
            for i in range(l,r+1):
                h[i] = h[i] - 1
            counta += 1
    print(counta)


Measured memory_bytes: 43372
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    System.out.println(48-a);
  }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll A[202020];
ll mk[202020];
ll i, j, k;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        ++mk[A[i]];
    }
    ll ans = 0;
    fornum(i,0,N){
        ans += mk[i + 1] * (mk[i + 1] - 1) / 2;
    }
    fornum(i,0,N){
        printf("%lld\n", ans - mk[A[i]] + 1);
    }

    
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS=1E-8;


vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];

  for(int i=0;i<n;i++)B[i][n]=b[i];

  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);

    if(abs(B[i][i])<EPS)return vec(); 

    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];

    for(int j=0;j<n;j++)
      if(i!=j)
	for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
    
  }

  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}
#define N 101
#define INF 1e9

int main(){

  while(1){
    int n,s,t;
    cin>>n>>s>>t;
    if(!n&&!s&&!t)break;
    s--,t--;
    int G[N][N],g[N][N],q[N];
    for(int i=0;i<n;i++)cin>>q[i];

    for(int i=0;i<n;i++)
      for(int j=0,c;j<n;j++)cin>>c,G[i][j] = g[i][j] =c>0? c:INF;
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)G[i][j] = min(G[i][j],G[i][k]+G[k][j]);


    mat A(n,vec(n,0));
    vec B(n,0);
    for(int i=0;i<n;i++){
      if(G[i][t]==INF||i==t) {A[i][i] = 1; continue;}

      int cnt=0,sum=0;
      G[t][t]=0;
      for(int j=0;j<n;j++){
	if(g[i][j] >= INF||
	   (q[i]&&G[i][t]<g[i][j]+G[j][t]))continue;
	A[i][j] = -1;
	sum+=g[i][j];
	cnt++;
      }
      B[i] = sum;
      A[i][i] = cnt;
    }
  
    vec ans=gauss_jordan(A,B);
    if(ans.empty()) cout<<"impossible"<<endl;
    else printf("%.10f\n",(double)ans[s]);
  }
  return 0;
}

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

const int INF = 1 << 30;

int main() {
	int N;
	cin >> N;
	vector<long long> R(N);
	for (int i = 0; i < N; i++) cin >> R[i];
	long long ans = -INF;
	long long min_R = R[0];
	for (int i = 1; i < N; i++) {
		ans = max(ans, R[i] - min_R);
		min_R = min(min_R, R[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4372
import math

a, b, h, m = map(int, input().split())
x = h * (360 / 12) + m * (30 / 60)
y = m * (360 / 60)

z = x - y if x >= y else y -x
ans = math.sqrt((a*a) + (b*b) - 2 * a * b * math.cos(math.radians(z)))
print(ans)

Measured memory_bytes: 9528
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([line[2] for line in c]) - sum([line[1] for line in c])) % 3 == 0
    assert (sum([line[1] for line in c]) - sum([line[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    int cnt = 0;
    for(int i = 1; i <= N; ++i){
        cin >> P[i-1];
        if(i != P[i-1]) ++cnt;
    }

    if(cnt < 3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)

## a, bを無向辺として，隣接リストを作成
N = int(input())
p = [0] + list(map(float, input().split()))

m = N // 2 + 1

dp = [[0.0]*(m+1) for i in range(N+1)]

dp[0][0] = 1.0
for i in range(1,N+1):
    dp[i][m] = dp[i-1][m] + dp[i-1][m-1]*p[i]
    for k in range(1,m):
        dp[i][k] = dp[i-1][k]*(1.0-p[i]) + dp[i-1][k-1]*p[i]
    dp[i][0] = dp[i-1][0]*(1.0-p[i])

print(dp[N][m])

Measured memory_bytes: 101712
a, b, c, d = gets.split(" ").map(&:to_i)
def gcd(c, d)
	return d==0 ? c : gcd(d, c%d)
end
def lcm(c, d)
	return c/gcd(c, d) * d
end
def func(x, c, d)
	return ret = x - x/c - x/d + x/lcm(c, d)
end
ans = func(b, c, d) - func(a-1, c, d)
puts ans


Measured memory_bytes: 14288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define int ll

signed main(){
    int n;
    cin>>n;
    static int a[1000001]={};
    rep(i,n){
        int x;
        cin>>x;
        a[x]+=x;
    }
    for(int i=1;i<1000001;i++){
        a[i]=a[i]+a[i-1];
    }
    int m;
    cin>>m;
    static int b[300000],c[300000];
    rep(i,m){
        cin>>b[i];
    }
    rep(i,m){
        cin>>c[i];
    }
    rep(i,m){
        if(a[b[i]]>=c[i]){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second

#define pow10(n) stoll("1"+string(n,'0'))

#define debug(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LNF = 1e18;

void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

const int N = 1e4+7;
int cnt[N];

int main() {
    
    setIO("input");
    int n; cin >> n;
    for(int x=1; x<=100; ++x) {
        for(int y=1; y<=100; ++y) {
            for(int z=1; z<=100; ++z) {
                int val = x*x + y*y + z*z + x*y + y*z + x*z;
                if(val <= n)
                    ++cnt[val];
            }
        }
    }
    for(int i=1; i<=n; ++i)
        cout << cnt[i] << '\n';
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3636
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt(), c = sc.nextInt(), x = sc.nextInt();
        int ans = 0;
        for(int i = 0; i <= a; i++)
            for(int j = 0; j <= b; j++)
                for(int k = 0; k <= c; k++)
                    if(500 * i + 100 * j + 50 * k == x) ans++;
        System.out.println(ans);
    }
}

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

ll bfs(int k) {
  queue<ll> que;
  int cur = 0;
  int count = 0;
  
  for (ll i = 1; i <= 9; ++i) {
    que.push(i);
  }
  
  ll tmp;
  while (count < k) {
    tmp = que.front();
    que.pop();
    ++count;
    
    int last = tmp % 10;
    if (last == 0) {
      que.push(tmp * 10);
      que.push(tmp * 10 + 1);
    }
    else if (last == 9) {
      que.push(tmp * 10 + 8);
      que.push(tmp * 10 + 9);
    }
    else {
      que.push(tmp * 10 + last - 1);
      que.push(tmp * 10 + last);
      que.push(tmp * 10 + last + 1);
    }
  }
  
  return tmp;
}

int main() {
  int k;
  cin >> k;
  
  cout << bfs(k) << endl;
  
  return 0;  
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
int main(){
	int a,b,c,cnt=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++)
    {
		if(c%i==0) cnt++;
	}
		cout<<cnt<<endl;
	return 0;
}		
		



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
     n-=k;
     if(n==0){
         cout<<1<<endl;
         return 0;
     }
     k--;
     if(n%k==0)cout<<1+n/k<<endl;
     else cout<<2+n/k<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] -= i;
    sort(all(a));
    ll ans = 0;
    rep(i, n) ans += abs(a[i] - a[n/2]);
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N, M;
    cin >> N >> M;

    vector<P> digit;
    P temp;
    REP(i,M){
        cin >> temp.first >> temp.second;
        digit.eb(temp);
    }

    vi ans(N,-1);
    REP(i,M){
        if(ans[digit[i].first - 1] == -1){
            ans[digit[i].first - 1] = digit[i].second;
        }
        else{
            if(ans[digit[i].first - 1] != digit[i].second){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(ans[0] == 0 && N > 1){
        cout << -1 << endl;
        return 0;
    }
    else if(ans[0] == -1 && N == 1) ans[0] = 0;
    else if(ans[0] == -1){
        ans[0] = 1;
    }
    if(N>1){
        REP(i,N-1){
            if(ans[i+1] == -1){
                ans[i+1] = 0;
            }
        }
    }

    REP(i,N){
        cout << ans[i];
    }
    cout << "\n";

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int x[100];
  int y[100];
  int h[100];
  int i;
  for(i=0;i<n;i++) scanf("%d%d%d",x+i,y+i,h+i);
  int j;
  for(i=0;i<=100;i++){
    for(j=0;j<=100;j++){
      int k;
      for(k=0;k<n && h[k]==0;k++);
      int height=h[k]+ABS(x[k]-i)+ABS(y[k]-j);
      for(k=0;k<n;k++){
	if(MAX(height-ABS(x[k]-i)-ABS(y[k]-j),0)!=h[k]) break;
      }
      if(k==n){
	printf("%d %d %d\n",i,j,height);
	return;
      }
    }
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
from itertools import combinations_with_replacement

N, M, Q = list(map(int, input().split()))
num_list = [list(map(int, input().split())) for _ in range(Q)]

m_range = list(range(1, M+1))
max_point = 0
for array in combinations_with_replacement(m_range, N):
    point = 0
    for (a, b, c, d) in num_list:
        if array[b-1] - array[a-1] == c:
            point += d
    max_point = max(max_point, point)
print(max_point)

Measured memory_bytes: 9052
import java.util.Scanner; 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a >12){
      System.out.println(b);
    }else if(a>5){
      System.out.println(b/2);
    }else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;


void solve()
{
    cin>>n;
    cout<<((n==0)?1:0);
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

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

using namespace std;

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

#define ll long long
typedef complex<double> P;


int main() {
  int n;
  ll k;
  ll a[100001] = {};

  cin >> n >> k;
  for (int i = 0; i < n ; i++) {
    int b, c;
    cin >> b >> c;
    a[b] += c;
  }

  for (int i = 0; i < 100001; i++) {
    k -= a[i];
    if(k <= 0) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
  int a,b,c;
cin>>a>>b>>c;
cout<<max({a,b,c})*9+a+b+c<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int a,b;
  cin >> a >> b;
  int N;
  cin >> N;
  bool can = true;
  for(int i=0; i<N; i++){
    int s,f;
    cin >> s >> f;
    if(!(f<=a || b<=s)) can = false;
  }
  if(can){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3104
from collections import defaultdict
N, M = map(int, input().split())
l = []
for i in range(M):
  p, y = map(int, input().split())
  l.append((y, p, i))

l.sort()
d = defaultdict(int)

c = []
for y, p, i in l:
  d[p] += 1
  c.append((i, str(p).zfill(6) + str(d[p]).zfill(6)))
  
c.sort()
for i, x in c:
  print(x)

Measured memory_bytes: 42020
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
b=[x for x in a if x>0]
c=[x for x in a if x<=0]
if len(b)==0:
    if len(c)%2==0:
        print(sum(c)*-1)
    else:
        print(sum(c[:-1])*-1+c[-1])
elif len(c)%2==0:
    s=sum(b)
    s-=sum(c)
    print(s)
else:
    c.append(b.pop(0))
    s=sum(b)
    s-=sum(c[:-2])
    if c[-1] > c[-2]*-1:
        s+=c[-1]
        s+=c[-2]
        print(s)
    else:
        s-=c[-1]
        s-=c[-2]
        print(s)


Measured memory_bytes: 14496
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

vector<int> factors(int n){
    vector<int> ret;
    for(int i = 1; i*i <= n; i ++) if(n % i == 0) ret.push_back(i), ret.push_back(n/i);
    return ret;
}

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    
    ll m = 1e10, s = 0, t = 0;
    For(i, n){
        if(a[i] < 0) s ++;
        if(abs(a[i]) < m) m = abs(a[i]);
        t += abs(a[i]);
    }
    Cout((s % 2) ? t-2*m : t);
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi d(n);
    cin >> d;

    if(d.size() % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(d));
    int mid = d.size() / 2;

    cout << d[mid] - d[mid - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using namespace std;
ll du(ll a, ll b) {
	return (a + b - 1) / b;
}
ll dd(ll a, ll b) {
	return a / b;
}
const int N = 1e6;
int n;
ll a[N];



int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	ll l = 2, r = 2;
	for (int i = n - 1; i >= 0; --i) {
		ll A = a[i];
		l = A * du(l, A);
		r = A * dd(r, A) + A - 1;
	}
	if (l > r) {
		cout << -1;
	} else {
		cout << l << " " << r;
	}
	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; cin >> a;
    ll b; cin >> b;
    if ((a<10)&& (b<10)){
        cout << a*b << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> dp;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

int main()
{
    IOS;
    ll n;
    cin>>n;
    ll ans=0;
    repf(i,1,n+1)
    {
        if(i%15==0 || i%5==0 || i%3==0) continue;
        else ans+=i;
    }
    cout<<ans<<endl;
}     


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int h,a;
    std::cin >> h>>a;
    std::cout << ceil(double(h)/a) << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>
#define NIL NULL
#define TREE_VALUE INT_MAX

typedef struct Node* NodePointer;
typedef NodePointer Tree;

typedef struct Node {
  int key;
  NodePointer p, left, right;
}
  Node;

NodePointer makeNode(int key) {
  NodePointer node = (NodePointer)malloc(sizeof(Node));
  node->key = key;
  node->p = node->left = node->right = NIL;
  return node;
}

void treeInsert(Tree tree, NodePointer z) {
  NodePointer yi = NIL;
  NodePointer xy = tree->left;
  while(xy != NIL) {
    yi = xy;
    if(z->key < xy->key) {
      xy = xy->left;
    } else {
      xy = xy->right;
    }
  }

  z->p = yi;
  if(yi == NIL) {
    tree->left = z; // if T is empty
  } else if(z->key < yi->key) {
    yi->left = z;
  } else {
    yi->right = z;
  }
}
void printInorder(NodePointer node) {
  if(node->left  != NIL) printInorder(node->left);
  if(node->key != TREE_VALUE) printf(" %d", node->key);
  if(node->right != NIL) printInorder(node->right);
}

void printPreorder(NodePointer node) {
  if(node->key != TREE_VALUE) printf(" %d", node->key);
  if(node->left  != NIL) printPreorder(node->left);
  if(node->right != NIL) printPreorder(node->right);
}

NodePointer find(NodePointer node, int key) {
  if(node == NIL) return NIL;
  if(node->key == key) return node;
  else if(key < node->key)
    return find(node->left, key);
  else
    return find(node->right, key);
}

NodePointer treeMinimum(NodePointer x) {
  while(x->left != NIL) {
    x = x->left;
  }
  return x;
}

NodePointer treeSuccessor(NodePointer x) {
  NodePointer y;
  if(x->right != NIL)
    return treeMinimum(x->right);
  y = x->p;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->p;
  }
  return y;
}void treeDelete(Tree T, NodePointer z) {
  NodePointer x, y;

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->p = y->p;

  if(y->p == NIL)
    T->left = x;
  else if(y == y->p->left)
    y->p->left = x;
  else
    y->p->right = x;

  if(y != z)
    z->key = y->key;

}
int main() {
  int ka, key;
  char str[10];
  Tree tree;

  // initialize tree
  tree = makeNode(TREE_VALUE);

  scanf("%d", &ka);
  while(ka--) {
    scanf("%s", str);
    if(str[0] == 'i') {
      scanf("%d", &key);
      treeInsert(tree, makeNode(key));
    } else if(str[0] == 'p') {
      printInorder(tree);
      printf("\n");
      printPreorder(tree);
      printf("\n");
    } else if(str[0] == 'f') {
      scanf("%d", &key);
      printf(find(tree,key)?"yes\n":"no\n");
    } else {
      scanf("%d", &key);
      treeDelete(tree, find(tree,key));
    }
  }
  return 0;
}



Measured memory_bytes: 20476
#include <bits/stdc++.h>
#define MAX ((int)(1e6 + 5))
using namespace std;
typedef long long ll;
///sieve of eratosthenes
int status[(MAX/32)+2];  /// mx = maximum prime
vector < int > prime;
bool Check(int n,int pos){
    return (bool)(n & (1<<pos));
}
int Set(int n,int pos){
    return (n | (1<<pos));
}
void sieve(int n){
     for(int i = 3; i*i <= n; i += 2){
		 if( Check(status[i>>5],i&31)==0){
	 		 for(int j = i*i; j <= n; j += (i<<1) ){
				 status[j>>5]=Set(status[j>>5],j & 31);
	 		 }
		 }
	 }
	 prime.push_back(2);
	 for(int i=3;i<=n;i+=2) if( Check(status[i>>5],i&31)==0) prime.push_back(i);
}


int main()
{
   sieve(MAX-2);
   ll n , p, ans = 1, c = 0;
   cin>>n>>p;
   for(int a:prime){
      c = 0;
      while(p%a==0){
         c++;
         p /= a;
      }
      while(c>=n){
         ans *= a;
         c -= n;
      }
   }

   if(n==1) ans *= p;
   cout<<ans<<endl;
}


Measured memory_bytes: 1020
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            if (v % 2 == 1) {
                System.out.println("first");
                return;
            }
        }
        System.out.println("second");
    }
}

Measured memory_bytes: 60052
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
const long long N=1000000007;
long long d;
long long fx(long long a)
{
    long long c=1,e=1;
    while(c<=a)
    {
        e=(e*c)%N;
        c++;
        if(c==a)d=e;
    }
    //cout<<e<<endl;
    return e;
}
int main()
{
    long long n,m;
    cin>>n>>m;
    if(n<m){long long x=n;n=m;m=x;}
    if(n>m+1){cout<<0;return 0;}
        long long b=fx(n);
    if(n==m)
    {
        cout<<b%N*b%N*2%N;
    }
    else
    {
        //cout<<b<<d<<endl;
        cout<<b%N*d%N;
    }
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut g = vec![vec![]; n];
    for _ in 0..n - 1 {
        input! { u: Usize1, v: Usize1 }
        g[u].push(v);
        g[v].push(u);
    }
    let mut ans = vec![0; n];
    let mut lis = vec![a[0]];
    fn f(
        s: usize,
        p: usize,
        n: usize,
        a: &Vec<u64>,
        g: &Vec<Vec<usize>>,
        ans: &mut Vec<usize>,
        lis: &mut Vec<u64>,
    ) {
        ans[s] = lis.len();
        for &t in g[s].iter() {
            if t == p {
                continue;
            }
            let i = lis.lower_bound(&a[t]);
            if i < lis.len() {
                let prev = lis[i];
                lis[i] = a[t];
                f(t, s, n, a, g, ans, lis);
                lis[i] = prev;
            } else {
                lis.push(a[t]);
                f(t, s, n, a, g, ans, lis);
                lis.pop();
            }
        }
    };
    f(0, n, n, &a, &g, &mut ans, &mut lis);
    for &x in ans.iter() {
        println!("{}", x);
    }
}

use std::cmp::Ordering;
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
    fn partition_point<F>(&self, f: F) -> usize
    where
        F: FnMut(&T) -> bool;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        self.partition_point(|y| match y.cmp(x) {
            Ordering::Less => true,
            Ordering::Equal | Ordering::Greater => false,
        })
    }
    fn upper_bound(&self, x: &T) -> usize {
        self.partition_point(|y| match y.cmp(x) {
            Ordering::Less | Ordering::Equal => true,
            Ordering::Greater => false,
        })
    }
    fn partition_point<F>(&self, mut f: F) -> usize
    where
        F: FnMut(&T) -> bool,
    {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            if f(&self[mid]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        low
    }
}


Measured memory_bytes: 36456
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')
#

def main():
    N = ii()
    S = input()
    for s in S:
        p = ord(s) - ord('A')
        p += N
        p %= 26
        print(chr(p+ord('A')), end='')

main()


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

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 100010
#define MOD 1000000007


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, k;
    cin >> a >> b >> k;
    int l = min(a, k);
    a -= l;
    k -= l;
    b -= min(b, k);
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cassert>

struct Point{ int x, y; };

Point set_p(int a, int b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ int vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

int cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

bool outlow(const Point &p, const Point &q){
	if(p.y != q.y){ return p.y < q.y; }
	return p.x < q.x;
}

bool is_convex(const Point &P0, const Point &P1, const Point &P2)
{
	Vector V1 = set_v(P0, P1), V2 = set_v(P1, P2);
	if(cross(V1, V2) < 0) return false;
	return true;
}

int main()
{
    int i, n;
    int *X, *Y;
    scanf("%d", &n);
    assert(n >= 3);

    X = new int [n];
    Y = new int [n];
    for(i = 0; i < n; i++){
        scanf("%d %d", &X[i], &Y[i]);
    }
    Point *Plg;
    Plg = new Point [n];
    for(i = 0; i < n; i++){
        Plg[i] = set_p(X[i], Y[i]);
    }

    sort(Plg, Plg + n, outlow);

    int *cc;
    cc = new int [n + 1];
    cc[0] = 0; cc[1] = 1;
    int size = 2;

    for(i = 2; i < n; i++){
        while(size >= 2){
            assert(cc[size - 2] >= 0 && cc[size - 1] >= 0);
            if(is_convex(Plg[cc[size - 2]], Plg[cc[size - 1]], Plg[i])) break;
            size--;
        };
        cc[size] = i; size++;
    }

    cc[size] = n - 2; size++;

    for(i = n - 3; i >= 0; i--){
        while(size >= 2){
            assert(cc[size - 2] >= 0 && cc[size - 1] >= 0);
            if(is_convex(Plg[cc[size - 2]], Plg[cc[size - 1]], Plg[i])) break;
            size--;
        };
        cc[size] = i; size++;
    }

    printf("%d\n", size - 1);
    for(i = 0; i < size - 1; i++){
        printf("%d %d\n", Plg[cc[i]].x, Plg[cc[i]].y);
    }

    return 0;
}

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

 using namespace std;

 int main() {
   long long A, B, K;
   cin >> A >> B >> K;

   if (K > A + B) cout << "0 0" << endl;
   else if (A < K) cout << "0 " << A + B - K << endl;
   else cout << A - K << " " << B << endl;

}


Measured memory_bytes: 256