akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr long INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

int n, a;
vector<pair<int,int>> ps;

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n;
  REP(i,n) {
    cin >> a;
    ps.emplace_back(a, i+1);
  }
  sort(ps.begin(),ps.end());
  REP(i,n) cout << ps[i].second << endl;
  return 0;
}

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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int X = max(A, max(B, C));
    int Y = X;
    for (int i = 0; i < K; i++){
        Y *= 2;
    }
    int ans = A + B + C + Y - X;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


long long N, T, Q;
long long a[100000], d[100000], q[1000];
vector<long long> stop;

int main() {
	cin >> N >> T >> Q;

	for (int i = 0; i < N; i++) {
		cin >> a[i] >> d[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> q[i];

		q[i]--;
	}

	for (int i = 0; i < N-1; i++) {
		if (d[i] < d[i + 1]) {
			stop.push_back((a[i]+a[i+1]) / 2);
		}
	}

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

		if (d[ q[i]] == 1) {
			for (int j = 0; j < stop.size(); j++) {

				if (a[q[i]] < stop[j]) {
					cout << min(a[q[i]] + T, stop[j]) << endl;
					break;
				}
				else if (j == stop.size() - 1) {
					cout << a[q[i]] + T << endl;
				}
			}
		}

		if (d[q[i]] == 2) {
			for (int j = stop.size()-1; j >= 0; j--) {

				if (a[q[i]] > stop[j]) {
					cout << max(a[q[i]] - T, stop[j]) << endl;
					break;
				}
				else if (j == 0) {
					cout << a[q[i]] - T << endl;
				}
			}
		}


	}


	return 0;
}




Measured memory_bytes: 4736
S = int(input())
mod = 10 ** 9 + 7

if S <= 2:
    print(0)
    exit()

ans = 0
max_items = S // 3

# print("max_items", max_items)

for item in range(1, max_items + 1):
    # print("---------------------------")
    # print("item", item)
    n = S - 3 * item
    # print("n", n)
    if n == 0:
        ans += 1
        break

    modinv_table = [-1] * (n + 1)
    modinv_table[1] = 1
    for i in range(2, n + 1):
        modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

    add = 1
    for p in range(n):
        add *= (n + item - 1) - p
        add *= modinv_table[p + 1]
        add %= mod


    # print("add", add)


    ans += add
    ans %= mod



print(ans)


Measured memory_bytes: 9208
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
from collections import deque
l = []
r = []
for i in a:
  if i < 0:
    l.append(i)
  else:
    r.append(i)
    
ll = len(l)
rr = len(r)
r.sort()
l.sort()
ans = []
l = deque(l)
r = deque(r)

for i in range(n-1):
  if ll == 0:
    mi = r.popleft()
    ma = r.pop()
    ans.append((mi,ma))
    l.append(mi-ma)
    ll += 1
  else:
    if rr > 1:
      L = l.pop()
      R = r.pop()
      ans.append((L,R))
      l.append(L-R)
      rr -= 1
    elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
    else:
      mi = l.popleft()
      ma = l.pop()
      ans.append((ma,mi))
      r.append(ma-mi)
      rr += 1
      
p,q = ans[-1]
print(abs(p-q))
if p < q:
  ans[-1] = (q,p)
for i,j in ans:
  print(i,j)

Measured memory_bytes: 20872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll L;
    cin >> L;
    double ans = pow(L/3.0, 3.0);
    printf("%.07f\n", ans);
}


Measured memory_bytes: 4048
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#include <iomanip>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 1000000;
const int MAX_DIGIT = 6;
long long n, m;
long long p[MAX_NUM], y[MAX_NUM];
vector<long long> ans[MAX_NUM + 1];
void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> y[i];
    }
    for (int i = 0; i < m; i++) {
        ans[--p[i]].push_back(y[i]);
    }
    for (int i = 0; i < n; i++) {
        sort(ans[i].begin(), ans[i].end());
    }
    for (int i = 0; i < m; i++) {
        printf("%06lld%06lld\n", p[i] + 1, lower_bound(ans[p[i]].begin(), ans[p[i]].end(), y[i]) - ans[p[i]].begin() + 1);
    }
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 35328
#include<iostream>
using namespace std;
int main(){
    int n,i;
    cin >> n;
    int a[n];
    for(i = 0; i < n; i++){
        int x;
        cin>>x;
        a[n-1-i]=x;
    }
    int j;
    for ( j = 0; j < n; j++ ){
        if ( 1<=j && j<n ) cout<<" "; 
        cout<<a[j];
}
    cout<<endl;
    return 0;
    
}


Measured memory_bytes: 3076
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

//long A[12345],B[12345];

int main(){
 
    long n;
    cin>>n;
    uint64_t minB_a,minB_b=UINT64_MAX,maxB_a,maxB_b=0;
    uint64_t a,b;
    REP(i,n){
        cin>>a>>b;

        if(minB_b>b){
            minB_b=b;
            minB_a=a;
        }

        
        if(maxB_b<b){
            maxB_b=b;//最大得点
            maxB_a=a;//最大得点者の順位
        }
    }
   
  
    cout<<(minB_a+minB_b)<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, m, i, j, k, minn, minid, s;
	cin >> n >> m;
	vector<int> x(n), y(n), xx(m), yy(m), ans(n);
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (i = 0; i < m; i++) cin >> xx[i] >> yy[i];

	for (i = 0; i < n; i++) {
		minn = 1000000000;
		for (j = 0; j < m; j++) {
			s = abs(xx[j] - x[i]) + abs(yy[j] - y[i]);
			if (s < minn) {
				minn = s; minid = j;
			}
		}
		ans[i] = minid + 1;
	}

	for (auto p : ans) cout << p << "\n";

	return 0;
}



Measured memory_bytes: 888
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n, m = map(int, input().split())
  l = [list(map(int, input().split())) for i in range(m)]
  ways = [[] for i in range(n+1)]
  for i in l:
    ways[i[0]].append(i[1])
    ways[i[1]].append(i[0])
  que = collections.deque()
  ans = [-1]*n
  que.append(1)
  ans[0] = 0
  while(len(que)!=0):
    item = que.popleft()
    for i in ways[item]:
      if ans[i-1] == -1:
        ans[i-1] = item
        que.append(i)
  if -1 in ans:
    print("No")
  else:
    print("Yes")
    for i in range(1,n):
      print(ans[i])
  return 0
 
if __name__ == "__main__":
  solve()


Measured memory_bytes: 79136
#include <iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;
 
int main() {
    string s;
    cin>>s;
    int n = s.size();
    string t=s;
    if(s[n-1]=='s')
    {
        t = t + 'e';
    }
    t = t + 's';
    cout<<t;
	return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(d < a or b < c) {
        cout << 0 << endl;
        return 0;
    }

    cout << (min(b, d) - max(a, c)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("../ip.txt", "r", stdin);
//    freopen("../op.txt", "w", stdout);
//#endif
    AKASH_PATEL;
    SVNIT_SURAT;
    int t=1;
//    cin>>t;
    queue <ll> q;
    fpr(i,1,10)
    {
        q.push(i);
    }
    ll cnt=0;
    vector <ll> v;
    while (!q.empty() && cnt<100000)
    {
        ll tp=q.front();
        q.pop();
        v.pb(tp);
        string s=to_string(tp);
        int x=s.back()-'0';
        if(x-1>=0)
        {
            q.push(stoll(s+char((x-1)+'0'), nullptr,10));
        }
        if(x>=0)
        {
            q.push(stoll(s+char((x)+'0'), nullptr,10));
        }
        if(x+1<=9)
        {
            q.push(stoll(s+char((x+1)+'0'), nullptr,10));
        }
        cnt++;
    }
//    print_arr(v,30)
    while(t--)
    {
        ll n;
        cin>>n;
        cout<<v[n-1]<<'\n';
    }
    return 0;
}





Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
int n,a,f;
vector<int> t;
int c0,c1,c2,c3;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a==0)c0++;
    if(a==1)c1++;
    if(a==2)c2++;
    if(a==3)c3++;
    if(a>=2)t.push_back(a);
  }
  n=t.size();
  sort(t.begin(),t.end());

  if(c2>0&&c3==1&&t.back()==3){
    f=1;    
    swap(t[n-1],t[n-2]);
  }

  
  if(c0==0){
    for(int i=0;i<n;i++)cout<<t[i]<<endl;
    for(int i=0;i<c1;i++)cout<<1<<endl;
    return 0;
  }
  
  if(c0%2==0){
    for(int i=0;i<n;i++)cout<<t[i]<<endl;
    for(int i=0;i<c0;i++)cout<<0<<endl;
    for(int i=0;i<c1;i++)cout<<1<<endl;
    return 0;
  }

  if(c1>0){
    for(int i=0;i<n;i++)cout<<t[i]<<endl;
    for(int i=0;i<c0-1;i++)cout<<0<<endl;
    cout<<1<<endl;
    cout<<0<<endl;
    for(int i=0;i<c1-1;i++)cout<<1<<endl;
    return 0;
  }
  
  if(n>0){
    
    if(f){
      if(c2==1)sort(t.begin(),t.end());
    }else sort(t.begin(),t.end());
    
    for(int i=1;i<n;i++)cout<<t[i]<<endl;
    for(int i=0;i<c0-1;i++)cout<<0<<endl;
    cout<<t[0]<<endl;
    cout<<0<<endl;
    return 0;
  }
  
  for(int i=0;i<c0;i++)cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> hs(N);
    for (int i = 0; i < N; i++) {
        std::cin >> hs.at(i);
    }
    std::vector<int> costs(N);
    costs.at(0) = 0;
    costs.at(1) = std::abs(hs.at(1) - hs.at(0));
    for (int i = 2; i < N; i++) {
        costs.at(i) = std::min<int>(costs.at(i - 1) + std::abs(hs.at(i) - hs.at(i - 1)),
                costs.at(i - 2) + std::abs(hs.at(i) - hs.at(i - 2)));
    }
    std::cout << costs.at(N - 1) << std::endl;
    return 0;
}

Measured memory_bytes: 1024
namespace Rectangle {
    class Program {
        static void Main(string[] args) {
            string[] N = System.Console.ReadLine().Split(' ');
            int a = System.Convert.ToInt32(N[0]);
            int b = System.Convert.ToInt32(N[1]);

            int menseki = a * b;
            int shu = a * 2 + b * 2;
            System.Console.WriteLine(menseki + " " + shu);
        }
    }
}

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

typedef long long ll;
ll MOD = 1e9+7;

int dp[3001][3001];//dp[i][j]...最適アラインメント

int main()
{
	string s,t;
	string ans="";
	cin>>s;
	cin>>t;
	
	fill(dp[0],dp[3001],0);
	//ここからDP
	for(int i=1;i<=s.size();i++)
	{
		for(int j=1;j<=t.size();j++)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(s[i-1]==t[j-1])
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
		}
	}
	//ここまでDP
	cerr<<s.size()<<" "<<t.size()<<endl;
	cerr<<dp[s.size()][t.size()]<<endl;

	//逆順にたどる
	int a=s.size();
	int b=t.size();
	int d=dp[s.size()][t.size()];
	while(d!=0)
	{
		while(dp[a-1][b]==d)
			a--;
		while(dp[a][b-1]==d)
			b--;
		ans+=s[a-1];
		a--;b--;d--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main(){
    int i,n;
    scanf("%d",&n);
    int *a = (int *)malloc(sizeof(int)*n);
    for(i=0;i<n;i++)scanf("%d",a+i);

    sort(a,a+n);

    long long int ans = 0;
    int m = n/2;
    if(n%2){
        long long int tmp1,tmp2;
        tmp1 = 2*a[m+1]-a[m]-a[m-1];
        tmp2 = a[m+1]+a[m]-2*a[m-1];

        for(i=0;i<m-1;i++){
            ans-=a[i]*2;
        }
        for(i=m+2;i<n;i++){
            ans+=a[i]*2;
        }
        ans+=max(tmp1,tmp2);
    }else{
        for(i=0;i<m-1;i++){
            ans-=a[i]*2;
        }
        ans-=a[m-1];
        ans+=a[m];
        for(i=m+1;i<n;i++){
            ans+=a[i]*2;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 512
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		ll a[n];
		c=1;
		rep(i,n)
		{
			cin>>a[i];
			if(a[i]==0)
				c=0;
		}
		if(c==0)
		{
			cout<<"0\n";
			return 0;
		}
		rep(i,n)
		{
			k=a[i];
			m=c;
			if(c>(1000000000000000000ll/k))
			{
				c=-1;
				break;
			}
			c*=k;
		}
		// c=n*m;
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <stdio.h>

int main()
{
  std::string c;
  int sum = 0;
  std::cin >> c;
  for (int i=0; i<c.length(); ++i)
  {
    sum += c.c_str()[i] - '0';
  }
  if (sum % 9)
  {
    std::cout << "No";
  }
  else
  {
    std::cout << "Yes";
  }
  return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    long long a,b,k;
    cin >> a >> b >> k;

    if(a >= k){
        cout << a -k << " "<< b;
    }else if(k <= a+b){
        cout << 0 << " " << b - (k - a);
    }else{
        cout << 0 << " " << 0;
    }
}
   


Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll ans = A[0];
  for(int i=1;i<N-1;++i) {
    ans += A[(i+1)/2];
  }
  cout<<ans<<endl;
}



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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

string s;

void read() {
  cin >> s;
}

void solve() {
  int sol = 0;
  stack <char> st;
  for(int i = 0; s[i]; ++i) {
    if (st.empty() || st.top() == s[i]) {
      st.push(s[i]);
    } else if (!st.empty()) {
        st.pop();
        sol += 2;
    }
  }
  cout << sol;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


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

int main() {
  int h,w;cin >> h >>w;
  vector<vector<char>> v(h+2, vector<char>(w+2,'.'));
  for (int i = 1; i< h+1; i++){
    for (int j =1; j < w+1; j++){
      cin>>v.at(i).at(j);
    }
  }
  
  bool ok = true;
  for (int i = 1; i< h+1; i++){
    for (int j =1; j < w+1; j++){
      if (v.at(i).at(j) == '.'){
        continue;
      }
      else if(v.at(i-1).at(j) == '.' && v.at(i+1).at(j) == '.' && v.at(i).at(j-1) == '.' && v.at(i).at(j+1) == '.'){
        ok = false;
        break;
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  
  if (a == 0) {
    cout << 0 << endl;
    return 0;
  }
  
  ll term = a + b;
  ll ans = (n / term) * a;
  ll diff = n - (n / term) * term;
  if (diff != 0) {
    if (diff > a) {
      ans += a;
    } else {
      ans += diff;
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
const int MAXN=2005;
const int MAXM=4000005;
const int MOD=1e9+7;

ll n,k;
ll d[MAXN][MAXN],fac[MAXM],inv[MAXM];

void Init(){
    fac[0]=1;
    for(int i=1;i<MAXM;i++) fac[i]=fac[i-1]*i%MOD;
    inv[1]=1;
    for(int i=2;i<MAXM;i++) inv[i]=1ll*(MOD-MOD/i)*inv[MOD%i]%MOD;
    inv[0]=1;
    for(int i=1;i<MAXM;i++) inv[i]=inv[i]*inv[i-1]%MOD;
}

ll C(ll x,ll y){
    if(x<y) return 0;
    return (fac[x]*inv[y]%MOD)*inv[x-y]%MOD;
}

int main(){

    Init();
    scanf("%lld%lld",&n,&k);
    if(k==1) return puts("1"),0;
    d[0][0]=1;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=i;j++){
            if(i) d[i][j]=d[i-1][j];
            if(j) d[i][j]=(d[i][j]+d[i][j-1]*C(n*k-i-(j-1)*(k-1)-1,k-2)%MOD)%MOD;
        }
    d[n][n]=(d[n][n]*fac[n])%MOD;
    printf("%lld",d[n][n]);

    fclose(stdin);
    fclose(stdout);
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N; cin >> N;
  int C[N], S[N], F[N];
  rep(i, N-1) cin >> C[i] >> S[i] >> F[i];
  rep(i, N){
    int now = i;
    int tm = 0;
    while(now < N-1){
      if(tm < S[now]){
        tm = S[now] + C[now];
        now++;
      }
      else{
        while(tm%F[now]) tm++;
        tm += C[now];
        now++;
      }
    }
    cout << tm << endl;
  }
  return 0;
}

Measured memory_bytes: 3660
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
S = list(map(int,input()))
steps = [N]
i = N
while i > M:
    prev = i
    i -= M
    while S[i] > 0:
        i += 1
    if i >= prev:
        print(-1)
        exit()
    else:
        steps.append(i)
ans = []
cur = 0
while steps:
    prev = cur
    cur = steps.pop()
    ans.append(cur-prev)
print(' '.join(map(str,ans)))


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

int main()
{
	int n;
	cin >> n;
	int debt = 100000;
	for (int i = 0; i < n; i++){
		debt *= 1.05;
		int temp = debt % 1000;
		if (temp){
			debt += 1000 - temp;
		}
	}
	cout << debt << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i].first;
    A[i].second=i;
  }
  sort(A.begin(),A.end());
  int cnt=0;
  for(int i=0;i<N;i++)
    if((A[i].second-i)%2!=0)cnt++;
  cout<<cnt/2<<endl;
}

Measured memory_bytes: 4808
#include<iostream>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B)
    {
      cout<<C<<endl;
    }
  if(B==C)
    {
      cout<<A<<endl;
    }
  if(A==C)
    {
      cout<<B<<endl;
    }

 
  return 0;
}

 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        sc.close();
        int a=Integer.parseInt(str.substring(0,2));
        int b=Integer.parseInt(str.substring(2));
        boolean am=false,bm=false;
        if(1<=a&&a<=12)am=true;
        if(1<=b&&b<=12)bm=true;
        if(am&&bm){
            System.out.println("AMBIGUOUS");
        }else if(am==false&&bm==false){
            System.out.println("NA");
        }else if(am==false){
            System.out.println("YYMM");
        }else{
            System.out.println("MMYY");
        }
    }
}


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

struct query{
  int type;//0=empty, 1=set
  ll value;
  query(int a=0,ll b=0):type(a),value(b) {}
};

query s[(1<<18)];
ll t[(1<<18)];

void compute(int k,int l,int r){
  query q=s[k];
  s[k].type=0;
  if(q.type==0||r-l==1)return;
  s[k*2+1]=s[k*2+2]=q;  
  t[k*2+1]=t[k*2+2]=q.value;
}

void Set(int a,int b,ll x,int k=0,int l=0,int r=(1<<17)){
  if(b<=l || r<=a)return;
  compute(k,l,r);
  if(a<=l && r<=b){
    s[k]=query(1,x);
    t[k]=x;
  }else{
    int m=(l+r)/2;
    Set(a,b,x,k*2+1,l,m);
    Set(a,b,x,k*2+2,m,r);
    t[k]=min(t[k*2+1],t[k*2+2]);
  }
}

ll Get(int a,int b,int k=0,int l=0,int r=(1<<17)){
  if(b<=l || r<=a)return (1LL<<60);
  compute(k,l,r);
  if(a<=l && r<=b){
    return t[k];
  }else{
    int m=(l+r)/2;
    ll lv=Get(a,b,k*2+1,l,m);
    ll rv=Get(a,b,k*2+2,m,r);
    return min(lv,rv);
  }
}



int main(){
  int n,q,type,a,b,x;
  Set(0,(1<<17),2147483647);
  scanf("%d %d",&n,&q);
  while(q--){
    scanf("%d",&type);
    if(type==0){
      scanf("%d %d %d",&a,&b,&x);
      b++;
      Set(a,b,x);
    }else{
      scanf("%d %d",&a,&b);
      b++;
      printf("%lld\n",Get(a,b));
    }
  }
  return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,i=0;
  cin >> n;
  vector<int> a(n);
  for(;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int l=0,s=0;
  for(i--;i>0;i--){
    if(l==0){
      if(a[i]==a[i-1]){
        l=a[i];
        i--;
      }
    }else {
      if(a[i]==a[i-1]){
        s=a[i];
        break;
      }
    }
  }
  cout << (long long)l*s << endl;
}

Measured memory_bytes: 640
N=int(input())
P=[None]*N
for i in range(N):
  x,l=map(int,input().split())
  P[i]=[x-l,x+l]
  
P=sorted(P,key=lambda x:x[1])

ans=1
curR=P[0][1]
for i in range(1,N):
  if P[i][0]>=curR:
    ans+=1
    curR=P[i][1]
print(ans)


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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    string s;
    cin>>s;
    int sum = 0;
    for(int i=0;i<s.size();i++){
        sum = sum+(s[i]-'0');
        sum = sum%9;
    }
    if(sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3712
import math
A, B, H, M = map(int, input().split())
xa = A * math.sin(math.pi * H / 6 + M * math.pi / 360)
ya = - A * math.cos(math.pi * H / 6 + M * math.pi / 360)
xb = B * math.sin(math.pi * M / 30)
yb = - B * math.cos(math.pi * M / 30)
print(math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2))

Measured memory_bytes: 9448
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a+0,a+3);
	cout<<a[0]+a[1]<<endl;
}

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

// int main(){
// 	ll a, b, c, k; cin >> a >> b >> c >> k;
// 	ll sum = 0;
// 	while(k) {
// 		if(a && k) {
// 			ll picked = min(a, k);
// 			sum += picked * 1;
// 			a -= picked;
// 			k -= picked;
// 		} else if(b && k) {
// 			ll picked = min(b, k);
// 			b -= picked;
// 			k -= picked;
// 		} else if(c && k) {
// 			ll picked = min(c, k);
// 			sum += -1 * picked;
// 			c -= picked;
// 			k -= picked;
// 		}
// 		trace(sum);
// 	}
// 	cout << sum << endl;
// }

int main(){
	ll n, k1, k; cin >> n >> k1;
	map<ll,ll>mp;
	for(ll i = 1; i <= n; i++){
		ll a; cin >> a;
		mp[i] = a;
	}	
	ll flag = 1;
	ll city = 1;
	k = k1;
	set<ll>st;
	vector<ll>ans;
	ll tar = -1;
	while(k && flag) {
		city = mp[city];
		if(st.find(city) == st.end()) {
			st.insert(city);
			ans.pb(city);
		}
		else {
			flag = 0;
			for(ll i = 0; i < ans.size(); i++) {
				if(ans[i] == city) {
					tar = i;
				}
			}
		}
		k--;
	}
	vector<ll>modi;
	for(ll i = tar ; i < ans.size(); i++){
		modi.pb(ans[i]);
	}
	if(flag) {
		cout << city << endl;
	} else {
		if(tar == 0 || k1 <= ans.size())
			cout << ans[(k1 - 1) % ans.size()] << endl;
		else {
			cout << modi[(k1 - ans.size() - 1) % modi.size()] << endl;
		}
	}
}

Measured memory_bytes: 25240
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

int main(){

int s[6];
string com;

cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4]>>s[5];
cin>>com;

for(int i=0;i<com.size();i++){

 if(com[i]=='S'){
 swap(s[0],s[4]);
 swap(s[4],s[5]);
 swap(s[5],s[1]);
  }else if(com[i]=='E'){
 swap(s[0],s[2]);
 swap(s[0],s[3]);
 swap(s[3],s[5]);
  }else if(com[i]=='W'){
 swap(s[0],s[2]);
 swap(s[2],s[5]);
 swap(s[5],s[3]);
  }else{
 swap(s[0],s[4]);
 swap(s[0],s[1]);
 swap(s[1],s[5]);
 }

}

cout<<s[0]<<endl;

}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define pi pair<ll,ll>
#define pii pair<int,int>
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,i,j,k,l,m,b,t,sum,sum1,flag,max1,min1;
    cin>>n;
    ll a[n+1];
    set<ll>s;
    for(i=1;i<=n;i++){
        cin>>a[i];
        s.insert(a[i]);
    }
//    vector<ll>v;
//    for(auto it:s){
//        v.pb(it);
//    }
    sort(a+1,a+1+n);
    sum=0;
     for(i=1;i<=n-2;i++){
        for(j=i+1;j<=n-1;j++){
            for(k=j+1;k<=n;k++){
                if(a[i]+a[j]>a[k] and a[i]!=a[j] and a[j]!=a[k]){
                    sum++;
                }
            }
        }
     }

    cout<<sum<<endl;

}



Measured memory_bytes: 3660
#include <iostream>
using namespace std;
using ll = long long;
const ll M = 998244353;
ll dp[3010];
signed main() {
    ll n, s;
    cin >> n >> s;
    ll x = 0;
    for (ll i = 0; i < n; i++) {
        ll a;
        cin >> a;
        (dp[0] += 1) %= M;
        for (ll v = s; v >= a; v--) {
            (dp[v] += dp[v - a]) %= M;
        }
        (x += dp[s]) %= M;
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

constexpr int MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> vp;
    for (int i = 1; i * i <= N; i++)
    {
        vp.emplace_back(i);
        if (i != N / i) vp.emplace_back(N / i);
    }
    sort(vp.begin(), vp.end());
    REP(i, vp.size() - 1) vp[i] = vp[i + 1] - vp[i];
    vector<int> dp(vp.size());
    dp[0] = 1;
    REP(_, K)
    {
        reverse(dp.begin(), dp.end());
        IREP(i, dp.size() - 1)
        {
            (dp[i] += dp[i + 1]) %= MOD;
            dp[i + 1] = dp[i + 1] * (lint)vp[i] % MOD;
        }
    }
    cout << accumulate(dp.begin(), dp.end(), 0LL) % MOD << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<pll> c;
	REP(i, N){
		ll a;
		cin >> a;
		c.push_back({a, 1});
	}
	REP(i, N){
		ll b;
		cin >> b;
		c.push_back({b, -1});
	}
	sort(c.begin(), c.end());
	ll res = 1;
	ll x = 0, y = 0;
	REP(i, 2*N){
		if(c[i].second==1){
			if(y>0){
				res *= y;
				res %= mod;
				y--;
			}else{
				x++;
			}
		}else{
			if(x>0){
				res *= x;
				res %= mod;
				x--;
			}else{
				y++;
			}
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int cnt[26];

int main()
{
	int n;
	string w;
	int ans=0;
	
	cin>>w;
	n=w.length();
	fill(cnt,cnt+26,0);
	for(int i=0;i<n;i++)
		cnt[(int)(w[i]-'a')]++;
	bool f=true;
	for(int i=0;i<26;i++)
	{
		if(cnt[i]%2!=0)
			f=false;
	}
	if(f)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N.length(); ++i) {
  	sum += N[i] - '0';
  }
  if (sum % 9 == 0)
    printf("Yes");
  else 
    printf("No");
  return 0;
}

Measured memory_bytes: 3804
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

def calculate_mode(data):
    c = Counter(data)
    # すべての要素とその出現回数を取り出します。
    freq_scores = c.most_common()
    #c.most_common内の最も多い要素[0]の最大出現回数[1]を[0][1]で指定
    max_count = freq_scores[0][1]

    modes = []
    #出現回数と最大出現回数が等しいかを確認します。
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

if __name__ == '__main__':
    modes = calculate_mode(S)

    modes.sort()
    for mode in modes:
        print(mode)

Measured memory_bytes: 45044
def main():
    s = input()
    
    cost = 700
    cost += 100 if s[0] == 'o' else 0
    cost += 100 if s[1] == 'o' else 0
    cost += 100 if s[2] == 'o' else 0

    print(cost)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    while(n != 0 || x != 0)
    {
        int count = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                    {
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
        cin >> n >> x;
    }
    return 0;
}



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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1000000007ll;
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; }
const ll inf = 1ll << 60;

int gcc(int n, int m) {
    int a = max({n, m});
    int b = min({n, m});
    if(b == 0) return a;
    int c;
    while(a % b != 0){
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<pair<int, int>>> tree(n+1);
    rp(i, 0, n-1){
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        tree.at(u).emplace_back(v, w);
        tree.at(v).emplace_back(u, w);
    }
    vector<int> ans(n+1, -1);
    ans.at(1) = 0;
    stack<int> task;
    task.push(1);
    while(task.size() > 0){
        int now = task.top();
        task.pop();
        int k = tree.at(now).size();
        rp(i, 0, k){
            int next = tree.at(now).at(i).first;
            if(ans.at(next) < 0){
                if(tree.at(now).at(i).second % 2 == 0){
                    if(ans.at(now) == 0) ans.at(next) = 0;
                    else ans.at(next) = 1;
                } else {
                    if(ans.at(now) == 0) ans.at(next) = 1;
                    else ans.at(next) = 0;
                }
                task.push(next);
            }
        }
    }
    rp(i, 1, n+1) printf("%d\n", ans.at(i));
    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,W;
	ll INF=1e18l+1;
	cin>>n>>W;
	int w[n];
	ll v[n];
	for(int i=0;i<n;i++)
	{
		cin>>w[i];
		cin>>v[i];
	}
	ll dp[n+1][W+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=W;j++){
			if(i==0 || j==0)
			dp[i][j]=0;
			else
			if(j-w[i-1]>=0)
			dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][W];
}

Measured memory_bytes: 82428
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int H[100010]={};
int main(){
    int N;
    cin >> N;
    rep(i,N){
        cin >> H[i];
    }
    int prev_max = H[0];
    for(int i=1;i<N;i++){
        if(H[i] < prev_max){
            if(prev_max - H[i] != 1){
                cout << "No"<<endl;
                return 0;
            }
        }
        prev_max = max(H[i], prev_max);
    }

    cout << "Yes" << endl;
    

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
bool flg;
 
void init(char field[8][8],bool can[8][8]){
  flg = false;
  for(int i = 0 ; i < 8 ; i++){
    for(int j = 0 ; j < 8 ; j++){
      field[i][j] = '.';
      can[i][j] = true;
    }
  }
}
 
bool inField(int y,int x){
  return 0 <= y && y < 8 && 0 <= x && x < 8;
}
 
void putQ(int r,int c,bool can[8][8]){
  const int dx[4] = {-1,1,1,-1};
  const int dy[4] = {-1,-1,1,1};
  for(int i = 0 ; i < 8 ; i++){
    can[r][i] = can[i][c] = false;
  }
  for(int i = 0 ; i < 4 ; i++){
    int x = c, y = r;
    while(inField(y,x)){
      can[y][x] = false;
      x += dx[i]; y += dy[i];
    }
  }
}
 
void print(char field[8][8]){
  for(int i = 0 ; i < 8 ; i++){
    for(int j = 0 ; j < 8 ; j++){
      cout << field[i][j];
    }
    cout << endl;
  }
}
 
void copy(bool a[8][8],bool b[8][8]){
  for(int i = 0 ; i < 8 ; i++){
    for(int j = 0 ; j < 8 ; j++){
      a[i][j] = b[i][j];
    }
  }
}
 
void solve(int now,int S,bool can[8][8],char field[8][8]){
  if(now == 8){
    print(field);
    flg = true;
    return;
  }
  if((S >> now) & 1){
    solve(now+1,S,can,field);
  }else{
    bool tmp[8][8];
    for(int i = 0 ; i < 8 ; i++){
      if(can[now][i]){
    copy(tmp,can);
    field[now][i] = 'Q';
    putQ(now,i,can);
    solve(now+1,S,can,field);
    if(flg) return;
    copy(can,tmp);
    field[now][i] = '.';
      }
    }
  }
}
 
int main(){
  int N,r,c,S = 0;
  bool can[8][8];
  char field[8][8];
 
  init(field,can);
 
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> r >> c;
    S |= 1<<r;
    field[r][c] = 'Q';
    putQ(r,c,can);
  }
  solve(0,S,can,field);
  return 0;
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    int max = 0;
    Arrays.sort(a);
    for (int i = 1; i < n; i++) {
      max = Math.max(max, a[i] - a[i - 1]);
    }
    max = Math.max(max, a[0] + k - a[a.length - 1]);
    System.out.println(k - max);
  }
}

Measured memory_bytes: 47188
import numpy as np
import math

N, H = map(int, input().split())
a = [0 for _ in range(N)]
b = [0 for _ in range(N)]
for i in range(N):
    a[i], b[i] = map(int, input().split())

a.sort(reverse=True)
b.sort(reverse=True)
a = np.array(a)
b = np.array(b)
if a[0]>b[-1]:
    for i in range(len(b)-1, -1, -1):
        if a[0]>b[i]:
            b[i] = 0

cum_b = np.cumsum(b)
cum_b = np.unique(cum_b)
del_h = H - cum_b[-1]
'''
print('del_h = ' + str(del_h))
print('len(cum_b) = ' + str(len(cum_b)))
print('cum_b = ' )
print(cum_b)
'''
if del_h<=0:
    for i in range(len(cum_b)):
        if H<=cum_b[i]:
            print(i+1)
            break
else:
    n = math.ceil(del_h/a[0])
    print(len(cum_b) + n)


Measured memory_bytes: 21076
matrix = [[x for x in map(int, input().split())] for _ in range(3)]

matrix = sorted(matrix)
for i in range(1, 3):
    diff = matrix[i][0] - matrix[0][0]
    for j in range(3):
        if matrix[i][j] != matrix[0][j] + diff:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3060
// 解説前
#include <iostream>
#include <vector>
#include <cstdint>

// x^y (mod m)を計算する
// 参考：https://stackoverflow.com/questions/8496182/calculating-powa-b-mod-n
template <typename T>
T pow(T x, T y, T m) noexcept {
  T r = 1;
  while (y > 0) {
    // 指数のiビット目を見て、xの2^i乗をかける
    if (y & 1) {
      r *= x;
      if (r >= m) r %= m;
    }

    // xの2^i乗を累積的に計算する
    x *= x;
    if (x >= m) x %= m;

    y >>= 1;
  }
  return r;
}

// nCr (mod m)を計算する（ただし、mは素数とする）
// 参考：https://ikatakos.com/pot/programming_algorithm/number_theory/mod_combination
template <typename T>
T combination(T n, T r, T m) noexcept {
  if (r > n - r) r = n - r;
  
  // 分子（nPr (mod m)）を計算する
  T num = 1;
  for (T i = 0; i < r; ++i) {
    num *= n - i;
    if (num >= m) num %= m;
  }

  // 分母（r! (mod m)）を計算する
  T denom = 1;
  for (T i = 1; i <= r; ++i) {
    denom *= i;
    if (denom >= m) denom %= m;
  }

  // 分母の逆数（r!^{-1} (mod m)）を計算する
  // フェルマーの小定理より、素数pと互いに素なaに対して、
  // a^{p-1} ≡ 1 (mod p) <=> a^{p-2} ≡ a^{-1} (mod p)なので、
  // r!^{-1} (mod m) = r!^{m-2} (mod m)とすることができる
  const T denom_inv = pow(denom, m - 2, m);

  // nPr * r!^{-1} (mod m)を計算する
  return (num * denom_inv) % m;
}

// L^1ノルムを考えると、(1,2)と(2,1)のどちらの方向でも距離3だけ移動する
// => 到達可能な地点までのL^1ノルムは3の倍数になる
// => 動かした回数はn=(X+Y)/3となる
// 
// すべての移動を(1,2)の方向に動かしたとすると、X=nとなる
// その状態からどこか1つを(2,1)の方向に動かすよう変えた場合、Xは+1だけ増える
// => (2,1)方向に動かした回数はX-nとなる
//
// 進む経路を図に起こすと、その個数はパスカルの三角形を描く
// => 動かす回数をn、(2,1)の方向に動かした回数をrとして、nCrを計算すれば良い 
int main() {
  uint64_t X, Y;
  std::cin >> X >> Y;

  // 経路の数を計算する
  const auto distance = X + Y;  // L^1ノルム
  if (distance % 3 != 0) {
    // (X, Y)に到達できない場合
    std::cout << '0';
  } else {
    // (X, Y)に到達できる場合
	const auto n = distance / 3;  // 移動回数
	const auto r = X - n;  // (2,1)の方向に動かした回数

    // nCr (mod 10^9+7)を計算する
    const uint64_t m = 1'000'000'007;
    std::cout << combination(n, r, m);
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	string s;
	while(cin >> s) {
		cout << s.substr(0, 4) << " " << s.substr(4) << endl;
	}
	return 0;
}


Measured memory_bytes: 764
n, m = map(int, input().split())

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

b = []
for _ in range(m):
    b.append(int(input()))

for i in range(n):
    sum = 0
    for j in range(m):
        sum += mat[i][j] * b[j]
    print(sum)




Measured memory_bytes: 6024
#include <stdio.h>

int main (){
   int a,b,c;scanf("%d %d %d",&a,&b,&c);
   if(((a == b)&&(a != c))||((b == c)&&(b != a))||((c == a)&&(c != b))){
      printf("Yes\n");
      return 0;
   }
   printf("No\n");
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  
  int x, n;
  cin >> x >> n;
  vector<int> a(n);
  int ans = 0;
  rep(i,n){
    cin >> a[i];
    if(a[i] == x) ans = 1;
  }
  
  if(ans){
    for(int i = 1; i<101; i++){
      ans = 0;
      int check1 = x-i;
      int check2 = x+i;
      if(check1 <= 0 && check2 >= 102) break;
      
      rep(j, n){
        if(check1 == a[j]) ans += 1;
        if(check2 == a[j]) ans += 2;
      }
      
      if(ans == 0 || ans == 2){
        cout << check1 << endl;
        break;
      }
      else if(ans == 1){
        cout << check2 << endl;
        break;
      }
    }
  }
  else cout << x << endl;
  
return 0;
}

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

int main() {
    int m,r,sum=0;
    cin>>m>>r;
    for(int i=0;i<r;i++){
        int a;
        cin>>a;
        sum+=a;
    }
    if(m-sum==0 || m-sum<0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256