akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
    int N, yen;
    cin >> N;

    yen = N/1.08;

    for(int i = 0; i <= yen + 1; i++){
        if(static_cast<int>(i*1.08) == N){
            cout << i << endl;
            exit(0);
        }
    }

    cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
prime = [0] * (10**6+5)
for i in range(N):
    c = Counter(prime_factorize(A[i]))
    for j in c.items():
        prime[j[0]] = max(j[1],prime[j[0]])
lcm = 1
for i in range(10**6+2):
    if prime[i] > 0:
        lcm *= pow(i,prime[i])
        lcm %= MOD

ans = 0
for i in range(N):
    ans += lcm * pow(A[i],MOD-2,MOD)
    ans %= MOD
print(ans)


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll S;
  cin>>S;
  ll t = (S-1LL)/1000000000LL+1LL;
  cout<<0<<" "<<0<<" "<<t<<" "<<1<<" "<<t*1000000000-S<<" "<<1000000000<<endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli bToC[100100];
lli bToCSum[100100];

void func(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    REP(i,0,N){
        lli num = B[i];
        bToC[i] = (lli)(lower_bound(A.begin(),A.end(),num)-A.begin());
    }

    REP(i,0,N){
        bToCSum[i+1] = bToC[i]+bToCSum[i];
        //bToCSum[i+1] %= MOD;
    }

    REP(i,0,N+1)if(DEBUG)cout<<"i="<<i<<"bToCSum[i]="<<bToCSum[i]<<endl;

    lli ans = 0;

    REP(i,0,N){
        lli num = C[i];
        lli index = (lli)(lower_bound(B.begin(),B.end(),num)-B.begin());

        ans += bToCSum[index];
       // ans %= MOD;
    }
    cout<<ans<<endl;


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    func(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


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

int main() {
	// your code goes here
	int N = 0;
	cin >> N;
	int n = 3 * N;
	vector <long long> vect(n);
	for (int i = 0; i < n; i++)
	{
		cin >> vect[i];
	}
	sort(vect.begin(), vect.end());
	int  i = 0;
	long long res = 0;
	int a = n - 2;
	while (i < N)
	{
		res = res + vect[a];
		a = a - 2;
		i++;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 2560
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int num;
  cin >> num;
  vector<int> numbers;
  for (int i = 0; i < num; i++) {
    int temp;
    cin >> temp;
    numbers.push_back(temp);
  } 

  vector<int> b;
  for (int i = 0; i < numbers.size(); i++) {
    int index = lower_bound(b.begin(), b.end(), numbers[i]) - b.begin();
    if (index == b.size()) 
      b.push_back(numbers[i]);
    else 
      b[index] = numbers[i];
  }
  cout << b.size() << endl;
}

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

long long cnt =1;

long long dfs(long long a,long long k){
    if(a%k == 0){
        return cnt;
    }
    cnt++;
    return dfs((a*10 + 7)%k,k);
}

int main(){
    long long k;
    cin>>k;
    if(k%2 == 0 || k%10 == 5){
        cout<<"-1";
    }
    else{
        cout<<dfs(7,k);
    }
    return 0;
}

Measured memory_bytes: 3608
if __name__ == '__main__':
	d = input()
	e = d.split(' ')
	a = e[0]
	b = e[1]
	c = e[2]
	if a >= b:
		if b >= c: 
			print (c+" "+b+" "+a)
		elif c >= a:
			print (b+" "+a+" "+c)
		else:
			print (b+" "+c+" "+a)
	else:
		if c >= b:
			print (a+" "+b+" "+c)
		elif a >= c:
			print (c+" "+a+" "+b)
		else:
			print (a+" "+c+" "+b)





Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> class RPQ : public priority_queue<T, vector<T>, greater<T>> { };
template<typename C> void dijkstra(int s, vector<pair<int, C>> g[], C d[]) {
	RPQ<pair<C, int>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while(! q.empty()) {
		C   c = q.top().FI;
		int v = q.top().SE;
		q.pop();
		if(d[v] != c) { continue; }
		for(auto & e : g[v]) {
			int ev = e.FI;
			C   ec = e.SE;
			if(setmin(d[ev], d[v] + ec)) { q.emplace(d[ev], ev); }
		}
	}
}

vector<pair<int, int>> g[2000];
int d[2000];

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}


int main() {
	IN(int, n, x, y);
	x--; y--;
	inc(i, n - 1) {
		g[i].EB(i + 1, 1);
		g[i + 1].EB(i, 1);
	}
	g[x].EB(y, 1);
	g[y].EB(x, 1);
	
	vector<int> ans(n);
	inc(i, n) {
		inc(j, n) { d[j] = 1e9; }
		dijkstra(i, g, d);
		inc(j, i) { ans[d[j]]++; }
	}
	incID(i, 1, n) { OUT(ans[i]); }
}


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

#define F first
#define S second
#define pb push_back 
#define mp make_pair

#define ll long long 
#define ld long double 

#define vi vector <int>
#define vb vector <bool>
#define vc vector <char>
#define vll vector <ll>
#define vs vector <string>

#define pll pair < ll , ll >
#define pld pair < ld , ld >
#define pii pair < int , int >

#define vpld vector < pld >
#define vpii vector < pii >
#define vpll vector < pll >

#define vvi vector < vector < int > >
#define vvll vector < vector < ll > >
#define vvld vector < vector < ld > >
#define vvb vector < vector < bool > >
#define vvpii vector < vector < pii > >
//vector<vector<int>> v(n, vector<int>(n));

#define all(v) (v).begin() , (v).end()
#define allrev(v) (v).rbegin() , (v).rend()

#define dist(x1 , y1 , x2 , y2) sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))

const int MOD = 1e9 + 7 ;

bool isprime (ll num) {
    for (ll i = 2 ; i * i <= num ; ++i) {
		if (num % i == 0) return false ;
	}
    return true;
}
 
ll gcd (ll a, ll b) {
    if (b == 0) return a ;
	else return gcd (b , a % b) ;
}
 
ll lcm (ll a, ll b) {
    return ((a / gcd(a , b)) * b) ;
}
 
ll cel (ll x1, ll y1) {
    if ((x1) <= 0) return (x1) / (y1) ;
    return (((x1) / (y1)) + (((x1) % (y1)) != 0)) ;
}

int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

void solve (int test_case) {
	int n,flag=0;
	cin>>n;
	vpii v(n);
	for(int i=0;i<n;i++)
	{
	    cin>>v[i].F>>v[i].S;
	}
	for(int i=0;i<n;i++)
	{
	    if(v[i].F==v[i].S&&v[i+1].F==v[i+1].S&&v[i+2].F==v[i+2].S) {flag=1; break;}
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
}
int main() {
	ios_base :: sync_with_stdio (false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	int tc = 1 ;
	//cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}


Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll H,W; cin>>H>>W;
  vector<vector<ll>> c(10,vector<ll>(10)); rep(i,10) rep(j,10) cin>>c[i][j];
  vector<vector<int>> A(H,vector<int>(W)); rep(i,H) rep(j,W) cin>>A[i][j];
  
  vector<ll> table(10,INF);
  //table[1]=0;
  priority_queue<pair<ll,int>> que;
  que.push({0,1});
  while(!que.empty()){
    auto p=que.top(); que.pop();
    ll cost,v; tie(cost,v)=p; cost*=-1;
    //cout<<v<<" "<<cost<<'\n';
    if(table[v]<INF) continue;
    table[v]=cost;
    rep(i,10){
      if(table[i]<INF) continue;
      que.push({-cost-c[i][v],i});
    }
  }
  
  ll ans=0;
  rep(i,H) rep(j,W) if(A[i][j]!=-1) ans+=table[A[i][j]];
  
  cout<<ans<<'\n';
  
  return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
typedef pair <lli,lli> pll;
 
// CODE BEGINS :

lli log3(lli x)
{
    return (lli)((double)log((double)x)/log((double)3));
}

int main()
{
    kira; randomINIT;
    
    vector <lli> v;
    lli t; 
    
    forz(i,3)
    {
        cin>>t;
        v.pb(t);
    }
    
    sort(v.be, v.en);
    
    if(v[0]==5 && v[1]==5 && v[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}

















Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // int型へ変換
    var N = Integer.parseInt(str_scan);

    String[] D = new String[N];

    for(var j=0;j < N;j++){
      D[j] = scan.nextLine();
    }

    int zoro = 0;
    var ans = "No";
    String[] DiceLine = new String[2];

    for (var i=0;i < N;i++){
      DiceLine = D[i].split(" ");
      if (DiceLine[0].equals(DiceLine[1])){
        zoro++;
      }else{
        zoro = 0;
      }

      if(zoro == 3){
        ans = "Yes";
      }
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35640
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[N-1])

Measured memory_bytes: 13928
// abc144_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b;
  cin >> a >> b;
  if (a > 9 || b > 9) {
    cout << "-1" << endl;
  } else {
    cout << a*b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {	
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long ans = 1 , n = scan.nextLong();
		long MOD = 1000000007;
		for (long i = 1;i <= n;i ++) {
			ans = (ans * i) % MOD;
		}
		System.out.println(ans);
		
	}
	
		
}














Measured memory_bytes: 21204
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  vector<int> a;
  int q;
  cin >> q;
  REP(i, q) {
    int n;
    cin >> n;
    if (n == 0) {
      int x;
      cin >> x;
      a.push_back(x);
    } else if (n == 1) {
      int p;
      cin >> p;
      cout << a[p] << endl;
    } else {
      a.pop_back();
    }
  }
  return 0;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int k;cin>>k;
	vector<ll> a;
	for(ll i = 1; i <= 9; i++) {
		a.pb(i);
	}
	int size = 9;
	int cnt = 0;
	while(size < k){
		// if(a[cnt] % 10 == 1){
		// 	a.pb(a[cnt] * 10);
		// 	a.pb(a[cnt] * 10 + 1);
		// 	size += 2;
		// }
		if(a[cnt] % 10LL == 9LL){
			a.pb(a[cnt] * 10LL + 8LL);
			a.pb(a[cnt] * 10LL + 9LL);
			size += 2;
		}
		else if(a[cnt] % 10LL == 0LL){
			a.pb(a[cnt] * 10LL);
			a.pb(a[cnt] * 10LL + 1LL);
			size += 2;
		}
		else{
			a.pb(a[cnt] * 10LL + (a[cnt] % 10LL) - 1LL);
			a.pb(a[cnt] * 10LL + (a[cnt] % 10LL));
			a.pb(a[cnt] * 10LL + (a[cnt] % 10LL) + 1LL);
			size += 3;
		}
		cnt++;
	}
	// for(int i = 0; i < a.size(); i++) {
	// 	cout << a[i] << endl;
	// }
	cout << a[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;

int lcs(string X, string Y) {
    int c[1001][1001];
    int m = X.size();
    int n = Y.size();
    X = ' ' + X;
    Y = ' ' + Y;
    int maxl = 0;
    for (int i = 0; i < m + 1; i++) c[i][0] = 0;
    for (int j = 1; j < n + 1; j++) c[0][j] = 0;
    
    for (int i = 1; i < m + 1; i++) {
        for (int j = 1; j < n + 1; j++) {
            if (X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main() {
    string s1, s2;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N=26;
	int D;
	cin >>D;
	vector<int> c(N+1, 0);
	Rep1(i, N)
		cin >>c.at(i);
	vector<vector<int>> s(D+1, vector<int> (N+1, 0));
	Rep1(i, D)
		Rep1(j, N)
			cin >>s.at(i).at(j);
	vector<int> t(D+1);
	Rep1(i, D)
		//	cin >>t.at(i);
		t.at(i)=i%26+1;
	//
	vector<vector<int>> LAST(D+1, vector<int> (N+1, 0));
	int S=0;
	vector<vector<int>> SS(D+1, vector<int> (N+1, 0));
	Rep1(i, D) {
		Rep1(j, N) {
			if (j==t.at(i)) {
				LAST.at(i).at(j)=0;
				SS.at(i).at(j)=SS.at(i-1).at(j)+s.at(i).at(j);
				S +=s.at(i).at(j);
			} else {
				LAST.at(i).at(j) =LAST.at(i-1).at(j)+c.at(j);
				SS.at(i).at(j)=SS.at(i-1).at(j)-LAST.at(i).at(j);
			}
			S -=LAST.at(i).at(j);
		}
		//cout <<S <<endl;
	}
	//
	int SSS=0;
	int M=400000;
	Rep1(i, M) {
		int SSSS=S;
		int d=rand()%365+1;
		int q=rand()%26+1;
		//int d, q;
		//cin >>d >>q;
		int q0=t.at(d);
		if (q==q0)
			continue;
		S -=SS.at(D).at(q0)+SS.at(D).at(q);
		t.at(d)=q;
		for (auto j=d; j<=D; j++) {
			if (q0==t.at(j)) {
				LAST.at(j).at(q0)=0;
				SSS=SS.at(j-1).at(q0)+s.at(j).at(q0);
			} else {
				LAST.at(j).at(q0)=LAST.at(j-1).at(q0)+c.at(q0);
				SSS=SS.at(j-1).at(q0)-LAST.at(j).at(q0);
			}
			if (SSS==SS.at(j).at(q0))
				break;
			else
				SS.at(j).at(q0)=SSS;
		}
		for (auto j=d; j<=D; j++) {
			if (q==t.at(j)) {
				LAST.at(j).at(q)=0;
				SSS=SS.at(j-1).at(q)+s.at(j).at(q);
			} else {
				LAST.at(j).at(q)=LAST.at(j-1).at(q)+c.at(q);
				SSS=SS.at(j-1).at(q)-LAST.at(j).at(q);
			}
			if (SSS==SS.at(j).at(q))
				break;
			else
				SS.at(j).at(q)=SSS;
		}
		S +=SS.at(D).at(q0)+SS.at(D).at(q);
		if (S<SSSS) {
			t.at(d)=q0;
			for (auto j=d; j<=D; j++) {
				if (q0==t.at(j)) {
					LAST.at(j).at(q0)=0;
					SSS=SS.at(j-1).at(q0)+s.at(j).at(q0);
				} else {
					LAST.at(j).at(q0)=LAST.at(j-1).at(q0)+c.at(q0);
					SSS=SS.at(j-1).at(q0)-LAST.at(j).at(q0);
				}
				if (SSS==SS.at(j).at(q0))
					break;
				else
					SS.at(j).at(q0)=SSS;
			}
			for (auto j=d; j<=D; j++) {
				if (q==t.at(j)) {
					LAST.at(j).at(q)=0;
					SSS=SS.at(j-1).at(q)+s.at(j).at(q);
				} else {
					LAST.at(j).at(q)=LAST.at(j-1).at(q)+c.at(q);
					SSS=SS.at(j-1).at(q)-LAST.at(j).at(q);
				}
				if (SSS==SS.at(j).at(q))
					break;
				else
					SS.at(j).at(q)=SSS;
			}
			S=SSSS;
		}
		//cout <<i <<":" <<S <<endl;////////////////////////////
	}
	Rep1(i, D)
		cout <<t.at(i) <<endl;
	//cout <<S <<endl;//////////////////////
	return 0;
}



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

int main() {
  
  int A, B;
  cin >> A >> B;
  
  if (A == B) {
    cout << "Draw" << endl;
  }
  else if (A == 1) {
    cout << "Alice" << endl;
  }
  else if (B == 1) {
    cout << "Bob" << endl;
  }
  else if (A > B) {
    cout << "Alice" << endl;
  }
  else if (A < B) {
    cout << "Bob" << endl;
  }
  
return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

const int MOD = 1000000007;

int main(){
	long long N;
	long long dp[2][3];
	while(cin >> N){
		fill(dp[0], dp[0]+3, 0);
		dp[0][0] = 1; dp[0][1] = 0; dp[0][2] = 0;
		for(int i=60;i>=0;i--){
			fill(dp[1], dp[1]+3, 0);
			for(int j=0;j<3;j++){
				long long prevSum = (N >> (i+1)) - j;
				for(int k=0;k<3;k++){
					long long newDif = (N >> i) - (2 * prevSum + k);
					if(newDif < 0) continue;
					newDif = min(newDif, 2LL);
					dp[1][newDif] += dp[0][j];
					dp[1][newDif] %= MOD;
				}
			}
			copy(dp[1], dp[1]+3, dp[0]);
		}
		long long res = 0;
		for(int i=0;i<3;i++) res = (res + dp[0][i]) % MOD;
		cout << res << endl;
	}
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = Array.new(n + 1, 0)
a[0] = 1
m.times do |i|
    a[gets.to_i] = -1
end
0.upto(n) do |i|
    next if a[i] == -1
    a[i + 1] = (a[i + 1] + a[i]) % (10 ** 9 + 7) if i < n && a[i + 1] != -1
    a[i + 2] = (a[i + 2] + a[i]) % (10 ** 9 + 7) if i + 1 < n && a[i + 2] != -1
end
puts a[n]

Measured memory_bytes: 2812
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H,W,N;
    cin >> H >> W >> N;
    vint a(N);
    rep(i, N) cin >> a[i];
    v2int ans(H, vint(W, 0));
    int c = 0;
    rep(i, H) {
        if (i % 2 == 0) {
            rep(j, W) {
                if (a[c] == 0) c++;
                ans[i][j] = c + 1;
                a[c]--;
            }
        }
        else {
            for (int j = W - 1; j >= 0; j--) {
                if (a[c] == 0) c++;
                ans[i][j] = c + 1;
                a[c]--;
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Guidebook
            int N = int.Parse(Console.ReadLine());

            var restaurants = new List<Restaurant>();

            for(int i = 1; i <= N; i++)
            {
                var r = new Restaurant(i);
                restaurants.Add(r);
            }

            var query = restaurants.OrderBy(r => r.city).
                                    ThenByDescending(r => r.score);

            foreach(var q in query)
            {
                Console.WriteLine(q.id);
            }
        }
    }

    struct Restaurant
    {
        public int id;
        public string city;
        public int score;

        public Restaurant(int id)
        {
            var arr = Console.ReadLine().Split(' ');
            city = arr[0];
            score = int.Parse(arr[1]);

            this.id = id;
        }
    }
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 53;
int t[MAX][MAX];
int n;
int a[MAX],b[MAX];
int uz[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n)cin >> a[i];
  R(i,n)cin >> b[i];
  
  
  while(1){
    R(i,MAX)R(j,MAX)t[i][j] = i == j ? 0 : 100;
    R(i,MAX)R(j,MAX)if(j){
      mini(t[i][i % j], uz[j] ? 0 : j);
    }
    R(i,MAX)R(j,MAX)R(k,MAX){
      mini(t[j][k], max(t[j][i], t[i][k]));
    }
    int naj = 0;
    R(i,MAX){
      maxi(naj,t[a[i]][b[i]]);
    }
    if(naj > 60){
      cout << "-1\n";
      return 0;  
    }
    if(naj == 0){
      break;
    }
    uz[naj] = 1;
  }
  int res = 0;
  R(i,MAX)if(uz[i]){
    res += 1ll << i;
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    int count = 0;
    cin >> n;
    int p[30];

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

    for (int i=1; i<n-1; i++) {
        if (p[i-1] <= p[i] && p[i] < p[i+1]) {
            count++;
        }else if (p[i+1] <= p[i] && p[i] < p[i-1]) {
            count++;
        }else if (p[i+1] == p[i-1] && p[i] < p[i+1]) {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

bool ifsu(int);
int like(int s,int e);
int p[100002],f[100002];

int main()
{
	int n;cin>>n;
	int s,e;
	p[1]=1;

    for (int i=2; i<=100000; i++)
    {
        for (int j=2*i; j<=100000; j+=i)
            p[j]=1;
    }
    p[2]=0;
    for (int i=1; i<=100000; i++)
    {
        if(p[i]==0 && p[(i+1)/2]==0 && i!=2)
            {
                f[i]=f[i-1]+1;
            }
        else f[i]=f[i-1];
    }
    
    for(int i=1;i<=n;i++){
    	cin>>s>>e;
    	cout<<f[e]-f[s-1]<<endl;
	}
	return 0;
}

bool ifsu(int n)
{
	for(int i=2;i<n;i++){
		if(n%i==0)return false;
	}
	return true;
}
int like(int s,int e)
{
	int nu=0;
	for(int i=s;i<=e;i++){
		if(ifsu(i)&&ifsu((i+1)/2))nu+=1;
	}
	return nu;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }


int main()
{
    li n,ans=1;
    bool F=0;
    cin>>n;
    string a,b;
    cin>>a>>b;
    rep(i,n){
        if(i!=n-1 && a[i]==a[i+1]){
            if(i) ans=ans*(2+F)%1000000007;
            else ans=6;
            i++,F=1;
        }
        else {
            if(!F) ans=ans*2%1000000007;
            if(!i) ans=3;
            F=0;
        }
    }
    cout<<ans<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  std::cout << (a+b)/2 + (a+b)%2 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int m;
	
	m = 100000;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		m *= 1.05;
		if (m % 1000 > 0){
			m += 1000 - (m % 1000);
		}
	}
	printf("%d\n", m);
	
	return (0);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	int ans = a - 1;
	if(b >= a) ans++;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,M,L,K;

int main() {
	int D;
	cin >> D;
	if (D == 25)cout << "Christmas" << endl;
	else if(D == 24)cout << "Christmas Eve" << endl;
	else if(D==23)cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n,k;
	scanf("%d %d", &n, &k);
	if (n%k == 0) {
		puts("0");
	}
	else {
		puts("1");
	}
}

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

int main() {
  int n,k;
  string s;
  cin>>n>>s>>k;
  char c=s.at(k-1);
  for(int i=0;i<n;i++){
    if(s.at(i)!=c){
      s.at(i)='*';
    }
  }
  
  cout<<s<<endl;
  
}




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

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for(int i = 0; i < k; ++i) {
    ans += a[a.size()-1-i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

int main()
{
    int k,t;
    cin >> k >> t;
    vector<int> a(t);
    vector<int> tmp(t);
    rep(i,t)cin >> a[i];
    rep(i,t){
        tmp[i]=k-a[i];
    }
    int ans=0;
    rep(i,t){
        if(a[i]-1>tmp[i])ans+=(a[i]-1-tmp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.util.*;
 
class Main{
  
  public static void main(String args[])
  {
    
    Scanner s = new Scanner(System.in);
      
      int a = s.nextInt();
    	
    long sum=0;
    
    sum=(long)(a+Math.pow(a,2)+Math.pow(a,3));
    
    System.out.println(sum);
    
  }
  
  
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int N; ll K; cin >> N >> K;
  vector<pair<int, int>> a(N);
  rep(i, N) cin >> a[i].first >> a[i].second;
  sort(all(a));

  ll cnt = 0LL;
  rep(i, N) {
    cnt += (ll)a[i].second;
    if (cnt >= K) {
      cout << a[i].first << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

type Light struct {
	Switches []int
	Condition int
}

func main() {
	var n, m, k, s int
	fmt.Scan(&n)
	fmt.Scan(&m)

	var lights []Light
	var switches []int

	for i := 0; i < m; i++ {
		fmt.Scan(&k)

		for j := 0; j < k; j++ {
			fmt.Scan(&s)
			switches = append(switches, s)
		}

		lights = append(lights, Light{switches, 0})
		switches = []int{}
	}

	var condition int
	for i := 0; i < m; i++ {
		fmt.Scan(&condition)

		lights[i].Condition = condition
	}

	c := 0
	next:
	// 全探索
	for s := 0; s < int(math.Pow(2, float64(n))); s++ {
		for i := 0; i < m; i++ {
			ons := 0
			for j := 0; j < len(lights[i].Switches); j++ {
				ons += refbit(s, uint(lights[i].Switches[j] - 1))
			}
			if ons % 2 != lights[i].Condition {
				continue next
			}
		}
		c++
	}

	fmt.Println(c)
}

func refbit(i int, b uint) int {
	return (i >> b) & 1
}


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


void solve(long long A, long long B){
    cout <<  ceil((A + B) / 2.) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

using namespace std;

string A(int N) {
	while (N) {
		if (N % 10 == 7)
			return "Yes";
		N /= 10;
	}
	return "No";
}

int main() {
	int N;
	cin >> N;
	cout << A(N);
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int bubbleSort(int *,int);

int main() {
  
  int n,a[100],i,b[100],cnt=0;
  
  // input data
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  
  // sort
  cnt = bubbleSort(a,n);
  
  // output sorted data
  for(i=0;i<n-1;i++) printf("%d ",a[i]);
  printf("%d\n",a[n-1]);
  printf("%d\n",cnt);
  
  return 0;
}

// Sort by bubble sort and asc.
int bubbleSort(int *a, int n) {
  
  int tmp,j,cnt=0,flag=1;
  
  while(flag) {
    flag = 0 ;
    for(j=n-1;j>=1;j--) {
      if(a[j] < a[j-1]) {
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	flag = 1;
	cnt++;
      }
    }
  }
  
  
  return cnt;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, l;
  cin >> a >> b;
  if(a <= b){
    c = a;
    l = b;
  }else{
    c = b;
    l = a;
  }
  for(int i = 0; i < l - 1; i++){
    cout << c;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    T = read_lists(M)
    T.sort()

    S = []
    C = [10 ** 20] * N
    C[0] = 0
    t = 0
    for i in range(N):
        if i != 0 and len(S) == 0:
            print(-1)
            return

        c, r = (0, 0) if len(S) == 0 else S[0]
        while t < M:
            ll, rr, cc = T[t]
            ll -= 1
            rr -= 1
            if ll > i:
                break
                
            C[rr] = min(C[rr], c + cc)
            heapq.heappush(S, (C[rr], rr))
            t += 1

        while S:
            if S[0][1] > i:
                break
            heapq.heappop(S)

    print(C[-1])


if __name__ == "__main__":
    main()



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

int N, A, B;
int P[110];

int main() {
    cin >> N >> A >> B;
    for (int i = 0; i < N; i++) cin >> P[i];

    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] <= A) one++;
        else if (A < P[i] && P[i] <= B) two++;
        else three++;
    }

    cout << min(one, min(two, three)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
typedef long long LL;

int N;
struct node{
    int x,y;
}A[maxn*2];
bool cmp(node a,node b)
{
    if(a.y==b.y)
        return a.x<b.x;
    return a.y<b.y;
}
int main()
{
    while(~scanf("%d",&N))
    {
        for(int i=0;i<N;i++)
            scanf("%d%d",&A[i].x,&A[i].y);
        sort(A,A+N,cmp);
        int S=0;
        bool flag=true;
        for(int i=0;i<N;i++)
        {
            S+=A[i].x;
            if(S>A[i].y)
            {
                flag=false;
                break;
            }
        }
        if(flag)
            puts("Yes");
        else
            puts("No");
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include <cstdio>
using namespace std;
stack <int> st;
int solve(string);
int main(){
  string str;
  while(cin>>str){
    if(str=="+"||str=="-"||str=="*"||str=="/")
      st.push(solve(str));
    else st.push(atoi(str.c_str()));
    if(getchar()=='\n'){
      cout << st.top() << endl;
      return 0;
    }
  }
}
int solve(string str){
  int b = st.top(); st.pop();
  int a = st.top(); st.pop();
  if(str=="+")return a+b;
  else if(str=="-")return a-b;
  else if(str=="*")return a*b;
  else if(str=="/")return a/b;
}



Measured memory_bytes: 3220
N,M = [ int(it) for it in input().split() ]
li = [ int(it) for it in input().split() ]

if (M==1):
  print(0)
else:
  li.sort()
  di = [ li[i+1] - li[i] for i in range( len(li) - 1 ) ]
  di.sort()

  if (M-N>=1):
    print (sum(di[:M-N]))
  else:
    print ( 0 )


Measured memory_bytes: 56744
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;

int gcd(int x,int y){
    return y?gcd(y,x%y):x;
}

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9')f|=c=='-',c=getchar();
    while(c>='0'&&c<='9')x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

int main(){
    int N=read(),Ans=0;
    for(int i=1;i<=N;i++){
        int cnt=0,t=i;
        while(t){
            cnt++;
        t/=10;
        }
        Ans+=cnt%2==1;
    }
    printf("%d",Ans);
}


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


int main() {
  int a, b;
  int ans = 0;
  cin >> a >> b;
  for(int i = a; i <= b;i++){
    int s = i%10, t = i/10000;
    int u = i/1000%10, z = i/10%10;
    if(s==t&&u==z)ans++;
  }
  cout << ans << endl;
}


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

int main(){
	int n,m, total=0;
	cin >>n >> m;
	vector<long> x(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i];
      	total += x[i];
	}
  	sort(x.begin(), x.end());
  	
	cout << ((total <= 4*m* x[n-m]) ? "Yes" : "No") << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    RSORT(a);
    ll cnt = 0,k = 0;
    rep(i,n) k += a[i];
    if (k > n*(n-1)) k -= n*(n-1);
    else k = 0;
    cnt += k;
    if (k > 0){
        rep(i,n) a[i] += k;
    }
    rep(i,n){
        if (k > 0 && a[i] > n-1){
            ll c = (a[i]-(n-1))/(n+1);
            if ((a[i]-(n-1))%(n+1)) c++;
            a[i] -= min(c,k)*(n+1);
            k -= min(c,k);
        }
    }
    while(*max_element(all(a)) >= n){
        RSORT(a);
        a[0] -= n;
        rep(i,1,n) a[i]++;
        cnt++;
    }
    PRINT(cnt);
}




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

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


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

int	main() {
	int N;
	long L;
	cin >>N >>L;
	long a0;
	cin >>a0;
	long i0=0;
	for (int i=1; i<N; i++) {
		long a1;
		cin >>a1;
		if (L<=a0+a1) 
			i0=i;
		a0=a1;
	}
	if (0==i0) {
		cout <<"Impossible" <<endl;
		return 0;
	}
	cout <<"Possible" <<endl;
	for (int i=1; i<i0; i++)
		cout <<i <<endl;
	for (int i=N-1; i>=i0; i--)
		cout <<i <<endl;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
        cout<<"YES";
    }
    else cout<<"NO";
   
    return 0;
}




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

int main(void){
    double ans=0.0;
    int n; cin >> n;

    for(int i=0; i<n; i++){
        double x; string u;
        cin >> x >> u;
        if(u[0]=='J') ans+=(double)x;
        else ans+=380000.0*x;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int H, W; cin >> H >> W;
    vector<vector<int>> as(H, vector<int>(W));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            cin >> as[i][j];
        }
    }
    // 一筆書きの経路を作り，経路上の奇数を次の奇数まで順次移動させていく
    struct Pos
    {
        int R; int C;
    };
    vector<Pos> line;
    for (int r = 1; r <= H; ++r)
    {
        if (r % 2 == 1)
        {
            for (int c = 1; c <= W; ++c) line.push_back({ r, c });
        }
        else
        {
            for (int c = W; c >= 1; --c) line.push_back({ r, c });
        }
    }
    vector<pair<Pos, Pos>> ans;
    vector<pair<Pos, Pos>> tmp;
    bool movingOdd = false;
    for (int i = 0; i < H * W - 1; ++i)
    {
        const auto pos = line[i];
        // 奇数を見つけたとき
        if (as[pos.R - 1][pos.C - 1] % 2 == 1)
        {
            // 既に奇数を移動中ならば，ここで移動を終了
            // これまで記録してきた移動経路を答えに追加
            if (movingOdd)
            {
                movingOdd = false;
                ans.insert(ans.end(), tmp.begin(), tmp.end());
                tmp.clear();
            }
            // 奇数を移動中でないならば，この奇数を移動開始する
            // 次の点への移動経路を記録
            else
            {
                movingOdd = true;
                tmp.push_back({ pos, line[i + 1] });
            }
        }
        // 奇数でないとき
        // 奇数を移動中ならば，次の点への移動経路を記録
        else
        {
            if (movingOdd)
            {
                tmp.push_back({ pos, line[i + 1] });
            }
        }
    }
    // 最後の点が奇数のとき
    // 奇数を移動させていたならば，これまでの移動記録を答えに追加
    if (as[line.back().R - 1][line.back().C - 1] % 2 == 1)
    {
        if (movingOdd)
        {
            ans.insert(ans.end(), tmp.begin(), tmp.end());
        }
    }
    cout << ans.size() << endl;
    for (const auto &move : ans)
    {
        cout << move.first.R << ' ' << move.first.C << ' '
            << move.second.R << ' ' << move.second.C << endl;
    }
}


Measured memory_bytes: 10400
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<ll> a(n);
    ll s{},t{};
    for(auto&i:a) in>>i,s+=i;
    fr(i,n){
        t+=a[i];
        if(2*t>=s){
            cout<<min(2*t-s,s-2*(t-a[i]))<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N; 
    int  D;   
    if(N%2!=0)
    {
        D=(N/2)+1;
        cout<<D;
    }
    else
    {
        D=N/2;
        cout<<D;
    }
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,y;
  cin >> n >> y;
  REP(a,n+1){
    REP(b,n+1-a){
      if(a*10000+b*5000+(n-a-b)*1000==y){
        printf("%d %d %d\n",a,b,n-a-b);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256