akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    for(int i = sy + 1; i <= ty; i++) printf("U");
    for(int i = sx + 1; i <= tx; i++) printf("R");
    for(int i = ty - 1; i >= sy; i--) printf("D");
    for(int i = tx - 1; i >= sx; i--) printf("L");
    printf("L");
    for(int i = sy; i <= ty; i++) printf("U");
    for(int i = sx; i <= tx; i++) printf("R");
    printf("DR");
    for(int i = ty; i >= sy; i--) printf("D");
    for(int i = tx; i >= sx; i--) printf("L");
    printf("U\n");
}

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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        while(A % 2 == 0) {
            A /= 2;
             ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){ //ABC 
    /* A */
    // int d,t,s;
    // cin >> d >> t >> s;
    // cout << (((double)d/s<=t)? "Yes":"No") << endl;

    /* B */
    string s,t;
    cin >> s >> t;
    int cnt,ans=0;
    for(int i=0;i<s.size()-t.size()+1;i++){
        cnt=0;
        for(int j=0;j<t.size();j++){
            if(s.at(i+j)==t.at(j)){
                cnt++;
            }
        }
        if(cnt>ans)ans = cnt;
    }
    cout << t.size()-ans << endl;

    /* C */
    // int n;
    // cin >> n;
    // vector<int64_t> a(n);
    // for(int i=0;i<n;i++){
    //     cin >>a[i];
    // }
    // int64_t ans=0;
    // for(int i=1;i<n;i++){
    //     if(a[i-1]>a[i]){
    //         ans += a[i-1]-a[i];
    //         a[i] = a[i-1];
    //     }
    // }
    // cout << ans << endl;


    return 0;
}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 1e5 + 1;
ll a[MAX];

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n, ans = 0;
		double dist;
		cin >> n >> dist;
		double x, y;
		for(int i = 1; i <= n; ++i)
		{
			cin >> x >> y;
			double dd = x * x + y * y;
			dd = (double) sqrt(dd);
			if(dd <= dist) ans += 1;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3860
s = input()
r,l = "R","L"

ans = [0]*len(s)

count = 0
i = 0
while i < len(s):
  
  while s[i] == r:
    count += 1
    i += 1
  ans[i] += count//2
  ans[i-1] += count-count//2
  count = 0
  index = i
  while  i < len(s) and s[i] == l :
    count += 1
    i += 1
  ans[index-1] += count//2
  ans[index] += count - count//2
  count =0
print(' '.join(map(str,ans)))
  
  



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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll minv=2020202020;
    for(int i=1;i<n;i++) minv=min(minv,abs(2*sum[i]-sum[n]));
    cout<<minv<<"\n";
    return 0;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,h,w;
	cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1);
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N, C = map(int, input().split())
    XV = [list(map(int, input().split())) for _ in range(N)]

    ans = 0

    R = [0]
    x0, v0 = 0, 0
    for i in range(N):
        x, v = XV[i]
        v0 += v-(x-x0)
        x0 = x
        R.append(max(v0, R[-1]))
        ans = max(ans, v0)

    L = [0]
    x0, v0 = C, 0
    for i in reversed(range(N)):
        x, v = XV[i]
        v0 += v-(x0-x)
        x0 = x
        L.append(max(v0, L[-1]))
        ans = max(ans, v0)

    x0, v0 = 0, 0
    for r in range(N):
        x, v = XV[r]
        v0 += v-2*(x-x0)
        x0 = x
        ans = max(ans, v0+L[N-1-r])

    x0, v0 = C, 0
    for l in reversed(range(N)):
        x, v = XV[l]
        v0 += v-2*(x0-x)
        x0 = x
        ans = max(ans, v0+R[l])

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 36836
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

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

void solve()
{
    //If you cannot approach a problem
    //directly in the way it is proposed then try to think from backwards
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i = 0, j = n - 1, oper = 0;
    while(i < j){
        while((i < n) && (s[i] == 'R')){
            i ++;
        }
        while((j >= 0) && (s[j] == 'W')){
            j --;
        }
        if(i < j){
            swap(s[i], s[j]);
            oper ++;
        }
    }
    cout<<oper<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}


Measured memory_bytes: 3776
import sys
import itertools
import bisect

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            a, c = L[i], L[j]
            amc = abs(a - c)
            apc = a + c
            low = bisect.bisect_right(L, amc)
            low = max(j + 1, low)
            upp = bisect.bisect_left(L, apc)
            upp -= 1
            if low <= upp:
                ans += (upp - low) + 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 47116
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
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)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int dp[3010][3010];
ll MOD = 998244353;
signed main()
{
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
    }
     dp[0][0] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= s; j++)
        {
            if(j+a[i-1] <=3000)
            {
                dp[i][j + a[i - 1]] += dp[i - 1][j];
                dp[i][j + a[i - 1]] %= MOD;
            }
            dp[i][j] += dp[i - 1][j]*2;
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n][s] << endl;

    return 0;
}

Measured memory_bytes: 74204
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
int x, j, res(1e12);
int32_t main() {
    DAU
    cin >> x;
    for (int i = 1; i * i <= x; ++i)
        if (x % i == 0) {
            j = x / i;
            res = min(res, i + j - 2);
        }
    cout << res;
    PLEC
}


Measured memory_bytes: 3640
a,b,c,x=map(int,[input() for i in range(4)])
sum=0
left1,left2=0,0
for i in range(a+1):
    left1=x-i*500
    if left1>=0:
        for j in range(b+1):
            left2=x-i*500-j*100
            if left2>=0:
                for k in range(c+1):
                    if left2==k*50:
                        sum+=1
print(sum)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n;
int main() {
	cin >> n;
	int s = 0;
	while (n > 0) {
		s += n % 10;
		n /= 10;
	}
	cout << (s == 1 ? 10 : s) << '\n';
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class Program
    {   
        static bool IsCheckPrime(int numeric)
        {
            if (numeric <= 1)
            {
                return false;
            }
            if (numeric == 2)
            {
                return true;
            }

            if (numeric % 2 == 0)
            {
                return false;
            }
            for(int i = 3; i <= Math.Sqrt(numeric); i += 2)
            {
                if (numeric % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
            
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int count = 0;
            for (int i = 0; i < n; i++)
            {
                if (IsCheckPrime(int.Parse(Console.ReadLine())))
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;
typedef std::vector<PII> VPII;

int n;
VPII v;
int main() {
    int h, m, s;
    while(std::cin >> n, n != 0) {
        v.clear();
        REP(i, n) {
            scanf("%d:%d:%d", &h, &m, &s);
            v.pb(mp(h*3600+m*60+s, 1));
            scanf("%d:%d:%d", &h, &m, &s);
            v.pb(mp(h*3600+m*60+s, -1));
        }
        SORT(v);

        int res = 0, ans = 0;
        for(auto t: v) {
            res += t.snd;
            ans = std::max(ans, res);
        }
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 3420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;

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

    int n;
    cin >> n;
    int a[100005],b[100005];
    reps(i,n+1){
      cin >> a[i];
    }
    reps(i,n){
      cin >> b[i];
    }

    lol sum = 0;
    b[n+1] = 0;
    for(int i = n+1 ; i > 1 ; i--){
      sum += min(a[i],b[i]);
      if( a[i] >= b[i] ){
	a[i] -= b[i];
	b[i] = 0;
      } else {
	b[i] -= a[i];
	a[i] = 0;
      }
      sum += min(a[i],b[i-1]);
      if( a[i] >= b[i-1] ){
	a[i] -= b[i-1];
	b[i-1] = 0;
      } else {
	b[i-1] -= a[i];
	a[i] = 0;
      }
    }
    cout << sum + min(a[1],b[1]) << '\n';
    return 0;
}


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

#define ll long long
ll f(ll x)
{
    if (x == -1) return 0;
    if ( x % 4 == 0) return x;
    if ( x % 4 == 1) return 1;
    if ( x % 4 == 2) return x+1;
    if ( x % 4 == 3) return 0;
}

int main()
{
    ll A,B;
    cin>> A >> B;

    cout << (f(B) ^ f(A-1)) << endl;

    return 0;
}


Measured memory_bytes: 256
def solve(n):
    if n in range(400, 600):
        print(8)
        return
    if n in range(600, 800):
        print(7)
        return
    if n in range(800, 1000):
        print(6)
        return
    if n in range(1000, 1200):
        print(5)
        return
    if n in range(1200, 1400):
        print(4)
        return
    if n in range(1400, 1600):
        print(3)
        return
    if n in range(1600, 1800):
        print(2)
        return
    if n in range(1800, 2000):
        print(1)
        return



def main():
    t = int(input())
    solve(t)


main()


Measured memory_bytes: 9204
#include<iostream>

int main(){
	int w,n,tate[31],yoko1,yoko2,i,j;
	char c;

	
	std::cin>>w>>n;
	for(i=1;i<=w;i++){
		tate[i]=i;
	}

	for(i=0;i<n;i++){
		std::cin>>yoko1>>c>>yoko2;
		j=tate[yoko1];
		tate[yoko1]=tate[yoko2];
		tate[yoko2]=j;
	}

	for(i=1;i<=w;i++){
		std::cout<<tate[i]<<std::endl;
	}

		
	
	
  return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  for(int i = 0; i < N; i++)cin >> A[i] >> B[i];
  ll cnt = 0;
  for(int i = N - 1; i >= 0; i--){
    A[i] += cnt;
    ll t = A[i] % B[i];
    if(B[i] != 1 && t != 0)cnt += (B[i] - t);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int cnt[101] = {0};
    int i,n,max;
    int j = 0;
    for(i = 0;i < 100;i++){
        scanf("%d",&n);
        cnt[n]++;
    }
    max = cnt[j];
    for(j = 0;j < 101;j++){
        if(max < cnt[j]){
            max = cnt[j];
        }
    }
    for(j = 0;j < 101;j++){
        if(max == cnt[j]){
            printf("%d\n",j);
        }
    }
    return 0;
}

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

typedef long long ll;
ll k;
string s;
 
int main() {
	cin>>k>>s;
	if(k%2==1)
	{
		cout<<"No";
		return 0;
	}
	for(ll i=0;i<k/2;i++)
	{
		if(s[i]!=s[k/2+i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int a=0,b=0,c=0,x=0;
        for (int i = 0; i < n; i++) {
			char s[]=sc.nextString().toCharArray();
			for (int t = 0; t+1 < s.length; t++) {
				if(s[t]=='A' && s[t+1]=='B')c++;
			}

			if(s[0]=='B' && s[s.length-1]=='A') {
				x++;continue;
			}

			if(s[0]=='B')b++;
			if(s[s.length-1]=='A')a++;
		}
//        db(a,b,x,c);
        if(x>0)c+=x-1;
        if(x>0 && a>0) {a--;c++;}
        if(x>0 && b>0) {b--;c++;}
        out.println(c+min(a,b));
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch>'9' || ch<'0'){
        if(ch=='-') f=-1;
	    ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

char c[10000000];

int main(){
	cin>>c;
	int l=strlen(c)-1;
	if(c[0]!='A'){
		printf("WA\n");
		return 0;
	}
	if(c[1]>'z' || c[1]<'a'){
		printf("WA\n");
		return 0;
	}
	if(c[l]>'z' || c[l]<'a'){
		printf("WA\n");
		return 0;
	}
	int f=0;
	for(int i=2;i<l;i++){
		if(c[i]!='C' && (c[i]>'z' || c[i]<'a')){
		    printf("WA\n");
			return 0;
		}
		if(c[i]=='C') f++;
	}
	if(f==1) printf("AC\n");
	else printf("WA\n");
	return 0;
}

Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))
As.sort(reverse=True)
Bs.sort(reverse=True)
Cs.sort(reverse=True)
Fs = []
for i in range(X):
  if (i+1) > K:
    break
  for j in range(Y):
    if (i+1)*(j+1) > K:
      break
    for k in range(Z):
      if (i+1)*(j+1)*(k+1) > K:
        break
      Fs.append(As[i]+Bs[j]+Cs[k])
Fs.sort(reverse=True)
for i in range(K):
  print(Fs[i])


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

int main()
{
 int n;
  cin >> n;
	long long a[100100] = {};
  for (int i = 0;i < n;i++)
  {
	cin >> a[i];    
  }
  
  int mxcnt = 0;
  int cnt = 0;
  int prev = a[0];
  for (int i = 1;i < n;i++)
  {
   if (a[i] <= prev)
   {
    cnt++;
     prev = a[i];
   }
    else
    {
      mxcnt = max(mxcnt, cnt);
      cnt = 0;
      prev = a[i];
    }
  }
  mxcnt = max(mxcnt, cnt);
  cout << mxcnt << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<numeric>
#include<algorithm>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> h(N);
	for(int i=0; i<N; i++)
		cin >> h[i];

	int ans = 0;
	int sum = accumulate(h.begin(), h.end(), 0);
	while(sum != 0){
		int l, r;
		for(l=0; h[l]==0; l++);
		for(r=l+1; r<N&&h[r]!=0; r++);

		int cnt = *min_element(h.begin()+l, h.begin()+r);
		ans += cnt;
		sum -= (r-l) * cnt;
		for(int i=l; i<r; i++)
			h[i] -= cnt;
	}

	cout << ans << endl;

	return 0;
}


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

int main(void){
    int n, h[20], result = 1;
    cin >> n;

    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 1; i < n; i++){
        bool can = true;
        for(int j = 0; j < i; j++){
            if(h[j] > h[i]) can = false;
        }
        if(can) result++;
    }
    cout << result << endl;
    return 0;
}

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

const int MAX = 1e+5 + 10;
const int INF = INT_MAX;
using ll = long long;
ll dp[100 + 10][MAX];

int main() {

    int n, max_w;

    cin >> n >> max_w;

    vector<pair<int, int>> w(n + 1);

    int sum = 0;

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

        cin >> w[i].first >> w[i].second;
        sum += w[i].second;
    }


    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= sum; ++j) {
            if(j == 0)
                dp[i][j] = 0;
            else
                dp[i][j] = INF;
        }

    }

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

        for(int j = 1; j <= sum; ++j) {

            if(j < w[i].second) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
                
            
            
            dp[i][j] = min(dp[i - 1][j - w[i].second] + w[i].first, dp[i - 1][j]);
            

        }


    }

    /*
    for(int i = 0; i <= sum; ++i)
        printf("%3d ", i);
    cout << endl;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= sum; ++j) {
            if(dp[i][j] == INF) 
                cout << "INF";
            else
                printf("%3d", dp[i][j]);
            cout << " ";

        }
        cout << endl;
    }
*/

    for(int i = sum; i >= 0; --i) {
        if(dp[n][i] <= max_w) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 80128
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val str = sc.next
    if(str.matches("""^keyence.*$""")
      || str.matches("""^keyenc.*e$""")
      || str.matches("""^keyen.*ce$""")
      || str.matches("""^keye.*nce$""")
      || str.matches("""^key.*ence$""")
      || str.matches("""^ke.*yence$""")
      || str.matches("""^k.*eyence$""")
      || str.matches("""^.*keyence$""")
    ){
      println("YES")
    }
    else{
      println("NO")
    }
  }
}

Measured memory_bytes: 25676
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll X; cin >> X;
	ll x = floor(sqrt(X));
	cout << x*x<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
		cout << (s[i]=='?' ? 'D':s[i]);
	cout << endl;




}

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

using namespace std;

int MAXN = 1e4 + 10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, a, dp[MAXN] = {0};
	
	cin >> n >> a;
	
	for(int i = 1; i <= a; i++)
	{
		for(int j = n; j - i >= 0; j--)
		{
			dp[j] = max(dp[j], dp[j - 1] + 1);
		}//for j
	}//for i
	
	for(int i = 500; i <= n; i++)
	{
		dp[i] = max(dp[i], dp[i - 500] + 500);
	}//for i
	
	if(dp[n] == n)
		cout << "Yes";
		
	else
		cout << "No";
	
	return 0;
}//main


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

typedef long long ll;

// dp[i][j][k] := i 桁目まで見たとき、0 以外の数字がちょうど j 個使われていている数字の個数
// k は、N 未満(:=0)か N と同じ(:=1)かを表すフラグ
ll dp[105][5][2];

int main(){
    string s;   // N を文字列で受け取る
    int K;
    cin >> s >> K;
    int n = s.length();
    
    dp[0][0][1] = 1;    // 0 桁目で、入力 N と一致している個数を 1 とする
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';   // 入力 N の i+1 桁目の数

        for(int j = 0; j <= K; ++j){
            for(int x = 0; x < 10; ++x){    // i+1 桁目にどの数字を入れる場合を考えるか
                int next = (x == 0) ? 0 : 1;    // j の遷移先を考えるときに必要
                
                // フラグの遷移は、未満 → 未満, 同じ → 未満
                if(x < num){
                    dp[i+1][j+next][0] += dp[i][j][0];
                    dp[i+1][j+next][0] += dp[i][j][1];
                }
                // フラグの遷移は、未満 → 未満, 同じ → 同じ
                else if(x == num){
                    dp[i+1][j+next][0] += dp[i][j][0];
                    dp[i+1][j+next][1] += dp[i][j][1];
                }
                // フラグの遷移は、未満 → 未満
                else{   // x > num
                    dp[i+1][j+next][0] += dp[i][j][0];
                }
            }
        }
    }

    cout << dp[n][K][0] + dp[n][K][1] << endl;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

std::string s, t;
std::map<char, std::vector<int>> mp;
ll n, m;
ll ans = 0;
ll pos = 0;
void calc(std::vector<int>& val) {
    if (ans == -1)
        return;

    if (val.size() == 0) {
        ans = -1;
        return;
    }

    auto p = std::lower_bound(val.begin(), val.end(), pos);

    if (p == val.end()) {
        ans += n - pos;
        pos = 0;

        calc(val);

    }
    else {
        if (*p >= pos) {
            ans += *p - pos + 1;
            pos = *p + 1;
        }
        else {
            ans += n - pos + *p + 1;
            pos = *p + 1;
        }
    }
}

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

    std::cin >> s >> t;

    n = (ll)s.size();
    m = (ll)t.size();
    for (int i = 0; i < n; ++i)
        mp[s[i]].push_back(i);

    for (int i = 0; i < m; ++i)
        calc(mp[t[i]]);


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

    return 0;
}


Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int r;
	cin >> r;
	if (r < 1200) cout << "ABC\n";
	else if (r < 2800) cout << "ARC\n";
	else cout << "AGC\n";
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

int main(void) 
{
   char a;
   cin >> a;

   if(isupper(a))cout << "A" << endl;
   else cout << "a" << endl;
   return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N,i,ans = 0,count;
    cin >> N;
    int A[N],B[N],C[N];
    for(i = 0;i < N;i++)
    {
        cin >> A[i];    
    }
    
    
    for(i = 0;i < N;i++)
    {
        cin >> B[i];    
    }
    
    for(i = 0;i < N - 1;i++)
    {
        cin >> C[i];    
    }
    
    for(i = 0;i < N - 1;i++)
    {
        if((A[i]+1) - A[i+1] == 0)
        {
            count = A[i];
            ans += C[count-1];
        }
    }
    
    for(i = 0;i < N;i++)
    {
        ans += B[i]; 
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll x,y;cin>>x>>y;

    ll ans = LINF;
    rep(i,2) rep(j,2){
        ll xx = x;
        ll yy = y;
        if(i==1) xx*=-1;
        if(j==1) yy*=-1;

        ll cost=i+j;
        if(yy<xx) continue;
        cost += yy-xx;
        ans = min(ans,cost);
    }
    cout << ans << endl;
}


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

using namespace std;
int n, w;
int V[105], W[105];
long long dp[105][100005];

long long solve(int idx, int w) {
    if (idx == n)
        return 0;
    if (dp[idx][w] != -1)
        return dp[idx][w];
    long long ch1 = solve(idx + 1, w);
    long long  ch2 = 0;
    if (W[idx] <= w) {
        ch2 = solve(idx + 1, w - W[idx]) + V[idx];
    }
    long long finalres = max(ch1, ch2);
    dp[idx][w] = finalres;
    return finalres;
}

int main()
{
    cin >> n >> w;
    for (int i = 0; i < n; i++)
        cin >> W[i] >> V[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, w);
    return 0;
}


Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#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=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vp = vector<Pii>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

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

int f(int x, int y) {
  return x / y;
}

int g(int x, int y, int z) {
  return x - f(x, y) - f(x, z) + f(x, lcm(y, z));
}

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << g(b, c, d) - g(a - 1, c, d) << endl;
}


Measured memory_bytes: 256
arr = Array.new(45,0)
def fib(n,arr)
  if(arr[n]>0)
    ret=arr[n]
  elsif(n < 2)
    ret=1
  else
    ret=fib(n-2,arr)+fib(n-1,arr)
  end
  arr[n]=ret
end

n = STDIN.gets.split[0].to_i
puts fib(n,arr)

Measured memory_bytes: 8608
#include<stdio.h>
int main(void){
    int n,i,a;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        a=i;
        if((a%3)==0){
            printf(" %d",i);
        }else{
            for(;a;){
                if((a%10)==3){
                    printf(" %d",i);
                    a=0;
                }
                a=a/10;
            }
        }
    }
    putchar('\n');
    return 0;
}


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

int main(void) {
    int i, j, n, cnt=0;
    cin >> n;
    int A[n];

    for (i = 0; i < n; i++) cin >> A[i];

    for (i = 0; i < n; i++) {
        for (j = n - 1; j > i; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                cnt++;
            }
        }
    }

    for (i = 0; i < n; i++) {
        cout << A[i];
        if (i == n - 1) cout << endl;
        else cout << ' ';
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(){

    int a;
    int count = 0;

    cin >> a;

    for (int i = 0; i <= a; i++){
        if(i % 2 != 0){
            count++;
        }
    }

    cout << (float) count / (float)a << endl;

    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int max = a + b;
	if (max < a - b) max = a - b;
	if (max < a * b) max = a * b;
	cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int a, b, c; cin >> a >> b >> c;
	cout << (a + b + c > 21 ? "bust" : "win") << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<cstdlib>
#include<ctime>
#include<cctype>

using namespace std;

long long n, W;
long long v[110];
long long w[110];
long long dp[100010];
int main()
{
	cin >> n >> W;
	for(int i = 1; i <= n; i++)
	{
		cin >> w[i] >> v[i];
	}
	for(int j = 1; j <= 1e5; j++)
	{
		dp[j] = 1e12;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1e5; j >= v[i]; j--)
		{
			dp[j] = min(dp[j - v[i]] + w[i], dp[j]);
		}
	}
	for(int i = 1e5; i >= 0; i--)
	{
		if(dp[i] <= W)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
#define log2(x) (63 - __builtin_clzll(x))
typedef long long ll;
typedef long double ld;

int t, n, s[400];
ll a[400];
vector<ll> bs;

ll l1(ll x) {
  return 1LL << log2(x);
}

ll reduce(ll x) {
  for (int i = sz(bs) - 1; i >= 0; i--)
    if (x & l1(bs[i]))
      x ^= bs[i];
  return x;
}

void add(ll x) {
  x = reduce(x);
  if (x)
    bs.push_back(x), sort(bs.begin(), bs.end());
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> t;
  while (t--) {
    bs.clear();
    cin >> n;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    char c;
    for (int i = 0; i < n; i++)
      cin >> c, s[i] = c - '0';
    int w = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i]) {
        if (reduce(a[i]))
          w = 1;
      } else
        add(a[i]);
    }
    cout << w << "\n";
  }
}


Measured memory_bytes: 3556
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(){
	int n;
	cin>>n;
	int a[110000]={0};
	int sum=0;
	for(int i=1;i<=n;i++)cin>>a[i];

	for(int i=0;i<=n;i++){
		sum += abs(a[i] - a[i+1]);
	}

	for(int i=1;i<=n;i++){
		int s = sum + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]));
		cout<< s <<endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n;
  ll a[n+1]={};
  for(i=1;i<n+1;i++){
    cin >> a[i];
    a[i]+=a[i-1];
  }
  ll ret = 10000000;
  for(i=1;i<n;i++){
    if(ret>abs(a[n]-2*a[i]))ret=abs(a[n]-2*a[i]);
    //cout << a[i] << endl;
  }
  //cout << a[n] << endl;
  cout << ret << endl;
  return 0;
}


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

typedef long long ll;

int N,M;

int main(){
    
    cin>>N>>M;
    vector<pair<ll,ll>> V(N);
    for(int i=0; i<N; i++){
        cin>>V[i].first>>V[i].second;
    }
    
    sort(V.begin(),V.end());
    
    long long ans=0;
    for(int i=0; ;i++){
        if(V[i].second<M){
            M-=V[i].second;
            ans+=V[i].first*V[i].second;
        }else{
            ans+=M*V[i].first;
            break;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (v.empty() ? 0 : v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define fi first
#define se second
#define pb push_back
#define int long long
#define mod 1000000007
#define rem 998244353
#define maxn 500005
const int INF = 1e18;
typedef pair<int, int> pii;


signed main() {
    boostIO;
    int n;
    cin >> n;
    int a[n];
    trav(i, a) cin >> i;
    int ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i] < a[i - 1]){
            ans += (a[i - 1] - a[i]);
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}
// XD

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a;
  for(int i=1;i<=9;i++){
    if(a%i==0 && a/i<=9){
      cout<<"Yes"<<endl;
      return(0);
    }
  }
  cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
import std.stdio;
import std.string;

void main() {
	const string m = "kstnhm";
	const string ch = "aiueo";
	const string dir = "TLURD";
	auto str = readln;
	bool flag = false;
	foreach (int i, c; str) {
		if (!(i % 2)) {
			auto a = c - '0';
			if (a == 0) flag = true;
			else if (2 <= a && a <= 7) {
				write(m[a-2]);
			} else if (a == 9) {
				write('r');
			} else if (a == 8) {
				write('y');
			}
		} else {
			auto a = dir.indexOf(c);
			if (flag) {
				if (a == 0) {
					write("wa");
				} else if (a == 2) {
					write("nn");
				} else {
					write("wo");
				}
				flag = false;
			} else {
				write(ch[a]);
			}
		}
	}
	writeln;
}

Measured memory_bytes: 2480
(n,k),p,c=[[*map(int,t.split())]for t in open(0)]
a=-9e9
while n:
 n-=1;s,x,*l=0,n;f=j=k
 while f:x=p[x]-1;s+=c[x];l+=s,;f=x!=n
 for t in l[:k]:j-=1;a=max(a,t+j//len(l)*s*(s>0))
print(a)

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

int main() {
  ll k, x;
  cin >> k >> x;
  cout << (500 * k >= x ? "Yes" : "No") << endl;
}


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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, s;
	static int[][][] memo;
	static int[] a;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		PriorityQueue<pair> pq = new PriorityQueue<>((yu, xu) -> xu.v - yu.v);
		for (int i = 0; i < a; i++)
			pq.add(new pair(1, sc.nextInt()));
		for (int i = 0; i < b; i++)
			pq.add(new pair(2, sc.nextInt()));
		for (int i = 0; i < c; i++)
			pq.add(new pair(3, sc.nextInt()));
		PriorityQueue<Integer> p = new PriorityQueue<>((oo, ii) -> ii - oo);
		int xx = 0;
		long ans = 0;
		while (x > 0 && y > 0) {
			if (xx == y + x)
				break;
			if (pq.peek().id == 3) {
				p.add(pq.poll().v);
				xx++;
			} else if (pq.peek().id == 1) {
				x--;
				ans += pq.poll().v;
			} else {
				y--;
				ans += pq.poll().v;
			}

		}
		if (x > 0 && y > 0) {
			while (!p.isEmpty())
				ans += p.poll();
		} else if (y == 0) {
			while (!p.isEmpty() && x > 0) {
				ans += p.poll();
				x--;
			}
			while (!pq.isEmpty() && x>0) {
				if (pq.peek().id == 2)
					pq.poll();
				else {
					x--;
					ans += pq.poll().v;
				}
			}
		} else {
			while (!p.isEmpty() && y > 0) {
				ans += p.poll();
				y--;
			}
			while (!pq.isEmpty() && y>0) {
				if (pq.peek().id == 1)
					pq.poll();
				else {
					y--;
					ans += pq.poll().v;
				}
			}
		}
		System.out.println(ans);
		out.close();
	}

	static class pair {
		int id;
		int v;

		public pair(int i, int vi) {
			id = i;
			v = vi;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 64868
#include <iostream>
#include <math.h>

using namespace std;

unsigned long long  min(unsigned long long  x, unsigned long long  y) {
    if (x>y)
        return y;
    return x;
}

unsigned long long  max(unsigned long long  x, unsigned long long  y) {
    if (x<y)
        return y;
    return x;
}

int main() {
    unsigned long long  A,B,C,X,Y;
    unsigned long long  res = 0;
    cin >> A >> B >> C >> X >> Y;

    unsigned long long minim;
    if ((double) C < (double)(A + B) / 2)
    {
        minim = min(X, Y);
        res = minim * C * 2;
        X -= minim;
        Y -= minim;
        if (X != 0)
        {
            if (C < A / 2)
                res += X * C * 2;
            else
                res += X * A;
        }
        else if (Y != 0)
        {
            if (C < B / 2)
                res += Y * C * 2;
            else
                res += Y * B;
        }
    }
    else
    {
        res = X * A;
        res += Y * B;
    }

   /* if (C < min(A,B)/2) {
        res = max(X,Y)*2 * C;
    } else {
        if (C < (A+B)/2) {
            res = min(X,Y)C2;
            if (X>Y) {
                res += (X-Y) * A;
            } else {
                res += (Y-X) * B;
            }
        } else {
            res = XA + YB;
        }
    }*/

    cout << res;
}

Measured memory_bytes: 256