akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){

	int max1=0,max2=0,max3=0;
	int montain[10] = { 0 };
	int tmp = 0,i,j;

	for (i = 0; i < 10; i++){
		scanf("%d", &montain[i]);
	}

	for (i = 0; i < 9; i++){
		for (j = 9; j > i; j--){
			if (montain[j - 1] > montain[j]){
				tmp = montain[j];
				montain[j] = montain[j - 1];
				montain[j - 1] = tmp;
			}
		}
	}

	printf("%d\n%d\n%d\n", montain[9], montain[8], montain[7]);

	return 0;
	
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}




bool vaild(char ch){




	return ch=='A' or ch=='C' or ch=='G' or ch=='T';
}

int main() {
    int i,n,m,k,c=0;
    c_p_c();
    string s;
    cin>>s;

    int maxa=0;

    for (int i = 0; i < s.size(); ++i)
    {
    	/* code */
    	if(vaild(s[i])){
    		c++;
    		maxa=max(maxa,c);
    	}
    	else
    		c=0;
    }
    cout<<maxa<<endl;
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*ここから*/
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> v(H, vector<int>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char w;
            cin >> w;
            if(w=='#'){
                v[i][j]=1;
            }else{
                v[i][j]=0;
            }
        }
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int count=0;
            if(v[i][j]==0){
                for(int k=i;k<H;k++){
                    if(v[k][j]==1){
                        break;
                    }
                    count++;
                }
                for(int k=i;k>=0;k--){
                    if(v[k][j]==1){
                        break;
                    }
                    count++;
                }
                for(int k=j;k<W;k++){
                    if(v[i][k]==1){
                        break;
                    }
                    count++;
                }
                for(int k=j;k>=0;k--){
                    if(v[i][k]==1){
                        break;
                    }
                    count++;
                }
            }
            if(ans<count){
                ans = count;
            }
            if(ans==H+W+2){
                break;
            }
        }
    }
    ans -= 3;
    cout << ans << endl;
}

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

int main() {
  int  N;
  cin >> N;
  vector<int> numbers(N);
  for (int i = 0; i < N; i++) {
    cin >> numbers.at(i);
  }
  bool loop = true;
  int cnt = 0;
  while (loop) {
    for (int i = 0; i < N; i++) {
      if (numbers.at(i) % 2 == 0) {
        numbers.at(i) /= 2;
      }
      else {
        loop = false;
        break;
      }
    }
    cnt++;
  }
  cout << cnt - 1 << endl;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
# (上から, 左右から)の通り数
memo = [[0]*w for i in range(h+1)]
for i in range(0, w):
    memo[0][i] = 0
memo[0][0] = 1

# print(memo)

for i in range(1, h+1):
    for j in range(0, 1 << (w-1)):
        skip = False
        for l in range(w-2):
            skip = skip or ((j >> l) & 1 and (j >> (l+1)) & 1)
        # print(skip)
        if not skip:
            for l in range(w):
                if l-1 >= 0 and (j >> (l-1)) & 1:
                    memo[i][l] += memo[i-1][l-1]
                elif l+1 < w and (j >> l) & 1:
                    memo[i][l] += memo[i-1][l+1]
                else:
                    memo[i][l] += memo[i-1][l]
                memo[i][l] = memo[i][l] % 1000000007

# print(memo)
print(memo[h][k-1])


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n; cin >> n;
    set<string> st;
    rep(i,n){
        string s; cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}   

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

long long int temp[100000];
void MergeSort(long long int x[ ],long long int left,long long int right)
{
    long long int mid, i, j, k;

    if (left >= right)              /* 配列の要素がひとつなら */
        return;                     /* 何もしないで戻る */

                                    /* ここでは分割しているだけ */
    mid = (left + right) / 2;       /* 中央の値より */
    MergeSort(x, left, mid);        /* 左を再帰呼び出し */
    MergeSort(x, mid + 1, right);   /* 右を再帰呼び出し */

      /* x[left] から x[mid] を作業領域にコピー */
    for (i = left; i <= mid; i++)
        temp[i] = x[i];

      /* x[mid + 1] から x[right] は逆順にコピー */
    for (i = mid + 1, j = right; i <= right; i++, j--)
        temp[i] = x[j];

    i = left;         /* i とj は作業領域のデーターを */
    j = right;        /* k は配列の要素を指している */

    for (k = left; k <= right; k++)    /* 小さい方から配列に戻す */
        if (temp[i] <= temp[j])        /* ここでソートされる */
            x[k] = temp[i++];
        else
            x[k] = temp[j--];
}


int main (void){
int N;
long long int max;
long long int ans;
long long int A[100000];
scanf("%d",&N);
for (int i = 0; i < N; i++) {
        scanf("%lld",&A[i]);
}
MergeSort(A, 0, N-1);
max=A[N-1]/2;
if (N==2) {
  ans=A[0];
}else{
for (int i = 1; i < N-1; i++) {
if (max<=A[i]) {
  if (A[i]-max<=max-A[i-1]) {
    ans=A[i];
  }else{
    ans=A[i-1];
  }
  break;
}
}
}
printf("%lld %lld\n",A[N-1],ans);
        return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int s; cin>>s;
	set<int> st;
	int cur=1;
	while(!st.count(s)) {
		st.insert(s);
		cur++;
		if(s%2) s=3*s+1;
		else s/=2;
	}
	cout<<cur<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int px;
        int result;
        ArrayList inputList = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            px = Math.abs(sc.nextInt() - X);
            inputList.add(px);
        }
        Collections.sort(inputList, Comparator.reverseOrder());
        result = (int) inputList.get(0);

        for(int i=1; i<inputList.size(); i++){
            result = gcd(result, (int) inputList.get(i));

        }

        System.out.println(result);
    }
    static int gcd(int x, int y){
        if(x%y == 0) {
            return y;
        }
        return gcd(y,x%y);
    }


}

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

using namespace std;
typedef long long ll;

ll N,W;
ll w[101];
ll v[101];
ll dp[101][100002];

int main(){
    cin >> N >> W;
    ll V = N * 1000 + 1;
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];
    for(int i=0;i<=V;i++) dp[0][i] = 1e15;
    for(int i=1;i<=N;i++) dp[i][V] = 1e15;
    dp[0][0] = 0;
    for(int i=1;i<=N;i++){
        for(int j=V-1;j>=0;j--){
            dp[i][j] = min(dp[i-1][j], dp[i][j+1]);
            if(j - v[i-1] >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
            }
        }
    }
    for(int i=V;i>=0;i--){
        if(dp[N][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 79104
K = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c[3];
    cin >> a >> b;
    c[0] = a+b;
    c[1] = a-b;
    c[2] = a*b;
    sort(c, c+3);
    cout << c[2];
}

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

double cross(complex<double> z1, complex<double> z2) {
    return (z1.real()*z2.imag() - z1.imag()*z2.real());
}
 
int main(int argc, char** argv) {
    static const double EPS = 1e-10;
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        double x[4], y[4];
        for(int j=0; j<4; j++) {
            cin >> x[j] >> y[j];
        }
        complex<double> ab(x[1]-x[0], y[1]-y[0]);
        complex<double> cd(x[3]-x[2], y[3]-y[2]);
        if(abs(cross(ab, cd)) < EPS) { // 外積が0なら平行
            cout << "YES" << endl;
        }else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)


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

	printf("%s", (r >= 1200) ? "ARC" : "ABC");

	return 0;
}


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

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s)
    {
        cout << --a << " " << b;
    }
    else
    {
        cout << a << " " << --b;
    }

    return 0;
}


Measured memory_bytes: 256
n,m,x = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]


ans = 10**10

for bit in range(1<<n):
    b = [0]*m
    c =0
    for i in range(n):
        if bit & 1<<i:
            for j in range(m):
                b[j]+=a[i][j+1]
            c += a[i][0]
    if min(b)>=x:
        ans = min(ans,c)

if ans == 10**10:
    print(-1)
else:
    print(ans)

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

const double PHI = (1 + sqrt(5)) / 2;

int N;
int X[50], Y[50];

template <class F>
double f(double a, double b, F f) {
  for (auto e = (PHI - 2) * (a - b), c = a + e, d = b - e; c < d; e *= PHI - 1) {
    if (f(c) < f(d)) {
      b = d;
      d = c;
      c = b - e;
    } else {
      a = c;
      c = d;
      d = a + e;
    }
  }
  return f((a + b) / 2);
}

int main() {
  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i];
  printf("%.13f\n", sqrt(f(0, 1000, [](double x) {
           return f(0, 1000, [=](double y) {
             double r = 0;
             rep(i, N) {
               auto dx = X[i] - x, dy = Y[i] - y;
               r = max(r, dx * dx + dy * dy);
             }
             return r;
           });
         })));
  return 0;
}


Measured memory_bytes: 256
arr = []

while (s = gets)
  arr += s.chomp.chars
end

map = {}
('a'..'z').each do |a|
  map[a] = 0
end

arr.each do |ch|
  ch.downcase!
  map[ch] += 1 if map.key?(ch)
end

map.each do |k, v|
  puts "#{k} : #{v}"
end



Measured memory_bytes: 6876
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int N, M;
    vector<int> A(200010), B(200010);
    vector<set<int>> S(100010);
    cin >> N >> M;
    for (int i=0;i<M;i++) cin >> A[i] >> B[i];
    for (int i=0;i<M;i++) {
        S[A[i]].insert(B[i]);
        S[B[i]].insert(A[i]);
    }

    queue<int> Q;
    vector<bool> C(100010,false);
    vector<int> G(100010,0);
    Q.push(1);
    C[1] = true;
    bool flag = false;
    while (!Q.empty()) {
        int x = Q.front();
        Q.pop();
        for (auto itr: S[x]) {
            if (!C[itr]) {
                C[itr] = true;
                Q.push(itr);
            }
            if (!G[itr]) G[itr] = x;
        }
    }
    cout << "Yes" << endl;
    for (int i=2;i<=N;i++) {
        cout << G[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 28968
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut acc = vec![0; N];
    acc[0] = A[0];
    for i in 1..N {
        acc[i] = acc[i - 1] + A[i];
    }
    let ans = (1..N)
        .map(|i| (acc[i - 1] - (acc[N - 1] - acc[i - 1])).abs())
        .min()
        .unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 10492
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

ll mod=1e9+7;

ll fact(int n)
{
    ll tot=1;
    FOR(i,1,n+1)
    {
        tot=(tot*i)%mod;
    }
    return tot;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s[0]=='W' || s[sz(s)-1]=='W')
    {
        cout << 0;
        return 0;
    }
    vector<int> cs(sz(s));
    cs[0]=0;
    cs[sz(s)-1]=1;
    FOR(i,1,sz(s)-1)
    {
        if(s[i]==s[i-1])
            cs[i]=1-cs[i-1];
        else
            cs[i]=cs[i-1];
    }
    int sum=0;
    F0R(i,sz(s))
    {
        sum+=cs[i];
    }
    if(sum!=sz(s)/2)
    {
        cout << 0;
        return 0;
    }
    vector<int> nl(sz(s),0), nr(sz(s),0);
    nl[0]=1;
    nr[0]=0;
    FOR(i,1,sz(nl))
    {
        if(cs[i]==0) nl[i]=nl[i-1]+1;
        else nl[i]=nl[i-1];
    }
    FOR(i,1,sz(nr))
    {
        if(cs[i]) nr[i]=nr[i-1]+1;
        else nr[i]=nr[i-1];
    }
    ll tot=1;
    ll cnt=0;
    F0R(i,sz(cs))
    {
        if(cs[i])
        {
            tot=((tot*(nl[i]-cnt))%mod);
            cnt++;
        }
    }
    tot=((tot*fact(sz(s)/2))%mod);
    cout << tot;

    return 0;
}


Measured memory_bytes: 2964
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K;
    cin>>N>>K;
    if((N-2)*(N-1)/2<K) cout<<-1<<endl;
    else{
        ll oth=(N-2)*(N-1)/2-K;
        cout<<oth+N-1<<endl;
        rep1(i, N-2) reps(j, i+1, N){
            if(oth==0) break;
            cout<<i<<sp<<j<<endl;
            oth--;
        }
        rep1(i, N-1){
            cout<<i<<sp<<N<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
def getInputListStr():
    outputData = []
    inputData = input().split()
    outputData = [str(n) for n in inputData]

    return outputData

def replace(s, a, b, new_s):
    s = s[:a] + new_s + s[b+1:]
    return s

def reverse(s, a, b):
    tmp = s[a:b+1]
    tmp2 = tmp[::-1]
    s = s[:a] + tmp2 + s[b+1:]
    return s

s=input()
for _ in range(int(input())):
    o=input().split()
    a,b=map(int,o[1:3]);b+=1
    c=o[0][2]
    if c=='p':s=s[:a]+o[3]+s[b:]
    elif c=='i':print(s[a:b])
    elif c=='v':s=s[:a]+s[a:b][::-1]+s[b:]



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

typedef long long ll;
const int N = 1e5 + 5;
int a[N];
ll p[N<<1];
int n, m;

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	ll all = 0;
	for (int i=1; i<=n; ++i) {
		cin >> a[i];
		if (i > 1) {
			int l = a[i-1], r = a[i];
			if (l > r) r += m;
			all += r - l;
			if (l+1 < r) {
                p[l+2] += 1;
                p[r+1] -= (r-(l+2)+1+1);
                p[r+2] += (r-(l+2)+1);
			}
		}
	}
	for (int i=1; i<=2*m; ++i) p[i] += p[i-1];
	for (int i=1; i<=2*m; ++i) p[i] += p[i-1];
	ll ans = 0;
	for (int i=1; i<=m; ++i) {
		ans = max(ans, p[i]+p[i+m]);
	}
	cout << all - ans << '\n';
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int charToInt(char c) {
  return (int)c - (int)'0';
}

int main() {
  string str;
  while(getline(cin, str)) {
    bool flag = false;
    stringstream sin;
    if(str.length() % 2 != 0) {
      flag = true;
    } else {
      for(int i = 0; i < str.length(); i += 2) {
	int num1 = charToInt(str[i]);
	int num2 = charToInt(str[i+1]);
	if(num1 < 1 || num1 > 6 || num2 < 1 || num2 > 5) {
	  flag = true;
	  break;
	}

	if(num1 == 6 && num2 >= 2) {
	  switch(num2) {
	  case 2: sin << '.'; break;
	  case 3: sin << '?'; break;
	  case 4: sin << '!'; break;
	  case 5: sin << ' '; break;
	  }
	} else {
	  sin << (char)(((num1-1) * 5 + num2-1) + (int)'a');
	}
      }
    }
    if(flag) {
      cout << "NA" << endl;
    } else {
      cout << sin.str() << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int dp[200001][27];
int idx[200001][27];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<26;j++)
		{
			dp[i][j]=n+10;
		}
	}
	memset(idx,-1,sizeof(idx));
	for(int i = 0; i < 26; i++)
	{
		dp[n-1][i] = 1;
	}
	dp[n-1][s[n-1]-'a'] = 2;
	idx[n-1][s[n-1]-'a'] = 0;
	string ans;
	for(int i = n - 2; i >= 0; i--)
	{
		for(int j = 0; j < 26; j++)
		{
			if(s[i]==j+'a')
			{
				for(int k = 0; k < 26; k++)
				{
					if(dp[i+1][k] + 1 < dp[i][j])
					{
						dp[i][j] = dp[i+1][k] + 1;
						idx[i][j] = k;
					}
				}
			}
			else
			{
				if(dp[i+1][j] < dp[i][j])
				{
					idx[i][j] = j;
					dp[i][j] = dp[i+1][j];
				}
			}
		}
	}
	int cur = 0;
	int best = -1; int mini = 100000000;
	for(int i = 0; i < 26; i++)
	{
		if(dp[0][i] < mini)
		{
			mini=dp[0][i];
			best=i;
		}
	}
	ans+=char('a'+best);
	cur = best;
	for(int i = 0; i < n; i++)
	{
		if(i+1<n)
		{
			if(dp[i][cur]>dp[i+1][idx[i][cur]])
			{
				ans+=char('a'+idx[i][cur]);
			}
		}
		else
		{
			if(idx[i][cur]!=-1)
			{
				ans+=char('a'+idx[i][cur]);
			}
		}
		//cerr<<i<<' '<<cur<<'\n';
		cur=idx[i][cur];
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 42900
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
};

int main(){
    int n, d, a; cin >> n >> d >> a;
    vector<pair<int, int>> xh(n);
    rep(i, n) cin >> xh[i].first >> xh[i].second;
    sort(xh.begin(), xh.end());
    ll ans = 0;
    BIT<ll> bit(n + 1);
    rep(i, n){
        ll x = xh[i].first, h = xh[i].second;
        h -= bit.sum(i);
        if (h <= 0) continue;
        ll up = min<ll>(x + 2 * d, INF);
        auto right = upper_bound(xh.begin(), xh.end(), pair<int, int>{up, INF});
        size_t index = distance(xh.begin(), right);
        ll a_num = (h + a - 1) / a;
        bit.add(i, a * a_num);
        bit.add(index, -a * a_num);
        ans += a_num;
    }
    cout << ans << endl;
}


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

const int moder = 1e9 + 7;
const int N = 400010;

int n, x, y;
int fa[N], _cnt[N], fac[N], inv[N];
std::pair <int, int> p[N];
std::vector <int> cnt[N];
std::set <int> rollback;

int power_mod(int a, int exp){
	int ret = 1;
	while (exp){
		if (exp & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
		exp >>= 1;
	}
	return ret;
}

int comb(int n, int m){
	return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int find(int u){
	return u == fa[u] ? u : fa[u] = find(fa[u]);
}

void unite(int u, int v){
	int _u = find(u), _v = find(v);
	if (_u == _v){
		return;
	}
	fa[_u] = _v;
	find(v);
}

int main(){
	for (int i = 0; i < N; ++ i){
		fa[i] = i;
	}
	fac[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
	}
	inv[N - 1] = power_mod(fac[N - 1], moder - 2);
	for (int i = N - 1; i; -- i){
		inv[i - 1] = 1ll * inv[i] * i % moder;
	}
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 0; i < n; ++ i){
		scanf("%d%d", &p[i].first, &p[i].second);
	}
	std::sort(p, p + n);
	if (p[0].first == p[n - 1].first){
		return printf("1\n"), 0;
	}
	int sit, sit1 = 0, sit2 = 0, min1 = INT_MAX, min2 = INT_MAX;
	for (int i = 0; i < n; ++ i){
		if (!i || p[i].first != p[i - 1].first){
			sit = i;
			if (p[i].second <= min1){
				min2 = min1;
				sit2 = sit1;
				min1 = p[i].second;
				sit1 = i;
			}
			else if (p[i].second <= min2){
				min2 = p[i].second;
				sit2 = i;
			}
		}
		if (p[i].second + p[sit].second <= x){
			unite(i, sit);
		}
	}
	for (int i = 0; i < n; ++ i){
		if (p[sit1].second + p[i].second <= y && p[i].first != p[sit1].first){
			unite(sit1, i);
		}
		if (p[sit2].second + p[i].second <= y && p[i].first != p[sit2].first){
			unite(sit2, i);
		}
	}
	for (int i = 0; i < n; ++ i){
		find(i);
		cnt[fa[i]].push_back(p[i].first);
	}
	int ans = 1;
	for (int i = 0; i < n; ++ i){
		if (!cnt[i].size()){
			continue;
		}
		rollback.clear();
		int sum = cnt[i].size();
		for (auto u : cnt[i]){
			++ _cnt[u];
			rollback.insert(u);
		}
		for (auto u : rollback){
			ans = 1ll * ans * comb(sum, _cnt[u]) % moder;
			sum -= _cnt[u];
		}
		for (auto u : rollback){
			_cnt[u] = 0;
		}
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 28916
#include <bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
    int n,a,b,ans=0; cin>> n >> a >> b;
    for(int i=1;i<=n;++i){
        int aux=i,sum=0;
        while(aux){
           sum=sum+(aux%10);
           aux/=10;
        }
        if(sum>=a && sum<=b)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<string> S(N);
    vector<int> T(N);
    for (int i = 0; i < N; i++) cin >> S[i] >> T[i];
    string X; cin >> X;
    bool flag = false;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (flag) ans += T[i];
        if (X == S[i]) {
            flag = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
n, m, c = map(int, input().split())
B = list(map(int, input().strip().split()))
A = [list(map(int, input().strip().split())) for i in range(n)]

out = 0
for i in range(n):
    smpr = 0
    for j in range(m):
        smpr += A[i][j] * B[j]
    if smpr + c > 0:
        out += 1
print(out)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	int a[1000];
	bool ans=1;
	FOR(i,n){
		cin >> a[i];
		if(a[i]%2==0){
			if(a[i]%3==0 || a[i]%5==0){

			}else{
				ans=0;
			}
		}
	}

	if(ans){
		cout << "APPROVED" << endl;
	}else{
		cout << "DENIED" << endl;
	}


}

Measured memory_bytes: 256
import sys
mapin = lambda: map(int, sys.stdin.readline().split())
listin = lambda: list(map(int, sys.stdin.readline().split()))
inp = lambda: sys.stdin.readline()

N = int(inp())
vec = listin()
ans = 0
for i in range(N):
    for j in range(i + 1,N):
        #print(str(i) + ',' + str(j))
        if ans < abs(vec[i] - vec[j]):
            ans = abs(vec[i] - vec[j])
print(ans)

Measured memory_bytes: 9084
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
#define p(a,b) (b-a)*(b-a)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
 
int compute(int a,int b,int c,int d){
    int e[4] = {a,b,c,d};
    int res = (1<<29);
 
    rep(i,4){
	rep(j,4){
	    if(i == j) continue;
	    rep(k,4){
		if(i == k || j == k) continue;
		rep(l,4){
		    if(i == l || j == l || k == l) continue;
		    res = min(res,p(e[j],e[i])+p(e[k],e[j])+p(e[l],e[k]));
		}
	    }
	}
    }
  
    return res;
}
 
int main(){
    int a,b;
 
    while(cin >> a >> b , a | b){
	vector<P> c,d;
	for(int i = 1 ; i*i <= a ; i++){
	    if(a % i == 0){
		c.push_back(P(i,a/i));
	    }      
	}
 
	for(int i = 1 ; i*i <= b ; i++){
	    if(b % i == 0){
		d.push_back(P(i,b/i));
	    }
	}
 
	int ans = (1<<29);
	rep(i,(int)c.size()){
	    rep(j,(int)d.size()){
		ans = min(ans,compute(c[i].first,c[i].second,d[j].first,d[j].second));
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
n,t=map(int,input().split())

x=[list(map(int,input().split())) for _ in range(n)]

cst=[]

for i in range(n):
	if x[i][1]<=t:
		cst.append(x[i][0])

if len(cst)>0:
	print(min(cst))
else:
	print('TLE')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

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

int main()
{
    int n;
    cin >> n;
    map<int, int> rensou;
    int a;
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        rensou[a]++;
        sum++;
        if (rensou[a] > 1)
        {
            sum -= 2;
            rensou[a] = 0;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4992
import math

K = int(input())

gcd_tmp = list()
total = 0
for b in range(1, K+1):
    for c in range(1, K+1):
        tmp = math.gcd(b, c)
        gcd_tmp.append(tmp)

gcd_tmp.sort()
length = len(gcd_tmp)

type_of_gcd = list()
num_of_gcd = list()

counter = 0
for i in range(length-1):
    counter += 1
    if gcd_tmp[i] != gcd_tmp[i+1]:
        type_of_gcd.append(gcd_tmp[i])
        num_of_gcd.append(counter)
        counter = 0
type_of_gcd.append(gcd_tmp[-1])
num_of_gcd.append(counter+1)

# print(gcd_tmp)
# print(type_of_gcd)
# print(num_of_gcd)


for a in range(1, K+1):
    for i in range(len(type_of_gcd)):
        tmp = math.gcd(a, type_of_gcd[i])
        total += tmp*num_of_gcd[i]

print(total)

Measured memory_bytes: 9324
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] calculator = new String[3];
    int first_number = 0;
    int second_number = 0;
    String operator;
    List<String> answers = new ArrayList<String>();
    int answer = 0;

    while(true){
      calculator = br.readLine().split(" ");
      first_number = Integer.parseInt(calculator[0]);
      second_number = Integer.parseInt(calculator[2]);
      operator = calculator[1];

      if(operator.equals("+")){
        answer = first_number + second_number;
        answers.add(String.valueOf(answer));
      }else if(operator.equals("-")){
        answer = first_number - second_number;
        answers.add(String.valueOf(answer));
      }else if(operator.equals("*")){
        answer = first_number * second_number;
        answers.add(String.valueOf(answer));
      }else if(operator.equals("/")){
        answer = first_number / second_number;
        answers.add(String.valueOf(answer));
      }else if(operator.equals("%")){
        answer = first_number % second_number;
        answers.add(String.valueOf(answer));
      }else{
        break;
      }
    }

    for(String score:answers){
      System.out.println(score);
    }
  }
}



Measured memory_bytes: 24164
/*
	RAone00
	Rohit sharma
	*/

	#include <bits/stdc++.h>
	using namespace std;

	typedef long long ll;
	typedef long double ld;
	typedef pair < ll, ll > pll;
	typedef vector < vector < ll > > matrix;
	typedef vector < ll > vll;

	#define pb push_back
	#define debug(x) cout << (#x) << " is " << (x) << endl
	#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

	const ll mod = 1e9 + 7;
	const ll inf = LLONG_MAX;
	const ll N = 1e5 + 10;

	
	int main() {
	    fast_io();
	    set <int> s; 
	    for (int i = 0; i < 3; ++i) {
	    	int a;
	    	cin >> a;
	    	s.insert(a);
	    }
	    cout << (s.size() == 2 ? "Yes\n" : "No\n");
	    return 0;
	}

 

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define d double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n,m;
  cin>>n>>m;
  
  if(n==m){
  	cout<<"Yes"<<endl;
  }
  
  else{
  	cout<<"No"<<endl;
  }
  
  
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	// scanf("%d", &x);
	cin >> x;
	return x;
}

void solve() {
	int n = nxt();
	vector<long long> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	string s;
	cin >> s;

	vector<long long> basis;

	auto check = [&](long long x) {
		for (auto b : basis) {
			if (x & (1ll << (63 - __builtin_clzll(b)))) {
				x ^= b;
			}
		}
		return x == 0;
	};

	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == '0') {
			auto x = a[i];
			int j = 0;
			while (x > 0 && j < (int)basis.size() && __builtin_clzll(x) >= __builtin_clzll(basis[j])) {
				if (__builtin_clzll(x) == __builtin_clzll(basis[j])) {
					x ^= basis[j];
				}
				++j;
			}
			if (x == 0) {
				continue;
			}
			basis.insert(basis.begin() + j, x);
		} else {
			if (!check(a[i])) {
				cout << "1\n";
				return;
			}
		}
	}
	cout << "0\n";
}

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

	int t = nxt();
	while (t--) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 3620
#a, b, c, d = (int(i) for i in input().split())  
#W = [int(i) for i in input().split()] 
import math

W, H, x, y = (int(i) for i in input().split())
flag=0
if W/2 == x and H/2 == y:
    flag = 1
    pass

mense = W*H/2
print(mense, flag)

Measured memory_bytes: 3060
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 3e6 + 111;
        
using namespace std;          

int n, k;

void solve(){             
	cin >> n >> k;
	int ans = 0;

	while (n > 0){
		ans++;
		n /= k;
	}

	cout << ans;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
# coding:utf-8
import itertools
n = int(input())
a = list(map(int, input().split()))
cum = [0] + list(itertools.accumulate(a))
# print(cum)
ans = 0
mod = 10**9 + 7

for i in range(n):
    ans += a[i] * cum[i]
    # print(a[i], cum[i])

print(ans % mod)


Measured memory_bytes: 31168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int count =0;
		int sum = 0;
		if (X==1) {
			sum +=300000;
			count ++;
		}
		if (X==2) {
			sum +=200000;
		}
		if (X==3) {
			sum +=100000;
		}
		X = sc.nextInt();
		if (X==1) {
			sum +=300000;
			count ++;
		}
		if (X==2) {
			sum +=200000;
		}
		if (X==3) {
			sum +=100000;
		}
		if (count ==2) {
			sum +=400000;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,M;
	cin >> N >> M;
	vector<pl> v;
	FOR(i,0,N){
		ll A,B;
		cin >> A >> B;
		v.push_back(make_pair(A,B));
	}
	sort(ALL(v));
	ll ans = 0;
	FOR(i,0,N){
		while(M && v[i].second){
			M--;
			v[i].second--;
			ans += v[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
a[4],s[3];main(x){for(;~scanf("%d,%s",&x,s);a[x]++)x=*s>99?2:*s=='A'?0:*s=='O'?3:1;printf("%d\n%d\n%d\n%d\n",*a,a[1],a[2],a[3]);return 0;}

Measured memory_bytes: 596
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

typedef long long ll;

int main() {
	int N,M;
	ll modulo = (ll)1e9+7;
	cin >> N >> M;
	if(abs(N-M)>1) {
		cout << "0" << endl;
		return 0;
	}
	ll count = 1;
	int T = min(N,M);
	while (T>1) {
		count *= T;
		count = count % modulo;
		T--;
	}
	count = count*count;
	count = count % modulo;
	if (N!=M) count *= max(M,N);
	if (N==M) count *= 2;
	count = count % modulo;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 632
/* ex4_2
   urah  */

#include <stdio.h>
#include <math.h>

double distance(int len_hour_hand, int len_minute_hand, double hour, double minute);

int main(void){
    int len_hour_hand, len_minute_hand;
    double hour, minute, ans;

    // 入力の受け取り
    scanf("%d\t%d\t%lf\t%lf", &len_hour_hand, &len_minute_hand, &hour, &minute);
    // 関数の呼び起こし
    ans = distance(len_hour_hand, len_minute_hand, hour, minute);
    // 出力
    printf("%.9f", ans);

    return 0;
}

double distance(int len_hour_hand, int len_minute_hand, double hour, double minute){
    double ans, angle;

    // 二つの針の角度を求める
    angle = ((hour + minute / 60) / 12 - minute / 60) * 2 * M_PI;
    // 余弦定理
    ans = sqrt(pow(len_hour_hand, 2) + pow(len_minute_hand, 2) - 2 * len_hour_hand * len_minute_hand * cos(angle));

    return ans;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int k,s; cin >> k >> s;

  int ans = 0;
  for(int x = 0;x<=k;++x)
    for(int y = 0;y<=k;++y)
      if(s-(x+y)>=0 && s-(x+y)<=k) ans++;

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


Measured memory_bytes: 3604
'use strict'

getHeadsSuperior(require('fs').readFileSync('/dev/stdin', 'utf8'))

function getHeadsSuperior(input) {
    const lines = input.split('\n')
    const n = parseInt(lines.shift())
    let probabilities = lines.shift().split(' ').map(item => parseFloat(item))
    let dp = new Array(n + 1)
    for (let i = 0; i <= n; i++){
        dp[i] = new Array(n + 1).fill(0.0)
    }
    dp[0][0] = 1
    for (let i = 1; i <= n; i++) {
        for (let j = 0; j <= n; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - probabilities[i - 1])
            if (j > 0) {
                dp[i][j] += dp[i - 1][j - 1] * probabilities[i - 1]
            }
        }
    }
    let result = 0.0
    for (let i = Math.ceil(n / 2); i <= n; i++) {
        result += dp[n][i]
    }
    console.log(result)
}

Measured memory_bytes: 172816
N,K=map(int,input().split())
A=[0 for i in range(N)]
B=[0 for i in range(N)]
for i in range(N):
    A[i],B[i]=map(int,input().split())
S=bin(K)
X=[K]
M=len(S)-2
for k in range(1,M+1):
    if S[-k]=="0":continue
    tmp=S[:-k]+"0"+"1"*(k-1)
    X.append(int(tmp,2))
ans=0
for n in X:
    tmp=0
    for i in range(N):
        if A[i]&n==A[i]:
            tmp+=B[i]
    ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 11204
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000
#define mod 1000000007
const int N = 210;
int  n , arr[N];

int main(){
	scanf("%d",&n);
	n <<= 1;
	for(int i= 0 ;i < n;i++){
		scanf("%d",&arr[i]);
	}
	sort(arr,arr+n);
	int ans = 0;
	for(int i = 0;i<n;i+=2)
		ans += arr[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,m,Q,l,r,p,q,ans[501][501];
    cin>>n>>m>>Q;
    vector<pair<int,int>> A(m);
    rep(i,m) cin>>l>>r,A[i]=make_pair(l,r);
    sort(A.begin(),A.end());
    rep(i,n){
        int a=i+1;
        vector<int> B;
        rep(i,m) if(A[i].first>=a) B.push_back(A[i].second);
        sort(B.begin(),B.end());
        for(int b=a;b<=n;b++) ans[a][b]=upper_bound(B.begin(),B.end(),b)-B.begin();
    }
    rep(i,Q) cin>>p>>q,cout<<ans[p][q]<<endl;
}

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

int real_order_time(const int t);

int main() {
    vector<int> order_times;
    int a, b, c, d, e;

    std::cin >> a; order_times.push_back(a);
    std::cin >> b; order_times.push_back(b);
    std::cin >> c; order_times.push_back(c);
    std::cin >> d; order_times.push_back(d);
    std::cin >> e; order_times.push_back(e);

    int order_time = 0;
    int last_order_time = -1;
    for (auto time : order_times) {
        if (time % 10 != 0) {
            last_order_time = time;
            break; 
        }
    }
    if (last_order_time != -1) {
        for (auto time : order_times) {
            if (time % 10 == 0) {
                continue;
            }
            if (last_order_time % 10 > time % 10) {
                last_order_time = time;
            }
        }
        order_time = last_order_time - real_order_time(last_order_time);
    }

    for (auto time : order_times) {
        order_time += real_order_time(time);
    }

    cout << order_time << endl;
}

int real_order_time(const int t) {
    int add_t = 0;
    if (t % 10 != 0) {
       add_t = 10 - (t % 10);
    }
    return t + add_t;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	ll ans = max(max((ll)a * c, (ll)a * d), max((ll)b * c, (ll)b * d));
	printf("%lld\n", ans);
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

int main(){
    long long a,b,c;
    std::cin >> a >> b >> c;
    long long m = a > b ? b : a;
    int cnt = 0;
    for(long long t = m; t >= 1;--t ){
        if (a % t ==0  && b % t == 0) cnt++;
        if (cnt == c) return !(std::cout << t) ;
    }
}

Measured memory_bytes: 256