akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int64_t get_int(void) {
  int64_t num;
  scanf("%lld", &num);
  return num;
}

#define NUM_MAX 50
int main(void) {
    int64_t k = get_int();
    int64_t quo = k/NUM_MAX;
    int64_t rem = k%NUM_MAX;

    int64_t arr[NUM_MAX];
    int i;
    for(i = 0; i < rem; i++) {
        arr[i] = quo + NUM_MAX;
    }
    for(i = rem; i < NUM_MAX; i++) {
        arr[i] = quo + (NUM_MAX-rem-1);
    }

    printf("%d\n", NUM_MAX);
    for(i = 0; i < NUM_MAX; i++) {
        printf("%lld%c", arr[i], i == (NUM_MAX-1) ? '\n' : ' ');
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int array[n];
    for(int i=0; i<n; i++){
    	cin >> array[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
    	for(int j=i+1; j<n; j++){
    		ans += array[i]*array[j];
    	}
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
N,C=map(int, input().split())
x=[]
v=[]

for i in range(N):
  xi,vi = map(int, input().split())
  x.append(xi)
  v.append(vi)

l1 = [0]
l2 = [0]
r1 = [0]
r2 = [0]

vtotal = 0
for i in range(N):
  vtotal += v[i]
  l1.append(max(l1[-1], vtotal - x[i]))
  l2.append(max(l2[-1], vtotal - 2 * x[i]))

vtotal = 0
for i in range(N-1, -1, -1):
  vtotal += v[i]
  r1.append(max(r1[-1], vtotal-(C-x[i])))
  r2.append(max(r2[-1], vtotal-2*(C-x[i])))

ans = 0
for i in range(N+1):
  ans = max(ans, l1[i] + r2[N-i], l2[i] + r1[N-i])

print(ans)

Measured memory_bytes: 29280
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool func(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	string S;
	ll ans, tmp, len;

	cin >> S;
	len = S.size();
	ans = len;

	for (int i = 0; i < len; i++) {

		if (S[i] != S[i + 1])ans = MIN(ans, MAX(i + 1, len - i - 1));

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
X, K, D = map(int, input().split())
X = abs(X)

if X > K*D:
  print(X-K*D)
  exit()

K -= X//D

if K%2 == 0:
  print(abs(X-(X//D)*D))
else:
  print(abs(X-(X//D)*D-D))

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;

long long  a[105];

int main(){
	int n;
	cin>>n;
    long long sum;
	long long ans;
	long long  maxx = -0x3f3f3f3f;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		maxx = max(maxx,a[i]);
	}
    ans = 0x3f3f3f3f;
	for(int i=1;i<=maxx;i++){
		sum = 0;
		for(int j=1;j<=n;j++){
			sum += (a[j]-i)*(a[j]-i);
		}
		ans = min(ans,sum);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<ll> c(n-1), s(n-1), f(n-1);
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
  vector<ll> ans(n);
  rep(i,n - 1) {
    ll temp = 0;
    for (int j = i; j < n - 1; j++) {
      if (temp < s[j]) temp = s[j];
      if (temp % f[j] != 0) temp += f[j] - temp % f[j];
      temp += c[j];
    }
    ans[i] = temp;
  }
  rep(i,n) cout << ans[i] << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(1000000)
a = list(map(int, input().split()))


def stair(n):
    if n == 1:
        return 1
    else:
        return (n * stair(n - 1)) % 1000000007
if abs(a[0] - a[1]) > 1:
    print("0")
elif abs(a[0] - a[1]) == 1:
    print((stair(a[0]) * stair(a[1]) % 1000000007))
else:
    print((stair(a[0]) * stair(a[1]) * 2)% 1000000007)


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

signed main() {
  int n,a,b;
  cin>>n>>a>>b;
  if(n==1){
    if(a!=b)cout<<0;
    else cout<<1;
  }
  else{
    if(a>b)cout<<0;
    if(a==b)cout<<1;
    if(a<b)cout<<(b-a)*(n-2)+1;
  }
  cout<<endl;
}


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

int main() {
  int k,a; string s;
  cin >> k >> s;
  a = s.size();
  if (k>=a) cout << s <<endl;
  else{
    for (int i=0 ; i<k; i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

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


void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long>> s, std::vector<long long> t){
    vector<long long> last(26);
    vector<long long> score(26);
    long long ans = 0;
    for (int d = 0; d < D; d++) {
        for (int i = 0; i < 26; i++) {
            if (i == t[d] - 1) {
                last[i] = d;
                ans += s[d][i];
                score[i] = 0;
            } else {
                score[i] -= c[i];
                ans += score[i];
            }
        }
        cout << ans << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    std::vector<long long> c(26);
    for(int i = 0 ; i < 26 ; i++){
        scanf("%lld",&c[i]);
    }
    std::vector<std::vector<long long>> s(D, std::vector<long long>(26));
    for(int i = 0 ; i < D ; i++){
        for(int j = 0 ; j < 26 ; j++){
            scanf("%lld",&s[i][j]);
        }
    }
    std::vector<long long> t(D);
    for(int i = 0 ; i < D ; i++){
        scanf("%lld",&t[i]);
    }
    solve(D, std::move(c), std::move(s), std::move(t));
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N;
    while (cin >> N) {
        string res = "";
        for (int i = 0; i < N; ++i) res += "ACL";
        cout << res << endl;
    }
}

















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

int main() {
int n;
  cin >> n;
  int ans = 0;
  while(true){
    if(n-3<0) break;
    else if(n-3>=0){
      n-=3;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout << n*n*n<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int D; cin >> D;
    vector<int> c(27);
    for (int i = 1; i < 27; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(D+1, vector<int> (27));
    for (int i = 1; i < D+1; i++) {
        for (int j = 1; j < 27; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D+1);

    ll score = 0;
    vector<int> last(27, 0);
    int M;
    int MJ;
    for (int i = 1; i < D+1; i++) {
        M = 0;
        for (int j = 1; j < 27; j++) {
            if(s[i][j] + c[j] * (i-last[j]) > M){
                M = s[i][j] + c[j] * (i-last[j]);    
                MJ = j;
            }
        }
        t[i] = MJ;
        score += s[i][MJ];
        last[MJ] = i;
        for (int j = 1; j < 27; j++) {
            score -= c[j] * (i - last[j]);
        }
    }
    for (int i = 1; i < D+1; i++) {
        printf("%d\n", t[i]);
    }

}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

typedef unsigned long long ull;
const ull B = 100000007;
const int MAX_LOG = 50;

signed main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<ull> H(n + 1);
    H[0] = 0;
    rep(i, n) {
        H[i + 1] = H[i] * B + s[i];
    }

    vector<ull> bb(MAX_LOG);
    bb[0] = B;
    rep(i, MAX_LOG - 1) {
        bb[i + 1] = bb[i] * bb[i];
    }

    set<ull> hash;
    int l = 1, r = 1;
    rep(i, m) {
        string q;
        cin >> q;
        if (q == "R++") {
            r++;
        } else if (q == "R--") {
            r--;
        } else if (q == "L++") {
            l++;
        } else if (q == "L--"){
            l--;
        }

        ull t = 1;
        ull e = r - l + 1;
        rep(i, MAX_LOG) {
            if (e & 1) {
                t *= bb[i];
            }
            e /= 2;
            if (e <= 0) break;
        }
        ull h = H[r] - t * H[l-1];
        hash.insert(h);
    }

    cout << hash.size() << endl;
}

Measured memory_bytes: 19452
#include<bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;

int ans ;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s;
	ull k;
	cin >> s >> k;
	for(int i=0;i<s.size();i++){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}else{
			ans++;
			if(ans == k){
				cout << 1 << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> A >> B >> C >> D;
	while(A > 0 && C > 0){
		C -= B;
		if(C <= 0){
			cout << "Yes";
			return 0;
		}
		A -= D;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nmax=55;
ll sum[nmax],p[nmax];
ll f(ll n,ll x){
  if(x==0||x==1){
    if(n==0&&x==1){
      return 1;
    }
    else{
      return 0;
    }
  }
  else if(x<=1+sum[n-1]){
    return f(n-1,x-1);
  }
  else if(x==2+sum[n-1]){
    return p[n-1]+1;
  }
  else if(x<=2+2*sum[n-1]){
    return p[n-1]+1+f(n-1,x-2-sum[n-1]);
  }
  else{
    return p[n];
  }
}
int main(){
  ll n,x;
  cin >> n >> x;
  p[0]=1;
  sum[0]=1;
  for(int i=1;i<=n;i++){
    sum[i]=3+sum[i-1]*2;
    p[i]=1+p[i-1]*2;
  }
  cout << f(n,x) << endl;
}

Measured memory_bytes: 256
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n; cin >> n;
    vector<map<char, int>> m(n);
    FOR(i, 0, n) {
        string s; cin >> s;
        each(j, s)++m[i][j];
    }

    FOR(i, 0, 26) {
        int cnt = INF;
        FOR(j, 0, n)chmin(cnt, m[j][char('a' + i)]);
        FOR(j, 0, cnt)cout << char('a' + i);
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

LL H, W, A, B;

using P = pair<LL, int>;

int ans[1000][1000];

int main() {
	cin >> H >> W >> A >> B;
	LL sum = H * (W - A);
	for (int i = 0; i <= H; ++i) {
		int j;
		if (B * 2 != H)j = (sum - (H - B) * W) / (B * 2 - H);
		else {
			if (sum != B * W) {
				continue;
			}
		}
		if (B * j + (H - B) * (W - j) != sum || j < 0 || W < j) {
			sum -= W - A;
			sum += A;
			continue;
		}
		set<P, greater<P>>S;
		for (int k = 0; k < i; ++k) {
			S.insert({ A,k });
		}
		for (int k = i; k < H; ++k) {
			S.insert({ W - A,k });
		}
		for (int m = 0; m < W; ++m) {
			int val;
			if (m < j) {
				val = B;
			}
			else {
				val = H - B;
			}
			for (int loop = 0; loop < val; ++loop) {
				auto top = *S.begin();
				S.erase(S.begin());
				top.first--;
				ans[top.second][m] = 1;
				S.insert(top);
			}
		}
		for (auto elm : S) {
			assert(elm.first == 0);
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cout << ans[i][j];
			}
			cout << endl;
		}
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#define MAX 2000000
 
int main(){
  int n;
  int i;
  int A[MAX];
 
  scanf("%d", &n);
 
  for ( i = 1; i <= n; i++ ){
    scanf("%d", &A[i]);
  }
 
  for ( i = 1; i <= n; i++ ) {
    printf("node %d: key = %d, ", i, A[i]); 
    if ( i / 2 >= 1 )printf("parent key = %d, ", A[i/2]);
    if ( i*2 <= n ) printf("left key = %d, ", A[i*2]);
    if ( i*2+1 <= n ) printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }
  
  return 0;
}

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

int main(){
  string s;
  cin>>s;
  int n=s.length();
  long long int sum=0;
  for (int i=0; i<n; i++){
    sum+=(s[i]-'0');
  }
  if (sum%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3748
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  if a[i]%2==0:
    if a[i]%3 !=0:
      if a[i]%5 !=0:
        b.append(0)
        break
if 0 in b:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   string S,T;
   cin>>S>>T;
   int count = 0;
   for(int i = 0;i<S.size();i++){
       if(S.at(i)!=T.at(i)){
           count++;
       }
   }
       cout<<count<<endl;
}
       
       
       
       
       
       
       
       
       
       
       
       
       
       
  



Measured memory_bytes: 3928
//---------------------------
// AOJ???????????¬???
// made by future731
// 2016/5/27
//---------------------------
#include <iostream>

int main()
{
    int in_second; // ??\??????????????????S
    int out_hour, out_minute, out_second; // ?????????h:m:s

    // ??\???
    std::cin >> in_second;

    // ?????????????¨????
    out_second = in_second % 60;
    out_minute = (in_second /60) % 60;
    out_hour = (in_second / 60) /60;
    // ??????
    std::cout << out_hour << ":" << out_minute << ":" << out_second << std::endl;

    return 0;
}

Measured memory_bytes: 1164
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < t; i++) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[]x = new int[n];
			for(int j = 0; j < n; j++) {
				x[j] = sc.nextInt();
			}
			if(k >= n) {
				sb.append(0).append("\n");
			}else {
				int []l = new int[n - 1];
				int sum = 0;
				for(int j = 0; j < n - 1; j++) {
					l[j] = x[j + 1] - x[j];
					sum += l[j];
				}
				Arrays.sort(l);
				for(int j = 0; j < k - 1; j++) {
					sum -= l[n - 2 - j];
				}
				sb.append(sum).append("\n");
			}
		}
		sc.close();
		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 102084
#include <iostream>

using namespace std;

string s;

int a[27];

int main() {
	cin >> s;
	bool flag = 1;
	for(int i = 0; i < s.length(); i++) {
		a[s[i] - 'A']++;
	}
	for(int i = 0; i < 27; i++) {
		if (a[i] > 0 && a[i] != 2) {
			flag = 0;
			break;
		}
	}
	if(flag) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
ll a, b, c;
int main() 
{
	rd(a), rd(b), rd(c);
	ll x = min(b - 1, c);
	printf("%lld\n", a * x / b - a * (x / b));
    return 0;
}

Measured memory_bytes: 1604
#include<iostream>

using namespace std;

int main() {
	int a[5], x[5];

	for (int i = 0; i < 5; i++) {
		a[i] = i+1;
		cin >> x[i];
		if (x[i] == 0) {
			cout << a[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
        sc.close();
    }
}


Measured memory_bytes: 40428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,i ,r =0 ,w =0 ,ans =0 ;

 		String s =fr.next() ;	n =s.length() ;

 		boolean ar[] =new boolean[n] ;

 		for (i =0 ; i<n ; ++i) {
 			if (s.charAt(i) == 'R') {
 				ar[i] =true ;	++r ;
 			}
 			else
 				++w ;
 		}

 		for (i =0 ; i<r ; ++i) {
 			if (!ar[i])
 				++ans ;
 		}

 		op.println(ans) ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 36420
<?php
  fscanf(STDIN,"%d %d", $n, $m);
  $g = [];
  for ($i=1; $i<=$n; $i++)  $g[$i] = [];
  for ($i=0; $i<$m; $i++) {
	fscanf(STDIN, "%d %d", $a, $b);
	$g[$a][] = $b;
    $g[$b][] = $a;
  }

  $ans = false;
  foreach ($g[1] as $u) {
    foreach($g[$u] as $v) {
      if ($v == $n) $ans = true;
      if ($ans) break;
    }
    if ($ans) break;
  }

  echo $ans? "POSSIBLE" : "IMPOSSIBLE";
?>

Measured memory_bytes: 93804
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi fwin(K+1,0);
  srep(i,1,K+1) {
    rep(j,N) {
      if(i-A[j]<0) continue;
      if(!fwin[i-A[j]]) {
        fwin[i]=true;
      }
    }
  }
  if(fwin[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
cin >>n;
cout <<n+n*n+n*n*n<<'\n';

  return(0);
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int a;
	double b;
	cin >> a;
	for(int i = 1;i <= 9;i++){
		for(int j = 1;j <= 9;j++){
			if(i * j == a){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}


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

int main() {
    char ch;
    cin >> ch;

    if (ch >= 'A' && ch <= 'Z') {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
using namespace std;
using ll = long long;
const int mod = 1000000007;
vector<vector<ll>> v;
map<pair<ll,ll>,ll> w;
vector<bool> col; 

void dfs(ll cur,ll par,bool color){
    col[cur] = color;
    ll N = v[cur].size();
    for(ll i=0;i<N;i++){
        ll nxt = v[cur][i];
        // cout<<"CUR:"<<cur<<", NXT:"<<nxt<<", PAR:"<<par<<endl;
        if(nxt==par)continue;
        ll _max = max(nxt,cur);
        ll _min = min(nxt,cur);
        if(w[make_pair(_min,_max)]%2==1){
            dfs(nxt,cur,!color);
        }else{
            dfs(nxt,cur,color);
        }

    }
}

int main(){
    ll N;
    cin>>N;
    v.resize(N);
    col.resize(N);
    for(ll i=0;i<N;i++)col[i]=false;
    for(ll i=0;i<N-1;i++){
        ll _u,_v,_w;
        cin>>_u>>_v>>_w;
        _u--;_v--;
        v[_u].push_back(_v);
        v[_v].push_back(_u);
        w[make_pair(_u,_v)]=_w;
    }
    dfs(0,-1,true);
    for(ll i=0;i<N;i++){
        cout<<col[i]<<"\n";
    }

}

Measured memory_bytes: 17536
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	int n;
	cin>>n;
	int *a=new int[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int j=0;
	int num=0;
	int flag=0;
	for(int i=0;i<n;i++){
		if(a[j]==2){
			flag=1;
			break;
		}
		num++;
		j=a[j]-1;
	}
	if(flag){
		cout<<num+1<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>

int main(void){
  char string1[10],string2[10];

  scanf("%s%s",string1,string2);

  int num=0;
  for(int i=0;i<3;i++){
    if(string1[i]==string2[i])num++;
  }

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

  return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    char ch; cin >> ch;
    ch+=1;
    cout << ch << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

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

const LL  INF=1<<31;



int main(){
     int n;
     cin>>n;
     int fun[100000][3];
     for(int i=0;i<n;++i){
          for(int j=0;j<3;++j){
               cin>>fun[i][j];
          }
     }
     LL dp[100001][3]={0};
     


     for(int i=0;i<n;++i){
          for(int j=0;j<3;++j){
               for(int k=0;k<3;k++){                   
                    if(j!=k)dp[i+1][k]=max(dp[i+1][k],dp[i][j]+fun[i][k]);
               }
          }
     }
     LL ma=dp[n][0];
     for(int i=1;i<3;++i){
          if(ma<dp[n][i])ma=dp[n][i];
     }
     cout<<ma<<endl;
}

Measured memory_bytes: 3712
#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<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<pair<ll,ll>, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;

ll a[200001];
int timer=1;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]-=k;
	}
	for(int i=1;i<n;i++)
	{
		a[i]+=a[i-1];
	}
	pbds tmp;
	ll ans=0;
	tmp.insert(mp(0,++timer));
	for(int i=0;i<n;i++)
	{
		ans+=tmp.order_of_key(mp(a[i]+1,-1));
		tmp.insert(mp(a[i],++timer));
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 14336
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;

int main()
{
    int n,d,x[20][50];
    while(~scanf("%d%d",&n,&d))
    {
        int cnt=0;
        int sum=0;
        for(int i=0;i<n;i++)
            for(int j=0;j<d;j++)
                scanf("%d",&x[i][j]);
        for(int i=0;i<n;i++)
            for(int j=i+1;j<n;j++)
            {
                sum=0;
                for(int o=0;o<d;o++)
                {
                    sum+=(x[i][o]-x[j][o])*(x[i][o]-x[j][o]);
                }
                if(sum==(int)((int)sqrt(sum)*(int)sqrt(sum)))
                cnt++;
            }
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,k;
    map<int,int>cnt;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        int d;
        cin>>d;
        for(int j=1;j<=d;j++){
            int v;
            cin>>v;
            cnt[v]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(cnt[i]==0) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readInt()
	a := readIntSlice(n)

	//
	d := make(map[int]bool)

	for i := 0; i < n; i++ {
		if _, ok := d[a[i]]; ok {
			// 2つ以上ある場合は割れる数がある
			d[a[i]] = true
		} else {
			d[a[i]] = false
		}
	}

	// fmt.Println("debug:", d)

	keys := []int{}

	for i := range d {
		keys = append(keys, i)
	}

	sort.Ints(keys)

	for _, v := range keys {
		// fmt.Println("v", v, "dv", d[v])

		// if d[v] == true {
		// 	for j := 2; j*v <= keys[len(keys)-1]; j++ {
		// 		// fmt.Println("jv", j*v)
		// 		if _, ok := d[j*v]; ok {
		// 			d[j*v] = true
		// 		}
		// 	}
		// }

		for j := 2; j*v <= keys[len(keys)-1]; j++ {
			// fmt.Println("jv", j*v)
			if _, ok := d[j*v]; ok {
				d[j*v] = true
			}
		}

	}

	// fmt.Println("d", d)
	answer := 0
	for _, v := range d {
		if v == false {
			answer++
		}
	}

	fmt.Println(answer)
}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.Atoi(t)
	if err != nil {
		log.Fatal(err)
	}

	return n

}

func readIntSlice(n int) []int {
	s := make([]int, n)
	var t string

	for i := 0; i < int(n); i++ {
		if scanner.Scan() {
			t = scanner.Text()
		}

		num, err := strconv.Atoi(t)
		if err != nil {
			log.Fatal(err)
		}
		s[i] = num
	}

	return s
}


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

long long int N, a[60] = {2, 7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297, 1307, 1327, 1367, 1427, 1447};

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        cout << a[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize, k: usize,
    }
    let mut snuke = vec![1; n];
    for _ in 0..k {
        proconio::input! {
            d: usize,
            a: [usize; d],
        }
        for i in 0..d {
            snuke[a[i] - 1] = 0;
        }
    }
    let total: i32 = snuke.iter().sum();
    println!("{}", total);
}


Measured memory_bytes: 2136
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 998244353
#define INIT -1

long long int fact[200010] = {};

long long int mypow(long long int x, long long int n)
{
   if (n == 0)
      return 1;
   long long int tmp = mypow(x, n / 2);
   long long int res = (tmp * tmp) % MOD;
   if (n % 2 == 1)
      res = (res * x) % MOD;
   return res;
}

long long int comb(int n, int r)
{
   long long int res = fact[n];
   res = (res * mypow(fact[r], MOD - 2)) % MOD;
   res = (res * mypow(fact[n - r], MOD - 2)) % MOD;
   return res;
}

int main()
{
   long long int n, m, k;
   cin >> n >> m >> k;

   fact[0] = 1;
   for (int i = 1; i <= n - 1; i++)
   {
      fact[i] = (fact[i - 1] * i) % MOD;
   }

   long long int ans = 0;
   for (int i = 0; i <= k; i++)
   {
      ans += (m * ((comb(n - 1, i) * mypow(m - 1, n - 1 - i)) % MOD)) % MOD;
      ans %= MOD;
   }
   cout << ans << endl;
}

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

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

  if(S.size()<4){
    cout << "No" << endl;
    return 0;
  }
  if(S.substr(0,4)=="YAKI") cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

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


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

  int N, M;
  string S;
  cin >> N >> M;
  cin >> S;
  int iti = N;
  vector<int> ans;
  while(iti > 0){
    int a = max((int)0,iti - M);
    bool ans1 = false;
    for(int i=a;i<iti;i++){
      if(S[i] == '0'){
        ans.push_back(iti - i);
        ans1 = true;
        iti = i;
        break;
      }
    }
    if(ans1 == false){
      cout << -1 << endl;
      return 0;
    }
  }

  for(int i=ans.size()-1;i>=0;i--){
    cout << ans[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1480
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int N;
	cin>>N;
	int A[N];
	for(int i=0; i<N; i++) cin>>A[i];
	double ans, temp[N], t=0.0;
	for(int i=0; i<N; i++) temp[i]=1.0/A[i];
	for(int i=0; i<N; i++) t+=temp[i];
	ans=1.0/t;
	printf("%.14f", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    if(N % 2 == 0){
        cout << N / 2 - 1 << endl;
    }else{
        cout << N / 2 << endl;
    }
    return 0;
}

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

int main() {
	
	long long k,a,b;cin>>k>>a>>b;
	
	if(a>=b || k<=a){
		cout<<k+1<<endl;
		return 0;
	}
	
	
	long long x=k-(a+1);
	long long ans=b;
	
	long long cnt=x/2;
	
	ans+=(b-a)*cnt;
	
	if(x%2==1){
		ans++;
	}
	
	if(ans<k+1){
		ans=k+1;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

//

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<utility>
#include<vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

typedef std::pair<int, int> P;

int N, M;
std::vector<P> ps;

int main()
{
  while( scanf( "%d%d", &N, &M ), N|M )
  {
    ps.clear();

    rep( i, N )
    {
      int d, p;
      scanf( "%d%d", &d, &p );

      ps.push_back( P( -p, d ) );
    }

    std::sort( ps.begin(), ps.end() );

    int p = 0, ans = 0;
    while( M > 0 && p < N )
    {
      M -= ps[p].second;

      if( M < 0 )
	ans += (-ps[p].first)*(-M);

      ++p;
    }

    while( p < N )
      ans += (-ps[p].first)*(ps[p].second), ++p;

    printf( "%d\n", ans );
  }
  
  return 0;
}

Measured memory_bytes: 2792
#line 2 "../../library/template.cpp"

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

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 2 "a.cpp"

ll h, w;
string s[100];
ll dp[100][100];

ll dfs(ll i, ll j) {
  if (i == h-1 and j == w-1) return 0;

  if (dp[i][j] != -1) {
    return dp[i][j];
  }

  ll n = 1LL<<60, m = 1LL<<60;
  if (i+1 < h) n = dfs(i+1, j);
  if (j+1 < w) m = dfs(i, j+1);

  if (i+1 < h and s[i+1][j] == '#' and s[i][j] == '.') {
    n++;
  }
  if (j+1 < w and s[i][j+1] == '#' and s[i][j] == '.') {
    m++;
  }
  
//  if (i == 0 and j == 0 and s[i][j] == '#') {
//    if (i+1 < h and s[i+1][j] == '.') {
//      n++;
//    }
//    if (j+1 < w and s[i][j+1] == '.') {
//      m++;
//    }
//  }
  return dp[i][j] = min(n, m) + (i == 0 and j == 0 and s[i][j] == '#' ? 1 : 0);
}

bool visit[100][100];

bool dfs2(ll i, ll j) {
  visit[i][j] = true;
  if (i == h-1 and j == w-1) return s[i][j] == '#';
  if (s[i][j] == '.') {
    return false;
  }

  bool ret = false;;
  if (i+1 < h) ret |= dfs2(i+1, j);
  if (j+1 < w) ret |= dfs2(i, j+1);

  return ret;
}

int main() {
  cin >> h >> w;
  rep(i, h) {
    cin >> s[i];
  }

  bool f = 1;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') {
        f = 0;
      }
    }
  }
  if (f) {
    cout << 1 << endl;
    return 0;
  }

  ll ans = 1LL<<60;

//  if (dfs2(0, 0)) {
//    ans = 1;
//  }

  rep(i, h) {
    rep(j, w) {
      dp[i][j] = -1;
    }
  }

  cmin(ans, dfs(0, 0));

  cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  char c;
  bool flag=false;
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=='Y') flag=true;
  }
  if(flag) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char aa[3];
    cin>>aa;
    char a=aa[strlen(aa)-1];
    if(a=='2'||a=='4'||a=='5'||a=='7'||a=='9'){
    	cout<<"hon";
	}
	else if(a=='1'||a=='0'||a=='6'||a=='8'){
		cout<<"pon";
	}
	else{
		cout<<"bon";
	}
	return 0;
}

Measured memory_bytes: 3652
// 個数制限なしナップサックDP
#include <bits/stdc++.h>
using namespace std;
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }

const int MAX_N = 15;
const int MAX_W = 110000;
int dp[MAX_N][MAX_W];

int main() {
    int N; cin >> N;
    vector<int> weight;
    for (int i=1;i<=N;i*=6) weight.push_back(i);
    for (int i=9;i<=N;i*=9) weight.push_back(i);
    int n = (int)weight.size();

    for (int i=0;i < MAX_N; ++i) for (int w=0;w<MAX_W;++w) dp[i][w] = 1<<29;
    for (int i=0;i<=n;++i) dp[i][0] = 0;

    for (int i=0;i<n;++i){
        for (int w=0;w<=N;++w){
            if (w>=weight[i]) chmin(dp[i+1][w], dp[i+1][w-weight[i]]+1);
            chmin(dp[i+1][w], dp[i][w]);
        }
    }

    cout << dp[n][N] << endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    //cout << sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)) << endl;
    printf("%.6f\n", sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)));
    return 0;
}


Measured memory_bytes: 3284
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 200010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]
 
def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))
 
def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))
 
def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD
 
    return (num*(pow(den,MOD-2,MOD)))%MOD
 
def flush():
    return sys.stdout.flush()
 
'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n = int(input())
a = [arrIN() for _ in range(n)]
dp = deepcopy(a)
for i in range(1,n):
    for j in range(3):
        dp[i][j]+=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])
print(max(dp[-1]))


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
  }

  ll ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      for(int k = j + 1; k < n; k++) {
        if (v[i] != v[j] && v[j] != v[k] && v[k] != v[i]) {
          if (v[i] + v[j] > v[k] && v[j] + v[k] > v[i] && v[k] + v[i] > v[j]) ans++;
        }
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int n[50] = {0};
    REP(a,10) {
        REP(b,10) {
            REP(c,10) {
                REP(d,10) {
                    if (a+b+c+d>0 && a+b+c+d<=50) n[a+b+c+d-1]++;
                }
            }
        }
    }
    
    int k;
    while(cin >> k) {
        cout << n[k-1] << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>M>>K;
    cout<<max(K+M-N,0LL)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	
	int modul;
	long long int total=0;
	int sum;
	for(int i=1; i<=n; i++){
		int j=i;
		sum=0;
		while (j>0){
			modul=j%10;
			j=j/10;
			sum+=modul;
		}		
		if(sum>=a && sum<=b){
		
		total+=i;
		}
		
		
		
	}

	printf("%lld\n", total);

    return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;

/* セグフォ 再帰による計算 答えが大きすぎる
int solve(int X, int Y){
  if(X == 0 && Y == 0) return 1;
  if(X == 0 && Y == 1) return 0;
  if(X == 1 && Y == 0) return 0;
  if(X < 0 || Y < 0) return 0;
  return solve(X-1, Y-2) + solve(X-2, Y-1);
}
*/

/* セグフォ 再帰による計算 答えが大きすぎる
int factorial(int i){
  if(i == 0) return 1;
  return (i * factorial(i-1)) % (int)(1e9 + 7);
}
*/

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// n の階乗
ll factorial(ll n){
  vector<ll> fac(n+1, 1);
  for(ll i=1; i < n+1; i++){
    fac[i] = fac[i-1]*i%MOD;
  }
  return fac[n];
}

// nCk
ll nCk(ll n,ll k){
  if(n<k)return 1;if(k<0)return 0;
  ll res=factorial(n);
  res*=modinv(factorial(k),MOD);res%=MOD;
  res*=modinv(factorial(n-k),MOD);res%=MOD;
  return res;
}



ll solve(ll X, ll Y){
  if((X + Y) % 3 != 0) return 0;
  else if((X + Y) / 3 >= (2 * X - Y)) return nCk((X + Y) / 3, (2 * X - Y) / 3); 
  else return nCk((X + Y) / 3, (2 * Y - X) / 3);
}

int main(){
  ll X, Y;
  cin >> X >> Y;
  ll res = solve(X, Y);
  cout << (res >= 0 ? res : (res + MOD)) << endl;
}

Measured memory_bytes: 5504