akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	vector<pair<int, int>> V;
	for(int i=0; i<M; i++){
		int a, b; cin >> a >> b;
		a--; b--;
		V.push_back(make_pair(a, b));
	}

	sort(V.begin(), V.end());
	vector<pair<int,int>> A;
	int bl = -1, br = -1;
	for(int i=0; i<V.size(); i++){
		auto p = V[i];
		int l = p.first;
		int r = p.second;
		if(i == 0){
			A.push_back(make_pair(l, r));
			bl = l; br = r;
		}
		else if(br <= l){
			A.push_back(make_pair(l, r));
			bl = l;
			br = r;
		}
		else{
			bl = l;
			br = min(br, r);
		}
	}
	int ans = (int)A.size();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4284
A,B,C,X,Y = map(int,input().split())

money = 0
if A + B >= C*2:
    t = min(X,Y)
    money += t * 2 * C
    X -= t
    Y -= t
    if X > 0:
        if A > C*2:
            money += C * 2 * X
        else:
            money += A * X
    elif Y > 0:
        if B > C*2:
            money += C * 2 * Y
        else:
            money += B * Y
else:
    money += A * X + B * Y
print(money)


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

using namespace std;

const long long MOD = 1e9 + 7;

static long long calc_exp_mod (
    long long base,
    long long exponent)
{
    if ( exponent == 1 )
        return base;
    if ( exponent % 2 != 0 )
        return base * calc_exp_mod(base, exponent-1) % MOD;
    long long sqrt = calc_exp_mod(base, exponent/2);
    return (sqrt * sqrt) % MOD;
}

static long long calc_combin_mod (
    long long n,
    long long k)
{
    long long x = 1;
    long long y = 1;

    for ( int i=0; i<k; i++ ) {
        x *= n - i;
        y *= i + 1;
        x %= MOD;
        y %= MOD;
    }
    y = calc_exp_mod(y, MOD-2);
    return (x * y) % MOD;
}

int main (void) {
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans = calc_exp_mod(2, n) - 1;
    ans += MOD - calc_combin_mod(n, a);
    ans %= MOD;
    ans += MOD - calc_combin_mod(n, b);
    ans %= MOD;

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



Measured memory_bytes: 256
#include <stdio.h>
#define INF 10000
#define BLACK 1
#define WHITE 0
#define NIL -1
#define N 2000


int A[N][N];
int n;

int prim()
{
  int i, u, v, count=0, mincost;
  int p[N],d[N],color[N];
  for( i=0 ; i<n ; i++ ){
    d[i] = N;
    p[i]=NIL;
    color[i]=WHITE;
  }
  while(1){
    mincost = INF;
    for( i=0 ; i<n ; i++ ){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost = d[i];
	u=i;
      }
    }
    if(mincost==INF)
      break;

    color[u] = BLACK;
    for( v=0 ; v<n ; v++ ){
      if(color[v]!=BLACK && d[v]>A[u][v] && A[u][v]!=-1){
	p[v] = u;
	d[v] = A[u][v];
      }
    }
  }
  for( i=0 ; i<n ; i++ )
    count+=A[i][p[i]];

  return count;
}

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

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

  return 0;
}



Measured memory_bytes: 2180
import math
N,D = list(map(int,input().split()))
X = [list((map(int,input().split()))) for i in range(N)]

def diff(A,B,D):
    y = []
    for l in range(D):
        y.append((A[l] - B[l])**2)
    return math.sqrt(sum(y))

count = 0
for i in range(N):
    for j in range(i+1,N):
        y = diff(X[i], X[j], D)
        if y % 1 == 0:
            count += 1
print(count)

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

int main(){
  long long int n,ans=0;
cin >>n;

for(long long int i=1;i<=pow(n,0.5);i++){
if((n-i)%i==0 && (n-i)>i*i)ans+=(n-i)/i;
}
cout <<ans <<endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

int main() {
	make(n);
	makev(v, n);
	makev(w, n);
	int sum = 0;
	FORE(i,w) sum += *i;
	int best = 0;
	FOR(i,0,n) {
		sum += v[i];
		best = max(best, sum);
		sum -= w[i];
	}
	printf("%d\n", best);
}


Measured memory_bytes: 256
use std::cmp;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

fn main() {
    let n: usize;
    input!(n);
    let mut v: Vec<usize> = input_vector();
    v.sort();
    let a = *v.last().unwrap();
    let mut b = match v.binary_search(&(a / 2)) {
        Ok(s) => v[s],
        Err(s) => {
            if v[s] - a / 2 > a / 2 - v[s - 1] {
                v[s - 1]
            } else {
                v[s]
            }
        }
    };
    if n == 2 {
        b = v[0];
    }
    println!("{} {}", a, b);
}

Measured memory_bytes: 8444
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define sz size()
#define vec vector<int>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}


int main() {
	ll d, n; cin >> d >> n;
	if (n != 100) {
		if (d == 0)cout << n << endl;
		else if (d == 1)cout << n * 100 << endl;
		else cout << n * 10000 << endl;
	}
	else {
		if (d == 0)cout << n + 1 << endl;
		else if (d == 1)cout << 101 * 100 << endl;
		else cout << 10000 *101 << endl;
	}
	return 0;
}

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

string s,t;

int main(){
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());
	if(s<t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int X1 = sc.nextInt();
		int Y1 = sc.nextInt();
		int X2 = sc.nextInt();
		int Y2 = sc.nextInt();

		int X3 = X2 + (Y1 - Y2);
		int Y3 = Y2 + (X2 - X1);
		int X4 = X3 + (X1 - X2);
		int Y4 = Y3 + (Y1 - Y2);

		System.out.printf("%d %d %d %d\n", X3, Y3, X4, Y4);
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int h,w,k;cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c[i];

    int ans = 0;
    
    for(int i=0;i<(1<<h);++i){
        for(int j=0;j<(1<<w);++j){
            vector<string> cp = c;

            for(int ii=0;ii<h;++ii){
                for(int jj=0;jj<w;++jj){
                    if(((i>>ii)&1) || ((j>>jj)&1)){
                        cp[ii][jj] = 'r';
                    }
                }
            }

            int temp = 0;
            for(int ii=0;ii<h;++ii){
                for(int jj=0;jj<w;++jj){
                    if(cp[ii][jj] == '#') ++ temp;
                }
            }
            if(temp == k) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const int INF=1e9;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


         
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  ll dp[10][10]={};
  exrep(i,1,n){
    string t=to_string(i);
    ll f=t[0]-'0';
    ll b=t[t.size()-1]-'0';
    dp[f][b]++;
  }
  ll ans=0;
  rep(i,10){
    rep(j,10){
      if(i==j)continue;
      else ans+=dp[i][j]*dp[j][i];
    }
  }
  rep(i,10)ans+=dp[i][i]+dp[i][i]*(dp[i][i]-1);
  
  cout << ans << endl;
  return 0;     
}


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

int main() {
    char c;
    cin >> c;
    cout << ((c=='a'||c=='i'||c=='u'||c=='e'||c=='o')?"vowel":"consonant") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long a = sc.nextLong();
	long b = sc.nextLong();
	long x = sc.nextLong();
	long count=0;
	if(x>=a){
		long figure = (x-a)/(a-b)+1;
		count = x%1000000007+(figure%1000000007)*(b%1000000007);
		System.out.println(count%1000000007);
	}else System.out.println(x%1000000007);
    }
}



Measured memory_bytes: 26372
n,m=map(int,input().split())
roads=[]
for i in range(m):
  roads.append(input().split())
count=0
for j in range(1,n+1):
  for k in range(m):
    if int(roads[k][0])==j or int(roads[k][1])==j:
      count+=1
      #print('road')
  print(count)
  count=0


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	cin >> n >> k;
	
	set<int> st;
	for(int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		
		for(int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			st.insert(a);
		}
	}

	int x = st.size();
	cout << max(0, n - x) << endl;
	
	return 0;
}


Measured memory_bytes: 3644
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int x, y;
  cin >> x >> y;
  int sum = 0;
  if(x<=3&&x>=1){
    sum += 100000*(4-x);
  }
  if(y<=3&&y>=1){
    sum += 100000*(4-y);
  }
  if(x==1&&y==1){
    sum += 400000;
  }
  cout << sum << endl;
  return 0;
}


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

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


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), c(n+1);
  REP(i, n) cin >> a[i];
  REP(i, n) c[i+1] = c[i] + a[i];
  ll ans = 0;
  REP(i, n-k+1) {
    ans = max(ans, c[i+k] - c[i]);
  }
  cout << (ans + k) / 2.0  << endl;
  return 0;
}


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

#define MAX 103
using namespace std;


int main()
{
	int n, w, d, wi[MAX], di[MAX];
	while (cin >> n >> w >> d, n || w || d){

		fill(wi, wi + MAX, 0);
		fill(di, di + MAX, 0);
		wi[0] = w;
		di[0] = d;

		for (int i = 0; i < n; i++){
			int p, s,w1,d1,w2,d2;
			cin >> p >> s;
			p--;
			s = s % (wi[p] + di[p] + wi[p] + di[p]);

			if (s < wi[p]){
				w1 = s;
				d1 = di[p];
				w2 = wi[p] - w1;
				d2 = d1;
			}
			else if (s < wi[p] + di[p]){
				w1 = wi[p];
				d1 =  s - wi[p];
				w2 = w1;
				d2 = di[p] - d1;
			}
			else if (s < wi[p] + di[p] + wi[p]){
				w1 = s - di[p] - wi[p];
				d1 = di[p];
				w2 = wi[p] - w1;
				d2 = d1;
			}
			else{
				w1 = wi[p];
				d1 = s - wi[p] - di[p] - wi[p];
				w2 = w1;
				d2 = di[p] - d1;
			}

			for (int j = p; j < i; j++){
				wi[j] = wi[j + 1];
				di[j] = di[j + 1];
			}

			if (w1*d1 < w2*d2){
				wi[i] = w1;
				di[i] = d1;
				wi[i + 1] = w2;
				di[i + 1] = d2;
			}
			else{
				wi[i] = w2;
				di[i] = d2;
				wi[i + 1] = w1;
				di[i + 1] = d1;

			}


		}
		vector<int>ans;
		



		for (int i = 0; i < n+1; i++){
			ans.push_back(wi[i] * di[i]);
		}
		sort(ans.begin(), ans.end());
		for (int i = 0; i < n; i++)
			cout << ans[i] << " ";
		cout << ans[n] << endl;
	
	}
	return 0;
}

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


#define INF 10000
#define MAX_V 10


int d[MAX_V][MAX_V];
int n, m, a, b, c, num, t;


void Init(){
	t=INF; m=0;//ツ陳ャツづ個青板。
	for(int i=0; i<MAX_V; i++)
			for(int j=0; j<MAX_V; j++)
				i==j ? d[i][j]=0 : d[i][j]=INF;
}


void Input(){
	for(int i=0; i<n; i++){
		cin>>a>>b>>c;
		m = max(a, max(b, m));//ツ陳ャツづ個青板。
		d[a][b]=d[b][a]=c;
	}
}


void wf(){	
	int tmp = 0;
	for(int k=0; k<=m; k++)
		for(int i=0; i<=m; i++)
			for(int j=0; j<=m; j++)
				d[i][j]=min(d[i][j], d[i][k]+d[k][j]);



	for(int i=0; i<=m; i++){
		for(int j=0; j<=m; j++){
			if(d[i][j]!=INF || i!=j)tmp+=d[i][j];
		}
		if(tmp<t)t=tmp, num=i;
		tmp=0;
	}
	return;
}



int main(){
	while(cin>>n, n){
		Init();
		Input();
		wf();
		printf("%d %d\n", num, t);
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d[i];
  sort(all(d));
  int ans = d[n/2] - d[n/2-1];
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long k,a,b;
	scanf("%llu%llu%llu",&k,&a,&b);
	if(b>a+2){
		if(k<a+1) printf("%llu",k+1);	
		else{
			k-=a+1;
			printf("%llu",b+k/2*(b-a)+k%2);
		} 
	}
	else printf("%llu",k+1);
}

Measured memory_bytes: 256
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N = int(input())
R = 10**5 + 10
IXY = []

for i in range(N):
    x, y = map(int, input().split())
    IXY.append((i, x, y))

X = [[] for _ in range(R)]
Y = [[] for _ in range(R)]
for i, x, y in IXY:
    X[x].append(i)
    Y[y].append(i)

tree = UnionFind(N)

for x in X:
    for fr, to in zip(x, x[1:]):
        tree.union(fr, to)
for y in Y:
    for fr, to in zip(y, y[1:]):
        tree.union(fr, to)

G = [[0, set(), set()] for _ in range(N)]
for i, x, y in IXY:
    r = tree.root(i)
    G[r][0] += 1
    G[r][1].add(x)
    G[r][2].add(y)

ans = 0
for grp in G:
    if grp[0] < 3:
        continue
    x = len(grp[1])
    y = len(grp[2])
    A = x * y
    ans += max(0, A - grp[0])
print(ans)


Measured memory_bytes: 101572
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
	string S;
	cin >> S;
	int upperNum = 0;
	int Cnum = 0;
	for (int i = 0; i < S.size(); i++) {
		if (i == 0 && S[i] != 'A') {
			cout << "WA" << endl;
			return 0;
		}
		if (isupper(S[i]) != 0) {
			upperNum++;
		}
		if (i >= 2 && i <= S.size() - 2 && S[i] == 'C') {
			Cnum++;
		}
	}
	if (Cnum != 1) {
		cout << "WA" << endl;
		return 0;

	}
	if (upperNum != 2) {
		cout << "WA" << endl;
		return 0;
	}

	cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int asumikana, sakuraayane;
	int mimorisuzuko;
	if(scanf("%d%d", &asumikana, &sakuraayane) != 2) return 1;
	for(mimorisuzuko = 0; mimorisuzuko < asumikana - 1; mimorisuzuko++) {
		printf("%d ", mimorisuzuko <= asumikana / 2 ? 0 : sakuraayane);
	}
	printf("%d\n", sakuraayane);
	return 0;
}

Measured memory_bytes: 596
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    ba <- fmap sort $ replicateM m $ do
        [a,b] <- getIntList
        return (b, a)
    print . fst $ foldl' f (0,0) ba

f (l,p) (b,a) | a <= p = (l,p)
              | otherwise = (l+1,b-1)

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

using namespace std;

const int maxn = 300 + 50;

template < typename T >
void Read( T & x ){
	x=0;
	char ch;
	for( ch = getchar() ; ch < '0' || ch > '9' ; ch = getchar() );
	for( ; ch <= '9' && ch >= '0' ; ch = getchar() ) x = x * 10 + ch - '0';
}

int n , a[maxn][maxn];

int main( int argc , char * argv[] ){
	Read( n );
	for(int i = 1 ; i <= n ; ++ i)
		for(int j = 1 ; j <= n ; ++ j)
			Read( a[i][j] );
	long long ans = 0;
	for(int i = 1 ; i <= n ; ++ i)
		for(int j = i + 1 ; j <= n ; ++ j){
			int find = 0;
			for(int k = 1 ; k <= n ; ++ k)
				if( k != i && k != j ){
					int ret = a[i][k] + a[k][j];
					if( ret < a[i][j] ){
						find = -1;
					}else if( ret == a[i][j] )
						find = 1;
				}
			if( find == -1 ){
				puts( "-1" );
				return 0;
			}else if( !find ) ans += a[i][j];
		}
	printf( "%lld\n" , ans );
	return 0;
}

Measured memory_bytes: 640
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    cnt = 0
    manip = []
    for i in range(H):
        for j in range(W - 1):
            if A[i][j] % 2 != 0:
                cnt += 1
                manip.append((i, j, i, j + 1))
                A[i][j] -= 1
                A[i][j + 1] += 1
    
    for i in range(H - 1):
        if A[i][W - 1] % 2 != 0:
            cnt += 1
            manip.append((i, W - 1, i + 1, W - 1))
            A[i][W - 1] -= 1
            A[i + 1][W - 1] += 1
    
    print(cnt)
    for a, b, c, d in manip:
        print("{} {} {} {}".format(a + 1, b + 1, c + 1, d + 1))


                



if __name__ == "__main__":
    main()


Measured memory_bytes: 91224
N = int(input())

A = [list(map(int,input().split())) for i in range(N)]

DP = [[0]*3 for i in range(N+1)]

for i in range(N):
    DP[i+1][0] = A[i][0] + max(DP[i][1],DP[i][2])
    DP[i+1][1] = A[i][1] + max(DP[i][0],DP[i][2])
    DP[i+1][2] = A[i][2] + max(DP[i][0],DP[i][1])

print(max(DP[N]))

Measured memory_bytes: 76376
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()

if n >= m:
    print(0)
else:
    zan=m-n
    y = []
    res = 0
    for i in range(1,m):
        y.append(x[i]-x[i-1])
    
    y.sort()

    for i in range(0,zan):
        res +=y[i]
    
    print(res)

Measured memory_bytes: 13968
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  for (int i = 0; i < 1000; ++i) {
    int c[3] = {i / 100, (i / 10) % 10, i % 10};
    int f = 0;
    for (int j = 0; j < N; ++j) {
      if (S[j] == ('0' + c[f])) {
        ++f;
      }
      if (f == 3) {
        break;
      }
    }
    if (f == 3) {
      ++count;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<bitset>
using namespace std;

int main(){

    int s;
    cin >> s;
    vector<int> v;
    v.push_back(s);
    int cnt=1;
    while(1){
        if(v[v.size()-1]==1||v[v.size()-1]==2||v[v.size()-1]==4){
            cnt += 3;
            break;
        }
        cnt++;
        if(v[v.size()-1]%2==0){
            v.push_back(v[v.size()-1]/2);
        }else{
            v.push_back(v[v.size()-1]*3+1);
        }
    }

    cout << cnt <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<list>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

bool comp(pair<double, string> lhs, pair<double, string> rhs) {
    if (lhs.first == rhs.first)
        return lhs.second < rhs.second;
    else if (lhs.first != rhs.first)
        return lhs.first > rhs.first;
    return lhs.second < rhs.second;
}
int main() {
    int n;
    while (cin >> n && n) {
        vector<pair<double, string> > v(n);
        rep(i, n) {
            cin >> v[i].second;
            double p, a, b, c, d, e, f, s, m;
            cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double time = a + b + c;
            time += (d + e) * m;
            //cout << f * m * s << " " << time << endl;
            v[i].first = (f * m * s - p) / time;
        }
        sort(v.begin(), v.end(), comp);
        rep(i, n) cout << /*v[i].first << " " <<*/ v[i].second << endl;
        cout << "#" << endl;
    }
}








Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int64_t a,b,c; cin >> a >> b >> c;
  if(a==b&&b==c) {
    if(a%2==0&&b%2==0&&c%2==0){
      puts("-1");
      return 0;
    }else{
      puts("0");
      return 0;
    }
  }

  int cont=0;

  while(a%2==0&&b%2==0&&c%2==0){
    int aa,bb,cc;
    aa=b/2+c/2;
    bb=c/2+a/2;
    cc=a/2+b/2;
    a=aa;
    b=bb;
    c=cc;
    cont++;
  }

  cout << cont << endl;
}


Measured memory_bytes: 256
// c++ cpp.cpp -o cpp.exe -std=c++14

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;

int main()
{
	int N;
	cin >> N;
	vector<int> h(N), dp(N, INF);

	rep(i, N)
	{
		cin >> h[i];
	}

	dp[0] = 0;
	rep(i, N - 1)
	{
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		if (i + 2 < N)
		{
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
		}
	}
	cout << dp[N - 1] << endl;
}

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

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

    long long n, k;
    cin >> n >> k;
    vector<long long> arr(n+1);
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        arr[i]+=arr[i-1];
    }

    for(int i=1;i<=n;i++){
        arr[i] = (arr[i]-i)%k;
    }

    long long cnt = 0;
    map <long long, long long> mp;
    for(int i=0;i<=n;i++){
        mp[arr[i]]++;
        if(i>=k){
            mp[arr[i-k]]--;
        }
        cnt+=mp[arr[i]]-1;
    }

    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 14336
import heapq

n, m = map(int, input().split())
edge = [[]] + [[(0, i)] for i in range(n-1)]
for _ in range(m):
  l, r, c = map(int, input().split())
  edge[l-1].append((c, r-1))

inf = 1 << 60
dp = [0] + [inf] * (n - 1)
queue = [(0, 0)]
check = [False] * n
while queue and not check[-1]:
  dist, act = heapq.heappop(queue)
  check[act] = True
  for cost, vertex in edge[act]:
    if check[vertex]:
      continue
    d = dist + cost
    if dp[vertex] > d:
      heapq.heappush(queue, (d, vertex))
      dp[vertex] = d
if dp[-1] < inf:
  print(dp[-1])
else:
  print(-1)

Measured memory_bytes: 45216
import numpy as np

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

kaisa = [1]
for i in range(100):
    kaisa.append(kaisa[-1]+(i+1))


N = int(input())
soinsu = np.array(factorization(N))
tate = soinsu.shape[0]
kaisawa = []
wa = 0
for i in range(100):
    kaisawa.append(((i+2)*(i+1)//2))

for i in range(tate):
    for j in range(100):
        if soinsu[i, 1] < kaisawa[j]:
            wa += j
            break

if N == 1:
    wa = 0

print(wa)

Measured memory_bytes: 27196
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define fid(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pii pair<int,int>
#define TTT "Knapsack1"
#define maxn 105
#define maxm 100005
using namespace std;
int n, W;
ll f[maxm];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(TTT".inp", "r", stdin);
    freopen(TTT".out", "w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> W;
    fi(i, 1, W) f[i] = -1e15;
    int w, v;
    while(n--)
    {
        cin >> w >> v;
        fid(i, W - w, 0)
            f[i + w] = max(f[i + w], f[i] + v);
    }
    ll res = 0;
    fi(i, 1, W) res = max(res, f[i]);
    cout << res;
}


Measured memory_bytes: 4412
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
 
using namespace std;
bool vis[200];
int que[100],sum[100];
int tot;
void get(){
    tot=0;
    for(int i=2;i<=100;i++){
        int tmp=i*i;
        if(!vis[i]){
            que[++tot]=i;
            //cout<<i<<endl;
        if(tmp>100) continue;
            while(tmp<=100){
                vis[tmp]=true;
                tmp+=i;
            }
        }
    }
}
int main(){
    int n;
    get();
    scanf("%d",&n);
    int res=0,ans=0;
    for(int i=1;i<=tot;i++){
        int pp=0;
        for(int j=que[i];j<=n;j+=que[i]){
            int tmp=j;
            while(!(tmp%que[i])){
                pp++;
                tmp/=que[i];
            }
        }
        //cout<<pp<<' '<<i<<endl;
        sum[i]=pp;
        /*if(que[i]>=5){
            if(que[i]*4<=n) ans++,res++;
            else if(que[i]*2<=n) ans++;
        }
        else if(que[i]<5){
            if(que[i]*que[i]<=n) ans++,res++;
            else if(que[i]*2<=n) ans++;
        }*/
    }
    int a=0,b=0,c=0,d=0,p=0;
    //cout<<res<<' '<<ans<<endl;
    for(int i=1;i<=tot;i++){
        if(sum[i]>=74) p++;
        if(sum[i]>=24) a++;
        if(sum[i]>=14) b++;
        if(sum[i]>=4) c++;
        if(sum[i]>=2) d++;
    }
    //cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
    int ANS=a*(d-1);
    ANS+=b*(c-1);
    ANS+=((c-1)*c/2)*(d-2);
    ANS+=p;
    printf("%d\n",ANS);
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> cnt(40);
	for (ll i = 0; i < 40; i++) {
		for (ll j = 0; j < n; j++) {
			if ((1LL << i)&a[j]) {
				cnt[i]++;
			}
		}
	}
	vector<ll> ans(41);
	for (ll i = 0; i <= 40; i++) {
		ll p = k;
		for (ll j = 39; j >= 0; j--) {
			ll t = (1LL << j);
			if (p < t || cnt[j] * 2 >= n || i == j) {
				ans[i] += t * cnt[j];
			}
			else {
				ans[i] += t * (n - cnt[j]);
				p -= t;
			}
		}
	}
	ll res = 0;
	for (auto x : ans) res = max(res, x);
	cout << res << endl;
}

Measured memory_bytes: 1024
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const res = Array.from(Array(n), () => Array.from(Array(n), () => 0));
  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => res[i][e-1] = 1));
  console.log(res.map(r => r.join(' ')).join('\n'));
})();



Measured memory_bytes: 17112
s = input()
zcount = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "0":
            zcount += 1
    else:
        if s[i] != "1":
            zcount += 1
ocount = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "1":
            ocount += 1
    else:
        if s[i] != "0":
            ocount += 1
print(min(zcount, ocount))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    char a, b;
    cin >> a >> b;
    string x = "", y = "";
    rep(i, b - '0') x += a;
    rep(i, a - '0') y += b;
    cout << (x < y ? x : y) << endl;
}

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


Measured memory_bytes: 3552
A, B, C, D, E, F = [int(i) for i in input().split()]
memo = {}

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                water = (100*A)*a + (100*B)*b
                sugar = C*c + D*d

                if (water + sugar) <= F and water > 0:
                    if sugar <= int(water*E/100):
                        density = 100*sugar/(water + sugar)
                        memo[density] = [water + sugar, sugar]

max_density = max(memo)
print(memo[max_density][0], memo[max_density][1])


Measured memory_bytes: 44764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  
  int ans = 1001001001;
  for(int i=-100;i<=100;i++){
    int temp = 0;
    rep(j,n) temp += (i-a[j])*(i-a[j]);  
    ans = min(ans,temp);
  }
  
  cout << ans << endl;
  
  return 0;
}
        

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 100000000000000
#define test int t; cin>>t;
#define MOD 1000000007

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll n;
    cin>>n;
    string s;
    cin>>s;
    int i = 0; 
    int j = n-1;
    ll ans = 0;
    while(i<j){
        while(i<n && s[i] == 'R') i++;
        while(j>=0 && s[j] == 'W') j--;
        if(i<j) ans++,i++,j--;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3764
N = int(input()) 
X = []
btc = 380000
ans = 0
for i in range(N):
    X.append(list(map(str,input().split())))
for i in range(N):
    if X[i][1] == 'BTC':
        ans += float(X[i][0]) * btc
    else:
        ans += int(X[i][0])
print(ans)

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

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

constexpr int MOD = 1000000007;

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

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

    priority_queue<int> queue;
    rep(i, 0, n) {
        int h;
        cin >> h;
        queue.push(h);
    }

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

    rep(i, 0, k) {
        queue.pop();
    }

    ll sum = 0;
    while (!queue.empty()) {
        sum += queue.top();
        queue.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int n;
	cin >> n;
	string str_n;
	str_n = to_string(n);
	for (int i = 0; i < str_n.length(); i++) {
		if (str_n[i] == '1') {
			str_n[i] = '9';
		}
		else if (str_n[i] == '9') {
			str_n[i] = '1';
		}
	}
	cout << stoi(str_n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 998244353



int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif  
 
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      ll n;
      cin>>n;
      cout<<1-n<<"\n";





    }
     
      

      

    

    
return 0;
}     



Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>

int a[110][110],n=0,c,d[110][110];
char s[110][200];

int main(){
	int i,j;n=0;
	while(scanf("%s",s[n])!=EOF){
		c=0;a[n][c]=0;
		for(i=0;i<strlen(s[n]);i++){
			if(s[n][i]==','){
				a[n][c]/=10;
				c++;a[n][c]=0;
			}else{
				a[n][c]+=s[n][i]-'0';
				a[n][c]*=10;
			}
		}
		a[n][c]/=10;n++;
	}
	d[0][0]=a[0][0];
	for(i=1;i<n;i++){
		c=(i>=(n+1)/2)?(n-1-i):i;
		for(j=0;j<=c;j++){
			if(i<(n+1)/2){
				if(j==0)d[i][j]=d[i-1][0]+a[i][j];
				else if(j==i)d[i][j]=d[i-1][j-1]+a[i][j];
				else d[i][j]=(d[i-1][j-1]<d[i-1][j])?d[i-1][j]:d[i-1][j-1],
					d[i][j]+=a[i][j];
			}else d[i][j]=(d[i-1][j+1]<d[i-1][j])?d[i-1][j]:d[i-1][j+1],
				d[i][j]+=a[i][j];
		}
	}
	printf("%d\n",d[n-1][0]);
	return 0;
}

Measured memory_bytes: 0
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set

//#define      ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define        fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define        f first
#define        s second
#define        pb push_back
#define        eb emplace_back
#define        mp  make_pair
#define        forn(i,n) for(int i=0;i<n;++i)
#define        show(b) for(auto const&x: b) cout<<x<<" "
#define        sshow(b) for(auto x:b) cout<<x<<" "
#define        fix(b,val)   memset(b,val,sizeof(b))
#define        pill(b,n,v)  fill(b,b+n,v)
#define        itn          int
#define        w(t)     int t;cin>>t;while(t--)
#define        intmax    INT_MAX
#define        intmin    INT_MIN
#define        nl        "\n"
#define        prt(val)  cout<<val<<"\n"
#define        all(v)    v.begin(),v.end()
#define        vt        vector
#define        trace1(x)                cerr<<#x<<": "<<x<<endl
#define        trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define        trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define        trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define        trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define        trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef       long long int ll;
typedef       long double LD;
typedef       unsigned long long int LL;
typedef       pair<int,int> pii;
typedef       pair<long long int,int> pli;
typedef       pair<int,long long int> pil;
typedef       pair<long long int,long long int> pll;
const int N=1e5+5;
const int mod=1e9+7;
//mt19937 rnd(time(NULL));

/*------Global--------*/

/*-----Functions------*/
template<typename T>
void show2d(const vector<vector<T>>& adj)
{
    for(auto x:adj)
    {
        for(auto y:x)
        { 
           cout<<y<<" ";
        }
    cout<<"\n";
    }
}

ll modexp(ll a,ll b,ll mod)
{
    ll x=1;
    while(b)
    {
        if(b&1)
        x = ((x%mod) * (a%mod))%mod;
        a = ((a%mod) * (a%mod))%mod;
        b = b / 2;
    }
    return x;
}

bool ispalindrome(ll n)
{
    ll rev=0,n1=n;
    while(n1>0)
    {
       rev=rev*10+n1%10;
       n1/=10;
    }
    return (n==rev);
}

void rf()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fast;
   // rf();
    double d,t,s;
    cin>>d>>t>>s;
    double r = d/s;
    if(r <= t)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,x;
    cin>>n>>x;
    ll a=0,ans=1,y;
    for(ll i=0;i<n;i++)
    {
        cin>>y;
        a+=y;
        if(a<=x)
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

inline int ctoi(const char c)
{
	return c >= '0'&&c <= '9' ? c - '0' : -1;
}

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

	string n_str = to_string(n);

	int sn = 0;
	int i;


	for (i = 0; i < n_str.size(); i++) {
		sn += ctoi(n_str[i]);
	}

	if (n%sn == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def f(a,d,T):
    try:
        return T.index(a,d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0

A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))

T=[0]
for i in range(D):
    T.append(int(input()))
            
X=0
L=[0]*(A+1)
for d in range(1,D+1):
    X+=S[d][T[d]]
    for j in range(1,A+1):
        if j!=T[d]:
            L[j]+=1
            X-=C[j]*L[j]
        else:
            L[j]=0

M=int(input())
for _ in range(M):
    d,q=map(int,input().split())
    p=T[d]

    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
    
    T[d]=q
    X+=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    print(X)

Measured memory_bytes: 77580