akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<stack>
using namespace std;
typedef long long ll;
typedef long double lxd;
#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define fo(i,x,n) for (ll i=x;i<=n;i++)
#define pb(x) push_back(x)
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t; cin>>t;
#define fls fflush(stdout) ;
ll fn(ll w[],ll v[],ll sw,ll idx)
{
    if(idx<0)
    return 0;
    if(sw<w[idx])
     return fn(w,v,sw,idx-1);
     else
    return max(v[idx]+fn(w,v,sw-w[idx],idx-1),fn(w,v,sw,idx-1));
}
int main()
{
    ll n,sw;cin>>n>>sw;
    ll w[n],v[n];
    for(ll i=0;i<n;i++)
    cin>>w[i]>>v[i];
    ll dp[n+1][sw+1];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=n;i++)
    {   
        for(ll j=1;j<=sw;j++)
        { 
          if (w[i-1] <=j) 
                 dp[i][j] = max(v[i-1] + dp[i-1][j-w[i-1]],  dp[i-1][j]); 
           else
                 dp[i][j] = dp[i-1][j]; 
        }
    }

     ll mx=dp[n][sw];
     cout<<mx<<endl;
    //ll ans=fn(w,v,sw,n-1);
   // cout<<ans<<endl;
  /* for(ll i=0;i<=n;i++)
    {  
        for(ll j=0;j<=sw;j++)
        {
            cout<<dp[i][j];
        }cout<<endl;
    }*/
    return 0;
}

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

int main() {
	// your code goes here
	int s;
	int hh,mm,ss;
	cin >> s;
	hh = s/3600;
	s -= hh*3600;
	mm = s/60;
	s -= mm*60;
	ss = s;
	cout << hh << ":" << mm << ":" << ss << endl;
	return 0;
}

Measured memory_bytes: 3076
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int tt=1,ans=INT_MAX;
int abc[3];
int t[3];

int match(){
	int sum=0;
	for(int i=0;i<3;++i){
		// cout<<t[i]<<" ";
		sum+=abs(abc[i]-t[i]);
	}
	// cout<<endl;
	return sum;
}

int check(vector<int> v,int n){
	int a=INT_MAX;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			for(int k=j+1;k<n;++k){
				t[0]=v[i],t[1]=v[j],t[2]=v[k];
				sort(t,t+3);
				a=min(a,match());
			}
		}
	}
	return a;
}
void solve(vector<int> v ,int n,int cost){
	if(n<3)
		return;
	ans=min(ans,check(v,n)+cost);
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			vector<int> temp=v;
			temp[i]=temp[i]+temp[j];
			temp.erase(temp.begin()+j);
			solve(temp,n-1,cost+10);
		}
	}
}
int main(){
	//scanf("%d",&t);
	while(tt--){
		int n;
		cin>>n>>abc[0]>>abc[1]>>abc[2];
		sort(abc,abc+3);
		vector<int>l(n);
		for(int i=0;i<n;i++){
			cin>>l[i];
		}
		solve(l,n,0);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    ll MOD = 2019;
    ll l, r; cin >> l >> r;

    V<bool> I(MOD);
    for (ll i = l; i <= min(l + MOD - 1, r); i++) {
        I[i % MOD] = 1;
    }

    ll ans = MOD;
    loop (MOD, i) loop (MOD, j) {
        if (i == j || (!I[i] || !I[j])) continue;
        ans = min(ans, (i * j) % MOD);
    }

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



Measured memory_bytes: 256
h,w=io.read("*n","*n","*l")

grid={}
removerow={}
for i=1,h do
    s=io.read()
    grid[i]={}
    remove=true
    for j=1,w do
        grid[i][j]=s:sub(j,j)
        if grid[i][j]=="#" then
            remove=false
        end
    end
    if remove then
        table.insert(removerow,i)
    end
end

removecol={}
for j=1,w do
    remove=true
    for i=1,h do
        if grid[i][j]=="#" then
            remove=false
        end
    end
    if remove then
        table.insert(removecol,j)
    end
end

for i=#removerow,1,-1 do
    table.remove(grid,removerow[i])
end

for j=#removecol,1,-1 do
    for i,_ in pairs(grid) do
        table.remove(grid[i],removecol[j])
    end
end

for i,_ in pairs(grid) do
    print(table.concat(grid[i],""))
end

Measured memory_bytes: 760
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 110000
vector<pii> G[N];
main(){
    int n=in();
    string s;
    cin>>s;
    int r=0,b=0;
    rep(i,n){
        if(s[i]=='R')r++;
        else b++;
    }
    cout<<(r>b?"Yes":"No");
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;


int main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);


    int n, k;
    cin >> n >> k;

    int arr[n];
    int pos = -1;
    for (int i=0; i<n; i++) {
        cin >> arr[i];

        if (arr[i] == 1) {
            pos = i;
        }
    }

    if (n == k) {
        cout << 1 << endl;
        return 0;
    }

    int ops = 0;
    int done_until = -1;

    for (int i=0; i<n; i += (k-1)) {
        int from = i;
        int to = min(i+k-1, n - 1);

        if (from <= done_until && to <= done_until) {
            continue;
        }

        if (pos >= from && pos <= to) {
            //we found the 1
            ops++;
            done_until = to;
            continue;
        } else {
            done_until = to;
            ops++;
        }
    }

    cout << ops << endl;
    return 0;
}


Measured memory_bytes: 640
n,a,b=map(int,raw_input().split())
x=map(int,raw_input().split())
ans=0
for i in xrange(n-1):
    if (x[i+1]-x[i])*a>=b:
        ans+=b
    else:
        ans+=a*(x[i+1]-x[i])
print(ans)


Measured memory_bytes: 11296
INFTY = 10**6
Q = [1 for _ in range(INFTY)]
Q[0]=0
Q[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        Q[j]=0
A = []
for i in range(INFTY):
    if Q[i]==1:
        A.append(i)
N,P = map(int,input().split())
C = {}
for a in A:
    if P%a==0:
        C[a] = 0
        while P%a==0:
            P = P//a
            C[a] += 1
if P>1:
    C[P] = 1
b = 1
for a in C:
    b *= a**(C[a]//N)
print(b)

Measured memory_bytes: 114032
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    int h, w;
    cin >> h >> w;
    vector<string> vs;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        vs.push_back(s);
    }
    for (int i = 1; i <= 2 * h; i++) {
        cout << vs[(i + 1) / 2 - 1] << endl;
    }
}




Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
    string X;
    int tmp=1000;
    int x;
    cin >> X;

    for(int i=2;i<X.size();i++){
        x = (X[i-2]-0x30)*100 + (X[i-1]-0x30)*10 + (X[i]-0x30);
        if(abs(x-753)<tmp) tmp = abs(x-753);
    }

    cout << tmp;

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

//デバッグ時はTESTを定義する。本番時はこの行をコメントアウトする
//#define TEST //*******************************************************************************************************************************************

//そうすることで、以下に定義する、デバッグ時にのみ標準出力する、doutコマンドが実現できる。本番時はダミーストリームに出力
//#ifdef TEST
//    #define dout cout
//#else
//    stringstream dummy; //デバッグ時のdoutコマンドのダミー出力先
//    #define dout dummy
//#endif


int main(void) {
    int X, t;
    cin >> X >> t;
    
    cout << ( X-t > 0 ? X-t : 0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int n, d;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> d;
    ll rez = 0;
    for(int i=1;i<=n;i++){
        ll a, b;
        cin >> a >> b;
        double kol = (double)sqrt(a * a + b * b);
        if(kol <= d)rez++;
    }
    cout << rez << endl;
    return 0;
}


Measured memory_bytes: 3700
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n, m;
	cin >> n >> m;
	vector<P> data(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		data[i] = make_pair(a, b);
	}
	sort(data.begin(), data.end());
	int sum = 0;
	int p = 0;
	rep(i, n) {
		p = i;
		sum += data[i].second;
		if (sum >= m) break;
	}
	ll ans = 0;
	rep(i, p) {
		m -= data[i].second;
		ans += (ll)data[i].first * data[i].second;
	}
	ans += (ll)m * data[p].first;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#分かりやすい解説記事
#https://betrue12.hateblo.jp/entry/2019/03/31/084642

from collections import defaultdict as dd
mod=10**9+7
N,X=map(int,input().split())
S=sorted(list(map(int,input().split())),reverse=True)
#print(S)
d = dd(int)
d[X] = 1
for i in range(N):
    new = dd(int)
    for X in d:
        new[X] += d[X]*(N-i-1)
        new[X] %= mod
        #print(X,new[X])
        new[X%S[i]] += d[X]
        new[X%S[i]] %= mod
    d = new
ans = 0
for x in d:
    ans += x*d[x]
    ans %= mod
print(ans)

Measured memory_bytes: 5424
import java.util.*;
import java.lang.Math.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		System.out.println(c+" "+a+" "+b);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    ll res=0;
    rep(i,n+1){
        if(i==0)continue;
        if(i%3!=0&&i%5!=0)res+=i;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
pair<int,int> dfs(vector< vector< pair<int,int> > > &G, vector<bool> &visited, int v){
  pair<int,int> ret(0,v);
  visited[v] = true;
  for(size_t i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i].second;
    if(visited[v_]) continue;
    pair<int,int> ret_ = dfs(G,visited,v_);
    ret_.first += G[v][i].first;
    ret = max(ret,ret_);
  }
  return ret;
}
 
int diameter(vector< vector< pair<int,int> > > &G){
  int N = G.size();
  vector<bool> init(N,false);
  int v = dfs(G,init,0).second;
  init = vector<bool>(N,false);
  return dfs(G,init,v).first;
}
 
int main(){
  int n;
  cin >> n;
  vector< vector< pair<int,int> > > G(n);
  for(int i = 0; i < n-1; ++i){
    int s, t;
    cin >> s >> t;
    s--,t--;
    G[s].emplace_back(1,t);
    G[t].emplace_back(1,s);
  }
  int s = diameter(G);
  if((s+2)%3==0) puts("Second");
  else puts("First");
  return 0;
}


Measured memory_bytes: 26880
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int n,a,b;
    string s;
    cin>>n>>a>>b;
    cin>>s;
    int b_num = 0;
    int d_num =0;
    for(int i=0;i<n;i++){
        if(s[i]=='a'){
            if(d_num<a+b){
                cout<<"Yes"<<endl;
                d_num+=1;
            }else{
                cout<<"No"<<endl;
            }
        }else {
            if(s[i]=='b'){
                if(d_num<a+b && b_num<b){
                    cout<<"Yes"<<endl;
                    b_num+=1;
                    d_num+=1;
                }else{
                    cout<<"No"<<endl;
                }
            }else{
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}

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

int main() {
  const int64_t mod = 1000000007;
  int n, m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  for (int i = 0; i < n; i++) cin >> s.at(i);
  for (int i = 0; i < m; i++) cin >> t.at(i);
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(m + 1));
  for (int i = 0; i <= n; i++) dp.at(i).at(0) = 1;
  for (int i = 0; i <= m; i++) dp.at(0).at(i) = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp.at(i + 1).at(j + 1) = dp.at(i).at(j + 1) + dp.at(i + 1).at(j);
      if (s.at(i) != t.at(j)) {
        dp.at(i + 1).at(j + 1) += mod - dp.at(i).at(j);
      }
      dp.at(i + 1).at(j + 1) %= mod;
    }
  }
  cout << dp.at(n).at(m) << endl;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long
int main() {
    int N;
    cin>>N;
    int ar[N];
    int ar2[N];
    REP(i,N)
    {
        cin>>ar[i];
    }
    REP(i,N)
    {
        cin>>ar2[i];
    }int c=0;
    REP(i,N)
    {
        if(ar[i]>ar2[i])
        c+=ar[i]-ar2[i];
    }
    cout<<c<<endl;
}
    

Measured memory_bytes: 3508
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

// '.' is white
// '#' is black
// '.....#####' is goal
int n;
string s;
int b[1000000];
int w[1000000];
void solve() {
  cin >> n >> s;
  for(int i = 0; i < n; i++) {
    b[i+1] = b[i];
    w[i+1] = w[i];
    if(s[i] == '.') w[i+1]++;
    else b[i+1]++;
  }
  int ret = 1e9;
  for(int i = 0; i <= n; i++) {
    int curr = 0;
    curr += b[i];
    curr += w[n] - w[i];
    ret = min(ret, curr);
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 5524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int n,k;
  cin>>n>>k;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  double sum=0;
  for(int i=0;i<k;i++){
    sum+=((double)p[i]+(double)1)*0.5;
  }
  //cout<<sum<<endl;
  double kotae=sum;
  for(int i=1;i<n-k+1;i++){
    sum=sum-((double)p[i-1]+(double)1)*0.5+((double)p[i+k-1]+(double)1)*0.5;
    //if(i==1)cout<<sum<<endl;
    //cout<<p[i-1]<<" "<<p[i+k-2]<<" "<<sum<<endl;
    kotae=max(kotae,sum); 
  }
  cout<<fixed<<setprecision(12)<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;

    return 0;    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int main()
{
        //input->compute->output//
        ll N, A, B, C, D, E;
        cin >> N >> A >> B >> C >> D >> E;

        ll res = min({A, B, C, D, E});
        cout << ((N + res - 1) / res) + 4 << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner reader = new Scanner(System.in);
    int a = reader.nextInt();
    int b = reader.nextInt();
    int c = reader.nextInt();
    int[] result = new int[6];
    
    result[0] = c * 10 + b + a;
    result[1] = a * 10 + b + c;
    result[2] = b * 10 + a + c;
    result[3] = c * 10 + a + b;
    result[4] = a * 10 + c + b;
    result[5] = b * 10 + c + a;
    
    int max = result[0];
    
    for (int i= 1; i < 6; i++) {
    	if (max < result[i]) {
        	max = result[i];
        }
    }
    
    System.out.print(max);
  }
}

Measured memory_bytes: 21204
// 2014/07/29 Tazoe

#include <iostream>
#include <string>
#include <cctype>
using namespace std;

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

	for(int i=0; i<W.size(); i++){
		W[i] = tolower(W[i]);
	}

	int cnt = 0;

	while(true){
		string T;
		cin >> T;

		if(T=="END_OF_TEXT")
			break;

		for(int i=0; i<T.size(); i++){
			T[i] = tolower(T[i]);
		}

		if(T==W){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1192
# AOJ 1067 Cutting a Chocolate
# Python3 2018.7.10 bal4u

from bisect import bisect_left

while True:
	n, m, w, h, S = map(int, input().split())
	if n == 0: break
	m, wh2 = m+1, 2*(w*h)
	S = wh2-2*S
	tbl, s = [[0,0,0]], [0]
	for i in range(1, m):
		l, r = map(int, input().split())
		tbl.append([l, r, r-l])
		s.append((l+r)*w)
	p = []
	for i in range(n):
		x, y = map(float, input().split())
		p.append((y, x))
	if S == 0:
		print(n)
		continue
	elif S == wh2:
		print(0)
		continue
	p.sort()
	j, a = 1, [0]*m
	for i in range(n):
		y, x = p[i]
		while True:
			y1 = tbl[j-1][2]*x/w + tbl[j-1][0]
			y2 = tbl[j  ][2]*x/w + tbl[j  ][0]
			if y1 < y:
				if y < y2: break
				j += 1
			else: j -= 1
		a[j] += 1
	for i in range(1, m): a[i] += a[i-1]

	j = bisect_left(s, S, 0, m)
	if s[j] != S: j -= 1
	ans, i = a[j], 1
	while j+1 < m:
		j += 1
		while s[j]-s[i] > S: i += 1
		ans = max(ans, a[j]-a[i])
	print(n - ans)


Measured memory_bytes: 17788
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const int N = 1e6+7;

int n;
ll a[N];
map<ll,ll> fr;

int main () {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		fr[-a[i]]++;
	}

	ll fs = 0;
	for (auto it : fr) {
		if (fs == 0 && it.second >= 4) {
			printf("%lld\n", it.first*it.first);
			return 0;
		} else if (it.second >= 2) {
			if (fs == 0)
				fs = it.first;
			else {
				printf("%lld\n", fs*it.first);
				return 0;
			}
		}
	}

	printf("0\n");
}


Measured memory_bytes: 7296
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  map<ll, ll> em, om;
  rep(i, n) {
    ll a;
    cin >> a;
    if (i & 1)
      om[a]++;
    else
      em[a]++;
  }
  multiset<P> ev, ov;
  ev.insert({0, INF});
  ov.insert({0, INF});
  for (P p : em) ev.insert({p.second, p.first});
  for (P p : om) ov.insert({p.second, p.first});

  auto ite = ev.rbegin(), ito = ov.rbegin();
  ll e0c, e0v, e1c, e1v;
  tie(e0c, e0v) = *ite++;
  tie(e1c, e1v) = *ite;
  ll o0c, o0v, o1c, o1v;
  tie(o0c, o0v) = *ito++;
  tie(o1c, o1v) = *ito;

  ll ans;
  if (e0v != o0v) {
    ans = (n + 1) / 2 - e0c;
    ans += n / 2 - o0c;
  } else {
    ans = INF;
    ll tmp;
    tmp = (n + 1) / 2 - e0c;
    tmp += n / 2 - o1c;
    chmin(ans, tmp);
    tmp = (n + 1) / 2 - e1c;
    tmp += n / 2 - o0c;
    chmin(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

if sum(S) % 10 != 0:
    print(sum(S))
else:
    S.sort()
    for s in S:
        if s % 10 != 0:
            print(sum(S)-s)
            break
    else:
        print(0)

Measured memory_bytes: 9160
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
from collections import deque

UNVISITED, VISITED_IN_QUEUE, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(_v_info, _input_adj_table, _in_deg_list):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        _input_adj_table[v_from].append(v_to)
        _in_deg_list[v_to] += 1
    return _input_adj_table, _in_deg_list


def topological_sort():
    for v in range(vertices):
        if not in_deg_list[v] and status[v] is UNVISITED:
            bfs(v)

    return ans


def bfs(v):
    v_queue.append(v)
    status[v] = VISITED_IN_QUEUE

    while v_queue:
        current = v_queue.popleft()

        ans.append(current)

        for v_adj in adj_table[current]:
            in_deg_list[v_adj] -= 1
            if not in_deg_list[v_adj] and status[v_adj] is UNVISITED:
                status[v_adj] = VISITED_IN_QUEUE
                v_queue.appendleft(v_adj)

        status[current] = POPPED_OUT

    return None


if __name__ == '__main__':
    _input = stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    status = [UNVISITED] * vertices
    v_queue = deque()
    init_adj_table = tuple([] for _ in range(vertices))
    init_in_deg_list = [0] * vertices

    ans = []
    adj_table, in_deg_list = generate_adj_matrix(v_info, init_adj_table, init_in_deg_list)
    print(*topological_sort())

Measured memory_bytes: 14696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> a(3, vector<ll>(n));
  REP(i, 3) {
    REP(j, n) { cin >> a[i][j]; }
    sort(ALL(a[i]));
  }

  ll ans = 0;
  REP(k, n) {
    ll b = a[1][k];
    if (a[0][0] >= b) {
      continue;
    }
    if (a[2][n - 1] <= b) {
      continue;
    }
    ll ok = 0, ng = n;
    while (ok + 1 < ng) {
      ll m = (ok + ng) / 2;
      (a[0][m] < b ? ok : ng) = m;
    }
    ll l = ok + 1;

    ok = n - 1, ng = -1;
    while (ng + 1 < ok) {
      ll m = (ok + ng) / 2;
      (a[2][m] > b ? ok : ng) = m;
    }
    ll r = n - ok;
    ans += l * r;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    class UnionFind:
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        # 親が同じか判別
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        # 根を繋ぎ直す
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            if self.parents[x] > self.parents[y]:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x

        # 親が同じか判別
        def same(self, x, y):
            return self.find(x) == self.find(y)

        # 連結成分の大きさを返す
        def size(self, x):
            return -self.parents[self.find(x)]

    n, m = map(int, input().split())
    P = list(map(int, input().split()))
    uf = UnionFind(n)
    for _ in range(m):
        x, y = map(int, input().split())
        uf.union(x - 1, y - 1)

    idx = [0] * n
    for i in range(n):
        idx[P[i] - 1] = i

    res = 0
    for j in range(n):
        if j + 1 != P[j]:
            if uf.same(j, idx[j]):
                res += 1
        else:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 13876
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll a, b, c;
	cin >> a >> b >> c;

	if (a + b == c || a == b + c || a + c == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d" @@ fun n c ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y z -> x, y, z)) in
  Array.sort compare a;

  let pop t c = List.filter (fun (t',c') -> t < t' || (t' = t && c <> c')) in

  Array.fold_left (fun (z,q) (s,t,c) ->
    let q' = (t, c) :: pop s c q in
    (max z (List.length q'), q')) (0, []) a
  |> fst |> Printf.printf "%d\n"

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

using namespace std;


int main(int argc, char* argv[])
{
	int n;
	vector<int> h, step;
	cin >> n;
	h.resize(n);
	step.resize(n);
	int max = 0;
	

	for (int i = 0; i < n; i++) {
		cin >> h[i];
		step[i] = 0;
	}
	step[n - 1] = 0;

	for (int i = n - 2; i >= 0; i--) {
		if (h[i] >= h[i + 1]) {
			step[i] = step[i + 1] + 1;
		}
		else {
			step[i] = 0;
		}
		if (step[i] > max) {
			max = step[i];
		}
	}

	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
   string N;
     cin>>N;
   if(N[0] == N[2]){
     cout<<"Yes"<<endl;
   }else{
     cout<<"No"<<endl;
   }

   return 0;
}


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

int main(){
	long long int N;
  	char data[10]={'a','b','c','d','e','f','g','h','i','j'};
	cin >> N;
  	int n[10]={1,1,1,1,1,1,1,1,1,1};
  	while(1){
	  	cout << data[0];
      	for(int i=1; i<N;i++){
	  	cout << data[n[i]-1];
        }
	  	cout << endl;
      	
      	int flag=1;
      	for(int i=0; i<N ; i++){
	      if(n[i]!=i+1) flag=0;
      	}
      	if(flag==1)break;
      
      	n[N-1]++;
      	for(int i=N-1 ; i>1 ; i--){
        	int max=0;
        	for(int j=1;j<i;j++){
          		if(n[j]>max)max=n[j];
        	}
      		if(n[i]==max+2){
          		n[i]=1;
          		n[i-1]++;
        	}
        }
    }
}

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

int n;
vector<pair<int, int>> job;

int main() {
	cin >> n;
	for (int i = 0, a, b; i < n; i++) {
		cin >> a >> b;
		job.emplace_back(b, a);
	}
	long long t = 0;
	sort(&job[0], &job[n]);
	for (int i = 0; i < n; i++) {
		t += job[i].second;
		if (t > job[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

}


Measured memory_bytes: 2420
N, Y = map(int, input().split())


def isTrue(x, y, z, Y):
    if Y == 10000 * x + 5000 * y + 1000 * z:
        return True
    return False


for i in range(N + 1):
    for j in range(N - i + 1):
        if isTrue(i, j, N - i - j, Y):
            print(i, j, N - i - j)
            exit()

print(-1, -1, -1)


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

int a;

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	scanf("%d", &a);
	printf("%d\n", a+a*a+a*a*a);
	return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	int N, Q;	cin >> N >> Q;
	string S;	cin >> S;
	vector<int> l(Q);
	vector<int> r(Q);
	vector<int> rui(N,0);
	for (int i = 0; i < Q; i++)
	{
		cin >> l[i] >> r[i];
	}

	//cout << S;

	int a = 0;
	for (int i = 0; i < (N-1); i++)
	{
		if (S[i] == 'A' && S[i + 1] == 'C')
		{
			a++;
		}
		rui[i] = a;
	}
	rui[N - 1] = a;

	int ans;

	for (int i = 0; i < Q; i++)
	{
		if((l[i]-2)>=0)    ans = rui[r[i]-2] - rui[l[i]-2];
		else
		{
			 ans = rui[r[i] - 2];
		}
		cout << ans << endl;
	}

	return 0;
}

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

#define int 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 dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(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<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

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

signed main() {
  int n;
  cin >> n;
  vec<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  sort(all(v));
  int sum = 0;
  rep (i, n-1) {
    sum += v[i];
  }

  if (v.back() < sum) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long l = sc.NextLong();
        long r = sc.NextLong();
        long d = sc.NextLong();

        long answer = (r / d) - (l - 1) / d;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27484
#include <bits/stdc++.h>
using namespace std;
const int N = 711;
int w[N][N];
int n, m;
vector<int> adj[N];
int col[N];
int q[N], qt;
bool dfs(int u){
	q[qt++] = u;
	for(int v : adj[u])
		if(col[v] == 0){
			col[v] = 3 - col[u];
			if(!dfs(v)) return false;
		}
		else{
			if(col[v] != 3 - col[u])
				return false;
		}
	return true;
}
bool can[N], tcan[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	while(m--){
		int a, b; cin >> a >> b;
		w[a][b] = w[b][a] = 1;
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i != j && w[i][j] == 0)
				adj[i].push_back(j);
	can[0] = 1;
	for(int i = 1; i <= n; i++){
		if(col[i] == 0){
			col[i] = 1;
			qt = 0;
			if(!dfs(i)){
				cout << "-1\n";
				return 0;
			}
			int cnt1 = 0, cnt2 = 0;
			for(int j = 0; j < qt; j++)
				if(col[q[j]] == 1)
					cnt1++;
				else
					cnt2++;
			for(int j = N - 1; j >= 0; j--){
				tcan[j] = 0;
				if(j >= cnt1)
					tcan[j] = can[j - cnt1];
				if(j >= cnt2)
					tcan[j] |= can[j - cnt2];
			}
			for(int j = N - 1; j >= 0; j--){
				can[j] = tcan[j];
			}
		}
	}
	int thei;
	for(int i = n / 2; i >= 0; i--)
		if(can[i]){
			thei = i;
			break;
		}
	cout << thei * (thei - 1) / 2 + (n - thei) * (n - thei - 1) / 2;
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    return 0;
}

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

int main() {
	int H, W;
	while(1){
		cin >> H >> W;
		if(H==0 && W==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(!((i+j)%2)) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

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

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

  string akb = "AKIHABARA";

  for(int i=0; i < (1 << 9); i++){
    string tmp = "";
    bool f = true;
    for(int j=0; j<9; j++){
      if((i >> j) & 1) tmp += akb[j];
      else{
        if(akb[j] != 'A') f = false;
      }
    }
    if(!f) continue;
    
    if(tmp == s){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
    ll n;
    cin>>n;
    vi a(n);
    vi b(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) cin>>b[i];

    ll mnA = 0;
    ll mnB = 0;
    rep(i,0,n){
        if(a[i]%2!=b[i]%2){
            ++b[i];
            mnB++;
        }
        if(a[i]<b[i])
			mnA+=(b[i]-a[i])/2;
        else
			mnB+=a[i]-b[i];
        a[i] = b[i];
		//cout<<a[i]<<" ";
    }
    //cout<<endl;
    //cout<<mnA<<", "<<mnB<<endl;
    if(mnA>=mnB)
        cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 384
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,T;
  cin >> N >> T;
  vector<ll> t(N);
  REP(i,N) cin >> t[i];
  ll ans = T;
  REP(i,N-1){
    ans += min(T, t[i+1] - t[i]);
  }
  cout << (N==1 ? T : ans) << endl;
  return 0;
}


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

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


Measured memory_bytes: 3788
#include<stdio.h>

int main() {
  int n, i, j, number;
  int count = 0;
  int max = -1;
  int max_num;

  scanf("%d", &n);

  for (i = 1; i <= n; i++) {
    number = i;
    for (j = 0; j < 100; j++) {
      if (number%2 != 0)
        break;
      number = number / 2;
      count++;
    }

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

    count = 0;
  }

  printf("%d\n", max_num);

  return 0;
}

Measured memory_bytes: 128
import heapq
N, M = map(int, input().split())
A = [[-int(x), i] for i, x in enumerate(input().split())]
heapq.heapify(A)
for _ in range(M):
  a, i = heapq.heappop(A)
  _a = (-a) // 2
  heapq.heappush(A, [-_a, i])
print(sum([-a[0] for a in A]))

Measured memory_bytes: 27280
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N), b(N);
	for (ll i = 0; i < N; i++)cin >> a[i];
	for (ll i = 0; i < N; i++)cin >> b[i];

	ll cnt = 0;

	for (ll i = 1; i <= N; i++)
	{
		ll temp = a[0] + b[N - 1];

		for (ll k = 1; k < i; k++)
		{
			temp += a[k];
		}
		for (ll k = i - 1; k < N - 1; k++)
		{
			temp += b[k];
		}

		if (temp > cnt) cnt = temp;
	}	

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
ll X,Y;
int main(){
	cin>>X>>Y;
	if(X%Y==0)cout<<-1<<endl;
	else cout<<X<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

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

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll A, B;
	cin >> A >> B;

	int ans = -1;
	REP(i, 10000) {
		int aAns = i * 8 / 100;
		int bAns = i * 10 / 100;
		if (aAns == A && bAns == B) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = list(input())
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
    exit()
if s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print('Yes')
    exit()
if s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 38256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> triangle = new ArrayList<Integer>();
        for(int i=0; i<3; i++){
            triangle.add(sc.nextInt());
        }

        if((triangle.get(0)==(triangle.get(1)) && (triangle.get(0)==triangle.get(2)))){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP1 = [[0 for j in range(M)] for i in range(N + 2)]
DP2 = [[0 for j in range(M)] for i in range(N + 2)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP1[i][j] = max(DP1[i - 1][j], DP1[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP1[i][j] = DP1[i - 1][j]

for i in range(N, 0, -1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP2[i][j] = max(DP2[i + 1][j], DP2[i + 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP2[i][j] = DP2[i + 1][j]

mv = 0
for i in range(N):
    for j in range(M):
        mv = max(DP1[i][j] + DP2[i + 2][M - 1 - j] + D[i][1], mv)

print(mv)





Measured memory_bytes: 195076
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    N = len(S)
    ans = [0]*N
    curr = 0
    while curr < N:
        counter = [0, 0]
        while S[curr] == "R":
            counter[curr % 2] += 1
            curr += 1
        R, L = curr-1, curr
        RL = [(curr-1) % 2, curr % 2]
        while curr < N and S[curr] == "L":
            counter[curr % 2] += 1
            curr += 1
        # print(R, L, counter)
        ans[R] = counter[RL[0]]
        ans[L] = counter[RL[1]]
    print(*ans, sep=" ")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6528
package main

import (
	"bufio"
	"fmt"
	"os"
)

var N, M, Q int

func main() {
	N, M, Q = ReadInt(), ReadInt(), ReadInt()

	L := make([]int, M)
	R := make([]int, M)
	for i := 0; i < M; i++ {
		L[i] = ReadInt()
		R[i] = ReadInt()
	}
	sumTable := buildSumTable(L, R)

	for i := 0; i < Q; i++ {
		p, q := ReadInt(), ReadInt()
		fmt.Println(calcSum(sumTable, p, q))
	}
}

func buildSumTable(L, R []int) [][]int {
	sum := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		sum[i] = make([]int, N+1)
	}
	for i := 0; i < M; i++ {
		sum[L[i]][R[i]]++
	}
	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			sum[i][j] += sum[i-1][j]
			sum[i][j] += sum[i][j-1]
			sum[i][j] -= sum[i-1][j-1]
		}
	}
	return sum
}

func calcSum(sumTable [][]int, L, R int) int {
	return sumTable[R][R] - sumTable[R][L-1] - sumTable[L-1][R] + sumTable[L-1][L-1]
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 9656