akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.begin(), v.end(), greater<int>);
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
*/

int main(){
    int n;
    int cntf = 0, cntt = 0, cnto = 0;
    cin >> n;
    REP(i, n){
        int a;
        cin >> a;
        if(a % 4 == 0){
            cntf++;
        }else if(a % 2 == 0){
            cntt++;
        }else{
            cnto++;
        }
    }
    if(cntt == 0){
        if(cnto <= cntf + 1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(cnto <= cntf){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    
    int n, l;
    cin >> n >> l;
    vector <string> msg(n);
    for (int i = 0; i< n;i++) {
        cin>>msg[i];
    }
    sort(msg.begin(), msg.end());
  
  for (auto i: msg) {
    cout<< i;
      
  }
    cout<< endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<numeric>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
#define MOD 1000000007
int main(){
	int n,k;
	int ans=0;
	int h;
	cin>>n>>k;
	rep(i,n){
		cin>>h;
		if(h>=k) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// 白の右に赤があるとだめと読み替える
// RRRR...WWWWWみたいなのはOK

int main(){
    Init();
    ll n, ans = INFLL; cin >> n;
    string s; cin >> s;

    // 0; R, 1; W
    vi cnt(2, 0);
    // 片方の色に揃えるパターン
    rep(i, n) s[i] == 'R' ? cnt[0]++ : cnt[1]++;
    ans = min(cnt[0], cnt[1]);
    
    // 逆順で何箇所Wにしなきゃいけないか
    vi chgcnt(n+1, 0);
    for(ll i=n-1; i>=0; i--){
        chgcnt[i] = chgcnt[i+1];
        if(s[i] == 'R') chgcnt[i]++;
    }
    ll cntw = 0;
    rep(i, n){
        if(s[i] == 'W') cntw++;
        chmin(ans, max(chgcnt[i+1], cntw));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5176
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    x, a = map(int, input().split())

    if x < a:
        print(0)
    else:
        print(10)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5536
n, k, s = gets.chomp.split.map(&:to_i)
ans = []
k.times do
  ans.push(s)
end
(n-k).times do
  if s == 10 ** 9
    ans.push(10**9 - 1)
  else
    ans.push(10**9)
  end
end
puts ans.join(' ')


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  if (h <= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
n, m = gets.chomp.split.map(&:to_i)

a = []
b = []
m.times do |i|
  a[i], b[i] = gets.chomp.split.map(&:to_i)
end

t = []
(n+1).times do |i|
  t[i] = []
end

m.times do |i|
  t[a[i]].push(b[i])
end

t[1].each do |u|
  if t[u].include?(n)
    puts 'POSSIBLE'
    exit
  end
end
puts 'IMPOSSIBLE'


Measured memory_bytes: 16876
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    S = input()

    ans = 0
    cs = int(S[0])

    for s in S[1:]:
        s = int(s)
        if s == cs:
            ans += 1
            cs = 1 - s
        else:
            cs = s

    print(ans)


main()


Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	if (c - a - b > 0 && 4 * a*b < (c - b - a)*(c - b - a))cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt() % 10;
    if (n == 3) {
      System.out.println("bon");
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
      System.out.println("pon");
    } else {
      System.out.println("hon");
    }
  }
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define REV(n) reverse(n.begin(), n.end())
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, d, e, f, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  vi a(n);
  cin >> a;
  SORT(a);
  REV(a);
  rep(i, 0, n)
  {
    if (i % 2 == 0)
    {
      ans += a[i];
    }
    else
    {
      ans -= a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c, i;
	scanf("%d %d %d", &a, &b, &c);
	i=0;
	while (a<=b)
	{
		if (c%a==0) {
			i++;
		}
		a++;
	}
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int x,t;
  cin>>x>>t;
  cout<<max(x-t,0);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

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

    int count = 0;
    for(int i = 0; i < n; ++i){
        if(1 == std::to_string(i + 1).length() % 2){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;
const ll inf = 1e17;

vector < ll > parent(MAXN), sz(MAXN);

void make_set(int u){
  parent[u] = u;
  sz[u] = 1;
}

int find_set(int u){
  if(u == parent[u]) return u;
  return parent[u] = find_set(parent[u]);
}

void union_sets(int u , int v){
  u = find_set(u);
  v = find_set(v);
  if(u != v){
    if(sz[u] > sz[v]) swap(u, v);
    parent[u] = v;
    sz[v] += sz[u];
  }
}

struct Edge{
  ll u, v, wt;
  bool operator < (Edge const& other) const{
    return wt < other.wt;
  }
};

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

  ll n;
  cin >> n;
  vector < pair < ll, ll > > x, y;
  for(int i = 1; i <= n; i++){
    ll a, b;
    cin >> a >> b;
    x.push_back({a, i});
    y.push_back({b, i});
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  vector < Edge > edges;

  for(int i = 1; i < n; i++){
    edges.push_back({x[i].second, x[i - 1].second, x[i].first - x[i - 1].first});
    edges.push_back({y[i].second, y[i - 1].second, y[i].first - y[i - 1].first});
  }

  sort(edges.begin(), edges.end());

  for(int i = 1; i <= n; i++) make_set(i);

  ll total_wt = 0;
  for(Edge e : edges){
    if(find_set(e.u) != find_set(e.v)){
      total_wt += e.wt;
      union_sets(e.u, e.v);
    }
  }

  cout << total_wt << '\n';
}


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

int main(){ 
  int n,x,d=0,cnt=0,sum=0,result=1,mini=101;
  cin >> n >> x;
  for(int i=0;i<n;i++){
    sum+=x;
    if(abs(x)<abs(mini)) mini=x;
    x++;
  }
  result=sum-mini;
  
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int ac[100000] = {};
  int wa[100000] = {};
  int c_ac = 0, c_pt = 0;
  REP(i, M) {
    int P;
    string S;
    cin >> P >> S;
    P--;
    if(!ac[P]) {
      if(S == "AC") {
        ac[P] = true;
        c_ac++;
      } else {
        wa[P]++;
      }
    }
  }
  REP(i, N) {
    if(ac[i])
      c_pt += wa[i];
  }
  cout << c_ac << " " << c_pt << endl;
}

Measured memory_bytes: 1152
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    int now = 1;
    int res = 0;
    while (1) {
        if (now == str.size() || str.size() == 0) break;
        if (str[now] != str[now - 1]) {
            res += 2;
            str.erase(now - 1, 2);
            now = max(1, now - 2);
        } else {
            ++now;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 512
// #include<bits/stdc++.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<cstdio>
#include<bitset>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

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

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e6+7;


struct node{
        ll a,b;
        bool operator < (const node &x)const {
                return x.b==b?x.a<a:x.b>b;
                // return x.a==a ? x.b>b : x.a<a;
        }
}z[MAXN];

bool cmp(node x,node y) {
        return x.a==y.a?x.b>y.b:x.a<y.a;
}
int main(){
       // freopen("../in.txt","r",stdin);
      //  freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n,m;
        while(cin>>n>>m) {
                priority_queue<node> que;
                for(int i=0;i<n;++i) {
                        cin>>z[i].a>>z[i].b;
                        // que.push(z[i]);
                }
                // while(!que.empty()) {
                //         node e = que.top();que.pop();
                //         cout<<e.a<<" "<<e.b<<endl;
                // }
                // cout<<endl;
                sort(z,z+n,cmp);
                // for(int i=0;i<n;++i)
                //         cout<<z[i].a<<" "<<z[i].b<<endl;
                int ans = 0;
                int id = 0;
                for(int i=1;i<=m;++i) {
                        while(z[id].a<=i && id<n){
                                que.push(z[id]);

                                id++;
                        }
                        if(que.empty()) continue;
                        node e = que.top();que.pop();
                        // cout<<e.a<<" "<<e.b<<endl;
                        ans += e.b;
                }
                // while(!que.empty()) {
                //         node e = que.top();que.pop();
                //         cout<<e.a<<" "<<e.b<<endl;
                // }
                // cout<<endl;
                cout<<ans<<endl;

         }
        return 0;
}


Measured memory_bytes: 3956
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
struct edge{
    int to;
    ll cost;
};
vector<edge> g[5000];
int dp[5000][5000];
void dfs(const int s, int par,int t){
    for(auto &x : g[t]){
        if(x.to == par)continue;
        dp[s][x.to] = max(dp[s][t], (int)x.cost);
        dfs(s,t,x.to);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<pair<ll,pii>>e;
    while(m--){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--,b--;
        e.push_back({c,{a,b}});
    }
    sort(e.begin(),e.end());
    UnionFind uf(n);
    ll sum = 0;
    for(auto &x: e){
        if(!uf.same(x.second.first,x.second.second)){
            uf.unite(x.second.first,x.second.second);
            sum += x.first;
            int a = x.second.first;
            int b = x.second.second;
            ll c = x.first;
            g[a].push_back((edge){b,c});
            g[b].push_back((edge){a,c});
        }
    }
    show(sum);
    rep(i,n)dfs(i,-1,i);
    int q;
    cin >> q;
    while(q--){
        int s,t;
        cin >> s >> t;
        s--,t--;
        cout << sum - dp[s][t] << "\n";
    }
}

Measured memory_bytes: 89704
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, M = [int(x) for x in stdin.readline().rstrip().split()]

LR = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]

data = [i for i in range(N+1)]
max_L = 0
min_R = INF

for L, R in LR:
    max_L = max(max_L, L)
    min_R = min(min_R, R)

print(len(data[max_L:min_R+1]))


Measured memory_bytes: 87532
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

ll solve(vector<ll> a, vector<ll> f, ll n, ll k, ll l, ll r){
    if(r-l == 1){
        ll x = l;
        ll temp_sum = 0;
        rep(i,n){
            if(!f[i])continue;
            ll temp = x/f[i];
            if(temp < a[i])temp_sum += a[i] - temp;
        }
        if(k < temp_sum) return r;
        else return l;
    }
    ll x = (l + r) / 2;
    ll temp_sum = 0;
    rep(i,n){
        if(!f[i])continue;
        ll temp = x/f[i];
        if(temp < a[i])temp_sum += a[i] - temp;
    }
    if(k < temp_sum) return solve(a,f,n,k,x,r);
    else return solve(a,f,n,k,l,x);
}
int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> f(n);
    rep(i,n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());
    ll mm = 0;
    rep(i,n)mm = max(mm, a[i] * f[i]);
    cout << solve(a,f,n,k,0,mm) << endl;
    return 0;
}

Measured memory_bytes: 131584
fun main(args: Array<String>) = ABC166A.main()

object ABC166A {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val s = readString()
        val ans = if (s == "ABC") "ARC" else "ABC"
        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 34544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] g = new int[N][N];
		// 初期化(i番目の人は証言していない)
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				g[i][j] = -1;
			}
		}
		// 証言の入力
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			for(int j = 0; j < A; j++) {
				int X = sc.nextInt(); // X番目の人に対して
				int Y = sc.nextInt(); // 正直者(1)か不親切(0)であるか証言する
				g[i][X - 1] = Y;			
			}
		}
		sc.close();

		// System.out.println("-------------------");
		// for(int i = 0; i < N; i++) {
		// 	System.out.print((i + 1) + " Number = ");
		// 	for(int j = 0; j < N; j++) {
		// 		System.out.print("[" + (j + 1) + "]" + String.format("%2d", g[i][j]) + " ");
		// 	}
		// 	System.out.println("");
		// }
		// System.out.println("N^2 = " + (1 << N));
		// System.out.println("-------------------");

		int r = 0;
		// N^2のループ
		for(int i = 0; i < (1 << N); i++) {
			int[] d = new int[N];
			for(int j = 0; j < N; j++) {
				d[j] = i >> j & 1;
			}

			boolean ok = true;
			for(int j = 0; j < N; j++) {
				// 正直者と割当した場合
				if(d[j] == 1) {
					for(int k = 0; k < N; k++) {
						if(g[j][k] == -1) continue;
						if(g[j][k] != d[k]) ok = false;
					}
				}
			}
			if(ok) r = Math.max(r, Integer.bitCount(i));
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 25096
//  Author: Tanuj Johal
//  It's a show time, Enjoy your everyday.

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         1e18
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}
#define run_time cout << "\nTIME = " << clock() - tt << endl; tt = clock();

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;
ll tt;
const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 1e5+10;
ll dx[4]={-1, +1, 0, 0};
ll dy[4]={0, 0, +1, -1};
bool imp = false;


void solve(){
    ll l,r,d;
    cin>>l>>r>>d;
    ll ans =0;
    for(ll i=l;i<=r;i++){
        if(i%d==0)
            ans++;
    }
    cout << ans << endl;

}

int main()
{
 #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
 #endif
    fio
    int t=1;
    if(imp) cin>>t;
    tt = clock();
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }
//    run_time;

}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

static int ANS = 0;

void DFS(int V,vector<vector<int> >&GRAPH,vector<int> used)
{
  // if(used[V] == 1)return;
  used[V] = 1;
  // DEBUG(V);
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(used[GRAPH[V][i]] == 0)
    {
      DFS(GRAPH[V][i],GRAPH,used);
    }
  }
  int check = 1;
  for (int i = 0; i < used.size(); i++)
  {
    check *= (int)used[i];
  }
  ANS += check;
  
  return;
}

void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<int> > GRAPH(N);
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
  vector<int> used(N,0);

  DFS(0,GRAPH,used);
  cout<<ANS<<endl;
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int max_i = -1;
    int max = -1;
    int ret=0;
    
    cin >> N;
    
    int p[N];
    for(int i=0;i<N;i++){
        cin >> p[i];
        if(max<p[i]){
            max_i = i;
            max = p[i];
        }
    }
    p[max_i] /= 2;
    for(int i=0;i<N;i++){
        ret += p[i];
    }
    
    cout << ret << endl;
}


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

using namespace std;

int main()
{
    int N,i,cnt=0;
    cin>>N;
    vector<int> p(N);
    vector<int> q(N);
    for(i=0; i<N; i++){
        cin>>p[i];
        q[i]=p[i];
    }
    sort(p.begin(),p.end());
    for(i=0; i<N; i++){
        if(p[i]!=q[i])cnt++;
    }
    if(cnt<=2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include <cstdlib>
#include<stdlib.h>
using namespace std;
    

int main(){
    string str;
    cin >> str;
    vector<string> n_ary;

    for (int i = 0; i <= (str.length() - 3); i++) {
        string temp;
        temp = str[i];
        temp += str[i + 1];
        temp += str[i + 2];
        n_ary.push_back(temp);
    }

    string closest = n_ary.front();
    
    int close_abs = 9999;
    for (auto s: n_ary) {
        int temp = abs( 753 - stoi(s) );
        if (temp < close_abs)
            close_abs = temp;
    }
    
    cout << close_abs << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double eps = 1e-9;


void solve()
{
    /*
    I fear not the man who has practiced 10,000 kicks once,
    but I fear the man who has practiced one kick 10,000 times.
    */

    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++)
    {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << "\n";
}

int main()
{
    // BOOST;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 19356
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    S = [int(s) for s in input()]

    ret = 0
    for i in range(1000):
        code = [int(i / 10 ** j) % 10 for j in range(2, -1, -1)]
        # print(code)
        j = 0
        for s in S:
            if code[j] == s:
                j += 1
            if j == 3:
                break
        if j == 3:
            ret += 1
    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3444
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

	class Program
	{
		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			var N = inputNum[0];
			var M = inputNum[1];

			var inputNum2 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			// 合計値
			var total = inputNum2.Sum();

			// 条件
//			var rate = (total / (4 * M));

			var overRateNum = inputNum2.Where(x => x * 4 * M >= total).Count();

			if (overRateNum >= M)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}

		public static long Gcd(long a, long b)
		{
			if (a < b)
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;				
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

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

#define INF (INT_MAX>>4)

int main()
{
    int N, M; cin >> N >> M;
    vector<vector<int>> cost(N, vector<int>(N, INF));
    vector<pair<pair<int,int>,int>> ab_c;
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        cost[a][b] = cost[b][a] = c;
        ab_c.emplace_back(make_pair(a, b), c);
    }
    for (int i = 0; i < N; i++) {
        cost[i][i] = 0;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    int ans = 0;
    for (const auto& p : ab_c) {
        int a = p.first.first, b = p.first.second, c = p.second;
        bool including = false;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (cost[i][j] == cost[i][a] + c + cost[b][j]) {
                    including = true;
                    break;
                } 
            }
            if (including) break;
        }
        if (!including) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int calc(int types[], int D, int c[], int s[][27])
{
    int last[27];
    for (int i = 1; i <= 26; i++)
    {
        last[i] = 0;
    }
    int satisfy = 0;
    for (int d = 1; d <= D; d++)
    {
        int today = types[d];
        satisfy += s[d][today];
        last[today] = d;
        for (int i = 1; i <= 26; i++)
        {
            satisfy -= c[i] * (d - last[i]);
        }
        //cout << satisfy << endl;
    }
    return satisfy;
}

int d_calc(int types_old[], int D, int c[], int d, int q)
{
    int type_old = types_old[d];
    int type_new = q;
    int last_old[27];
    int last_new[27];
    int diff = 0;

    for (int i = 1; i <= 26; i++)
    {
        last_new[i] = 0;
        last_old[i] = 0;
    }

    int types_new[D];
    for (int i = 1; i <= D; i++)
    {
        if (i == d)
        {
            types_new[i] = q;
            continue;
        }
        types_new[i] = types_old[i];
    }

    for (int e = 1; e <= D; e++)
    {
        if (types_old[e] == type_old)
        {
            last_old[type_old] = e;
        }
        if (types_old[e] == type_new)
        {
            last_old[type_new] = e;
        }
        if (types_new[e] == type_old)
        {
            last_new[type_old] = e;
        }
        if (types_new[e] == type_new)
        {
            last_new[type_new] = e;
        }
        diff -= c[type_new] * (last_old[type_new] - last_new[type_new]);
        diff -= c[type_old] * (last_old[type_old] - last_new[type_old]);
    }
    return diff;
}

int main()
{
    int D;
    cin >> D;
    int c[26 + 1];
    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }
    int s[D + 1][26 + 1];
    for (int d = 1; d <= D; d++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[d][j];
        }
    }

    int t[D + 1];
    for (int d = 1; d <= D; d++)
    {
        cin >> t[d];
    }

    int M;
    cin >> M;
    int d[M + 1];
    int q[M + 1];
    for (int i = 1; i <= M; i++)
    {
        cin >> d[i] >> q[i];
    }

    int satisfy = calc(t, D, c, s);
    for (int i = 1; i <= M; i++)
    {
        satisfy += (s[d[i]][q[i]] - s[d[i]][t[d[i]]]);
        satisfy += d_calc(t, D, c, d[i], q[i]);
        t[d[i]] = q[i];
        cout << satisfy << endl;
    }

    return 0;
}

Measured memory_bytes: 4348
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
	int n;

	cin >> n;

	vector<int> x(n + 1, 0), y(n + 1, 0);

	for (int i = 0; i < n; i++){
		cin >> x[i + 1];
		y[i + 1] = x[i + 1];
	}


	sort(y.begin(), y.end());
	reverse(y.begin(), y.end());


	int mid = y[n/2-1];;


	for (int i = 1; i < n + 1; i++){
		if (x[i] < mid){
			cout << mid << endl;
		}
		else 
			cout << y[n/2] << endl;
	}
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define mem(a,b) memset(a,b,sizeof(a))
#define watch(x) cout<<(#x)<<" is "<<x<<endl
#define endl "\n"

ll gcd(ll a, ll b){
	return (!b)?a:gcd(b,a%b);
}

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

int main(){
	IOS
	string s;
	ll counter;
	cin>>s;
	ll n=s.size();
	vi v(n);
	counter=1;
	loop(0,n-1,1){
		if(s[i]=='L'){
			v[i]=-counter;
			counter++;
		}
		else counter=1;
	}
	counter=1;
	rloop(n-1,0,1){
		if(s[i]=='R'){
			v[i]=counter;
			counter++;
		}
		else counter=1;
	}
	vi ans(n,0);
	loop(0,n-1,1){
		if(v[i]%2==0){
			ans[i+v[i]]++;
		}
		else{
			if(v[i]<0) ans[i+v[i]+1]++;
			else ans[i+v[i]-1]++;
		}
	}
	display(ans," ");
	return 0;
}


Measured memory_bytes: 2256
X = int(input())
ans = 0
tmp = str(X)
if len(tmp) > 2:
    upper = int(tmp[:-2])
    under = int(tmp[-2:])
    if upper * 5 < under:
        ans = 0
    else:
        ans = 1
else:
    ans = 0

print(ans)

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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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;
}

template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int main() {
  int N,C,s,t,c;
  cin >> N >> C;
  vector<vector<int>> pp(1e5,vector<int>(C,0)); 
  rep(i,N){
    cin >> s >> t >> c;
    c--;s--;t--;
    pp[s][c] += 1;
    pp[t][c] -= 1;
  }

  vector<int> memo(C,0);
  int ans=0;
  rep(i,1e5) {
    rep(j,C) {
      if (pp[i][j]==1) memo[j]=1;
      }
    chmax(ans,accumulate(memo.begin(),memo.end(),0));
    rep(j,C) {
      if (pp[i][j]==-1) memo[j]=0;
      }
  }

  cout << ans << endl;
}

Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cShaprTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var M = int.Parse(input[1]);

            //   Tuple<int, int>[] tupleArray = new Tuple<int, int>[N];
            List<Tuple<long, long>> list = new List<Tuple<long, long>>();

            for (var i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split(' ');
                list.Add(new Tuple<long, long>(long.Parse(input[0]), long.Parse(input[1])));
            }

            list = list.OrderBy(i => i.Item1).ToList();

            long sum = 0;
            long count = M;
            foreach(var element in list)
            {
                if (count == 0) break;

                var currentCount = Math.Min(count, element.Item2);
                sum += element.Item1 * currentCount;
                count -= currentCount;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27844
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,c=0;
    cin>>n;
    ll a[n+1];
    for(int i=1;i<=n;i++)
    {
      ll x;
      cin>>x;
      if(x&1&&i&1)
        c++;
    }
    cout<<c<<endl;
}
return 0;
}

Measured memory_bytes: 3636
import java.util.*
//import kotlin.math.*
 
private fun readString() = readLine()!! // string line
private fun readInt() = readString().toInt() // single int
private fun readLong() = readString().toLong()
private fun readStrings() = readString().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
 
val INF = 1000000000
 
fun main(args: Array<String>)
{
    var n = readInt()
	var a = readInts().toTypedArray()
	var b = readInts().toTypedArray()
	var c = readInts().toTypedArray()
	var ret = 0
	var last = -2
	for (x in a)
	{
		var cur = x-1
		ret += b[cur]
		if (last+1 == cur) ret += c[last]
		last = cur
	}
	print(ret)
}


Measured memory_bytes: 37872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ar[500005],br[500005],cr[500005];
int main()
{
    ll a,b;
    cin >> a >> b;
    ll c = 0;
    for(int i=1; i<=sqrt(a); i++)
    {
        if(a%i==0)
        {
            ar[++c]=i;
            if(i!=(a/i))
            {
                ar[++c]=(a/i);
            }
        }
    }
    ll x = 0;
    for(int i=1; i<=sqrt(b); i++)
    {
        if(b%i==0)
        {
            br[++x]=i;
            if(i!=(b/i))
            {
                br[++x]=(b/i);
            }
        }
    }
    ll d=0;
    for(int i=1; i<=c; i++)
    {
        for(int j=1; j<=x; j++)
        {
            if(ar[i]==br[j])
            {
                cr[++d]=ar[i];
                break;
            }
        }
    }
    sort(cr+1,cr+d+1);
    ll cnt = 0;
    for(int i=1; i<=d; i++)
    {
        ll ck=0;
        for(int j=1; j<i; j++)
        {
            ll m = __gcd(cr[i],cr[j]);
            if(m>1)
            {
                ck=1;
                break;
            }
        }
        if(ck==0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4352
#include<stdio.h>
int dp[50][3001];
int main(){
	int n,m,s;
	int i,j,k;
	while(1){
	scanf("%d %d %d",&n,&m,&s);
	if(n==0)return 0;
	for(i=0;i<=n*n;i++)for(j=0;j<=s;j++)dp[i][j]=0;
	dp[0][0]=1;
	for(i=1;i<=m;i++){
		for(j=s;j>=0;j--){
			if(j+i<=s){
				for(k=0;k<n*n;k++){
					dp[k+1][j+i]=(dp[k+1][j+i]+dp[k][j])%100000;
				}
			}
		}
	}
	printf("%d\n",dp[n*n][s]);
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
#define mod 998244353 
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int binaryS(ll x, ll sb[], int m){
    int l = 0, r=m;
    int mid = (l+r)/2;
    while(l<r){
        mid = (l+r)/2;
        if(sb[mid]<x) l= mid+1;
        else if(sb[mid]>x) r = mid-1;
        else return mid;
    }
    return l;
}
int main(){
    fastio;
    string s; cin>>s;
    ll su = 0;
    rep(i,0,si(s)){
        su+=(s[i]-'0');
    }
    if(su%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}





Measured memory_bytes: 3780
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    int max = -1;
    rep(i, s.size()-t.size()+1){
        int cnt = 0;
        rep(j, t.size()){
            if(s[i+j] == t[j]) cnt++;
        }
        if(max < cnt) max = cnt;
    }
    int ans = t.size() - max;
    cout << ans << endl;
}

Measured memory_bytes: 3608