akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

string vowel = "aiueo";

string generate(string s, int k) {
    string ret = "";
    bool takechar = true;
    rep(i,0,s.length()) {
        if(takechar) ret += s[i];
        if(vowel.find(s[i]) != string::npos) takechar = true;
        else takechar = false;
    }
    if(ret.length() < k) return ret;
    else return ret.substr(0,k);
}

signed main() {
    int n;
    while(cin >> n, n) {
        vector<string> vs(n);
        int ma = 0;
        rep(i,0,n) {
            cin >> vs[i];
            ma = max((int)vs[i].length(), ma);
        }

        bool ok = false;
        repq(i,1,ma) {
            set<string> st;
            rep(j,0,n) {
                string S = generate(vs[j], i);
                st.insert(S);
            }
            if(st.size() == n) {
                cout << i << endl;
                ok = true;
                break;
            }
        }
        if(!ok) cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int dp[n]={0};
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;++i)
  {
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout<<dp[n-1];
  return 0;
}  

Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

	int ans = 0;
	FOR(i, 1, a+1) {
		if (i == a && a > b) {
			break;
		}
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 110000
using namespace std;
inline char gc(){
    static char now[1<<16],*T,*S;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
inline int read(){
    int x=0;char ch=gc();
    while (ch<'0'||ch>'9') ch=gc();
    while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
    return x;
}
struct node{
    int y,next;
}data[N<<1];
struct node1{
    int dep,id;
}vect[N];
int h[N],fa[N],n,in[N],a[N],num;
void dfs(int x){
    for (int i=h[x];i;i=data[i].next){
        int y=data[i].y;if (fa[x]==y) continue;fa[y]=x;
        vect[y].dep=vect[x].dep+1;vect[y].id=y;
        if (in[y]==1) vect[y].dep=0;dfs(y);
    }
}
inline bool cmp(node1 a,node1 b){return a.dep>b.dep;}
int main(){
    n=read();
    for (int i=1;i<=n;++i) a[i]=read();
    if (n==2){if (a[1]==a[2]) printf("YES");else printf("NO");return 0;}
    for (int i=1;i<n;++i){
        int x=read(),y=read();
        data[++num].y=y;data[num].next=h[x];h[x]=num;in[y]++;
        data[++num].y=x;data[num].next=h[y];h[y]=num;in[x]++;
    }int root=1;while (in[root]==1) ++root;
    vect[root].dep=1;vect[root].id=root;dfs(root);
    sort(vect+1,vect+n+1,cmp);int op=1;
    while (vect[op].dep!=0){
        int x=vect[op++].id;long long ans1=0;int max1=0,child=0,childn=0;
        for (int i=h[x];i;i=data[i].next){
            int y=data[i].y;if (fa[x]==y) continue;
            ans1+=a[y];max1=max(max1,a[y]);child++;
        }if (a[x]>ans1){printf("NO");return 0;}
        if (child==1) if (ans1!=a[x]){printf("NO");return 0;}
        long long rest=ans1-max1;
        if (rest>=max1){
            if (ans1-a[x]>(ans1>>1)){printf("NO");return 0;}else a[x]-=ans1-a[x];
        }else{
            if (ans1-a[x]>rest){printf("NO");return 0;}else a[x]-=ans1-a[x];
        }
    }
    if (a[root]==0) printf("YES");else printf("NO");
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}
double mini=0.00001;
int main(){
    double n;cin>>n;
    ll nn;
    for(ll i=0;i<=100;i++){
        if(fabs(i-n)<mini){
            nn=i;
        }
    }
    double a;
    a=(nn/2+nn%2)/n;
    cout<<a<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, m, i, j, A[100][100], b[100], c[100] = {0};

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			c[i] += A[i][j] * b[j];
		}
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int stoi(string s){
	int res=0;
	for(int i=s.size()-1;i>=0;i--){
		res+=(int)(s[i]-'0')*pow(10,s.size()-1-i);
	}
	return res;
}

int main(){
	int n;
	cin>>n;
	int dt[n];
	string s[n],alt;
	pair<int,string> p[n];
	priority_queue<int,vector<int>,greater<int> > que;
	rep(i,n){
		cin>>s[i];
		p[i]=pair<int,string>(stoi(s[i]),s[i]);
	}
	sort(p,p+n);
	rep(i,min(n,100)){
		rep(j,min(n,100)){
			if(i==j)continue;
			alt=p[i].second+""+p[j].second;
			que.push(stoi(alt));
		}
	}
	rep(i,2)que.pop();
	cout<<que.top()<<endl;
	return 0;
}

Measured memory_bytes: 1960
#include<cstdio>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

#define EPS (1e-9)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define REP(i,a) for(int i=0;i<a;i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;

const double PI = acos(-1);

P unit(P p){return p / abs(p);}
pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}
double dot(P x,P y){return real(conj(x)*y);}
double cross(P x,P y){return imag(conj(x)*y);}

P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

double arg(double a,double b,double c){return acos( (b*b+c*c-a*a)/(2*b*c) );}

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;
  if (cross(b,c)<-EPS) return -1;
  if (dot(b, c)<-EPS) return 2;
  if (abs(b)<abs(c)) return -2;
  return 0;
}

bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

int cpr(C a,C b){
  double d = abs(a.fs-b.fs);
  if(a.sc+b.sc + EPS < d)return -1;
  if(b.sc+d + EPS < a.sc)return 1;
  if(a.sc+d + EPS < b.sc)return 2;
  if(abs(a.sc+b.sc - d) < EPS)return -3;
  if(abs(b.sc+d - a.sc) < EPS)return 3;
  if(abs(a.sc+d - b.sc) < EPS)return 4;
  return 0;
}

vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  int pos = cpr(a,b);
  if(pos==0){
    double s = arg(b.sc,abs(b.fs-a.fs),a.sc);
    P x = a.sc * unit(b.fs - a.fs);
    v.pb(a.fs + rotate(x,s));
    v.pb(a.fs + rotate(x,-s));
  }else if(abs(pos) == 3){
    v.pb(a.fs + a.sc * unit(b.fs-a.fs));
  }else if(pos == 4){
    v.pb(a.fs + a.sc * unit(b.fs-a.fs));
  }
  return v;
}

int main(){
  int n,pn;
  double d[200][200];
  C c[100];
  L l[100],tmp;
  P p[200];
  vector<P> v;

  while(scanf("%d",&n),n){
      REP(i,n)scanf("%lf%lf%lf",&c[i].fs.real(),&c[i].fs.imag(),&c[i].sc);

    p[0] = c[0].fs;
    pn = 1;
    for(int i=1;i<n;i++){
      v = cp_cir_to_cir(c[i-1],c[i]);
      p[pn] = v[0]; p[pn+1] = v[1];
      l[i-1] = L(v[0],v[1]);
      pn += 2;
    }
    p[pn] = c[n-1].fs;
    pn++;
    
    for(int i=0;i<pn;i++)
      for(int j=0;j<pn;j++)d[i][j] = 1e6;

    for(int i=1;i<pn;i++){
      tmp = L(p[0],p[i]);
      bool f = true;
      for(int k=0;k<(i-1)/2;k++){
	f &= is_cp(tmp,l[k]);
	if(!f)break;
      }
      if(f)d[0][i] = abs(p[0]-p[i]);
      else d[0][i] = 1e6;
    }
    
    for(int i=1;i<pn-1;i++){
      for(int j=i+1;j<pn-1;j++){
	if(i&1 && j==i+1)continue;
	tmp = L(p[i],p[j]);
	bool f = true;
	for(int k=(i+1)/2;k<(j-1)/2;k++){
	  f &= is_cp(tmp,l[k]);
	  if(!f)break;
	}
	if(f)d[i][j] = abs(p[i]-p[j]);
	else d[i][j] = 1e6;
      }
    }

    for(int i=1;i<pn-1;i++){
      tmp = L(p[i],p[pn-1]);
      bool f = true;
      for(int k=(i+1)/2;k<n-1;k++){
	f &= is_cp(tmp,l[k]);
	if(!f)break;
      }
      if(f)d[i][pn-1] = abs(p[i]-p[pn-1]);
      else d[i][pn-1] = 1e6;
    }

    REP(k,pn)REP(i,pn)REP(j,pn)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    printf("%lf\n",d[0][pn-1]);
  }
}

Measured memory_bytes: 1212
#include <iostream>

using namespace std;


int main(){
    
    int n, m, l;
    int a[100][100], b[100][100];
    long long c[100][100]={0L};

    cin >> n >> m >> l;

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for(int j=0; j<m; j++){
        for(int s=0; s<l; s++){
            cin >> b[j][s];
        }
    }

    for(int i=0; i<n; i++){
        for(int k=0; k<l; k++){
            for(int j=0; j<m; j++){
                c[i][k]+=a[i][j]*b[j][k];
            }
        }
    }

    for(int row=0; row<n; row++){
        for(int col=0; col<l; col++){
            cout << c[row][col];
            if(col<l-1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}




Measured memory_bytes: 3256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

ans = 0
for i in S:
  cnt1 = S.count(i)
  cnt2 = T.count(i)
  ans = max(cnt1-cnt2,ans)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int x, a, b;
    cin >> x >> a >> b;
    
    cout << (x-a) % b << endl;

    return 0;
    

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        ll x; cin >> x;
        sum += x;
    }
    ll avg = sum / n;
    cout << avg << endl;
    return 0;
}




Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll const mod = 1e9+7;
ll const N = 50;
ll const inf = 2e16;
#define UNASSIGNED -1
ll n0,k0;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d,e,f,x,n,m,p,k,t,q;
    t=1;
    //cin>>t;
    //string s1,s2,s3;
    //simpleprime(sqrt(1000000000)+1);
	for(ll t0=0;t0<t;t0++)
    {
        cin>>n>>k;
        n0=n;
        k0=k;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        vector<bool> dp(k+1);
        for(int i=0;i<=k;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(i-arr[j]>=0&&!dp[i-arr[j]])
                {
                dp[i]=true;
                }
            }
        }
        if(dp[k]) 
        cout<<"First\n";
        else 
        cout<<"Second\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    priority_queue<ll, vector<ll>, greater<ll>> low_pq;
    priority_queue<ll> high_pq;
    vector<ll> a(3 * n),lef(2 * n),rig(2 * n);
    ll left = 0, right = 0;
    REP(i, 3 * n) scanf("%d", &a[i]);
    REP(i, 2 * n) {
        if (low_pq.size() == n) {
            if (low_pq.top() < a[i]) {
                left -= low_pq.top(); low_pq.pop();
                low_pq.push(a[i]);
                left += a[i];
            }
        }
        else {
            low_pq.push(a[i]);
            left += a[i];
        }
        lef[i] = left;
    }
    REP(j, 2 * n) {
        ll i = 3 * n - 1 - j;
        if (high_pq.size() == n) {
            if (high_pq.top() > a[i]) {
                right -= high_pq.top(); high_pq.pop();
                high_pq.push(a[i]);
                right += a[i];
            }
        }
        else {
            high_pq.push(a[i]);
            right += a[i];
        }
        rig[j] = right;
    }
    ll ans = lef[n - 1] - rig[2 * n - 1];
    REP(i, n + 1) {
        ans = max(ans, lef[i + n - 1] - rig[2 * n - 1 - i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8052
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        double total = 0;

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            total += arr[i];
        }

        int avg = (int) Math.round(total / n);
        int totalStamina = 0;
        for (int i = 0; i < n; i++) {
            totalStamina += Math.pow(Math.abs(avg - arr[i]), 2);
        }
        System.out.println(totalStamina);
    }
}

Measured memory_bytes: 22612
while 1:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


Measured memory_bytes: 5592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        long sum = 0;
        long half = 0;
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextLong();
            sum += A[i];
            B[i] = sum;
        }
        half = sum / 2;

        int i =0;
        int j = N - 1;
        long left = 0;
        long right = 0;
        while( i <= j) {
            if(left < right) {
                left += A[i];
                i++;
            }else {
                right += A[j];
                j--;
            }
        }
        long ans = Math.abs(left - right);

        System.out.println(ans);
    }

}

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

int main(){
  vector<int> T;
  int N,C,K,a;
  cin >> N >> C >> K;
  for (int i=0;i<N;i++){
    cin >> a;
    T.push_back(a);
  }
  sort(T.begin(), T.end());
  a=0;
  int bus=0;
  for(int i=1;i<N;i++){
    if(T[a]+K<T[i]||i-a==C){
      a=i;
      bus++;
    }
  }
  bus++;
  cout << bus << endl;
}



Measured memory_bytes: 892
n=int(input())  
h=list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(1,n):
  if h[i-1]>=h[i]:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
  ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 14252
import math

def get_distance(x2, y2):
  d = math.sqrt(x2 ** 2 + y2 ** 2)
  return d

N,D=(int(x) for x in input().split())
sum=0
for i in range(N):
  x2,y2=(int(x) for x in input().split())
  d = get_distance(x2, y2)
  if d <= D:
    sum+=1
print(sum)

Measured memory_bytes: 9188
<?php
    list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
    $a = str_split($a);
    $b = str_split($b);
    $c = str_split($c);
    $ans = $a[0].$b[0].$c[0];
    echo strtoupper($ans);
?>

Measured memory_bytes: 4604
import java.util.*;
import java.lang.*;

public class Main {
    
    static int n;
    static int[] h;

    
    public static void main (String args[]) {
        int ans = 0;

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        h = new int[n];
        int[] now = new int[n];
        boolean end = false;
        
        Arrays.fill(now, 0);
        
        int max = 0;
        
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        
        while(true) {
            int l = n;
            int r = 0;
            for (int i = 0; i < n; i++) {
                if (now[i] != h[i]) {
                    if (i < l) { l = i; }
                    if (i > r) { r = i; }
                } else {
                    if ((l == 0 && r == 0) || r != 0) {
                        break;
                    }
                }
                if (i == n - 1 && l == n && r == 0) { end = true; }
            }
            if (end) { break; }
            for (int i = l; i <= r; i++) {
                now[i] ++;
            }
            ans ++;
        }


        System.out.println(ans);
    }
    
    

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
	ll n,x;
	scanf("%lld%lld",&n,&x);
	ll ans=n;
	ll a=x,b=n-x;
	while(a && b){
		if(a>b) swap(a,b);
		ans+=b/a*a*2;
		b=b%a;
		if(b==0) ans-=a;
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   string s;
   cin >> s;
   map<char, int > mp;

   for (char c : s) {
      mp[c]++;
   }

   for (auto x : mp) {
      if (x.second&1) {
         puts("No");
         return 0;
      }
   }
   puts("Yes");

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a, b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    int W, H ,N;

    cin >> W >> H >> N;

    int x[N], y[N] ,a[N];

    vector<vector<int>> m(H,vector<int>(W,1));

    rep(i,0,N) {
        cin >>x[i] >> y[i] >> a[i];
        
        if (a[i]==1) {
            rep(w,0,x[i]) {
                rep(h,0,H){
                    m[h][w]=0;
                }
            }
        }
        if (a[i]==2) {
            rep(w,x[i],W) {
                rep(h,0,H){
                    m[h][w]=0;
                }
            }
        }
        if (a[i]==3) {
            rep(w,0,W) {
                rep(h,0,y[i]){
                    m[h][w]=0;
                }
            }
        }
        if (a[i]==4) {
            rep(w,0,W) {
                rep(h,y[i],H){
                    m[h][w]=0;
                }
            }
        }
    }
    int ans = 0;
    rep(w,0,W) {
        rep(h,0,H){
            //cout << m[h][w] << " ";
            ans += m[h][w];
        }
        //cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split("");
	//文字列から10進数に変換するときはparseIntを使います
  	var k = input[0].split(" ")[1] - 1;
	tmp[k] = (tmp[k] === "A") ? "a" : (tmp[k] === "B") ? "b" : "c";
	//出力
	console.log(tmp.join(""));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/


signed main(){
	string s;
	getline(cin,s);

	int a[1010];
	int top=0;
	int tmp=0;

	rep(i,s.size()){
		if('0'<=s[i]&&s[i]<='9'){
			tmp=tmp*10+(s[i]-'0');
		}else if(s[i]=='+'){
			int x=a[top];
			int y=a[top-1];
			a[top-1]=x+y;
			top--;
		}else if(s[i]=='*'){
			int x=a[top];
			int y=a[top-1];
			a[top-1]=x*y;
			top--;
		}else if(s[i]=='-'){
			int x=a[top];
			int y=a[top-1];
			a[top-1]=y-x;
			top--;
		}else if(s[i]==' '){
			if(tmp>0){
				a[++top]=tmp;
			}
			tmp=0;
		}
	}

	int ans=a[top];
	cout<<ans<<endl;


	return 0;
}




Measured memory_bytes: 3208
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  unordered_set<long> st;
  long a, b, c;
  cin >> a >> b >> c;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  cout << st.size() << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 384
n,k = map(int,input().split())
a_L = map(int,input().split())

import collections

count = collections.Counter(a_L)
c = count.most_common()

if len(set(a_L)) >= k:
    print(0)
    exit()

ans = 0
tmp = 0

for _,v in c:
    if tmp >= k:
        ans += v
    tmp += 1


print(ans)

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

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

  string alpha = "abcdefghijklmnopqrstuvwxyz";
  rep(i, S.length()) {
    alpha[S[i] - 'a'] = '_';
  }

  rep(i, alpha.length()) {
    if (alpha[i] != '_') {
      cout << alpha[i] << endl;
      return 0;
    }
  }

  puts("None");
}

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

using namespace std;

int main()
{
  string s; cin >> s;
  int len = s.length();
  int a[1000005]; int b[1000005]; a[0] = b[0] = 0;
  for (int i = 1; i <= len; ++i) a[i] = b[i] = s[i-1]-'0';
  
  int ans = 0;
  for (int i = len; i > 0; --i) {
    if (b[i] > 5 or (b[i] == 5 and b[i-1] >= 5)) {b[i] = 0; ++b[i-1];}
    ans += b[i];
  }
  ans += b[0];
  
  int c[1000005];
  for (int i = len; i > 0; --i) {
    c[i] = b[i] - a[i];
    if (c[i] < 0) {c[i] += 10; --b[i-1];}
    ans += c[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
vector<int> a;
char s[1000000] = {0};

bool b(int k,int c){
    //cout << c << k <<endl;
    if(97 == c) return false;
    else if(123 - c <= k){ 
        return true;}
    else return false;
}

void mainmain(){
    cin >> s;
    cin >> n;
    int i = 0;
    while(s[i] != 0){
        if (b(n,s[i])){
            n -= 123 - s[i];
            s[i] = 97;
        }
        i++;
    }
    s[i-1] =(((s[i-1] - 96) + n)%26)+96;
    if (s[i-1] == 96)s[i-1] = 122;
    int c = s[0];
    cout << s << endl;
}

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

Measured memory_bytes: 512
n, m = gets.split.map &:to_i

a = (1..n).map{gets.to_i}
b = (1..m).map{gets.to_i}

vote = Hash.new(0)
b.each{|budget|
    vote[a.index{|cost| cost <= budget}] += 1
}
p vote.max_by(&:last)[0] + 1

Measured memory_bytes: 6104
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main(void) {
	double a,b,c;
	scanf("%lf%lf%lf",&a,&b,&c);
	printf("%lf\n%lf\n%lf\n",a*b*sin(c*PI/180)/2.0,a+b+hypot(b*sin(c*PI/180),a-b*cos(c*PI/180)),b*sin(c*PI/180));
	return 0;
}


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

#define maxn 500010
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define inf 1e10
#define ll long long
int ans,a[maxn],b[maxn];
int read() {
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main() {
	int n=rd;
	if(n<=111)cout<<"111"<<endl;
	if(n>=112&&n<=222)cout<<"222"<<endl;
	if(n>=223&&n<=333)cout<<"333"<<endl;
	if(n>=334&&n<=444)cout<<"444"<<endl;
	if(n>=445&&n<=555)cout<<"555"<<endl;
	if(n>=556&&n<=666)cout<<"666"<<endl;
	if(n>=667&&n<=777)cout<<"777"<<endl;
	if(n>=778&&n<=888)cout<<"888"<<endl;
	if(n>=889)cout<<"999"<<endl;
	return 0;
}

Measured memory_bytes: 256
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            Dictionary<string, int> ans = new Dictionary<string, int>()
            {
                { "AC",0},
                { "WA",0},
                { "TLE",0},
                { "RE",0}
            };

            for(int i = 0;i< input; i++)
            {
                string jedge = Console.ReadLine();
                ans[jedge]++;
            }

            foreach(KeyValuePair<string,int> item in ans)
            {
                Console.WriteLine("{0} x {1}", item.Key, item.Value) ;
            }
        }
    }
}


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

int main(void)
{
    int K, S;
    cin >> K >> S;
    ll count = 0;
    for (int x = 0; x <= K; x++)
    {
        for (int y = x; y <= K; y++)
        {
            int z = (S - x - y);
            if(z < y) continue;
            if(z > K) continue;

            if(x != y && y != z){
                count += 6;
            } else if(x == y && y == z){
                count += 1;
            } else {
                count += 3;
            }
            
        }
    }
    
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int x[15][1005];
int h,w,z;
int shuyu[15];
int sum[15];
int main(){
	cin>>h>>w>>z;
	int ans=h+w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			char tmp;
			cin>>tmp;
			x[i][j]=tmp-'0';
		}
	}
	for(int k=0;k<(1<<(h-1));k++){
		memset(shuyu,0,sizeof(shuyu));
		memset(sum,0,sizeof(sum));
		int cnt=0,t=0;
		for(int i=0;i<h;i++){
			shuyu[i+1]=t;
			if((k>>i)&1)
			t++;
		}
		cnt=t;
		for(int i=1;i<=w;i++)
		{	
			bool can=1;
			if(cnt>ans)
			break;
			for(int j=1;j<=h;j++)
			{
				sum[shuyu[j]]+=x[j][i];
			}
			for(int j=1;j<=h;j++){
				if(sum[shuyu[j]]>z)
				{
				can=0;
				break;
				}
			}
			if(!can){
				cnt++;
				memset(sum,0,sizeof(sum));
				for(int j=1;j<=h;j++)
			{
				sum[shuyu[j]]+=x[j][i];
			}
			for(int j=1;j<=h;j++)
			{
				if(sum[shuyu[j]]>z)
				cnt=h+w+1;
			}
			}
		}
		ans=min(ans,cnt);
	} 
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> A(N+1);
    for(int i=0; i<M; i++){
        int a; cin >> a;
        A[a] = 1;
    }
    
    int ans1 = 0;
    int ans2 = 0;
    for(int i=0; i<X; i++)
        ans1 += A[i];
    for(int i=X+1; i<=N; i++)
        ans2 += A[i];
    
    cout << min(ans1, ans2) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define thik_thik_spat ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back

const llong MOD = 1e9 + 7;

using namespace std;

llong n, a[100001], pref[1000001], cnt, cnt1, q = 0;
llong m, nm;

int main ()
{
    cin >> n >> m >> nm;
    cout << (n - m) % nm;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

class Program {
  static void Main (string[] args) {
    int N = int.Parse(Console.ReadLine());
    string[] nums_str = Console.ReadLine().Split(' ');
    int[] nums = Array.ConvertAll(nums_str, int.Parse);
    int rem = 0;
    //int limit = (N * (N - 1)) / 2;
    for (int a = 0; a < N - 1; a++) 
    {
      for (int b = a + 1; b < N; b++) 
      {
        rem += nums[a] * nums[b];
      }
    }
    Console.WriteLine(rem);
  }
}


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

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

const int N = 2e5 + 5;
int n, k, r, s, p;
string t;
int dp[N][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;

  for (int i = 0; i < n; ++i) {
    if (t[i] == 'r') { // rock
      dp[i][1] = p;
    } else if (t[i] == 's') { // scissor
      dp[i][1] = r;
    } else { // paper
      dp[i][1] = s;
    }
  }
  for (int i = k; i < n; ++i) {
    dp[i][0] = max(dp[i - k][0], dp[i - k][1]);
    if (t[i] != t[i - k]) {
      dp[i][1] += max(dp[i - k][0], dp[i - k][1]);
    } else {
      dp[i][1] += dp[i - k][0];
    }
  }
  int res = 0;
  for (int i = n - 1; i > n - 1 - k; --i) {
    res += max(dp[i][0], dp[i][1]);
  }
  cout << res << endl;

  return 0;
}

// 1,1,1,1,1,1,1 // all win
// c       c


Measured memory_bytes: 1232
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};

function main(input) {
  const o = new I(input);

  var a = o.a();
  var b = o.a();

  var ans = 0;
  if (a > b) {
    ans += a;
    a-=1;
  } else {
    ans += b;
    b-=1;
  }
  ans += Math.max(a,b);
  console.log(ans);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,a,b) for (long long i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(long long)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-8
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n, ans, tmp;
string s;

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> s;
  REP (i, n - 1) if (s[i] == 'W') tmp++;
  ans = tmp;
  FORD (i, n - 2, 0) {
    if (s[i] == 'W') tmp--;
    if (s[i + 1] == 'E') tmp++;
    ans = min(ans, tmp);
  }
  cout << ans;
}


Measured memory_bytes: 720
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if(a >= 13) {
		cout << b << endl;
	}
	else if(a > 5) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


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

int main(){
	int n, x;
	scanf("%d", &n);
	multiset < int > g;
	for(int i = 1; i <= n * 2; i++){
		scanf("%d", &x);
		g.insert(x);
	}
	long long ans = 0;
	while(g.size()){
		int tmp = *g.begin();
		ans += tmp;
		g.erase(g.begin());
		g.erase(g.lower_bound(tmp));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define int long long
using namespace std;

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x * f;
}
const int MAXN = 1e5+100;
#define lowbit(x) (x&-x)
int n,m,x[MAXN],y[MAXN];
vector<pair<int,int> >V;
vector<int>w;
struct BIT{
    int C[(1<<20)+100];
    inline void add(int x,int d){++x; for (int i = x; i <= (1<<20); i += lowbit(i)) C[i] += d;}
    inline int query(int x){int ret = 0;if (x < 0) return 0; ++x; for (int i = x; i >= 1; i -= lowbit(i)) ret += C[i]; return ret;}
}bit;
const int Mod = 1e9 + 7;
signed main(signed argc, char *argv[]){
    n = read(), m = read();
    rep(i,0,n-1) x[i] = read();
    rep(i,0,m-1) y[i] = read();
    w.pb(0);
    rep(i,0,n-1) {
        if (x[i] < y[0] || x[i] > y[m-1]) continue;
        int X = lower_bound(y,y+m,x[i])-y;
        V.pb(make_pair(x[i] - y[X-1], -(y[X] - x[i])));
        w.pb(y[X] - x[i]);
    }
    sort(V.begin(),V.end());
    V.erase(unique(V.begin(),V.end()),V.end());
    sort(w.begin(),w.end());
    w.erase(unique(w.begin(),w.end()),w.end());
    bit.add(0,1);
    for (auto& v : V) {
        int Y = lower_bound(w.begin(),w.end(),-v.se) - w.begin();
        bit.add(Y,bit.query(Y-1) % Mod);
    }
    printf("%lld\n",bit.query((int)w.size() + 2LL) % Mod);
	return 0;
}


Measured memory_bytes: 8680
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int POW[22],dp[20][1 << 20];
int P[1 << 20];
string line;

int main(){

	POW[0] = 1;
	for(int i = 1; i < 21; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	cin >> line;

	for(int i = 0; i < POW[N]; i++){

		scanf("%d",&P[i]);
		P[i+POW[N]] = P[i];
	}

	for(int i = 0; i < 2*POW[N]; i++){

		dp[0][i] = P[i];
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k+POW[i] < 2*POW[N]; k++){

			int loc = max(dp[i][k],dp[i][k+POW[i]])-min(dp[i][k],dp[i][k+POW[i]]);

			if(line[loc-1] == '1'){

				dp[i+1][k] =  max(dp[i][k],dp[i][k+POW[i]]);

			}else{

				dp[i+1][k] = min(dp[i][k],dp[i][k+POW[i]]);
			}
		}
	}

	for(int i = 0; i < POW[N]; i++){

		printf("%d\n",dp[N][i]);
	}

	return 0;
}



Measured memory_bytes: 43476
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h1*60+m1;
    int b = h2*60+m2;
    int d = b-a;
    cout << max(0,d-k) << endl;
}


Measured memory_bytes: 3644
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val as = List.fill(n)(sc.nextLong())

  def binSearch(begin: Int, end: Int): Int = {
    def check(x: Int): Boolean = {
      as.map(a => ((a + x - 1) / x - 1).max(0)).sum <= k
    }

    if (end - begin <= 1) {
      end
    } else {
      val m = begin + (end - begin) / 2
      if (check(m)) binSearch(begin, m) else binSearch(m, end)
    }
  }

  println(binSearch(0, Int.MaxValue))
}


Measured memory_bytes: 104716
#include<cstdio>
typedef long long LL;
const int N=2003;
const int O=2*N;
int n,m,ans;
int dp[3*N][5*N];

inline LL Pow(LL x,int p) {
	if(p==0) return 1;
	if(!(p&1)) return Pow(x*x%m,p>>1);
	return x*Pow(x*x%m,p>>1)%m;
}
inline void Add(int &x,int y) {
	x+=y; if(x>=m) x-=m;
}
int main() {
	scanf("%d %d",&n,&m); n*=3;
	dp[0][O]=1;
	for(int s=0;s<=n;s++) {
		for(int D=-s/2;D<=s;D++) {
			int d=D+O;
			Add(dp[s+1][d+1],dp[s][d]);
			Add(dp[s+2][d-1],dp[s][d]*(s+1ll)%m);
			Add(dp[s+3][d],dp[s][d]*(s+1ll)%m*(s+2ll)%m);
		}
	}
	for(int i=0;i<=n;i+=3)
		Add(ans,dp[n][i+O]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 233216
#include<stdio.h>
int main()
{
int N[4];
scanf("%d %d %d %d",&N[0],&N[1],&N[2],&N[3]);
int i,j;
int tmp;
for(i=0;i<4;i++)
for(j=i;j<4;j++)
if (N[i]>N[j])
{
tmp=N[i];
N[i]=N[j];
N[j]=tmp;
}
if(1000*N[0]+100*N[1]+10*N[2]+N[3]==1479)
printf("YES");
else
printf("NO");
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int s,w;
    cin >> s >> w;
    if (w>=s)
    {
        cout << "unsafe";
    }
    else
    {
        cout << "safe";
    }
    
    
    return 0;
}


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

using namespace std;

int main(void) {
  int n;
  string s, t, ans = "";
  cin >> n >> s >> t;
  
  for (int i = 0; i < n; i++) {
    ans += s[i];
    ans += t[i];
  }

  cout << ans << endl;

  return 0;
}

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(),m=sc.nextInt(),ans=0;
		int[] a=new int[n],b=new int[n],c=new int[m],d=new int[m];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		for(int i=0;i<m;i++) {
			c[i]=sc.nextInt();
			d[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			int dis=2000000000;
			for(int j=0;j<m;j++) {
				int distance=Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
				if(distance<dis) {
					dis=Math.min(dis,distance);
					ans=j+1;
				}
			}
			System.out.println(ans);
		}
		sc.close();
	}
}

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

ll func(ll x){
    if (x%2) return ((x+1)/2) % 2;
    else return (((x+1)/2) % 2) ^ x;
}

int main(){
    ll a, b;
    cin >> a >> b;
    cout << (func(a-1)^func(b)) << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    for(int i=0; i < 26; i++){
        for(int j=0; j < 16; j++) {
            if(n==i*4+j*7){
                cout << "Yes" << endl;
                goto END;
            }
        }
    }
    cout << "No" << endl;
    END:
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    int Q;
    cin >> Q;
    using Tup = tuple<ll, ll, ll>;
    vector<Tup> va, vb, vc;
    while (Q--) {
        ll N;
        cin >> N;
        va.clear(), vb.clear(), vc.clear();
        for (ll i = 0; i < N; i++) {
            ll k, l, r;
            cin >> k >> l >> r;
            --k;
            if (k == N - 1 || l == r) {
                vc.emplace_back(k, l, r);
            }
            else if (l > r) {
                va.emplace_back(k, l, r);
            }
            else {
                vb.emplace_back(k, l, r);
            }
        }
        sort(va.begin(), va.end());
        sort(vb.begin(), vb.end(), greater<Tup>());

        ll ans = 0;
        for (auto [k, l, r] : vc) {
            ans += l;
        }

        priority_queue<Pll, vector<Pll>, greater<Pll>> pq1;
        ll cur = 0;
        for (auto [k, l, r] : va) {
            if (cur <= k) {
                ans += l;
                pq1.emplace(l - r, k);
                ++cur;
            }
            else {
                auto [val, kp] = pq1.top();
                if (val < l - r) {
                    pq1.pop();
                    ans -= val;
                    ans += l;
                    pq1.emplace(l - r, k);
                    if (cur <= kp) {
                        ans += val;
                        pq1.emplace(val, kp);
                        ++cur;
                    }
                }
                else {
                    ans += r;
                }
            }
        }

        priority_queue<Pll, vector<Pll>, greater<Pll>> pq2;
        cur = N - 1;
        for (auto [k, l, r] : vb) {
            if (cur > k) {
                ans += r;
                pq2.emplace(r - l, k);
                --cur;
            }
            else {
                auto [val, kp] = pq2.top();
                if (val < r - l) {
                    pq2.pop();
                    ans -= val;
                    ans += r;
                    pq2.emplace(r - l, k);
                    if (cur > kp) {
                        ans += val;
                        pq2.emplace(val, kp);
                        --cur;
                    }
                }
                else {
                    ans += l;
                }
            }
        }

        cout << ans << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main() {
  int N, A, B, a1, a2;
  cin >> N >> A >> B;
  
  a1 = N * A;
  a2 = B;
    
  if (a1 < a2)
    cout << a1 << endl;
  else
    cout << a2 << endl;
 
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = int(input())
for i in range(N):
   a, b, c = map(int, input().split())
   if a > b:
      a, b = b, a
   if b > c:
      b, c = c, b
   if a > b:
      a, b = b, a
   if c * c - a * a - b * b == 0:
      print("YES")
   else:
      print("NO")



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

int main(){
  int N, K;
  int ans = 0;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i < N; i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  for(int j = N - 1; j > N - K - 1; j--){
    ans = ans + l.at(j);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  int ans = 0;
  while (N != 0) {
    N = N / K;
    ans++;
  }
  cout << ans << endl;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=2019;

//status unsolved

int main(){
    string s;
    cin>>s;
    int n=s.size();
    long long sum[n+1];
    sum[n]=0;
    long long ten=1;
    for(int i=n-1;i>-1;i--){
        sum[i]=sum[i+1]+int(s[i]-'0')*ten;
        ten*=10;
        ten%=mod;
        sum[i]%=mod;
    }

    long long cnt[2019]={};
    rep(i,n+1){
        cnt[sum[i]]++;
    }
    long long ans=0;
    rep(i,2019){
        if(cnt[i]){
            ans+=(cnt[i]*(cnt[i]-1))/2;
        }
    }
    cout<<ans<<endl;
    

    return 0;

}
/*


*/


Measured memory_bytes: 5252
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] data = Console.ReadLine().Split(' ');
        string line = "";
        for (int i = n - 1; i >= 0; i--)
        {
            line = line + data[i] + " ";
        }
        Console.WriteLine(line.Trim());
        Console.ReadLine();
    }
}

Measured memory_bytes: 13520