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

#define FOR(i, a, b)  for (ll i = (a); i < (b); i++)
#define FORd(i, a, b) for (ll i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll unsigned long long

using namespace std;

ll pov(ll n, ll k) {
  ll out = (ll) 1;
  if (k > n - k) {
    ll j = (ll) 1;
    FOR(i, k + 1, n + 1) {
      out *= i;

      while (out % j == 0 && j <= (n - k)) {
        out /= j;
        j++;
      }
    }
  } else {
    ll j = (ll) 1;
    FOR(i, n - k + 1, n + 1) {
      out *= i;
      while (out % j == 0 && j <= k) {
        out /= j;
        j++;
      }
    }
  }
  return out;
}

int main() {
  ios_base::sync_with_stdio(false);

  ll n, p;
  ll par = 0, nep = 0;
  cin >> n >> p;
  REP(i, n) {
    ll a;
    cin >> a;
    if (a % 2 == 0) par++;
    else            nep++;
  }

  if (p == 0) {
    ll out = ((ll) 1 << par);
    ll tr = 0, um = 0;
    while (tr <= nep) {
      um += pov(nep, tr);
      tr += (ll) 2;
    }
    cout << out * um << endl;
  } else {
    ll um1 = ((ll) 1 << par);

    ll um2 = 0;
    ll tr = (ll) 1;
    while (tr <= nep) {
      um2 += pov(nep, tr);
      tr += (ll) 2;
    }
    cout << um1 * um2 << endl;
  }


  return 0;
}



Measured memory_bytes: 256
from collections import deque
alpha = "abcdefghijklmnopqrstuvwxyz"
A = input()
n = len(A)
B = ord('a')

links = [None]*(n+3)

link = [n]*26
for i in range(n-1, -1, -1):
    links[i] = link[:]
    link[ord(A[i]) - B] = i
links[-1] = link

deq = deque()
deq.append(-1)
prev = {-1: (None, 0)}
while deq:
    v = deq.popleft()
    if v == n:
        break
    link = links[v]
    for c in range(26):
        if link[c] in prev:
            continue
        prev[link[c]] = (v, c)
        deq.append(link[c])
v = n
ans = []
while v is not None:
    v, c = prev[v]
    ans.append(chr(c+B))
ans.reverse()
print("".join(ans[1:]))



Measured memory_bytes: 120948
N = int(input())
A = list(map(int, input().split()))

all_length = sum(A)
sum_length = 0
num = 0

for i in range(N):
    sum_length += A[i]
    if sum_length >= all_length // 2:
        num = i + 1
        break

half_l1 = [A[i] for i in range(num-1)]
sum_half_l1 = sum(half_l1)
rest1 = all_length - sum_half_l1

half_l2 = [A[i] for i in range(num)]
sum_half_l2 = sum(half_l2)
rest2 = all_length - sum_half_l2

need = min(abs(sum_half_l1 - rest1), abs(sum_half_l2 - rest2))
print(need)


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
inline void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;


void Main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) {
        int x;
        cin >> x;
        ++a[x - 1];
    }

    sort(ALL(a));
    vint s(n + 1);  // sum of [0, i)
    rep(i, n)s[i + 1] = s[i] + a[i];
    for (int k = 1; k <= n; ++k) {
        int l = 0, r = n / k + 1; // l:OK, r:NG
        while (l + 1 < r) {
            int c = (l + r) / 2;
            bool ok = [&](int c) {
                int i = lower_bound(ALL(a), c) - a.begin();
                int sum = c * (n - i) + s[i];
                return (sum >= c * k);
            }(c);
            if (ok) l = c; else r = c;
        }
        cout << l << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
constexpr auto INF = 2147483647;
typedef long long ll;

int main(){

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

  if(c-a-b < 0){
    cout << "No" << endl;
    return 0;
  }

  if((c-a-b)*(c-a-b) > 4*a*b) cout << "Yes" << endl;
  else cout << "No" << endl;



  return 0;
}

Measured memory_bytes: 256
import numpy as np

string = list(input())

min = 10000000

for i in range(len(string) - 2):
  num = int(string[i]) * 100 + int(string[i+1]) * 10 + int(string[i+2])
  if abs(num - 753) < min:
    min = abs(num - 753)

print(min)


Measured memory_bytes: 12420
#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
char s[maxn];
int n;
void no() { puts("-1"); exit(0);}
int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if(s[1] == '0' || s[n] == '1') no();
	for(int i = 1, j = n - 1; i < j; ++i, --j)
		if(s[i] != s[j]) no();
	int cur = 1;
	for(int i = 1; i < n; ++i)
	{
		printf("%d %d\n", cur, i + 1);
		if(s[i] == '1') cur = i + 1;
	}
	return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

int N,M;
ve<ve<ll>> A,AA;
ve<ve<ll>> C;
ll ans = 0;

void dfs(int n, string S){
    
    if(n == 3){
        rep(i,3){
            if(S[i] == '1') rep(j,N) C[j][i] = AA[j][i];
            else if(S[i] == '0') rep(j,N) C[j][i] = A[j][i];
        }
        ve<pair<ll,int>> pp;
        rep(i,N) pp.push_back({C[i][0]+C[i][1]+C[i][2],i});
        
        sor(pp);
        rev(pp);
        ll an = 0;
        rep(i,3){
            ll cc = 0;
            rep(j,M) cc+=C[pp[j].se][i];
            an += abs(cc);
        }
        ans = max(ans,an);
        
    }else{
        dfs(n+1,S+'1');
        dfs(n+1,S+'0');
    }
    
}



int main()
{
    
    cin>>N>>M;
    A.assign(N,ve<ll>(3,0));
    AA.assign(N,ve<ll>(3,0));
    C.assign(N,ve<ll>(3,0));
    rep(i,N){
        rep(j,3) cin >> A[i][j];
        rep(j,3) AA[i][j] = -A[i][j];
    }
    
    
    string s = "";
    dfs(0,s);
    
    out(ans);
  
    
    

    return 0;
}


Measured memory_bytes: 384
if __name__ == "__main__":
    N, M, K = map(int, input().split())

    for k in range(0, N + 1):
        for l in range(0, M + 1):
            b = k * (M - l) + (N - k) * l
            if b == K:
                print("Yes")
                exit()

    print("No")


Measured memory_bytes: 3060
w,h,n = map(int, input().split())
xmin = 0
xmax = w
ymin = 0
ymax = h
for _ in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        xmin = max(xmin,x)
    elif a == 2:
        xmax = min(xmax,x)
    elif a == 3:
        ymin = max(ymin,y)
    elif a == 4:
        ymax = min(ymax,y)
print(max(0,xmax-xmin)*max(0,ymax-ymin))

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

struct SegmentTree{
    SegmentTree(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        for(int i=1;i<2*size;++i){
            data[i] = D;
        }
    }
    void propagate(int k){
        if(data2[k] != 0){
            data[k] += data2[k];
            if(k < size){
                data2[k*2] += data2[k] / 2;
                data2[k*2+1] += data2[k] / 2;
            }
            data2[k] = 0;
        }
    }
    void update(int l, int r, ll x){
        _update(1, 0, size, l, r, x);
    }
    inline void _update(int k, int a, int b, int l, int r, ll x){
        propagate(k);

        if(b <= l || r <= a){return;}
        if(l <= a && b <= r){
            data2[k] = x * (b - a);
            propagate(k);
        }else{
            int mid = (a + b) / 2;
            _update(k * 2, a, mid, l, r, x);
            _update(k * 2 + 1, mid, b, l, r, x);
            data[k] = data[k*2] + data[k*2+1];
        }
    }
    ll sum(int l, int r){
        return _sum(1, 0, size, l, r);
    }
    inline ll _sum(int k, int a, int b, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return D;}
        if(l <= a && b <= r){return data[k];}
        int mid = (a + b) / 2;
        ll vl = _sum(k * 2, a, mid, l, r),
            vr = _sum(k * 2 + 1, mid, b, l, r);
        return vl + vr;
    }
    
    int size;
    ll data[400100], data2[400100];
    const ll D = 0;
};

int N, Q;
SegmentTree segtree(100000);

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

    std::cin >> N >> Q;

    for(int i=0;i<Q;++i){
        int type, s, t;

        std::cin >> type >> s >> t;

        if(type == 0){
            ll x;
            std::cin >> x;

            segtree.update(s, t + 1, x);
        }else{
            std::cout << segtree.sum(s, t + 1) << std::endl;
        }
    }
}



Measured memory_bytes: 6788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    string s;
    cin >> s;
    int n = s.length();
    ll ans = 0;
    vector<int> vec(n);
    rep(i, n) {
        vec[i] = s[i] - '0';
    }
    for (int bit = 0; bit < (1 << n - 1); bit++)
    {
        //2^n繰り返す
        ll temp = vec[0];
        rep(i, n - 1)
        {
            if (bit & (1 << i))
            {
                //1が立っていればホニャララ
                ans += temp;
                temp = vec[i + 1];
            }
            else {
                temp *= 10;
                temp += vec[i + 1];
            }
        }
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rpd(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define pb push_back
using namespace std;
const int N=2e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int a,b;
int main(){
	a=read();b=read();
	if(a+b==15)cout<<"+";
	else
	if(a*b==15)cout<<"*";
	else
	cout<<"x";
	return 0;
}

Measured memory_bytes: 256
import collections
s = list(input())
t = list(enumerate(s[:]))
eng = [chr(ord('a') + i) for i in range(26)]
u = len(s)

ans = []
for i in eng:
    kar = [-1]
    kar.extend([j for j, v in t if v == i])
    kar.append(u)
    tyu = len(kar)
    if tyu == 2:
        continue
    f = 0
    for j in range(tyu-1):
        f = max(f,kar[j+1]-kar[j]-1)
    ans.append(f)

print(min(ans))

Measured memory_bytes: 3316
#include<stdio.h>
int main(){
	int n;
	scanf("%d" , &n);
	if (n%10 == 7 || (n/10) %10 == 7 || n/100 == 7) {
		puts("Yes\n");
	} 
	else{
		puts("No\n");
	}
	return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    ll arr[32] = {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};
    ll k;
    cin >> k;
    g(arr[k-1]);
}
int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
   // cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
pii ps[52];
vi xs, ys;

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n){
    int x,y;
    scanf("%d%d",&x,&y);
    ps[i] = pii(x,y);
    xs.push_back(x);
    ys.push_back(y);
  }
  sort(ALL(xs));
  sort(ALL(ys));
  ll ans = (ll)(xs[n-1]-xs[0]) * (ys[n-1]-ys[0]);
  REP(r,n)REP(l,r+1)REP(d,n)REP(u,d+1){
    ll tmp = (ll)(xs[r]-xs[l]) * (ys[d]-ys[u]);
    if(tmp>=ans)continue;
    int cnt = 0;
    REP(i,n){
      int x = ps[i].first;
      int y = ps[i].second;
      if(xs[l]<=x && x<=xs[r] && ys[u]<=y && y<=ys[d])cnt++;
    }
    if(cnt>=k)ans=tmp;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll a[200000];   
int main()
{
    fastread;
  ll n,i,j,k,l,m;
  cin>>n;
  for(i=1;i<=n;i++)
  cin>>a[i];
  int flag=0;
  for(i=1;i<=n;i++){
  	if(a[i]%2==0){
  		if(!(a[i]%3==0||a[i]%5==0))
  		flag=1;
	  }
  }
  if(flag==1)
  cout<<"DENIED";
  else
  cout<<"APPROVED";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,c=0,n;
    map<long long int , long long int >mp;
    map<long long int , long long int >::iterator it;
    cin>>n;

         i=1;
    while(1)
    {
            mp[n]++;
        if(n%2==0)
        {
            n=n/2;
            mp[n]++;
            if(mp[n]>=2)
               {
                   i++;
//                   cout<<"n= "<<n<<endl;
//                   cout<<"mp[n] = "<<mp[n]<<endl;
                   break;
               }
        }
        else
        {
            n=(3*n+1);
            mp[n]++;
            if(mp[n]>=2)
               {
                   i++;
//                   cout<<"n= "<<n<<endl;
//                   cout<<"mp[n] = "<<mp[n]<<endl;
                   break;
               }
        }
        i++;


    }
    cout<<i<<endl;
    mp.clear();

}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    long int N;
    long int x = 1;
    long int count = 0;
    scanf("%ld",&N);
    while(x*x+x < N){
        if(N%x==0){count += ((N/x)-1);}
        x++;
    }
    printf("%ld\n",count);
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;

int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    bool a[n]={false};
    while(k--)
    {
        int d;
        cin>>d;
        forn(i,d)
        {
            int s;
            cin>>s;
            s--;
            a[s]=true;
        }
    }
    forn(i,n)
    {
        if(!a[i])
            ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3652
N=input()
A=list(map(int,input().split()))
B,C=[],[]
for i in (A):
    if i%2==0:B.append(i)
for i in (B):
    if i%3==0 or i%5==0:C.append(i)
if len(B)==len(C):
    print('APPROVED')
else:print('DENIED')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>
#include <string>
#include <map>

#include <iomanip>

class Union_find {
	const int _size;
	std::vector<int> _array;
public:
	Union_find(const int size) :_size{ size }, _array(size, -1) {};
	int find(int a) {
		if (_array[a] < 0) return a;
		else return _array[a] = find(_array[a]);
	}
	bool is_same(const int a, const int b) {
		return find(a) == find(b);
	}
	void merge(const int a, const int b) {
		auto ar = find(a);
		auto br = find(b);
		if (ar != br) {
			if (_array[ar] < _array[br]) {
				_array[ar] += _array[br];
				_array[br] = ar;
			}
			else {
				_array[br] += _array[ar];
				_array[ar] = br;
			}
		}
	}
};
int main() {
	int n, m;
	std::cin >> n >> m;
	Union_find card_type(n);
	for (auto i = 0; i < m; ++i) {
		int x, y, z; std::cin >> x >> y >> z;
		card_type.merge(x - 1, y - 1);
	}
	std::vector<bool> is_constrainted(n, true);
	for (auto i = 0; i < n; ++i) {
		is_constrainted[card_type.find(i)] = false;
	}
	auto count = 0;
	for (const auto root : is_constrainted) {
		if (!root) ++count;
	}
	std::cout << count << std::endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  cin >> a >> b >> c;
  string ans = "A";
  ans.push_back(b[0]);
  ans += "C";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

short memo[1001][101][101];

int n, m, x;
int limit;
int secE[110];
int secS[110];
int e[110];
int s[110];
char str[1000];

int calc(int use, int depth, int art) {
  if (use > limit) { return -30000; }
  if (depth == m) {
    return art >= x ? 0 : -30000;
  }
  if (memo[use][depth][art] != -1) { return memo[use][depth][art]; }
  int ret = -30000;
  ret = max(ret, calc(use, depth + 1, art));
  ret = max(ret, calc(use + e[depth], depth + 1, art + 1) + s[depth]);
  return memo[use][depth][art] = ret;
}

int main() {
  while (scanf("%d %d %d %d", &limit, &n, &m, &x), limit|n|m|x) {
    MEMSET(memo, -1);
    REP(i, n) {
      scanf("%s %d %d", str, &secE[i], &secS[i]);
    }
    REP(i, m) {
      scanf("%s %d %d", str, &e[i], &s[i]);
    }
    int ans = 0;
    REP(i, n) {
      {
        int use = secE[i];
        int sat = secS[i];
        ans = max(ans, calc(use, 0, 0) + sat);
      }
      REP(j, i) {
        int use = secE[i] + secE[j];
        int sat = secS[i] + secS[j];
        ans = max(ans, calc(use, 0, 0) + sat);
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=100;

int a[N];

int main(void) {
	int n,m; scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%d",&a[i]);
	std:: sort(a+1,a+n+1);
	int ans=0;
	rep(i,1,n-1) {
		if (a[i]<=m) m-=a[i],ans++;
	}
	if (a[n]==m) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define long long long
using namespace std;
long n,ans,mn=2e9;
struct data
{
  long a,b,d;
}arr[200005];
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i].a>>arr[i].b;
    arr[i].d=arr[i].a-arr[i].b;
    ans+=arr[i].a;
    if(arr[i].d>0)mn=min(arr[i].b,mn);
  }
  long bn=0,sum=0;
  for(int i=1;i<=n;i++)
  {
    if(arr[i].d<0)
    {
      bn-=arr[i].d;
      sum+=arr[i].a;
    }
  }
  if(bn==0)cout<<sum<<endl,exit(0);
  else cout<<ans-mn<<endl;

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, m, sum = 0;
    cin >> n >> m;
    vector<int> a(m);
    for(int i=0;i<m;i++) cin >> a[i];
    for(int i=0;i<m;i++) sum += a[i];
    n -= sum;
    if(n < 0) n = -1;
    cout << n << endl;
}


Measured memory_bytes: 3204
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;

    int ans = 0;
    for (int i = 0; i < 2; i++) {
        if (a > b) {
            ans += a--;
        } else {
            ans += b--;
        }
    }

    std::cout << ans << std::endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) cin >> p.at(i);
  sort(p.begin(), p.end());
  int min_total = 0;
  rep(i, K) min_total += p.at(i);
  cout << min_total << endl;
}

Measured memory_bytes: 3564
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;




int main() {
	int n;
	cin >> n;
	map<int, int> m;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		ans += m[-a + i];

		a += i;
		m[a]++;
	}

	

	cout << ans << endl;
}


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

int main() {
    string s;
    cin>>s;
    int ans = 0;
    int count = 0;
    for(char c:s){
        if(c == 'S'){
             count = 0;
        }else{
            ++count;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<vector<Pll>>;
Graph g, rg;
ll N, M, P;
Vl dist;
Vi check1, check2;

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    cin >> N >> M >> P;
    g.resize(N);
    rg.resize(N);
    for (ll i = 0; i < M; i++) {
        ll ai, bi, ci;
        cin >> ai >> bi >> ci;
        --ai, --bi;
        g[ai].emplace_back(bi, P - ci);
        rg[bi].emplace_back(ai, P - ci);
    }

    check1.assign(N, 0);
    check2.assign(N, 0);

    queue<int> q;
    q.emplace(0);
    check1[0] = 1;
    while (!q.empty()) {
        int idx = q.front();
        q.pop();
        for (const auto& edge : g[idx]) {
            ll to = edge.first;
            if (check1[to]) continue;
            q.emplace(to);
            check1[to] = 1;
        }
    }

    q.emplace(N - 1);
    check2[N - 1] = 1;
    while (!q.empty()) {
        int idx = q.front();
        q.pop();
        for (const auto& edge : rg[idx]) {
            ll to = edge.first;
            if (check2[to]) continue;
            q.emplace(to);
            check2[to] = 1;
        }
    }

    dist.assign(N, L_INF);

    dist[0] = 0;
    bool update;
    for (ll _ = 0; _ < N; _++) {
        update = false;
        for (ll i = 0; i < N; i++) {
            if (!(check1[i] && check2[i])) continue;
            for (const auto& edge : g[i]) {
                ll to, c;
                tie(to, c) = edge;
                if (!(check1[to] && check2[to])) continue;
                if (dist[i] != L_INF && dist[to] > dist[i] + c) {
                    dist[to] = dist[i] + c;
                    update = true;
                }
            }
        }
    }

    if (update) {
        cout << -1 << endl;
    }
    else {
        cout << max(-dist[N - 1], 0LL) << endl;
    }

    return 0;
}

Measured memory_bytes: 768
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main(){
	int n, l;
	string x;
	cin >> n >> l;
	vector<string> s;
	for (int i = 0; i < n; ++i){
		cin >> x;
		s.push_back(x);
	}
	sort(s.begin(), s.end());

	for (int i = 0; i < s.size(); ++i){
		cout << s[i];
	}
	cout << endl;

}


Measured memory_bytes: 256
import sys
from collections import Counter
MOD = 10 ** 9 + 7
n, *a = map(int, sys.stdin.read().split())

def main():
  c = Counter(a)
  ans = 0
  if n & 1:
    for i in range(2, n, 2):
      if c[i] != 2: break
    else:
      if c[0] == 1:
        ans = pow(2, n // 2, MOD)
  else:
    for i in range(1, n, 2):
      if c[i] != 2: break
    else:
      ans = pow(2, n // 2, MOD)
  print(ans)

if __name__ ==  '__main__':
  main()

Measured memory_bytes: 14316
#include<stdio.h>
 
int main(void)
{
  int i,k;
  int n[100];
  int fla=0;
 
  scanf("%d", &k);
  for(i=0;i<k;i++){
    scanf("%d", &n[i]);
  }
  for(i=0;i<k;i++){
    if((n[i]%2==0) && (n[i]%3!=0) && (n[i]%5!=0)){
        fla=1;
      break;
      }
  }
  
  if(fla==1){
    printf("DENIED\n");
  }
  else
    printf("APPROVED\n");
    return 0;
}

Measured memory_bytes: 1652
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>

using namespace std;

int main()
{
    int n,a;
    long int max,min,total = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(i == 0){
            max = a;
            min = a;
        }
        if(max < a){
            max = a;
        }
        if(min > a){
            min = a;
        }
        total += a;
    }
    cout <<min<<" "<<max<<" "<<total<<endl; 
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

const int N = (1 << 18);
const int M = 1e5 + 10;
const int H = 9;

int n, q, a, b;

int val[N];
int wei[N];
int ans[N];

vector <pair<int, int>> Q[N];

int dp[N];
int h[N];

int V[N];
int W[N];

void dfs(int v, int p) {
	if (v > n) return;
	h[v] = h[p] + 1;
	
	vector <int> ver;
	if (h[v] <= H) {
		int x = v;
		while (x) {
			ver.pb(x);
			x /= 2;
		}
	}
	else {
		int x = v;
		while (h[x] > H) {
			ver.pb(x);
			x /= 2;
		}
	}
	
	if (h[v] == H)
		rep(i, 0, M - 1)
			dp[i] = 0;
			
	if (ss(Q[v]) || h[v] == H) {
	
		int S = ss(ver);
		rep(mask, 0, (1 << S) - 1) {
			int waga = 0, war = 0;
			if (mask) {
				int bit = 32 - __builtin_clz(mask) - 1;
				assert((mask & (1 << bit)));
				W[mask] = W[mask ^ (1 << bit)] + wei[ver[bit]];
				V[mask] = V[mask ^ (1 << bit)] + val[ver[bit]];
				waga = W[mask];
				war = V[mask];
			}
			
			if (waga > M) continue;
				
			if (h[v] == H)
				dp[waga] = max(dp[waga], war);
					
			for (auto it : Q[v]) {
				if (it.fi < waga) continue;
				int z = war + (h[v] > H ? dp[it.fi - waga] : 0);
				ans[it.se] = max(ans[it.se], z);
			}
		}
		
		if (h[v] == H)
			rep(i, 1, M - 1)
				dp[i] = max(dp[i], dp[i - 1]);
	}
			
	
	dfs(2 * v, v);
	dfs(2 * v + 1, v);
}

int main() {
	scanf ("%d", &n);
	rep(i, 1, n)
		scanf ("%d%d", val + i, wei + i);
	scanf ("%d", &q);
	rep(i, 1, q) {
		scanf ("%d%d", &a, &b);
		Q[a].pb({b, i});
	}
	dfs(1, 0);	
	rep(i, 1, q)
		printf ("%d\n", ans[i]);
		
	return 0;
}	


Measured memory_bytes: 16876
N = int(input())
p = list(map(int,input().split()))
flag = 0
for i in range(N):
    if flag==0 and p[i]!=i+1:
        if p[p[i]-1] == i+1:
            flag = 1
        else:
            flag = 3
    elif flag==1 and p[i]!=i+1:
        flag=2
    elif flag==2 and p[i]!=i+1:
        flag=3
if flag <= 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  vector <int> x[200001];
  for (int i(0);i<M;i++) {
    int a,b;
    cin>>a>>b;
    x[a].push_back(b);
    x[b].push_back(a);
  }
  for (int i(0);i<x[1].size();i++){
    int next=x[1][i];
    for (int j(0);j<x[next].size();j++){
      if (x[next][j]==N){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 12016
import math


def resolve():
    n, h = map(int, input().split())
    ab = list(list(map(int, input().split())) for _ in range(n))
    ab.sort(key=lambda x: (x[0], x[1]), reverse=True)
    max_a = ab[0][0]
    count = 0
    throwers = sorted([b for _, b in ab if b > max_a], reverse=True)
    for t in throwers:
        h -= t
        count += 1
        if h <= 0:
            return count
    count += math.ceil(h / max_a)
    return count


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


Measured memory_bytes: 73304
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e5+10;
int v[N];

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

  int n,k; cin >> n >> k;
  for(int i = 0; i < n; i++){
    int a,b; cin >> a >> b;
    v[a] += b;
  }

  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += v[i];
    if(sum >= k){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	string S;
	cin >> S;

	int win = 0;
	for (int i = 0; i < S.length(); i++)
	{
		win += S[i] == 'o';
	}

	int nokori = 15 - S.length();

	if (win + nokori >= 8)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}


}





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

int main(){
    int K;
    string S;
    cin >> K >> S;

    if(S.size()<=K){
        cout << S << endl;
    }
    else{
        for(int i=0;i<K;i++){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
    // 入力
    map<int, int> mp1;
    map<int, int> mp2;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(i % 2 == 0) mp1[a]++;
        else mp2[a]++;
    }

    // 最頻値から答えを求める１
    int max1 = 0;
    int key = 0;
    for(pair<int, int> m: mp1)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    int max2 = 0;
    for(pair<int, int> m: mp2)
    {
        // mp1の最頻値となるkeyとは異なる値を選ぶ
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans1 = (N/2 - max1) + (N/2 - max2);

    // 最頻値から答えを求める２
    max1 = 0;
    key = 0;
    for(pair<int, int> m: mp2)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    max2 = 0;
    for(pair<int, int> m: mp1)
    {
        // mp2の最頻値となるkeyとは異なる値を選ぶ
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans2 = (N/2 - max1) + (N/2 - max2);

    // 答えを出力
    int ans = min(ans1, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    import scala.io.StdIn._
    val s = readLine.split(" ")
    val n = s(0).toInt
    val k = s(1).toInt
    val hs = new Array[Long](n)
    for (i <- 0 until n) {
      hs(i) = readLong
    }
    val sortedHs = hs.sorted

    var min = Long.MaxValue
    for (i <- 0 to n - k) {
      min = math.min(min, sortedHs(i + k - 1) - sortedHs(i))
    }

    println(min)

  }
}


Measured memory_bytes: 38856
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define M 1000000007
int main(void){
    char s[100001];
    int i,ans=0;
    scanf("%s",s);
    int len=strlen(s);
    for(i=0;i<len-1;i++){
        if(s[i]!=s[i+1])ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
using ll = long long;
using namespace std;


int main() {
    string s;
    int C = 0, small = 0;
    cin >> s;
    if (s[0] == 'A') {
        for (int i = 1; i < s.length(); i++) {
            if (s[i] == 'C')C++;
            else if ('a' <= s[i] && s[i] <= 'z')small++;
        }
        if (C == 1 && small == s.length() - 2 && s[1]!='C' && s[s.length()-1]!='C') {
            cout << "AC" << endl;
            return 0;
        }
    }
    cout << "WA" << endl;
    return 0;
}


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

int main(int argc, char **argv)
{
	ll n,l;
  cin>>n>>l;
  vector <string> arr(n);
  for(ll i=0;i<n;i++) cin>>arr[i];
  sort(arr.begin(),arr.end());
  for(ll i=0;i<n;i++) cout<<arr[i];
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  string s;
  cin >> s;
  bool a = false;
  rep(i,s.size()) {
    if(s[i]=='7') a = true;
  }
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
use std::io;
use std::collections::HashSet;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let h = v[0];
	let w = v[1];
	let mut v:Vec<Vec<char>> = Vec::new();
	for i in 0..h {
		v.push(Vec::new());
	}
	let mut row:HashSet<i32> = HashSet::new();
	let mut line:HashSet<i32> = HashSet::new();
	let mut flag = true;
	for i in 0..h {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let ch:Vec<char> = buf.trim().chars().collect();
		for j in &ch {
			if *j == '#' {
				flag = false;
				break;
			}
		}
		for j in 0..w {
			v[i as usize].push(ch[j as usize]);
		}
		if flag {
			line.insert(i);
		}
		flag = true;
	}
	for i in 0..w {
		for j in 0..h {
			if v[j as usize][i as usize] == '#' {
				flag = false;
				break;
			}
		}
		if flag {
			row.insert(i);
		}
		flag = true;
	}
	for i in 0..h {
		if !line.contains(&i) {
			for j in 0..w {
				if !row.contains(&j) {
					print!("{}", v[i as usize][j as usize]);
				}
			}
			println!("");
		}
	}
}

Measured memory_bytes: 4352
##### C 再チャレンジ

##以下、二次元配列を、各リストの最初の要素でソートするアルゴリズム

def two_dim_merge_sort(arr):#＃arrは二次元配列
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = two_dim_merge_sort(left)
    right = two_dim_merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return two_dim_merge(left, right)


def two_dim_merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i][0] <= right[r_i][0]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

##ここまで

n, m = map(int,input().split())

l = [0]*n

for i in range(0,n):
    l[i] = list(map(int,input().split()))

s = two_dim_merge_sort(l)

num = 0
ex = 0

for i in range(0,n):
    if num + s[i][1] <= m:
        ex = ex + s[i][0] * s[i][1]
        num = num + s[i][1]
    else:
        ex = ex + s[i][0] * (m-num)
        num = m
    if num == m:
        break
        
print(ex)

Measured memory_bytes: 29728
n = int(input())
s = input()
dup = 0
r = s.count('R')
g = s.count('G')
b = s.count('B')

for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n:
            #print(i,j,k)
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[i] != s[k]):
                #print(s[i], s[j], s[k])
                dup += 1
print(r*g*b - dup)

Measured memory_bytes: 73708
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,b,sq,x,y,ans=(long long)1e18,c,tem,ss;
	scanf("%lld %lld",&n,&b);
	sq=max((long long)sqrt(n),min((long long)10000000,n));
	if(n==b)ans=n+1;
	for(long long i=2;i<=sq;i++)
	{
		tem=n;
		ss=0;
		while(tem>0)
		{
			ss+=tem%i;
			tem/=i;
		}
		if(ss==b)ans=min(ans,i);
	}
	x=n+1;
	for(long long i=2;i<=sq;i++)
	{
		y=x-1;
		x=(n+i)/i;
		c=(i-1)+(n%(i-1));
		if(b%(i-1)==c%(i-1))
		{
			//printf("*/*/ %lld\n",i);
			if(y-(b/(i-1))+1>=x)
			{
				if(y-(b/(i-1))+1==1)continue;
				tem=n;
				ss=0;
				while(tem>0)
				{
					ss+=tem%(y-(b/(i-1))+1);
					tem/=(y-(b/(i-1))+1);
				}
				if(ss==b)ans=min(ans,y-(b/(i-1))+1);	
				//printf("%lld %lld\n",y-(b/(i-1))+1,ss);
			}	
		}	
	}
	if(ans==(long long)1e18||ans<2)printf("-1");
	else printf("%lld",ans);
}

Measured memory_bytes: 256
// AOJ TP2_2_A: Stack
// 2018.6.24 bal4u

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

typedef struct { char id; int t; char x[13]; } BUF;
BUF buf[200005];
int qend[1002];
int *Q[1002];
char a[30];

int main()
{
	int n, q, i, t;
	char *p;
	
	fgets(a, 30, stdin);
	n = atoi(a);
	p = a; while (*p >= '0') p++; q = atoi(p+1);
	for (i = 0; i < q; i++) {
		fgets(a, 30, stdin);
		buf[i].id = a[0];
		t = 0, p = a+2;
		while (*p >= '0') t = 10*t + (*p++ & 0xf);
		buf[i].t = t;
		if (a[0] == '0') {
			qend[t]++;
			strcpy(buf[i].x, p+1);
		}
	}
	for (i = 0; i < n; i++) if (qend[i] > 0) {
		Q[i] = malloc(qend[i]*sizeof(int)), qend[i] = 0;
	}
	
	for (i = 0; i < q; i++) {
		t = buf[i].t;
		if (buf[i].id == '0') Q[t][qend[t]++] = i; // push
		else if (buf[i].id == '1') {  // top
			if (qend[t] > 0) {
				printf(buf[Q[t][qend[t]-1]].x);
			}
		}
		else {  // pop
			if (qend[t] > 0) qend[t]--;
		}
	}
	return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int n;
    cin >> n;
    vi t(n);
    int sum = 0;
    rep(i, n) {
        cin >> t[i];
        sum += t[i];
    }

    int m;
    cin >> m;
    rep(i, m) {
        int p, x;
        cin >> p >> x;
        --p;
        cout << sum - t[p] + x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int time[] = new int[n];
    int count = 0;
    
    for(int i = 0 ; i < n ; ++i){
      time[i] = sc.nextInt();
    }
    
    int total = t;
    
    for(int i = 0 ; i < n-1 ; ++i){
      if(time[i+1]-time[i] <= t){
        total += time[i+1]-time[i];
      }else{
        total += t;
      }
    }
    
    System.out.println(total);
    
  }
}



Measured memory_bytes: 60320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,count = 0;
  cin >> N >> K;
  int h[N];
  for(int i = 0; i < N; i++){
  	cin >> h[i];
    if(h[i] >= K){
    	count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int M = Integer.parseInt(strArr[1]);
		if (N == M)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22996
#include <iostream>

int main(int argc, char const* argv[])
{
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a < b && b < c)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    scan.close();

    long sum = 0;
    for(int i=1; i<=N; i++) {
      if(i%3 != 0 && i%5 != 0) {
        sum += (long)i;
      }
    }

    System.out.println(sum);
  }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k;
void solve(){
	cin >> n >> k;
	
	i64 ans = k;
	for(int i = 1; i < n; i++){
		ans *= k-1;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin >>n >> k;
    ll ans=0;
    while(n){ans++;n/=k;}
    cout << ans;
    }

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    long long int x,y,z,count=0,count_1=1;
    while((scanf("%lld %lld",&x,&y))!=EOF)
    {
        if(x>=0&&y<=1000000)
        {
            z=x+y;
            //m=z;
            while(z!=0)
            {
                z=z/10;

                count++;
            }
            printf("%lld\n",count);

        }
         count=0;
        if(count_1>200)
            break;
            count_1++;
    }

    return 0;
}

Measured memory_bytes: 596