akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


int main()
{
	int n;
	cin >> n;
	vector<vector<int>>map(n, vi(n));
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		map[a][b]++;
		map[b][a]++;
	}
	vector<int>c(n);
	ll ans = 0;
	rep(i, n) {
		cin >> c[i];
		ans += c[i];
	}
	sort(all(c));
	reverse(all(c));
	ans -= *max_element(all(c));
	cout << ans << endl;
	queue<int>num;
	vector<int>cnt(n);
	num.push(0);
	int j = 1;
	cnt[0] = c[0];
	while (num.size() != 0) {
		rep(i, n) {
			if (map[num.front()][i] > 0) {
				num.push(i);
				cnt[i] = c[j];
				j++;
				//cout << j << endl;
				map[num.front()][i] = 0;
				map[i][num.front()] = 0;
			}
		}
		num.pop();
	}
	rep(i, n) {
		cout << cnt[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
}



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

using i64 = long long int;

const int INF = 1e9;

int pos[2][2004] = {0}; // 'W' -> 0, 'B' -> 1
int left_count[2][2004][4004] = {0};
int dp[2004][2004] = {0};

int main(){
    int n;
    cin >> n;
    vector<pair<char, int>> v;
    v.emplace_back('a', 0);
    for(int i=1;i<=2*n;++i){
        char c;
        int a;
        cin >> c >> a;
        pos[c == 'B'][a] = i;
        v.emplace_back(c, a);
    }

    for(int c=0;c<2;++c){
        for(int i=1;i<=n;++i){
            for(int j=2;j<=2*n;++j){
                if(c == (v[j-1].first == 'B') && v[j-1].second <= i){
                    left_count[c][i][j] = left_count[c][i][j-1] + 1;
                }else{
                    left_count[c][i][j] = left_count[c][i][j-1];
                }
            }
        }
    }

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

    for(int w=0;w<=n;++w){
        for(int b=0;b<=n;++b){
            int p = w + b + 1;
            if(w < n){
                int cnt = left_count[0][w][pos[0][w+1]] + left_count[1][b][pos[0][w+1]];
                int mv = pos[0][w+1] - p + (w+b-cnt);
                dp[w+1][b] = min(dp[w+1][b], dp[w][b] + mv);
            }
            if(b < n){
                int cnt = left_count[0][w][pos[1][b+1]] + left_count[1][b][pos[1][b+1]];
                int mv = pos[1][b+1] - p + (w+b-cnt);
                dp[w][b+1] = min(dp[w][b+1], dp[w][b] + mv);
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 78720
from operator import itemgetter

N, M = [int(_) for _ in input().split()]
PY = [[__] + [int(_) for _ in input().split()] for __ in range(M)]
PY.sort(key=itemgetter(1, 2))

p = 0
x = 1
for i in PY:
    if p != i[1]:
        p = i[1]
        x = 1
    i.append('{:06}{:06}'.format(p, x))
    x += 1

for i in sorted(PY):
    print(i[3])


Measured memory_bytes: 35376
#include <iostream>
using namespace std;
int main(void){
    int n,a[256],count=0;
    cin >> n;
    
    for(int i=0;i<n;i++) cin>>a[i];
    
    while(true){
        bool odd = false;
        
        for(int i=0;i<n;i++){
            if(a[i] %2 != 0) odd = true;
        }
        if(odd) break;//2で割り切れないならループ抜ける
        
        for (int i=0; i<n;i++) {
            a[i] /= 2;
        }
        count++;  // 操作回数をインクリメント
        
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;

int main(){
  ll n; cin >> n;
  ll ama = n%10;
  string ans = "pon";
  if(ama==2||ama==4||ama==5||ama==7||ama==9) ans="hon";
  if(ama==3) ans="bon";
  cout << ans;
  return 0;
}

Measured memory_bytes: 3628
S = list(input())
N = len(S)

def palindrome(string): 
    return 0 if string==string[::-1] else 1

S_before = []
S_before = S[0:int(((N-1)/2))]
#print(S_before)
S_after = []
S_after = S[int(((N+3)/2)-1):N]
#print(S_after)

if palindrome(S) + palindrome(S_after) + palindrome(S_before)==0:
    print("Yes")
else:
    print("No")


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<ll> a(N), b(N);

  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = 0; i < N; i++) cin >> b[i];

  ll m = 1;

  ll ans = 0;

  for(int j = 0; j < 29; j++){

    vector<ll> c(N);
    for(int i = 0; i < N; i++){
      c[i] = b[i] % (2*m);
    }

    sort(c.begin(), c.end());

    ll t = 0;
    for(int i = 0; i < N; i++){

      ll minval = m - (a[i] % (2*m));
      ll maxval = 2*m - (a[i] % (2*m));

      if(minval >= 0){

        auto itr_min = lower_bound(c.begin(), c.end(), minval);
        auto itr_max = lower_bound(c.begin(), c.end(), maxval);

        t += itr_max - itr_min;

      }else{

        auto itr_min = lower_bound(c.begin(), c.end(), minval + 2*m);
        auto itr_max = lower_bound(c.begin(), c.end(), maxval);
        
        t += c.end() - itr_max;
        t += itr_min - c.begin();
      }

    }

    if(t % 2 == 1){
      ans += m;
    }

    m *= 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, ba = 0, xa = 0, bx = 0, res = 0;
    string s;
    cin>>n;
    rep(i, n) {
        cin>>s;
        if(s[0] == 'B'){
            if(s[s.size() - 1] == 'A') ba++;
            else bx++;
        }else if(s[s.size() - 1] == 'A') xa++;
        rep(j, s.size() - 1) {
            if(s[j] == 'A' && s[j + 1] == 'B') res++;
        }
    }
    res += min(xa, bx);
    res += ba;
    if(xa + bx == 0 && ba) res--;
    cout<<res<<endl;
}


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

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 250 * 1000 + 47;

int A[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)
    scanf("%d", A + i);
    LL L = 2, R = 2;
    RFOR(i, n, 0)
    {
        L = ((L + A[i]-1)/ A[i]) * 1LL * A[i];
        R = ((R / A[i]) + 1) * 1LL * A[i] - 1;
        if (R < L)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << L << " " << R << endl;
}


Measured memory_bytes: 640
solve :: Int -> Int -> Int -> Int -> Int -> Int
solve a b c x y 
    | x >= y = minimum [l, m, n a]
    | x < y = minimum [l, m, n b]
    where
        l = a * x + b * y
        m = 2 * c * max x y
        n o = (2 * c * min x y) + (o * (abs $ x-y :: Int))

main = do
    [a,b,c,x,y] <- map read . words <$> getLine :: IO [Int]
    print $ solve a b c x y

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main(void) {
  int n;
  int dev;

  while(cin >> n) {
    dev = 1;
    for(int i = 0 ; i < n ; i++) {
      dev += i + 1;
    }
    cout << dev << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int main() {
	LL a[7];
	for (int i = 0; i < 7; i++) cin >> a[i];
	LL ans = (a[0] / 2) * 4 + a[1] * 2 + (a[3] / 2) * 4 + (a[4] / 2) * 4;
	if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
		a[0]--;
		a[3]--;
		a[4]--;
		ans = max(ans, 6 + (a[0] / 2) * 4 + a[1] * 2 + (a[3] / 2) * 4 + (a[4] / 2) * 4);
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s.size() % 2 == 0) {
		for (int i = 0; i < s.size() - 1; i+=2) {
			cout << s[i];
		}
		cout << endl;
		return 0;
	}
	else {
		for (int i = 0; i < s.size(); i += 2) {
			cout << s[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A - 2 * B > 0) cout << A - 2 * B << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3620
x,y,a,b,c=map(int,input().split())
*p,=sorted(map(int, input().split()))
*q,=sorted(map(int, input().split()))
*r,=map(int, input().split())

p=p[-x:]
q=q[-y:]
r=sorted(p+q+r)
print(sum(r[-x-y:]))
assert sum(r[-x-y:]) < 2**63

Measured memory_bytes: 117736
using System;using static System.Console;class P{static void Main(){while(1>0){var a=Array.ConvertAll(ReadLine().Split(),int.Parse);if(a[0]+a[1]==0)break;for(int i=0,j;i++<a[0];WriteLine())for(j=0;j++<a[1];Write("#"));WriteLine();}}}


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

int main(){

    int H, W;
    cin >> H >> W;

    string picture[H+2][W+2];
    string line;

    for(int i=0; i < H+2; i++){
        for(int j=0; j < W+2; j++){
            picture[i][j] = "#";
        }
    }

    for(int i=1; i<=H; i++){
        cin >> line;
        for(int j=0; j <= W; j++){
            picture[i][j+1] = line[j];
        }
        picture[i][W+1] = "#";
    }    



    for(int i=0; i < H+2; i++){
        for(int j=0; j < W+2; j++){
            cout << picture[i][j];
        }
        cout << endl;
    }    

   

    return 0;
}

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

class Main {

    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextInt()) {
                int dataSet = sc.nextInt();
                for (int i = 0; i < dataSet; i++) {
                    String originalNum = sc.next();
                    char[] charNum = originalNum.toCharArray();

                    // asc
                    Arrays.sort(charNum);
                    int maxNum = Integer.parseInt(String.valueOf(charNum));

                    // desc
                    int minNam = Integer
                            .parseInt(String.valueOf(desc(charNum)));

                    // max-min
                    int result = minNam - maxNum;
                    System.out.println(result);
                }
            }
        } finally {
            sc.close();
        }
    }

    private static char[] desc(char[] c) {
        char[] after = new char[c.length];

        for (int i = 0; i < c.length; i++) {
            after[i] = c[c.length - (1 + i)];
        }
        return after;
    }
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b && b<=c && a<=c){
	cout<<a <<" " <<b<< " " << c<<endl;
	return 0;
	}
	if(a<=b && b>=c && a<=c){
	cout<<a << " "<<c<<  " " <<b<<endl;
	return 0;
	}
	if(a>=b && b<=c && a<=c){
	cout<<b<<" " <<a<<" " <<c<<endl;
	return 0;
	}
	if(a>=b && b<=c && a>=c){
	cout<<b<<" "<<c<<" "<<a<<endl;
	return 0;
	}
	if(a<=b && b>=c && a>=c){
	cout<<c<<" "<<a<<b<<" "<<endl;
	return 0;
	}
	if(a>=b && b>=c && a>=c){
	cout<<c<<" "<<b<<" " <<a<<endl;
	return 0;
	}
}

Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d,e,p,q;
int main(){
	cin>>a>>b>>c>>d>>e;
	p=a*e;
	q=b;if(e>=c)q+=(e-c)*d;
	cout<<min(p,q)<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int a[100];
int main(){
    for (int i = 0; i < 4; i++) {
        int k;
        cin >> k;
        a[k]++;
    }
    if(a[1]&&a[7]&&a[9]&&a[4]) puts("YES");
    else puts("NO");
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;

namespace _064_SecretNumber
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;
			int sum = 0;

			StringBuilder tmp = new StringBuilder (5);

			while ((inputStr = Console.ReadLine ()) != null)
			{
				for (int lp = 0; lp < inputStr.Length; lp++)
				{
					if (char.IsDigit (inputStr, lp))
					{
						for (; lp < inputStr.Length && char.IsDigit (inputStr, lp); lp++)
						{
							tmp.Append (inputStr[lp]);
						}

						sum += int.Parse (tmp.ToString ());
						tmp = new StringBuilder (5);
					}
				}
			}

			Console.WriteLine (sum);
		}
	}
}

Measured memory_bytes: 9128
/*
	Date:2020.5.10
	Name:Aliemo
*/
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define rr register

#define MAXN 1010
#define inf 1e18

using namespace std;

inline int read(int &T) {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return T = f ? -s : s;
}

void print(int x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}

int a, b, c, k, ans;

signed main() {
	a = read(a);
	b = read(b);
	c = read(c);
	k = read(k);
	if (k <= a) {
		ans += k;
	}
	else {
		ans += a;
		k -= a;
		k -= b;
		if (k > 0) ans -= k; 
	}
	print(ans);
	putchar('\n');
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j;
	ld k,l,n;
	cin>>n>>k;

	ld an=0.0;
	for(i=1;i<=n;i++){
		if(i<k){
			ll c=0,v=i;
			while(v<k){
				v=v*2;
				c++;
			}
			l=c;
			//cout<<i<<" "<<l<<endl;
			an+=(1.0/n)*(1.0/(ld)power(2,l,1e18));
		}
		else {
			an+=(1.0/n);
		}
	}
	cout<<fixed<<setprecision(13)<<an;
	return 0;
}


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

int main() {
  ll n,tmp;
  string ans="No";
	cin >> n;
  if(n<=81){
  	for(ll i=1;i<=9;i++){
  		if(n%i==0){
  		  tmp=n/i;
  		  if(tmp<=9){
  		  	ans="Yes";
  				break;
  			}
  		}
  	}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#define maju 1919114514
using namespace std;

int gcd(int a, int b) {
	int c = a % b;
	if (c == 0)return b;
	else return gcd(b, c);
}
int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int cc, dc,cdc;
	long long int cd =c*d/gcd(c,d);

	if (a % c == 0)cc = a;
	else cc = a + (c - a % c);
	if (a % d == 0)dc = a;
	else dc = a + (d - a % d);
	if (a % cd == 0)cdc = a;
	else cdc = a + (cd - a % cd);
	if (cc > b)cc = b + c;
	if (dc > b)dc = b + d;
	if (cdc > b)cdc = b + cd;
	//cout << cc << " " << dc << " " << cdc << endl;
	cout << (b-a+1)-((b - cc) / c + (b - dc) / d - (b - cdc) / cd + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
//ll a[100001]={0};
int main()
{//ios_base::sync_with_stdio(false);


int a,b,k;
cin>>k>>a>>b;
if(b/k-a/k>=1||a%k==0||b%k==0)
{
    cout<<"OK";
}
else
    cout<<"NG";



}


Measured memory_bytes: 3624
#include<iostream>

int main(){
  char a, b;
  std::cin >> a >> b;
  bool isTopH;
  if(a == 'H' && b == 'H') isTopH = true;
  else if(a == 'D' && b == 'D') isTopH = true;
  else isTopH = false;
  if(isTopH) std::cout << 'H' << std::endl;
  else std::cout << 'D' << std::endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

const int INF = 1001001001;

int main() {
  ll x;
  cin >> x;
  ll counter500 = 0,counter5 = 0;
  for (;;) {
    if (x < 500) {
      break;
    }
    x -=500;
    counter500++;
  }
  for (;;) {
    if (x < 5) {
      break;
    }
    x -=5;
    counter5++;
  }
  ll ans = counter5*5+counter500*1000;
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

const int N = 5005;
const ll inf = 0x7fffffffffffffff;

ll n, f[N];
//f[i] 表示选i个人的最小高度 
struct Node {
	ll h, p;
}a[N];

bool cmp(Node x, Node y) { return x.h + x.p < y.h + y.p; }

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i].h >> a[i].p, f[i] = inf;
	sort(a + 1, a + 1 + n, cmp);
	f[0] = 0;
	for (int i = 1; i <= n; ++i) 
		for (int j = i - 1; j >= 0; --j)
			if (f[j] <= a[i].h) f[j + 1] = min(f[j + 1], f[j] + a[i].p);
	//for (int i = 1; i <= n; ++i) cout << f[i] << " ";
	for (int i = n; i >= 0; --i) if (f[i] != inf) { cout << i << endl; return 0; }
}

Measured memory_bytes: 384
N, Y = [int(k) for k in input().split(' ') if k]
Y //= 1000
x = Y // 10
Y -= x * 10
y = Y // 5
Y -= y * 5
z = Y
if N < x + y + z:
	print(-1, -1, -1)
	exit()
d = N - x - y - z
for dx in range(min(d, x) + 1):
	nx = x - dx
	ny = y + 2 * dx
	nd = N - nx - ny - z
	dy = min(nd // 4, ny)
	ny = ny - dy
	nz = z + dy * 5
	if nx + ny + nz == N:
		print(nx, ny, nz)
		exit()
print(-1, -1, -1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n,m,k;
int cnt[10005];
int ans[105][105];

int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<k;i++) scanf("%d",cnt+i+1);
	
	int t=1;
	for(int i=0;i<n;i++){
		if(i%2){
			for(int j=0;j<m;j++){
				while(!cnt[t]) t++;
				ans[i][j]=t;
				cnt[t]--;
			}
		}
		else{
			for(int j=m-1;j>=0;j--){
				while(!cnt[t]) t++;
				ans[i][j]=t;
				cnt[t]--;
			}
		}
	}
	for(int i=0;i<n;i++) for(int j=0;j<m;j++){
		printf("%d%c",ans[i][j]," \n"[j==m-1]);
	}
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;

const int maxn = 100009;
const int MOD = 1000000007;
int fac[maxn], rev[maxn];
int last[maxn];
int n, a, u, v;

int power(int x, int y){
	int res = 1;
	while (y){
		if (y&1) res = 1LL*res*x%MOD;
		x = 1LL*x*x%MOD; y >>= 1;
	}
	return res;
}

void init(){
	fac[0] = rev[0] = 1;
	for (int i=1; i<maxn; i++){
		fac[i] = 1LL*fac[i-1]*i%MOD;
		rev[i] = power(fac[i], MOD-2);
	}
}

int C(int n, int m){
	return 1LL*fac[n]*rev[m]%MOD*rev[n-m]%MOD;
}

int main(){
	scanf("%d", &n);
	for (int i=1; i<=n+1; i++){
		scanf("%d", &a);
		if (last[a]) { u = last[a]-1; v = n+1-i; }
		last[a] = i;
	}
	init();
	for (int k=1; k<=n+1; k++){
		int ans = 0;
		if (k <= n-1)
			ans = (ans + C(n-1, k)) % MOD;
		if (k <= n)
			ans = (ans + 2*C(n-1, k-1)%MOD)%MOD;
		if (k >= 2)
			ans = (ans + C(n-1, k-2))%MOD;
		if (u+v >= k-2)
			ans = (ans - C(u+v, k-1))%MOD;
		printf("%d\n", (ans+MOD)%MOD);
	}
	return 0;
}

Measured memory_bytes: 2304
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar
#define putchar putchar
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

int a[20001], b[20001];
int main(void){
	int n=nextint();
	for(int i=1; i<=n; i++){
		a[i]=n*i;
		b[i]=n*(n-i+1);
	}
	for(int i=0; i<n; i++){
		int p=nextint();
		a[p]+=i;
	}
	for(int i=1; i<=n; i++){
		printf("%d ", a[i]);
	}
	putchar(10);
	for(int i=1; i<=n; i++){
		printf("%d ", b[i]);
	}
	putchar(10);
}


Measured memory_bytes: 1688
L,R = list(map(int, input().split()))

if R - L > 2019:
    print("0")
else:
    A =[]
    for i in range(L ,R):
            for j in range(L+1,R+1):
                b = i*j % 2019
                A.append(b)
    ans = min(A) 
    print(ans)

Measured memory_bytes: 147632
def main():
    N, M = map(int,input().split())
    H = list(map(int,input().split()))

    route = dict()
    for i in range(M):
        A, B = map(int, input().split())
        if A in route:
            route.get(A, set()).add(B)
        else:
            route[A] = set([B])
        if B in route:
            route.get(B, set()).add(A)
        else:
            route[B] = set([A])

    counter = 0
    for k, mountains in route.items():
        if H[k-1] > max([H[i-1] for i in mountains]):
            counter +=1
        
    counter += N - len(route.keys())

    print(counter)

if __name__ == '__main__':
    main()

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

int main() {
	int N;

	cin >> N;

	long long output = 0;

	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 and i % 5 != 0) {
			output += i;
		}
	}
	cout << output << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int A[7],B[7],i;
int G[55][6]={
	{1,2,3},{1,3,5},{1,5,4},{1,4,2},
	{2,1,4},{2,4,6},{2,6,3},{2,3,1},
	{3,1,2},{3,2,6},{3,6,5},{3,5,1},
	{4,1,5},{4,2,1},{4,6,2},{4,5,6},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,4,5},{6,5,3},{6,3,2}};

int main()
{
	for(i=1;i<7;i++)scanf("%d",A+i);
	for(i=1;i<7;i++)scanf("%d",B+i);
	for(i=0;i<24;i++)
	{
		if(A[1]==B[G[i][0]]&&
		   A[2]==B[G[i][1]]&&
		   A[3]==B[G[i][2]]&&
		   A[6]==B[7-G[i][0]]&&
		   A[5]==B[7-G[i][1]]&&
		   A[4]==B[7-G[i][2]])
		{puts("Yes");
		return 0;
		}
	}
	puts("No");
	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}


int main(){
	int n; cin >> n;
	priority_queue<pair<ll,ll>> q;
	Rep(n){
		ll a,b; cin >> a >> b;
		q.push(make_pair(-b,a));
	}
	ll t = 0;
	while(!q.empty()){
		auto [b,a] = q.top();
		q.pop();
		b = -b;
		t += a;
		if(t > b){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes\n";
}

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

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  int arr[]={1,2,3};
  int res=0;
  for(int i=0;i<3;i++)
  {
    if(arr[i]!=a&&arr[i]!=b){
      cout<<arr[i];
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3428
#include<cstdio>
inline void swap(int&a,int&b){
  int t=a;a=b;b=t;
}
int main(){
  int n,m,l;
  scanf("%d %d %d",&n,&m,&l);
  if(n>m)swap(n,m);
  if(n>l)swap(n,l);
  if(m>l)swap(m,l);
  printf("%d %d %d\n",n,m,l);
}

Measured memory_bytes: 2748
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int main(){
  long long N,X,K,L;
  cin>>N>>X;
  K=X;
  L=N-X;
  if(K<L){
    swap(K,L);
  }
  long long sum=N;
  while(1){
    sum+=L*2*(K/L);
    if(K%L==0){
      sum-=L;
      break;
    }
    long long S=L;
    L=K%L;
    K=S;
  }
  cout<<sum<<endl;
  return 0;
}


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

// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp>     //required
// using namespace __gnu_pbds;              //required
// using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set<int> s;
// ordered_set<int>::iterator itr;
void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    int n, k;
    char qw;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < k; i++)
        sum += arr[i];
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3652
a,b=map(int,input().split())
S=input()
for i in range(len(S)):
  if i==a:
    if S[i]!="-":
      print("No")
      break
  else:
    try:
      Si = int(S[i])
    except:
      print("No")
      break
else:
  print("Yes")

Measured memory_bytes: 8980
ss = []
ss.push(gets.chomp.chars.map{|c| c.ord - "a".ord}.push(114514))
ss.push(gets.chomp.chars.map{|c| c.ord - "a".ord}.push(114514))
ss.push(gets.chomp.chars.map{|c| c.ord - "a".ord}.push(114514))
ii = Array.new(3,0)
turn = 0
while true
	if ss[turn][ii[turn]] == 114514 then
		puts ("A".ord + turn).chr 
		exit
	end
	curr = turn
	turn = ss[turn][ii[turn]]
	ii[curr] += 1
	#puts "turn:#{turn} ss:#{ss[turn][ii[turn]]}"
end

Measured memory_bytes: 1788
N, M, Q = map(int,input().split())
L = []
def dfs(List):
    if len(List) == N - 1:
        L.append([0] + List)
    else:
        k = List[-1]
        for i in range(M-k):
            n_L = List[:]
            n_L.append(k+i)
            dfs(n_L)
for i in range(M):
    dfs([i])

Qs = []
for _ in range(Q):
    Qs.append(list(map(int,input().split())))

MAX = 0
for l in L:
    cnt = 0
    for a, b, c, d in Qs:
        if l[b-1] - l[a-1] == c:
            cnt += d
    MAX = max(cnt, MAX)
print(MAX)

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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }
};

////////////////
// 組み合わせ //
///////////////

template<int64_t mod_ = 1'000'000'007, int max_ = 200'000>
class Combination {
public:
	std::array<ModInt<mod_>, max_ + 1> inv, fact, finv;

	Combination()
	{
		inv[0] = inv[1] = fact[0] = fact[1] = finv[0] = finv[1] = 1;
		for (int num{2}; num <= max_; num++)
		{
			inv[num] = (mod_ - (int64_t)inv[mod_ % num] * (mod_ / num) % mod_) % mod_;
			fact[num] = num * fact[num - 1] % mod_;
			finv[num] = inv[num] * finv[num - 1] % mod_;
		}
	}

	constexpr ModInt<mod_> getCombi(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[r] * finv[n - r];
	}

	constexpr ModInt<mod_> getPerm(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[n - r];
	}
};

constexpr int64_t mod{1'000'003};
Combination<mod, mod - 1> combi;

int64_t solve();

int main()
{
	int Q;
	scanf("%d", &Q);
	for (int i{}; i < Q; i++)
		printf("%lld\n", solve());
 
	return 0;
}
using mint = ModInt<mod>;
int64_t solve()
{
	int64_t x, d, n;
	scanf("%lld%lld%lld", &x, &d, &n);
	if (x == 0) return 0ll;
	if (d == 0) return mint(x) ^ n;
	mint xd_inv(mint(mod - x) / mint(d));
	if ((int64_t)xd_inv <= n - 1) return 0ll;
	// 0 < x < mod, d > 0, n-1 <-x/d < mod
	return combi.getPerm(xd_inv, n) * (mint(mod - d) ^ n);
}

Measured memory_bytes: 24448
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

int main() {
	int K, X;
	cin >> K >> X;

	for (int i = X - K + 1; i <= X + K - 1; i++) {
		cout << i << " ";
	}
	cout << endl;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi= 3.14159265358979323846;
    ll n,k;
    cin>>n;
    k=2;
    ll h[n+1];
    rep(i,n)
    {
        cin>>h[i+1];
    }
    ll dp[n+1]={0};
    dp[0]=INF;
    
    rep(i,n+1)
    {
        dp[i]=INF;
    }dp[1]=0; 
    for(ll i=2;i<=n;i++)
    {
        // debug(i);
        for(ll j=1;j<=k;j++)
        {
            if(i-j<1)
            {
                break;
            }
            // debug(dp[i-j]+abs(h[i]-h[i-j]));
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
  int n;
  cin >> n ;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  string str;
  for(int i = 0; i < n; i++){
    cin >> str;
    if(str == "AC") ac++;
    if(str == "WA") wa++;
    if(str == "TLE") tle++;
    if(str == "RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3652
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll n,c=1,mn;
    cin >> n;
    vll a(n);

    f(i,0,n-1)
        cin >> a[i];
    mn=a[0];
    f(i,1,n-1)
        if(a[i]<=mn)
        {
            mn=a[i];
            c++;
        }
    cout << c;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {

    int N,A;
    cin >> N >> A;

    cout << N*N-A << endl;
    
    return 0;

}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int max_count=0;
int c=0;

int main(){
    string s;
    cin >> s;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            c++;
        }else{
            if(c>max_count){
                max_count=c;
            }
            c=0;
        }
        
    }
    if(c>max_count) max_count=c;
    cout << max_count << endl;
    return 0;
}



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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    ll n, k;
    cin >> n >> k;

    n = n % k;
    ll ans = min(n, abs(n - k));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl
const ll m=1000000007;
ll mod(ll a,ll b)
{
	a=a%m;
	b=b%m;
	return(a*b)%m;
}
ll modd(ll a)
{
	return a%m;
}
void solve()
{
	ll n; cin>>n; ll a[n];
	ff(0,n) cin>>a[i];
	ll ans=0;
	ll x=0;
	for(ll i=0;i<n;i++)
	{
		ans+=modd(mod(a[i],x));
		x=(modd(x)+modd(a[i]))%m;
	}
	ans=ans%m;
	cout<<ans;
}

int main()
{
	solve();
}
/*




*/


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

void solve(std::string S)
{
    S = S == "ABC" ? "ARC" : "ABC";
    cout << S << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  for (ll i = 0; i < 60; ++i) {
    ll one = 0;
    for (int j = 0; j < n; ++j) {
      if ((a[j] >> i) & 1ll) {
        one++;
      }
    }
    ll t = (one * (n - one)) % MOD;
    ll u = (1ll << i) % MOD;
    ll res = (t * u) % MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
def main():
    N, M = map(int, input().split())
    HN = list(map(int, input().split()))

    temp = [True for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())

        if HN[A - 1] < HN[B - 1]:
            temp[A - 1] = False
        elif HN[B - 1] < HN[A - 1]:
            temp[B - 1] = False
        else:
            temp[A - 1] = False
            temp[B - 1] = False

    print(sum([1 for a in temp if a]))


main()


Measured memory_bytes: 20120
#include <iostream>

using namespace std;

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A==C){
        if(B<D) cout<<B-A<<endl;
        if(B>=D) cout<<D-C<<endl;
    }

    if(A<C){
        if(B<=C) cout<<"0"<<endl;
        else{
            if(B>=D) cout<<D-C<<endl;
            if(B<D) cout<<B-C<<endl;}
    }

    if(C<A){
        if(D<=A) cout<<"0"<<endl;
        else{
            if(D>=B) cout<<B-A<<endl;
            if(D<B)  cout<<D-A<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll N;
    cin >> N;
    static int v[2][3];
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> v[i][j];

    for (int i = 0; i < 2; ++i) {
        vector<ll> dp(N + 1);
        for (int j = 0; j < 3; ++j) {
            for (int k = v[i][j]; k <= N; ++k) {
                int cost = v[!i][j] - v[i][j];
                dp[k] = max(dp[k - v[i][j]] + cost, dp[k]);
            }
        }
        N += dp[N];
    }

    cout << N << endl;

    return 0;
}


Measured memory_bytes: 198456
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [100000000000 for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(min(i+1,k+1)):
        dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
print(dp[-1])


Measured memory_bytes: 56544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    long long int A,P;
    long long int t,l,m;
    cin>>A;
    P=100;
    t=0;
    while(1)
    {
        P+=(P/100);
        t++;
        if(P>=A)
        break;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int N;
    string S;
    cin >> N >> S;
    int count = 0;
    rep(i, 0, N - 2){
        if (S.substr(i, 3) == "ABC"){
            count++;
            i += 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	int n,t;
	cin >> n >> t;
	int cost=999999;
	vector<pair<int,int>> pa(n);
	for(int i=0;i<n;i++){
		cin >> pa[i].first;
		cin >> pa[i].second;
		if(pa[i].second<=t){
			cost=min(cost,pa[i].first);
		}
	}
	if(cost==999999){
		cout << "TLE" << endl;
	}else{
		cout << cost << endl;
	}
	return 0;
}


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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  
  vector<ll> v(100011);
  ll x;
  
  for ( ll i = 0; i < n; i++ ){
    cin >> x;
    v[x+9]++;
    v[x+10]++;
    v[x+11]++;
  }
  
  sort(v.begin(), v.end(), greater<ll>());
  
  cout << v[0] << endl;
    
}

Measured memory_bytes: 1024
X, N = map(int , input().split())
p = list(map(int, input().split()))
k = 0
hugou = 1
hantei = 0
while(hantei == 0):
    if(hugou == -1):
        X -= k
    elif(hugou == 1):
        X += k

    if(X not in p):
        print(X)
        hantei = 1
    else:
        if(hugou == 1):
            hugou = -1
        elif(hugou == -1):
            hugou = 1
        k += 1

Measured memory_bytes: 9204
n = int(input())
num_li = list(map(int,input().split()))

cnt = 0
ans = 0

for i in range(n-1):
    if num_li[i] >= num_li[i+1]:
        cnt += 1
        continue
    else:
        ans = max(ans,cnt)
        cnt = 0
        
ans = max(ans,cnt)
        
print(ans)
    

Measured memory_bytes: 14252
#include <bits/stdc++.h>
      #define ll  long long int
      #define N 100000
      #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
      #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
      #define po pop_back
      #define pb push_back
      #define pp pair<ll,ll>
      #define lb lower_bound
      #define fi first
      #define se second
      #define debug(x) cout << #x << " = " << x << endl
      #define ub upper_bound
      #define ibs ios_base::sync_with_stdio(false)
      #define cti cin.tie(0)
      #define all(x) x.begin(),x.end()
      #define PI 3.14159265
      #define cot cout.tie(0)
      using namespace std;
       /**
        * @author :: Sawlani
        *
        */
        int main()
        {
           ll n;
           cin >> n;
           vector <ll> a(n);
           f(i,0,n-1)
           {
               cin >> a[i];

           }

           sort(all(a));
           ll ans=0;
           f(i,0,n-3)
           {
               f(j,i+1,n-2)
               {
                   ll p=lb(a.begin()+j+1,a.end(),a[i]+a[j])-a.begin();
                    p--;
                     if((p-j)>0)
                        {
                   ans+=p-j;
            //        cout <<  i << " " <<  j <<  endl;
                   }
               }

           }
           cout <<  ans <<  endl;

        }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long n,m,sum=0,snu=0,ans=10000000000000000;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	rep(j,n)sum+=a[j];
	rep(k,n-1){
	    snu+=a[k];
	    ans=min(ans,abs(sum-snu*2));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
def insertSort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(' '.join(map(str, a)))

if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    print(' '.join(map(str, a)))
    insertSort(a, n)

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans;
  int N, A, B;
  cin >> N >> A >> B;

  int temp = N * A;

  if (temp <= B) {
    ans = temp;
  } else {
    ans = B;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256