akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

int answerNum(vector<pair<int, bool> > plus, vector<pair<int, bool> > minus, int total, vector<bool>& used)
{
    if(plus.size() == 0 && minus.size() == 0){
        if(total == 0)
            return 1;
        else
            return 0;
    }

    int tmp = total;
    int a = -1;
    for(unsigned i=0; i<plus.size(); ++i){
        while(used[++a]);
        tmp += plus[i].first * a;
    }
    a = 10;
    for(unsigned i=0; i<minus.size(); ++i){
        while(used[--a]);
        tmp += minus[i].first * a;
    }
    if(tmp > 0)
        return 0;

    tmp = total;
    a = 10;
    for(unsigned i=0; i<plus.size(); ++i){
        while(used[--a]);
        tmp += plus[i].first * a;
    }
    a = -1;
    for(unsigned i=0; i<minus.size(); ++i){
        while(used[++a]);
        tmp += minus[i].first * a;
    }
    if(tmp < 0)
        return 0;

    bool isNonZero;
    if(minus.size() == 0 || (plus.size() > 0 && plus[0].first > -minus[0].first)){
        a = plus[0].first;
        isNonZero = plus[0].second;
        plus.erase(plus.begin());
    }else{
        a = minus[0].first;
        isNonZero = minus[0].second;
        minus.erase(minus.begin());
    }

    int answer = 0;
    for(int i=(isNonZero?1:0); i<10; ++i){
        if(!used[i]){
            used[i] = true;
            answer += answerNum(plus, minus, total+a*i, used);
            used[i] = false;
        }
    }
    return answer;
}

void solve(vector<string>& mask)
{
    vector<int> num(26, 0);
    vector<bool> isUsed(26, false);
    vector<bool> isNonZero(26, false);
    for(unsigned i=0; i<mask.size(); ++i){
        int tmp = 1;
        for(int j=mask[i].size()-1; j>=0; --j){
            if(i < mask.size()-1)
                num[mask[i][j]-'A'] += tmp;
            else
                num[mask[i][j]-'A'] -= tmp;
            tmp *= 10;
            isUsed[mask[i][j]-'A'] = true;
        }
        if(mask[i].size() > 1)
            isNonZero[mask[i][0]-'A'] = true;
    }

    vector<pair<int, bool> > plus;
    vector<pair<int, bool> > minus;
    for(int i=0; i<26; ++i){
        if(isUsed[i]){
            if(num[i] >= 0)
                plus.push_back(make_pair(num[i], isNonZero[i]));
            if(num[i] < 0)
                minus.push_back(make_pair(num[i], isNonZero[i]));
        }
    }
    sort(plus.rbegin(), plus.rend());
    sort(minus.begin(), minus.end());

    vector<bool> used(10, false);
    cout << answerNum(plus, minus, 0, used) << endl;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;

        vector<string> mask(n);
        for(int i=0; i<n; ++i){
            cin >> mask[i];
        }

        solve(mask);
    }

    return 0;
}

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


void solve() {
  int N;
  scanf("%d", &N);

  cout << 3*N*N << "\n";
}

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


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a, b;
    cin >> a >> b;
    int x, y;
    cin >> x >> y;
    string s;
    cin >> s;
    if (s == a) x--;
    else y--;
    cout << x << " " << y << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

var m = map[string]int{
  "SUN": 7,
  "MON": 6,
  "TUE": 5,
  "WED": 4,
  "THU": 3,
  "FRI": 2,
  "SAT": 1,
}

func main() {
  var S string
  fmt.Scan(&S)
  fmt.Println(m[S])
}

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

int main (void){
	ll b;
	while(true){
		cin >> b;
		if(!b) break;
		for(ll n = 100000LL; n > 0LL; --n){
			ll d = b / n - (n - 1LL) / 2LL;
			if(d <= 0LL) continue;
			if(2LL * b == (2LL * d + n - 1LL) * n){
				cout << d << " " << n << endl;
				break;
			}
		}
	}
	return 0;
}


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

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

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) cin >> s.at(i).at(j);
    }
    vector<int> t(D);
    for (int i = 0; i < D; i++) cin >> t.at(i);
    vector<int> dp(26, 0);
    int ans = 0;

    for (int i = 0; i < D; i++) {
        int contest = t.at(i);
        contest--;
        int satisfy = s.at(i).at(contest);
        ans += satisfy;
        dp.at(contest) = i + 1;
        for (int j = 0; j < 26; j++) {
            ans -= c.at(j) * (i + 1 - dp.at(j));
        }
        cout << ans << endl;
    }

    
    return 0;
}

Measured memory_bytes: 3680
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include<climits>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <chrono>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp
{
	bool operator() (pii a, pii b) {
		return (a.l < b.l);
	}
};

int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

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



signed main()
{
	haha
#ifndef ONLINE_JUDGE

	freopen("inp.txt", "r", stdin);

	freopen("out1.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	int n = s.length();
	if (s[n - 1] == 's')
		s += "es";
	else
		s += 's';
	cout << s;




















}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define d7 1000000007
#define fori(n) for( ll i=0 ; i<n; i++)


long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){

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

return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    ll a;
    long double b;
    cin >> a >> b;
    long double ans = a*b;
    cout << (ll)ans << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
 
typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
 
const int maxn = 1e5 + 5;
const ll mod = 998244353;
const double PI = acos(-1.0);
 
int n, m;
int val[maxn];
 
void solve()
{
	int i, j, k;
	sa(n), sa(m);
 
	vector<int>odd;
	vector<int>even;
	for(i=1;i<=m;i++)
	{
		sa(val[i]);
		if (val[i] & 1)
		{
			odd.push_back(val[i]);
		}
		else
		{
			even.push_back(val[i]);
		}
	}
	if (n == 1)
	{
		printf("1\n");
		printf("1\n");
		printf("1\n");
	}
	else
	{
		int od_sz = odd.size();
		int ev_sz = even.size();
 
		if (od_sz > 2)
		{
			puts("Impossible");
		}
		else
		{
			if (od_sz == 0)
			{
				for(i=0;i<ev_sz-1;i++)
				{
					printf("%d ", even[i]);
				}
				printf("%d\n", even[ev_sz - 1]);
 
				printf("%d\n", ev_sz + 1);
				printf("1 ");
				for(i=0;i<ev_sz-1;i++)
				{
					printf("%d ", even[i]);
				}
				printf("%d\n", even[ev_sz - 1] - 1);
			}
			else if (od_sz == 1)
			{
				if (ev_sz == 0)
				{
					printf("%d\n", odd[0]);
					printf("2\n");
 
					printf("%d %d\n", odd[0] - 1, 1);
				}
				else
				{
					printf("%d ", odd[0]);
					for(i=0;i<ev_sz-1;i++)
					{
						printf("%d ", even[i]);
					}
					printf("%d\n", even[ev_sz - 1]);
					printf("%d\n", m);
 
					printf("%d ", odd[0] + 1);
					for(i=0;i<ev_sz-1;i++)
					{
						printf("%d ", even[i]);
					}
					printf("%d\n", even[ev_sz - 1] - 1);
				}
			}
			else if (od_sz == 2)
			{
				if (ev_sz == 0)
				{
					if (odd[0] == 1 && odd[1] == 1)
					{
						printf("1 1\n");
						printf("1\n");
						printf("2\n");
					}
					else
					{
						sort(odd.begin(), odd.end());
						printf("%d %d\n", odd[0], odd[1]);
						printf("2\n");
						printf("%d %d\n", odd[0] + 1, odd[1] - 1);
					}
				}
				else
				{
					printf("%d ", odd[0]);
					for(i=0;i<ev_sz;i++)
					{
						printf("%d ", even[i]);
					}
					printf("%d\n", odd[1]);
 
					vector<int>r;
					r.push_back(odd[0] + 1);
					for(i=0;i<ev_sz;i++)
					{
						r.push_back(even[i]);
					}
					if (odd[1] - 1)
					{
						r.push_back(odd[1] - 1);
					}
					printf("%d\n", r.size());
					int sz = r.size();
					for(i=0;i<sz;i++)
					{
						if (i == sz-1)
						{
							printf("%d\n", r[i]);
						}
						else
						{
							printf("%d ", r[i]);
						}
					}
				}
			}
		}
	}
}
 
int main()
{
	 solve();
	 return 0;
}

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

typedef long long LL;
int main(){
   // freopen("input", "r", stdin);
    LL N,T,ans=0,k,l;
    cin>>N>>T>>l;
    while(N--!=1){
      cin>>k;
      if(k-l<T)ans+=k-l;
      else ans+=T;
      l=k;
    }
    ans+=T;
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
	unsigned long long N , A , B , X, Y;
	cin >> N >> A >> B;
	X=N/(A+B);
	if(N%(A+B)>A)	Y=A;
	else Y=N%(A+B);
	
	cout << X*A+Y <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)
#define rd(n) ll n; cin >> n;
#define rd(n,k) ll n,k; cin >> n >> k;
#define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;

using namespace std;

const int N = 1e6+7;
int hasdiv[N];


void testcase() {
	int  n; cin >> n;
	vector<int> v(n);
	int ma = 0;

	for (int i = 0; i < n; i++) {
		cin >> v[i];
		ma = max(ma,v[i]);
	}

	for (int i = 0; i < n; i++) {
		if (hasdiv[v[i]] == 1) {
			hasdiv[v[i]] = -1;
		}
		if (hasdiv[v[i]] == 0) {
			hasdiv[v[i]] = 1;
			int runner = 2*v[i];
			while (runner <= ma) {
				hasdiv[runner] = -1;
				runner += v[i];
			}
		}

	}

	int count = 0;
	for (int i = 0; i < n; i++) {
		if (hasdiv[v[i]] == 1) {
			count++;
		}
	}

	cout << count;

	
}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 7704
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N;
  cin >> N;

  int a[N-1];

  rep(i,N-1){
    cin>>a[i];
  }

  int ans=0;

  ans+=a[0]+a[N-2];

  rep(i,N-2){
    ans+=min(a[i],a[i+1]);
  }

  cout<< ans<<"\n";

}


//-----------------------------------
int main(){
  cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}
//-----------------------------------


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

int main()
{
  int n;
  int a[200005];
  int flg = 0;

  cin >> n;

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

  sort(a,a+n);

  for(int i=0; i<n-1; i++) if(a[i] == a[i+1]) flg = 1;
  
  if(flg == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;

}


Measured memory_bytes: 1024
#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 long 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
#define PI 3.14159265358979323846L

void DFS(ll source, vector<ll> ed[], ll v, bool visited[], stack<ll> &s)
{
    visited[source] = true;
    rep(i, ed[source].size())
    {
        if(!visited[ed[source][i]])
        {
            DFS(ed[source][i], ed, v, visited, s);
        }
    }
    s.push(source);        // The vertex is added to stack only when its DFS is complete
}


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

    ll n,m;
    cin >> n >> m;

    ll x = n-1+m;

    vector<ll> ed[n+1];
    vector<ll> ed2[n+1];

    rep(i,x)
    {
    	ll a,b;
    	cin >> a >> b;

    	ed[a].pb(b);
    	ed2[b].pb(a);
    }

    stack<ll> s;
    bool visited[n+1] = {false};

    rep(i,n)
    {
        if(!visited[i+1])
        {
            DFS(i+1, ed, n, visited, s);
        }
    }

    ll root = 1;
    fr(i,1,n)
    {
    	if(ed2[i].size()==0)
    	{
    		root = i;
    		break;
    	}
    }

    ll sor[n+1];

    ll xx = 1;
    while(!s.empty())
    {
    	sor[s.top()] = xx;
    	xx++;
    	s.pop();
    }

    ll ans[n+1];
    ans[root] = 0;

    fr(i,1,n)
    {
    	if(i==root)
    		continue;
    	ll maxi = 0;
    	rep(j,ed2[i].size())
    	{
    		if(sor[ed2[i][j]]>maxi)
    		{
    			maxi = sor[ed2[i][j]];
    			ans[i] = ed2[i][j];
    		}
    	}
    }

    fr(i,1,n)
    {
    	cout << ans[i] << endl;
    }
}


Measured memory_bytes: 17820
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII; 
ll dig(ll a,ll b){
	int cnt1=0,cnt2=0;
	while(a!=0){
		a/=10;
		cnt1++;
	}
	while(b!=0){
		b/=10;
		cnt2++;
	}
	return max(cnt1,cnt2);
}
int main() 
{ 
	turbo();
	ll j,i,n,mi=INT_MAX;
	cin>>n;
	for(i=1;i<=sqrt(n);i++){
		if(n%i==0){
			mi=min(mi,dig(i,n/i));
		}
	}
	cout<<mi<<"\n";
	return 0; 
} 

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define maxn 301
using namespace std;

int n,n1,n2,n3;
bool mark[maxn][maxn][maxn];
double dp[maxn][maxn][maxn];

double f( int c1 , int c2 , int c3 ) {
	if( c1+c2+c3 == 0 )
		return 0;
	if( mark[c1][c2][c3] )
		return dp[c1][c2][c3];
	mark[c1][c2][c3] = true;
	if( c1 )
		dp[c1][c2][c3] += f( c1-1 , c2 , c3 ) * (double) c1 / (double) n;
	if( c2 )
		dp[c1][c2][c3] += f( c1+1 , c2-1 , c3 ) * (double) c2 / (double) n;
	if( c3 )
		dp[c1][c2][c3] += f( c1 , c2+1 , c3-1 ) * (double) c3 / (double) n;
	dp[c1][c2][c3] += 1.0;
	dp[c1][c2][c3] = dp[c1][c2][c3] * (double) n / (double) (c1+c2+c3);
	return dp[c1][c2][c3];
}

int main() {
	cin >> n;
	for( int i = 0 , x ; i < n ; i++ ) {
		cin >> x;
		switch(x) {
		case 1:
			n1++;
			break;
		case 2:
			n2++;
			break;
		case 3:
			n3++;
			break;
		}
	}
	printf( "%.10lf\n" , f(n1,n2,n3) );
}


Measured memory_bytes: 239872
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int H=in.nextInt(),r=in.nextInt(),res;
		if(H+r==0)res=0;
		else if(H+r>0)res=1;
		else res=-1;
		System.out.println(res);
	}

}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;

int main()
{
  ll X, Y; scanf("%lld %lld", &X, &Y);
  bool alice = true;
  ll d = abs(X - Y);
  if (d == 1) { alice = false; }
  else if (d == 0) { alice = false; }

  string ans = alice ? "Alice" : "Brown";
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())), np.int32)

ans = 0
while True:
    flg = 0
    for a in A:
        if a % 2 != 0:
            flg = 1
            break
    if flg:
        break
    else:
        A = A/2
        ans += 1
print(ans)

Measured memory_bytes: 12580
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  std::string S;
  std::cin >> S;
  if (S[2]==S[3]&&S[4]==S[5]){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 760
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);

        final int N = nextInt();

        int[] a = new int[N];

        long sum = 0L;

        for (int i = 0; i < N; i++) {
            a[i] = nextInt();
            sum += a[i];
        }

        long min = 200000000000001L;

        long tmp = 0L;

        // 必ず 1枚 は取る
        for (int i = 0; i < N - 1; i++) {
            tmp += a[i];
            // |x - y| = |x - (sum - x)|
            min = Math.min(min, Math.abs(2L * tmp - sum));
        }


        out.println(min);

        out.flush();
    }

    // FastScanner start
    static final InputStream in = System.in;
    static final byte[] buffer = new byte[1024];
    static int ptr = 0;
    static int buflen = 0;
    static boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    static int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    static String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    static long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    static int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    static double nextDouble() {
        return Double.parseDouble(next());
    }
    // FastScanner end
}


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

#define pb push_back
#define S second
#define F first
typedef long long ll;

using namespace std;

const ll maxn = 5e5 + 10;
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll n, p, a[maxn], ans, k;

int main(){

//	freopen("input.txt", "r", stdin);
	
	cin >> n;
	for(int i=0;i < n;i++){
		cin >> a[i];
	}
	p = 2;
	ans = a[0] - 1;
	for(int i=1;i < n;i++){
		ans += a[i] / p;
		if(!(a[i] % p)){
			ans--;
		}
		if(a[i] == p){
			p++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4428
def solve():

    H, W = [int(i) for i in input().split()]
    alist = [input() for i in range(H)]

    cols = [False]*H
    rows = [False]*W

    for i in range(H):
        for j in range(W):
            if alist[i][j] == '#':
                cols[i] = True
                rows[j] = True

    for i in range(H):
        if cols[i]:
            for j in range(W):
                if rows[j]:
                    print(alist[i][j], end="")
            print()


if __name__ == "__main__":
    solve()


Measured memory_bytes: 42712
'use strict';
(function(stdin){

//define function
//declare variable

var inputs =stdin.toString().trim().split('\n');
var S = parseInt(inputs[0]);

//????????????????§?
//1?????? ????????? ???????????????
 //main
var h = Math.floor(S/(60*60));//46979
var m = Math.floor((S%3600)/60);
var s =S % 60;
 //display

//console.log(S,typeof S);
//console.log(S % 60);
console.log([h,m,s].join(':'));
}(require('fs').readFileSync('/dev/stdin','utf8')))

Measured memory_bytes: 15560
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int main(){

	int H,W,N;
	scanf("%d %d %d",&W,&H,&N);

	int top = 0,left = 0,right = W,under = H;

	int x,y,a;

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

		scanf("%d %d %d",&x,&y,&a);

		switch(a){
		case 1:

			left = max(left,x);
			break;

		case 2:

			right = min(right,x);
			break;

		case 3:

			top = max(top,y);
			break;

		case 4:

			under = min(under,y);
			break;
		}
	}

	printf("%d\n",max(0,right-left)*max(0,under-top));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll N;
ll a[200010];
int main(void){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a+N);
    ll sad = 0;
    for(int i=0; i<N; i++){
        sad += abs(a[i] - a[N/2]);
    }
    cout << sad << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N;
    cin >> N;
    N %= 10;
    if(N == 3){
        cout << "bon" << endl;
    }
    else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
long long a, b, k;
int main() {
    cin >> a >> b >> k;
    if(a < k) {
        k -= a;
        a = 0;
        if(b < k) {
            b = 0;
        }else {
            b -= k;
        }
    }else {
        a -= k;
    }
    cout << a << " " << b << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

struct UnionFind{
    std::vector<int> parent, rank, cnt;

    UnionFind(int n) : parent(n), rank(n, 0), cnt(n, 1) {
        std::iota(parent.begin(), parent.end(), 0);
    }

    int find(int v){
        if(v == parent[v]){return v;}
        return parent[v] = find(parent[v]);
    }

    bool same(int v, int w){
        return find(v) == find(w);
    }

    void unite(int v, int w){
        v = find(v);
        w = find(w);

        if(v == w){return;}

        if(rank[v] > rank[w]){
            parent[w] = v;
            cnt[v] += cnt[w];
        }else{
            parent[v] = w;
            cnt[w] += cnt[v];
            if(rank[v] == rank[w]){rank[w] += 1;}
        }
    }

    int count(int v){
        return cnt[find(v)];
    }
};

int N;
int xs[100], ys[100];

int solve(){
    if(N == 1){
        return 1;
    }

    int mn = 10000;

    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            int p = xs[j] - xs[i], q = ys[j] - ys[i];

            UnionFind uf(100);

            for(int k=0;k<N;++k){
                for(int l=0;l<N;++l){
                    if(k == l){
                        continue;
                    }

                    int dx = xs[l] - xs[k],
                        dy = ys[l] - ys[k];

                    if(dx == p && dy == q){
                        uf.unite(k, l);
                    }
                }
            }

            int cost = 0;

            for(int k=0;k<N;++k){
                if(k == uf.find(k)){
                    cost += 1;
                }
            }

            mn = std::min(mn, cost);
        }
    }

    return mn;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> xs[i] >> ys[i];
    }

    int res = solve();
    std::cout << res << std::endl;
}


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

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	
	
	int Max = max(max(A, B), max(C, D));
	int Min = min(min(A, B), min(C, D));
	
	if(Max != 9){
		cout << "NO" << endl;
		return 0;
	}
	if(Min != 1){
		cout << "NO" << endl;
		return 0;
	}

	if(A+B+C+D-(Max+Min)!=11){
		cout << "NO" << endl;
		return 0;
	}
	
	if(A!=4 && B!=4 && C!=4 && D!=4){
		cout << "NO" << endl;
		return 0;
	}

	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b, k;
    cin >> a >> b >> k;

    int c=0;
    int i = min(a,b);
    for( ; i >0 ; i--)
    {
        if (a%i==0 && b%i==0) c++;
        if (c==k) break;
    }
    
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);


int main(int argc, char* argv[])
{
  int h, w;
  cin >> h >> w;
  rep(i, w+2) {
    cout << "#";
  }
  cout << endl;
  rep(i, h) {
    cout << "#";
    string a;
    cin >> a;
    cout << a;
    cout << "#" << endl;
  }
  rep(i, w+2) {
    cout << "#";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
vector <int> node[100010];
ll n,f[100010][2],b[100010];
void dfs(int k,int fa)
{
	f[k][0]=f[k][1]=1;
	for(int i=0;i<node[k].size();i++)
	{
		if(!b[node[k][i]])
		{
			b[node[k][i]]=1;
			dfs(node[k][i],k);
			f[k][0]=(f[k][0]*(f[node[k][i]][0]+f[node[k][i]][1]))%mod;
			f[k][1]=(f[k][1]*f[node[k][i]][0])%mod;
		}
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		node[x].push_back(y);
		node[y].push_back(x);
	}
	b[1]=1;
	dfs(1,1);
	cout<<(f[1][1]+f[1][0])%mod<<endl;
	return 0;
}


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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int p[n];
  for (int i=0; i<n; i++) cin>>p[i];
  sort(p, p + n);
  p[n-1] = p[n-1] / 2;
  int sum = 0;
  for (int i=0; i<n; i++) sum += p[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 256
//thang 1 phai thang min 2^(n-1) block
#include <bits/stdc++.h>
#define ll long long
 
using namespace std;
 
const int maxm = 18;
const int maxn = (1<<16) + 100;
const int base = (int)1e9+7;
 
int a[maxn],fact[maxn],finv[maxn],f[maxm][maxn],res,n,m;
 
int sum(int a,int b) {
    return (a+b)%base;
}
 
int sub(int a, int b) {
    return (a-b+base)%base;
}
 
int mul(int a,int b) {
    return (a*1ll*b)%base;
}
 
int power(int a,int b) {
    int res=1;
    while (b>0) {
        if (b&1) {
            res = mul(res,a);
        }
        a = mul(a,a);
        b>>=1;
    }
    return res;
}
 
int inv(int a) {
    return power(a,base-2);
}
 
int C(int k,int n) {
    if (n<k) return 0;
    return mul(fact[n],mul(finv[k],finv[n-k]));
}
 
int main() {
  //  freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    fact[0] = 1; fact[1] = 1;
    finv[0] = 1; finv[1] = 1;
    for (int i=2;i<=maxn;i++) {
        fact[i] = mul(fact[i-1],i);
        finv[i] = inv(fact[i]);
        //cout<<fact[i]<<endl;
    }
    cin>>n>>m;
    vector<int> a;
    for (int i=1;i<=m;i++) {
        int x;
        cin>>x;
        a.push_back(x);
    }
   // cout<<n<<" "<<m<<" "<<(1<<n)<<endl;
    reverse(a.begin(),a.end());
    f[0][0]= 1;
    for (int i=0;i<m;i++)
        for (int tt=0;tt<(1<<n);tt++) {
            if (f[i][tt] < 1) continue;
            f[i+1][tt] = sum(f[i+1][tt],f[i][tt]);
            for (int j=0;j<n;j++)
                if ((tt & (1<<j)) == 0) {
                   // cout<<C((1<<j) - 1,(1<<n) - tt - a[i])<<" "<<fact[1<<j]<<endl;
                    f[i+1][tt + (1<<j)] = sum(f[i+1][tt + (1<<j)],mul(f[i][tt],mul(C((1<<j) - 1,(1<<n) - tt - a[i]),fact[1<<j])));
                }
           // cout<<i<<" "<<tt<<" "<<f[i+1][tt]<<endl;
        }
    res=0;
    for (int tt=0;tt<(1<<n);tt++) {
       // cout<<f[m][tt]<<endl;
        if (__builtin_popcount(tt) % 2 == 0 ) res = sum(res,mul(f[m][tt],fact[(1<<n) - tt - 1]));
        else res = sub(res,mul(f[m][tt],fact[(1<<n) - tt - 1]));
    }
    res = mul(res,(1<<n));
    cout<<res;
}

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

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)

int main(void){
    
    int n,k;
    cin >> n  >> k;
    
    vector<int> l(n);
    int i;
    
    FOR(i,n){
        cin >> l[i];
        //cout << l[i] << " ";
    }
    
    sort( l.begin(), l.end(), greater<int>() );
    
    
    int ans=0;
    FOR(i,k){
        ans+=l[i];
        //cout << ans << " ";
    }
    
    cout << ans;
    
    return 0;
    
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)

#define BR "\n"
#define SP " "

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

  vector<ll> A(N);
  vector<ll> R(N);
  rep0(i, N) cin >> A[i];

  int Q;
  cin >> Q;

  rep0(i, Q) {
    int b, e; cin >> b >> e;
    R = A;
    rep(j, 0, e - b) {
      R[b + j] = A[e - 1 - j];
    }
    A = R;
  }

  rep0(i, N - 1) {
    cout << A[i] << SP;
  }
  cout << A[N - 1] << BR;
  return 0;
}


Measured memory_bytes: 3140
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[305][305];

bool del[305];

int cnt[305];

int ptr[305];

int n, m;

bool check(int lim) {
	for (int i = 1; i <= m; ++i) {
		cnt[i] = 0;
		del[i] = 0;
	} 	

	for (int i = 1; i <= n; ++i) {
		ptr[i] = 1;
		++cnt[arr[i][ptr[i]]];
	}

	while (1) {
		int mx = max_element(cnt + 1, cnt + m + 1) - cnt;        

		if (cnt[mx] > lim) {
			del[mx] = 1;
			cnt[mx] = 0;

			for (int i = 1; i <= n; ++i) {
				if (arr[i][ptr[i]] != mx) {
					continue;
				}

				while (ptr[i] <= m && del[arr[i][ptr[i]]]) {
					++ptr[i];
				}

				if (ptr[i] > m) {
					return 0;
				}

				++cnt[arr[i][ptr[i]]];
			}
		}
		else {
			break;
		}		
	}

	return 1;
}

void solve() {                   
	scanf("%d %d", &n, &m);

    for (int i = 1; i <= n; ++i) {
    	for (int j = 1; j <= m; ++j) {
    		scanf("%d", &arr[i][j]);
    	}
    }

    int l = 1, r = n, ans = -1;

    while (l <= r) {
    	int mid = (l + r) >> 1;

    	if (check(mid)) {
    		r = mid - 1;
    		ans = mid;
    	}
    	else {
    		l = mid + 1;
    	}
    }

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

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int w[100010];
int deg[100010];

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,n)scanf("%d",w+i);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		deg[x]++;
		deg[y]++;
	}
	g.vcnt=n;
	g.ecnt=2*m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

int oya[100010];
//dfs
void dfs(int v,int pre){
	oya[v]=pre+1;
	rep(i,g.id[v],g.id[v+1]){
		if(!oya[g.e[i].g]){
			dfs(g.e[i].g,v);
		}
	}
}


int d[100010];

int q[100010],qcnt;
int main(){
	readgraph();
	dfs(0,-1);
	rep(i,0,g.vcnt)if(deg[i]==1)q[qcnt++]=i;
	rep(ii,0,qcnt){
		int i=q[ii];
		if(i==0)continue;
		int v=oya[i]-1;
		d[v]=max(d[v],w[i]+d[i]);
		deg[i]--;
		deg[v]--;
		if(deg[v]==1)q[qcnt++]=v;
	}
	int ans=w[0];
	rep(i,1,g.vcnt)if(deg[i])ans+=w[i];
	int ddd=0;
	rep(i,0,g.vcnt)ddd=max(ddd,d[i]);
	printf("%d\n",ans+ddd);
}


Measured memory_bytes: 11892
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def inverse(self, k):
        """kの逆元を求める O(1)"""
        return (self.inv_fact[k] * self.fact[k - 1]) % self.MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r)
        kが大きいが、r <= nを満たしているときに使用
        """
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD


n, m = map(int, input().split())
MOD = 10 ** 9 + 7
comb = Combination(10 ** 6, MOD)


dp = [0] * (n + 1)
sum_ = 0
for match_cnt in range(n + 1):
    tmp = comb.combination(n, match_cnt)
    tmp *= comb.permutation(m, match_cnt)
    tmp *= comb.permutation(m - match_cnt, n - match_cnt)
    tmp *= comb.permutation(m - match_cnt, n - match_cnt)
    dp[match_cnt] = tmp
    dp[match_cnt] %= MOD
ans = 0
for i in range(n + 1):
    ans += dp[i] * (-1) ** i
    ans %= MOD
print(ans)

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

void fnInput(int& rnAchieve, vector<int>& rvnPrice, vector<vector<int>>& rvvnSkill)
{
  int nPriceSiz, nSkillSiz;
  cin >> nPriceSiz >> nSkillSiz >> rnAchieve;
  rvnPrice.resize(nPriceSiz);
  rvvnSkill.resize(nPriceSiz, vector<int>(nSkillSiz));

  for (int i = 0; i < rvvnSkill.size(); i++)
  {
    cin >> rvnPrice[i];

    for (int j = 0; j < rvvnSkill[i].size(); j++)
      cin >> rvvnSkill[i][j];
  }
}

int fnMinPriceSkillup(int nAchieve, const vector<int> cnrvnPrice, 
                      const vector<vector<int>>& cnrvvnSkill)
{
  int nMinPrice = INT_MAX;

  for (int nCtl = 0; nCtl < (1 << cnrvnPrice.size()); nCtl++)
  {
    int nPrice = 0;
    vector<int> vnSumSkill(cnrvvnSkill[0].size());

    for (int ny = 0; ny < cnrvnPrice.size(); ny++)
      if (nCtl & (1 << ny))
      {
        for (int nx = 0; nx < cnrvvnSkill[ny].size(); nx++)
          vnSumSkill[nx] += cnrvvnSkill[ny][nx];

        nPrice += cnrvnPrice[ny];
      }
    bool bRslt = true;

    for (int nSumSkill : vnSumSkill)
      if (nSumSkill < nAchieve)
      {
        bRslt = false;
        break;
      }
      if (bRslt)
        nMinPrice = min(nMinPrice, nPrice);
  }
  if (nMinPrice == INT_MAX)
    return -1;
  else
    return nMinPrice;
}
  
int main()
{
  int nAchieve;
  vector<int> vnPrice;
  vector<vector<int>> vvnSkill;

  fnInput(nAchieve, vnPrice, vvnSkill);
  cout << fnMinPriceSkillup(nAchieve, vnPrice, vvnSkill) << endl;

  return 0;
}

Measured memory_bytes: 3616
# Coins
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#define int long long

using namespace std;

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int res = 1;
	for (int i = 1; i * i <= (n - 1); i++) {
		int m = n - 1;
		if (m % i == 0) {
			if (i != 1) res++;
			if (i * i != m) res++;
		}
	}
	for (int i = 2; i * i <= n; i++) {
		int m = n;
		while (m % i == 0) m /= i;
		if (m != n && m % i == 1) res++;
	}
	 
	cout << res << '\n';
	
	return 0;
}

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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<pair<int, int>>v;

int main() {
	int n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << "-1" << endl;
		return 0;
	}
	int tmp = n;
	if (k == 0) {
		tmp = 2;
	}
	else {
		while (k < (tmp - 2) * (tmp - 3) / 2 + 1) {
			tmp--;
		}
	}
	int ans = 0;
	rep(i, 0, n - tmp) {
		rep(j, i + 1, n) {
			v.push_back(mp(i + 1, j + 1));
			ans++;
		}
	}
	rep(i, n - tmp, n - 1) {
		v.push_back(mp(i + 1, n));
		ans++;
	}
	rep(i, 0, (tmp - 1)* (tmp - 2) / 2 - k) {
		v.push_back(mp(n - tmp + 1 + i, n - tmp + 2 + i));
		ans++;
	}
	cout << ans << endl;
	rep(i, 0, ans) {
		cout << v[i].first << " " << v[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll X, A;
	cin >> X >> A;
	if(X < A) {
		cout << 0 << endl;
		return 0;
	}
	cout << 10 << endl;

}


Measured memory_bytes: 3652
using System;
using System.Linq;

class abc123_A
{
    static void Main(string[] args)
    {
        var firstPoint = readInt();
        var restPoints = Enumerable.Range(0, 4).Select(x => readInt()).ToArray();
        var k = readInt();

        if(restPoints.Any(rp => rp - firstPoint > k)) {
            Console.WriteLine(":(");
        } else {
            Console.WriteLine("Yay!");
        }
    }

    static int readInt() {
        return int.Parse(Console.ReadLine());
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#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 LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N,K;
  cin>>N>>K;
  ll h[N];
  FOR(i,0,N-1){
  cin>>h[i];}

  sort(h,h+N);
  ll ans =99999999999;
  FOR(i,0,N-K){
    ll tmp;
    tmp=h[i+K-1]-h[i];
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;


  return 0;
}
 


Measured memory_bytes: 1024
# include <cstdio>
# include <cmath>
# include <algorithm>

using namespace std;

const double EPS = 1e-10;
const double g = 9.8;
const int MAX_N = 50;

int N, V, X, Y;
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

inline double calc(double vy , double t)
{
	return vy * t - g * t * t / 2;
}

inline int cmp(double lb , double ub , double a)
{
	return a < lb + EPS  ? -1 : a > ub - EPS ? 1 : 0;
}

bool check(double qx , double qy)
{
	double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
	double D = b * b - 4 * a * c;
	
	if(D < 0 && D > -EPS)
		D = 0;
	
	if(D < 0)
		return 0;
	
	int d, i;
	for(d = -1 ; d <= 1 ; d += 2)
	{
		double t2 = (-b + d * sqrt(D)) / (2 * a);
		
		if(t2 <= 0)
			continue;
			
		double t = sqrt(t2);
		double vx = qx / t, vy = (qy + g * t * t / 2) / t;
		
		double yt = calc(vy , X / vx);
		if(yt < Y - EPS)
			continue;
			
		bool ok = 1;
		for(i = 0 ; i < N ; i++)
		{
			if(L[i] >= X)
				continue;
				
			if(R[i] == X && Y <= T[i] && B[i] <= yt)
				ok = 0;
				
			int yL = cmp(B[i] , T[i] , calc(vy , L[i] / vx));
			int yR = cmp(B[i] , T[i] , calc(vy , R[i] / vx));
			int xH = cmp(L[i] , R[i] , vx * (vy / g));
			int yH = cmp(B[i] , T[i] , calc(vy , vy / g));
			
			if(xH == 0 && yH >= 0 && yL < 0 && yL < 0)
				ok = 0;
				
			if(yL * yR <= 0)
				ok = 0;
		}
		if(ok)
			return 1;
	}
	return 0;
}

void solve()
{
	int i;
	for(i = 0 ; i < N ; i++)
	{
		R[i] = min(R[i] , X);
	}
	
	bool ok = check(X , Y);
	
	for(i = 0 ; i < N ; i++)
	{
		ok |= check(L[i] , T[i]);
		ok |= check(R[i] , T[i]);
	}
	
	puts(ok ? "Yes" : "No");
}

int main()
{
	while(~scanf("%d %d %d %d", &N, &V, &X, &Y))
	{
		int i;
		for(i = 0 ; i < N ; i++)\
			scanf("%d %d %d %d", &L[i], &B[i], &R[i], &T[i]); 
		
		solve();
	}
	
	return 0;
} 


Measured memory_bytes: 2672
N = int(input())

def digit_sum(x):
  num = x
  total = 0
  while num > 0:
    total += num%10
    num //= 10
  return(total)

total_list = []
for i in range(1, N):
  A, B = i, N - i
  total_list.append(sum([digit_sum(i) for i in [A, B]]))
print(min(total_list))

Measured memory_bytes: 3864
H,W,N = map(int, input().split())
st = [int(i) for i in input().split()]
S = input()
T = input()


def simu(dim1):
    now = [st[0],st[1]]

    if dim1 == 'U':
        dim2,L,step,dim = 'D',H,1,0
    if dim1 == 'D':
        dim2,L,step,dim = 'U',H,-1,0
    if dim1 == 'L':
        dim2,L,step,dim = 'R',W,1,1
    if dim1 == 'R':
        dim2,L,step,dim = 'L',W,-1,1

    for i in range(N):
        if S[i] == dim1:
            now[dim] -= step
        if now[dim] < 1 or now[dim] >= L+1:
            return True
        if T[i] == dim2:
            if step == 1:
                if now[dim] < L:
                    now[dim] += step
            else:
                if now[dim] > 1:
                    now[dim] += step
    return False
        
Dim = ['D','U','R','L']
for d in Dim:
    if simu(d):
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 42192