akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N)cin >> A[i];
	sort(ALL(A));
	//絶対二分探索するやつじゃん
	int ok = N;
	int ng = -1;
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		ll now = A[mid];
		int cnt = 0;
		for(int i=0;i<N;i++){
			if(i==mid)continue;
			if(2*now >= A[i]){
				now += A[i];
				cnt++;
			}else break;
		}
		if(cnt==N-1)ok = mid;
		else ng = mid;
	}
	cout << N - ok << endl;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())                    
route_lists = [input().split() for i in range(m)]   
new_lists = []                                      
for i in route_lists:                               
  for j in range(2):                                
    new_lists.append(i[j])                          
                                                                                      
for i in range(1, n+1, 1):                          
  print(new_lists.count(str(i)))  

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll N,D; cin >> N >> D;
	int res = 0;
	forn(i,0,N){
		ll x,y; cin >> x >> y;
		ll d = x*x+y*y;
		if(d <= D*D){
			res++;
		}
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3600
def main():
    n, k = map(int, input().split())
    arr = list(map(int, input().split()))
    L, R = 0, max(arr)
    while L+1 < R:
        P = (L+R+1)//2
        cnt = 0
        for a in arr:
            if P < a:
                if a % P == 0:
                    cnt += a//P - 1
                else:
                    cnt += a//P
        if cnt <= k:
            R = P
        else:
            L = P
    print(R)

if __name__ == "__main__":
    main()


Measured memory_bytes: 30840
/*	Author
@ Pranjal Walia
IIIT Bangalore
*/
#include<bits/stdc++.h>
using namespace std;

void fastscan(int &x){
bool neg = false;register int c;
x = 0;c = getchar();
if(c=='-'){neg = true;c = getchar();}
for(; (c>47 && c<58); c=getchar()){x = x *10 + c - 48;}
if(neg){x *= -1;}}

#define ff              				first
#define ss              				second
#define int             				long long
#define pb              				push_back
#define mp              				make_pair
#define pii             				pair<int,int>
#define vi              				vector<int>
#define mii             				map<int,int>
#define pqb             				priority_queue<int>
#define pqs             				priority_queue<int,vi,greater<int> >
#define setbits(x)      				__builtin_popcountll(x)
#define zrobits(x)      				__builtin_ctzll(x)
#define mod             				1000000007
#define inf             				1e18
#define mem(a,x,n)					memset(a,x,sizeof(a))		//initialise only 0 ans -1 with memset
#define ps(x,y)         				fixed<<setprecision(y)<<x
#define mk(arr,n,type)  				type *arr=new type[n];
#define w(x)            				int x; cin>>x; while(x--)
#define sortv(v)        				sort(v.begin() , v.end())
#define rsortv(v)       				sort(v.rbegin() , v.rend())
#define pw(b,p)         				pow(b,p) + 0.1
#define __          	   				ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b)	   					for(int i=a;i<b;i++)
#define repb(i,a,b) 	   				for(int i=a;i>=b;i--)
#define endl			   				"\n"    

#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;

#define sd(x) cin >> x;
#define sd2(x,y) cin >> x >> y;
#define sd3(x,y,z) cin >> x >> y >> z;
#define sd4(w,x,y,z) cin >> w >> x >> y >> z;

int mypow(int a, int b){	//(logn) --> faster than recursive --> binary expo
    int res = 1;            // call int x = mypow(2,5);
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
}



void CF_321_D2_A(){
    int n; sd(n);
    int a[n];
    rep(i , 0 , n)sd(a[i]);
    int c=1;
    int ans=0;

    rep(i  , 1 , n){
        if(a[i] >= a[i-1]){
            c++;
        }
        else{
            ans = max(ans,c);
            c=1;
        }
    }
    ans = max(ans , c);
    tr(ans);
}

int a[100005];


int32_t main(){
    __;	
    int n; sd(n);
    printf("%.2f" , 2*3.1415*n);
}

Measured memory_bytes: 3776
import java.util.*;

public class Main { 
    public static int compute_maxprofit(int n, int[] R){
      int max_profit = Integer.MIN_VALUE;
      int min = Integer.MAX_VALUE;
      int temp;
      for(int i = 0; i < n; i++) {
    	  temp = R[i];
    	  max_profit = Math.max(max_profit, temp - min);
    	  min = Math.min(temp,  min); 
      }
      return max_profit;
    }
 public static void main(String[] args) { 
	 Scanner in = new Scanner(System.in);
	 int lines = in.nextInt();
	 int[] values = new int[lines];
	 for(int i = 0; i < lines; i++){
	     values[i] = in.nextInt();
	 }
	 System.out.println(compute_maxprofit(lines, values));
	 in.close();
 }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> i(N+1);
  for (int j = 1; j <= M; ++j) {
    int aa, bb;
    cin >> aa >> bb;
    
    i.at(aa)++;
    i.at(bb)++;
  }
  
  for (int j = 1; j <= N; ++j) {
    cout << i.at(j) << endl;
  }
}


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


void solve(long long N, long long K, std::vector<long long> H){
    sort(H.begin(),H.end());
    long long sum = 0;
    if (K<N){
        for (int i= 0;i<N-K;i++){
            sum+= H[i];
        }
    }
    printf("%lld\n",sum);
        
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


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

using namespace std;


int main() {

	int n;
	cin >> n;

	int a, b;
	list<int> aa;
	list<int>::iterator itr=aa.end();
	list<int>::iterator olditr = itr;
	for (int i = 0; i < n; i++) {
		cin >> a  ;
		if (a == 0) {
			cin >> b;
			aa.insert(itr,b);
			itr--;
		}
		if (a == 1) {
			cin >> b;
			advance(itr, b);
		}
		if (a == 2) {
			olditr = itr;
			advance(olditr, 1);
			aa.erase(itr);
			itr = olditr;
		}
	}

	while(! aa.empty()){
		cout << aa.front() << endl;
		aa.pop_front();
	}
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> C(4, 0);
  rep(i, N) {
    string S;
    cin >> S;
    if (S == "AC") C[0]++;
    if (S == "WA") C[1]++;
    if (S == "TLE") C[2]++;
    if (S == "RE") C[3]++;
  }
  cout << "AC x " << C[0] << endl;
  cout << "WA x " << C[1] << endl;
  cout << "TLE x " << C[2] << endl;
  cout << "RE x " << C[3] << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    char a[n+1][n+1];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)   
            cin>>a[i][j];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        char temp[n+1][n+1];
        for(int j=0;j<n;j++)
        {
            for(int k=0;k<n;k++)
            {
                temp[(j+i)%n][k]=a[j][k];
            }
        }
        bool flag=true;

        for(int j=0;j<n;j++)
        {
            for(int k=0;k<n;k++)
            {
                if(temp[j][k]!=temp[k][j])
                {
                    flag=false;
                }
            }
        }
        ans+=flag*n;
    }    
    cout<<ans;

} 
    


Measured memory_bytes: 3824
from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(input())

m = int(input())
t = []
for i in range(m):
    t.append(input())

ls = Counter(s)
lt = Counter(t)

c = 0
for k in ls.keys():
    c_temp = ls[k] - lt[k]
    if c < c_temp:
        c = c_temp

print(c)


Measured memory_bytes: 3316
// Pana2020 D
// 2020.3.14 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define pc(c) putchar_unlocked(c)
void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

int a[12];
char s[12];

int N;
void pr(int id, int j, int ma) {
	int i;
	if (id == N) {
		outs(s);
		return;
	}
	for (i = 0; i <= a[id] && i <= ma; ++i) {
		s[id] = 'a'+i;
		if (i == ma) pr(id+1, 0, ma+1);
		else pr(id+1, 0, ma);
	}
}
int main()
{
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; ++i) a[i] = i;
	pr(0, 0, 1);
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int num[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};
    for(int i=0,x,y;i<n;i++){
        cin>>x>>y;
        if(x<6&&y<6&&y-x>0){
            cout<<num[x];
            for(int j=x+1;j<=y;j++)cout<<" "<<num[j];
            cout<<endl;
        }
        else if(x<6&&y<6){
            cout<<num[15-x];
            for(int j=16-x;j<16-y;j++)cout<<" "<<num[j];
            cout<<endl;
        }
        else{
            cout<<num[x];
            for(int j=x+1;num[j-1]!=y;j++){
                if(j==16)j=1;
                cout<<" "<<num[j];
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 3012
long t,A[1<<17],s[1<<17],p[1<<17];
g(u){return p[u]-u?p[u]=g(p[u]):u;}
f(j,a,b){
	if(~scanf("%d%d",&a,&b)){
		f(j-1);
		A[j]=t;
		a=g(a);b=g(b);
		if(a-b)t-=s[a]*s[b],s[p[a]=b]+=s[a];
	}
}
main(n,m){
	for(scanf("%d%d",&n,&m);n;t+=--n)s[p[n]=n]=1;
	for(f(m);m;)printf("%ld\n",A[m--]);
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    string s,t;
    cin>>n>>s>>t;

    string u;
    rep(i,n) {
        u.push_back(s[i]);
        u.push_back(t[i]);
    }
    cout<<u<<endl;

 return 0;
}

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

int main(){
    int a, b, c, t;
    cin >> a >> b >> c;
    
    if(a > b){
        t = a; a = b; b = t;
    }
    
    if(b > c){
        t = b; b = c; c = t;
    }
    
    if(a > b){
        t = a; a = b; b = t;
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     fopen     freopen("in.txt","r",stdin)
#define     fwrite    freopen("o.txt","w",stdout)
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int main()
{
    __
    int a[1111],b[1111],n,p,ans=0;
    mem(a),mem(b);
    cin>>n>>p;
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
       if(i+1==n) b[i]=p;
       else{
       if(a[i]<=p) {b[i]=a[i];
        p=p-a[i];}
       }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[i]) ans++;
        //cout<<b[i]<<" ";
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N][N - 1];
  int next[N];
  for(int i = 0; i < N; i++){
    next[i] = 0;
    for(int j = 0; j < N - 1; j++){
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  
  bool ok = true;
  int day = -1;
  vector<bool> fighter(N, false);
  while(true){
    day++;
    ok = false;
    for(int i = 0; i < N; i++){
      if(next[i] == N - 1) continue;
      
      ok = true;
      int hostile = A[i][next[i]];
      if(A[hostile][next[hostile]] == i) fighter[i] = true;
    }
    
    if(!ok) break;
    
    ok = false;
    for(int i = 0; i < N; i++){
      if(fighter[i]){
        next[i]++;
        fighter[i] = false;
        ok = true;
      }
    }
    
    if(!ok){
      day = -1;
      break;
    }
  }
  
  cout << day << endl;
  
  return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main(void)
{
	int n,l,sum;
	scanf("%d%d",&n,&l);
	sum=(2*l+n-1)*n/2;
	if(l>0)
		sum-=l;
	if(l+n-1<0)
		sum-=l+n-1;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int S ,h ,m ,s;
	scanf("%d" ,&S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = S % 60;
	printf("%d:%d:%d\n" ,h ,m ,s);
	return 0;
}

Measured memory_bytes: 1852
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){
	int N;
	scanf("%d",&N);
	int S[N];
	for(int i = 0; i < N; i++)scanf("%d",&S[i]);

	int M;
	scanf("%d",&M);

	int Q[M];
	for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
	sort(Q,Q+M);

	int left = 0,right,m,count = 0;

	for(int i = 0; i < M; i++){
		right = N-1;
		m = (left+right)/2;

		while(left <= right){
			if(S[m] == Q[i]){
				count++;
				left= m+1;
				break;
			}else if(S[m] > Q[i]){
				right = m-1;
			}else{ //S[m] < Q[i]
				left = m+1;
			}
			m = (left+right)/2;
		}
	}
	printf("%d\n",count);
}



Measured memory_bytes: 3828
/*
Ak(i,j) = Ak-1(i,x)*Adj(x,i) for all x from 1 to n

A1 = Adj;
A2 = Adj*Adj = (Adj)^2;
similarly = Ak = (Adj)^k;
solve it by using matrix exponentiation
Ans = sum of Ak for all i from 1 to n and j from 1 to n
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
vector<vector<ll>> multiply(vector<vector<ll>> a , vector<vector<ll>> b){
    ll n = a.size();
    vector<vector<ll>> res(n , vector<ll>(n , 0));
    for(ll i=0 ; i<n ; i++){
        for(ll j=0 ; j<n;  j++){
            for(ll x=0 ; x<n ; x++){
                res[i][j] = (res[i][j] + a[i][x]*b[x][j])%mod;
            }
        }
    }
return res;
}
vector<vector<ll>> power(vector<vector<ll>> mat , ll exp){
    if(exp == 1){
        return mat;
    }
    vector<vector<ll>> res = power(mat , exp/2);
    if(exp&1){
        return multiply(multiply(mat , res) , res);
    }else{
        return multiply(res , res);
    }
}
ll solve(vector<vector<ll>> &adj , ll n , ll k){
    vector<vector<ll>> ak = power(adj , k);
    ll ans = 0;
    for(ll i=0 ; i<n ; i++){
        for(ll j=0 ; j<n ; j++){
            ans = (ans + ak[i][j])%mod;
        }
    }
    return ans;
}
int main() {
    ll n;
    ll k;
    cin>>n>>k;
    vector<vector<ll>> adj(n , vector<ll>(n));
    for(ll i=0 ; i<n ; i++){
        for(ll j=0 ; j<n ; j++){
            cin>>adj[i][j];
        }
    }
    cout<<solve(adj , n , k);
}


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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	string *row;
	row = new string[H];

	//1行全部圧縮できるか
	for (int i = 0; i < H; i++) {
		cin >> row[i];
		for(int t = 0; t < W; t++) {
			if (row[i][t] != '.') break;
			if (t == W - 1) {
				i--;
				H--;
			}
		}
	}

	for(int t = 0; t < W; t++) {
		for (int i = 0; i < H; i++) {
			if(row[i][t] != '.') break;
			if (i == H - 1) {
				for (int i = 0; i < H; i++) {
					row[i].erase(row[i].begin() + t);
				}
				t--;
				W--;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		cout << row[i] << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

void solve1(int64, int64, int64);

const int MOD = 1000000007;
struct mint {
    int64 x;
    mint(const int64 x1=0) { x = x1%MOD; };

    mint& operator++(int n) { x+=1; return *this; };
    mint& operator--(int n) { x-=1; return *this; };
    mint& operator=(int64 n) { x=n%MOD; return *this; };
    mint& operator--() {x-=1; return *this; };
    mint& operator+=(const mint a) { if ( (x+=a.x) >= MOD) x-=MOD; return *this; }
    mint& operator+=(const int64 a) { if ( (x+=a) >= MOD) x-=MOD; return *this; }
    mint& operator-=(const mint a) { if ( (x+= MOD-a.x) >= MOD) x-= MOD; return *this; }
    mint& operator-=(const int64 a) { if ( (x+= MOD-a) >= MOD) x-= MOD; return *this; }
    mint& operator*=(const mint a) { (x*=a.x) %= MOD; return *this; }
    mint& operator*=(const int64 a) { (x*=a) %= MOD; return *this; }
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint& operator/=(const int64 a) { return (*this) *= mint(a).inv();}
    template <typename T> mint operator+(const T a) const { mint res(*this); return res+=a; }
    template <typename T> mint operator-(const T a) const { mint res(*this); return res-=a; }
    template <typename T> mint operator*(const T a) const { mint res(*this); return res*=a; }
    template <typename T> mint operator/(const T a) const { mint res(*this); return res/=a; }
    mint inv() const { return pow(MOD-2);}
    friend ostream& operator<<(ostream &os, const mint a) noexcept { return os << a.x; }
    constexpr bool operator == (const mint& r) const noexcept { return this->x == r.x; }
    constexpr bool operator != (const mint& r) const noexcept { return this->x != r.x; }
    mint pow(long long t) const {
        if (!t) return mint(1);
        mint a = pow(t>>1);
        a*=a;
        if(t&1) a*= *this;
        return a;
    }
};

mint nCr(int64 n, int64 r) {
    if (n < r) return mint(0);
    mint x = 1;
    mint y = 1;
    for (int i=1; i<=r; i++) {
        x *= (n - i + 1);
        y *= i;
    }
    return x / y;
}


const int N = 1000000;
int main() {
    int64 n,a,b;
    cin >> n >> a >> b;

    mint ans = mint(2).pow(n) - 1;
    ans -= nCr(n,a);
    ans -= nCr(n,b);
    
    debug(ans);


    cout << ans << endl;
}

Measured memory_bytes: 504
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

int k,n;
int a[300000];
int b[300000];
int cmp(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++){ cin>>a[i];b[a[i]]++;}
	
	sort(b,b+200001,cmp);
	
	int ans=0;
	int p=0,num=0;
	
	while (b[num]!=0) num++;
	
	for (int i=k;i<num;i++){
		ans+=b[i];
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
const int N = 1e5 + 10;
struct data
{
    data(int l, int r) : l(l), r(r) {}
    data() {}
    int l, r;
} x[N];
int cmp(struct data a, struct data b)
{
    //if (a.r != b.r)
    return a.r < b.r;
}
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        x[i] = data(a - b, a + b);
    }
    sort(x + 1, x + 1 + n, cmp);
    int sum = 1;
    int rr = x[1].r;
    for (int i = 2; i <= n; i++)
    {
        if (x[i].l < rr)
            continue;
        rr = x[i].r;
        sum++;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int mod = 1000000007;
inline int mul(int x,int y){return 1ll*x*y%mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int sq(int x){return 1ll*x*x%mod;}
int pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}
const int N = 200020;
int n,m,dp[N] = {0},sudp[N] = {0};
char ch[N];
int ans = 0;
int main() {
	read(n);read(m);
	scanf("%s",ch);
	int ftt = 0,clen = 0;
	for(int i=1;i<m;i++){
		if(ch[i]!=ch[0]){
			ftt = i;
			break;
		}
	}
	if(ftt){
	
		clen = (ftt%2)?(ftt):(ftt+1);
		int la = ftt;
		//cout<<clen<<endl;
		for(int i=ftt+1;i<m-1;i++){
			if(ch[i]==ch[0] && ch[i+1]!=ch[0]){
				//cout<<"OC "<<i<<' '<<la<<endl;
				if((i-la)%2) clen = min(clen,i-la);
			}
			if(ch[i]!=ch[0])la = i;
		}
		
	}
	int clim = (clen+1)/2;
	//cout<<ftt<<' '<<clen<<' '<<clim<<endl;
	dp[0] = sudp[0] = 1;
	for(int i=1;i<=n;i++){
		dp[i] = sudp[i-1];
		if(i-clim-1>=0)dp[i] = sub(dp[i],sudp[i-clim-1]);
		sudp[i] = add(sudp[i-1],dp[i]);
	}
	if(ftt == 0){
		ans = 0;
		dp[1] = sudp[1] = 1;
		dp[2] = sudp[2] = 1;
		ans = n+1;
		for(int i=3;i<n;i++){
			dp[i] = sudp[i-2];
			sudp[i] = add(sudp[i-1],dp[i]);
			ans = add(ans,mul(dp[i],n-i+1));
		}
		if(n == 1)ans = 1;
		cout<<ans<<endl;
		return 0;
	}
	if(n%2){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1;i<=min(clen+1,n);i++){
		int cl = (n-clen-1)/2,cr = (n-i)/2;
		if(n-2*cl-1>clen)cl+=1;
		if(i == 1 && i+cr*2 == n)cr-=1;
		if(cr<cl)continue;
		//cout<<i<<' '<<i+cl*2<<' '<<i+cr*2<<' '<<ans<<endl;
		ans = add(ans,sudp[cr]);
		if(cl>0) ans = sub(ans,sudp[cl-1]);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    int h[n];
    for (int i=0;i<n;i++)
        cin>>h[i];
    int ans=0;
    while (1) {
        int l=0;
        while (l<n&&h[l]==0)
            l++;
        if (l==n)
            break;
        int mn=100;
        int r=l;
        while (r<n&&h[r]!=0) {
            mn=min(mn,h[r]);
            r++;
        }
        while (l<r) {
            h[l]-=mn;
            l++;
        }
        ans+=mn;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True


n=I()
ans=1-(n//2)/n
for i in range(n):
    0
    
print(ans)

Measured memory_bytes: 39280
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int r;
	cin >> r;
 
	cout << setprecision(10) << 2 * r * 3.1415926535 << endl;
 
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;

  vector<bool> markrow(h, false), markcol(w, false);

  vector<string> mas(h);
  for (int i = 0; i < h; i++) cin >> mas[i];

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (mas[i][j] == '#') {
        markrow[i] = true;
        markcol[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (markrow[i] && markcol[j]) cout << mas[i][j];
    }
    if (markrow[i]) cout << endl;
  }
}


Measured memory_bytes: 256
a=int(input())
data=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(data[a-1])

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

int main(){
	int M,D;
	cin >> M >> D;
	int ans(0);
	int n10,n1;
	for(int i(1);i<=M;++i){
		for(int j(1);j<=D;++j){
			if(j<10) n10 = 0;
			else n10 = int(j/10);
			n1 = j%10;
			if(n1 >= 2 && n10 >= 2 && i == n1 * n10) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define INF 1000000001
int N;
int a[MAX];
int dp[MAX];
int max(int a,int b){
  return a>b?a:b;
}
int l_bound(int x){
  int l,h,m;
  l=0;
  int i;
  h=N-1;
  while(h-l>1){
    m=(l+h)/2;
    if(dp[m]>=x)h=m;
    else l=m;
  }
  if(dp[l]<x)return h;
  else return l;
}
int main(){
  int i,j,k;
  int res=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&a[i]);
  for(i=0;i<N;i++)dp[i]=INF;
  for(i=0;i<N;i++){
    j=l_bound(a[i]);
    dp[j]=a[i];
    //for(k=0;k<N;k++)printf("%d ",dp[k]);
    //printf("\n");
  }
  i=0;
  while(dp[i]<INF && i<N)i++;
  printf("%d\n",i);
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s.size() > 3) cout << "ABD" << endl;
  else cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n, m; cin >> n >> m;
    int a[m];
    rep(i, m) cin >> a[i];
    lint mod = 1e9 + 7;
    lint dp[n+10];
    rep(i, n+10) dp[i] = 0;
    dp[0] = 1;
    rep(i, m) dp[a[i]] = -1;
    rep(i, n){
        if(dp[i] < 0) continue;
        if(dp[i+1] >= 0) dp[i+1] = (dp[i+1] + dp[i]) % mod;
        if(dp[i+2] >= 0) dp[i+2] = (dp[i+2] + dp[i]) % mod;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
//https://codeforces.com/contest/877/problem/D

#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
const int N  = 1e6 + 7;
 
int n, m, k, x1, y11, x2, y2;
set<int> row[N], col[N];
vector<pair<int, int> > v;
 
void remove()
{
	for(auto it:v)
	{
		row[it.first].erase(it.second);
		col[it.second].erase(it.first);
	}
	v.clear();
}
 
int32_t main()
{
	IOS;
	cin>>n>>m>>k;
	vector<vector<char>> a(n + 5, vector<char> (m + 5));
	vector<vector<int>> level(n + 5, vector<int> (m + 5, -1));
	cin>>x1>>y11>>x2>>y2;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			row[i].insert(j);
			col[j].insert(i);
			cin>>a[i][j];
			if(a[i][j] == '@') 
			{
				a[i][j] = '#';
			}
		}
	}
	queue<pair<int, int> > q;
	level[x1][y11]=0;
	q.push({x1, y11});
	row[x1].erase(y11);
	col[y11].erase(x1);
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		auto it=row[x].lower_bound(y);
		while(it!=row[x].end())
		{
			int nxty=*it;
			if(nxty-y>k)
				break;
			if(a[x][nxty]=='#')
				break;
			level[x][nxty]=level[x][y]+1;
			q.push({x, nxty});
			v.push_back({x, nxty});
			it++;
		}
		remove();
		it=row[x].lower_bound(y);
		if(it!=row[x].begin())
			it--;
		while(it!=row[x].end())
		{
			int nxty=*it;
			if(nxty>=y)
				break;
			if(y-nxty>k)
				break;
			if(a[x][nxty]=='#')
				break;
			level[x][nxty]=level[x][y]+1;
			q.push({x, nxty});
			v.push_back({x, nxty});
			if(it==row[x].begin())
				break;
			it--;
		}
		remove();
		auto it2=col[y].lower_bound(x);
		while(it2!=col[y].end())
		{
			int nxtx=*it2;
			if(nxtx-x>k)
				break;
			if(a[nxtx][y]=='#')
				break;
			level[nxtx][y]=level[x][y]+1;
			q.push({nxtx, y});
			v.push_back({nxtx, y});
			it2++;
		}
		remove();
		it2=col[y].lower_bound(x);
		if(it2!=col[y].begin())
			it2--;
		while(it2!=col[y].end())
		{
			int nxtx=*it2;
			if(nxtx>=x)
				break;
			if(x-nxtx>k)
				break;
			if(a[nxtx][y]=='#')
				break;
			level[nxtx][y]=level[x][y]+1;
			q.push({nxtx, y});
			v.push_back({nxtx, y});
			if(it2==col[y].begin())
				break;
			it2--;
		}
		remove();
	}
	cout<<level[x2][y2];
}

Measured memory_bytes: 220172
while True:
    try:
        Tlist = list(input())
    except:
        break
    while '@' in Tlist:
        at = Tlist.index('@')
        t = Tlist[at+2]
        x = int(Tlist[at+1])
        del(Tlist[at:at+3])
        Tlist.insert(at,t*x)
    print(''.join(Tlist))


Measured memory_bytes: 5596
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

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

	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    String[] S = new String[N];
	    for (int i = 0; i < N; i++) {
	    	S[i] = sc.next();
	    }

	    int max = 0;
	    HashMap<String, Integer> map = new HashMap<>();
	    for ( int i = 0; i < N; i++) {
	    	Integer count = map.get(S[i]);
	    	if (count == null) {
	    		count = 1;
	    	} else {
	    		count++;
	    	}

	    	map.put(S[i], count);

	    	if (count > max) {
	    		max = count;
	    	}
	    }

	    ArrayList<String> list = new ArrayList<>();
	    for (Entry<String, Integer> entry : map.entrySet()) {
	    	if (entry.getValue() == max) {
	    		list.add(entry.getKey());
	    	}
	    }

	    Collections.sort(list);

	    for (String s : list) {
	    	System.out.println(s);
	    }

	}
}

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


int main(){
	while(1){
	int n,m;
	cin>>n>>m;
	if(n==0)break;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(),a.end());
	vector<int> res;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			res.push_back(-a[i]-a[j]);
	sort(res.begin(),res.end());
	auto it = lower_bound(res.begin(),res.end(),-m);
	if(it==res.end() )cout<<"NONE"<<endl;
	else cout<<-(*it)<<endl;
	}
	return 0;
}



Measured memory_bytes: 6760
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360: x = 720 - x
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
  }
  else{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			
			int[] a = new int[n];
			long[] b = new long[n];
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
			}
			Arrays.sort(a);
			
			for(int i=1;i<n;i++){
				b[i] = b[i-1] + a[i-1];
			}
			long sum = 0;
			for(int i=1;i<n;i++){
				sum += b[i];
			}
			
			System.out.println(sum);
		}
	}	
}

Measured memory_bytes: 45072
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep4(i, a, b, c) for (int i = int(a), i##__b = int(b), i##__c = int(c); i < i##__b; i += i##__c)
#define rep1(n) rep4(i, 0, n, 1)
#define rep2(i, n) rep4(i, 0, n, 1)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define REP(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep3(i, a, b) for (int i = int(b) - 1, i##__a = int(a); i >= i##__a; i--)
#define rrep1(n) rrep3(i, 0, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep4(i, a, b, c) for (int i = int(a + (b - a - 1) / c * c), i##__a = int(a), i##__c = int(c); i >= i##__a; i -= i##__c)
#define RREP(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define FOREACH(i, x) for (auto &i : x)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define mt make_tuple
#define print(x) cout << x << endl;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using vstring = vector<string>;
template <class T> using vv = vector<vector<T>>;
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;}

struct Point {int x, y; Point(int x, int y):x(x), y(y){}};
int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1};
pii dvs[] = {mp(1, 0), mp(0, 1), mp(-1, 0), mp(0, -1)};
// clang-format on


int main() {
    int n, x;
    for (cin >> n >> x; !(n == 0 && x == 0); cin >> n >> x) {
        int ans = 0;
        REP(a, 1, n + 1) {
            REP(b, 1, a) {
                REP(c, 1, b) {
                    if (a + b + c == x) {
                        ans += 1;
                    }
                }
            }
        }
        print(ans);
    }
}



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

int main(){
    string s; cin >> s;
    int q; cin >> q;
    string t;
    rep(i,q){
        int ty; cin >> ty;
        if(ty==1){
            swap(s,t);
        }else{
            int f; char c;
            cin >> f >> c;
            if (f==1){
                t+=c;
            }else{
                s+=c;
            }
        }
    }
    reverse(t.begin(),t.end());
    t+=s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 1128
from collections import deque

N = int(input())
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    links[a].append((b, c))
    links[b].append((a, c))

Q, K = map(int, input().split())

d = [float('inf')] * (N + 1)
d[K] = 0
q = deque([K])
while q:
    i = q.popleft()
    for j, c in links[i]:
        if d[i] + c < d[j]:
            d[j] = d[i] + c
            q.append(j)

result = []
for _ in range(Q):
    x, y = map(int, input().split())
    result.append(d[x] + d[y])
print('\n'.join(str(v) for v in result))


Measured memory_bytes: 55608
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c=0,d=0,e=0,f,g;cin>>a>>f>>g;
  b=(f-a)/g;
  if(f%g==0)b++;
  cout<<b;
}



Measured memory_bytes: 27056
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

LL a,b,c,d;

LL gcd(LL x,LL y)
{
    if (!y) return x;
    else return gcd(y,x%y);
}

int main()
{
    int T;scanf("%d",&T);
    while (T--)
    {
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        LL x=a%b,y=d%b;
        if (a<b) puts("No");
        else if (c>=b&&d>=b) puts("Yes");
        else if (d<b) puts("No");
        else if (x>c) puts("No");
        else
        {
            LL l=(b-x)%b,r=(c+b-x)%b,d=gcd(y,b);
            if (l<=r)
            {
                if (l-1>=d||r/d<(b-1)/d) puts("No");
                else puts("Yes");
                continue;
            }
            std::swap(l,r);
            l++;r--;
            if (l<=r&&(l/d!=r/d||l%d==0)) puts("No");
            else puts("Yes");
        }
    }
    return 0;
}

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

int ksum(int m){
    int _sum=0;
    for(int j=5; j>=0;j--){
        _sum += m/pow(10, j);
        m=m%(int)pow(10, j);
    }
    return _sum;
}

int main(){
    int n;
    cin >> n;
    int keta=5, mn=10000;
    for(int i=1; i<=n/2;i++){
        mn =min(ksum(i) + ksum(n-i), mn);
    }
    cout << mn << endl;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int n;
vector<vector<int>> g;
vector<int> c;
vector<int> v;

void dfs(int s){
    stack<int> st;
    vector<bool> vis(n,false);
    st.push(s);

    int cnt=0;

    while (!st.empty()){
        int cur = st.top();
        st.pop();

        v[cur] = c[cnt];
        ++cnt;
        vis[cur]=true;
        
        for(int i = 0;i < g[cur].size();i++){
            int nex = g[cur][i];
            
            if(vis[nex])continue;
            st.push(nex);
        }
    }
}

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    cin >>n;

    g.resize(n);
    c.resize(n);
    v.resize(n);

    for (int i = 0; i < n-1; i++){
        int a,b;
        cin >>a>>b;
        --a;--b;

        g[a].eb(b);
        g[b].eb(a);
    }

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

    sort(all(c),greater<int>());
    ans -= c[0];

    dfs(0);

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;
    for(int vi:v)cout << vi << " ";

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n];
  for(int i=0;i<n;i++)
    dp[i]=INT_MAX;
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      if(i-j>=0)
        dp[i]=min(dp[i],(dp[i-j]+abs(a[i-j]-a[i])));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 4424
n = int(input())
s = list(input())
d = [0]
x = 0

for i in range(len(s)):
    if s[i] == '(':
        x += 1
    else:
        x -= 1
    d.append(x)

ans = []
x = min(d)

for i in range(max(0,(-1*x))):
    ans.append('(')

for i in s:
    ans.append(i)

for i in range(max(d[len(d)-1]-x,0)):
    ans.append(')')

a = ''.join(ans)

print(a)


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

using namespace std;

#define all(v)   v.begin(), v.end()
#define pb       push_back
#define sz(x)    (int) (x.size())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

pii calc(int a, int b, int c){

    ld x1, x2, discriminant, realPart, imaginaryPart;
//   "coefficients a, b and c: ";
    discriminant = b*b - 4*a*c;

    if (discriminant > 0) {
        x1 = (-b + sqrt(discriminant)) / (2*a);
        x2 = (-b - sqrt(discriminant)) / (2*a);
//        cout << x1 << " " << x2 << endl;
       if(x1 == trunc(x1) && x2 == trunc(x2)) return {(int)x1, (int)x2};
       return {-1, -1};
    }

    else if (discriminant == 0) {
        x1 = (-b + sqrt(discriminant)) / (2*a);
//         cout << x1 << " " << x1 << endl;
        if(x1 == trunc(x1)) return {int(x1), int(x1)};
        return {-1, -1};
    }

    else {
        return {-1, -1};
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    const int N = 1e2;

    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        int ans = 0;
        for(int x = 1; x <= N; x++){
            for(int y = 1; y <= N; y++){
                int a = 1, b = (x + y), c = (x * x + y * y + x * y - i);
                pii p = calc(a, b, c);
//                cout << p.first << p.second << endl;
                if(p.first > 0) ans++;
                if(p.second > 0) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
sx,sy,tx,ty = map(int,input().split())

x=tx-sx
y=ty-sy


n1="U"*y +"R"*x+"D"*y+"L"*x
n2="L"+"U"*(y+1)+"R"*(x+1)+"D"
n3="R"+"D"*(y+1)+"L"*(x+1)+"U"
print(n1+n2+n3)


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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>x;
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	INN(r, g);
	cout<<(2*g-r)<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>
const int mx = 100009;
int n , k;
int arr[mx];
int dp[mx];
int solve(int idx)
{
    if(idx == n-1)return 0;
    int &rst = dp[idx];
    if(~rst) return rst;
    int choice = 1e9 , ans = 1e9;
    for(int i = idx + 1,cnt = 0 ;cnt < k && i < n;i++,cnt++)
    {
        choice  = solve(i) + abs(arr[idx] - arr[i]);
        ans     = min(choice , ans);
    }
    return rst = ans;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> k;
    loop(n) cin >> arr[i];
    clr(dp,-1);
    cout<<solve(0);
}


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

int n;
double a,b,c,arr[1005];

int main(){
	scanf("%d",&n);
	for(int i =0;i<n;i++){
		scanf("%lf",&arr[i]);
	}
	sort(arr,arr+n);
	for(int i =0;i<n-1;i++){
		a = arr[i];
		b = arr[i+1];
		c = (double)(a+b)/(double)2;
		arr[i+1] = c;
	}
	printf("%.8lf\n",c);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    ll x,y;
    cin >> x >> y;
    int ans = 1;
    while(x < y){
        x *= 2;
        if(x <= y)ans++;
    }
    pr(ans);
}

Measured memory_bytes: 256