akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	double diff = 1000000000;
	int n;
	double t,a;
	cin>>n;
	cin>>t>>a;
	int ans = 0;
	for(int i = 0; i < n; i++){
		double x;
		cin>>x;
		if( diff > abs(a- (t- x * 0.006))){
			diff = abs(a - (t - x * 0.006));
			ans = i + 1;
		}

	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		String T = stdIn.next();
		if(S.equals(T.substring(0,S.length()))){
			if(S.length() == T.length() - 1){
				System.out.println("Yes");
			}
		}
		else{
			System.out.println("No");
		}
		stdIn.close();
	}
}

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

int main(){
  int W,a,b;
  cin >> W >> a >> b;
  if(a+W < b){cout << b-(a+W) << endl;}
  else if(b+W < a){cout << a-(b+W) << endl;}
  else{cout << 0 << endl;}
  return 0;
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    //最大のものを求める
    int mx = 0;
    rep(i, n) mx = max(mx, a[i]);

    //comb(a, b)のbを、小さいものに調整しなおしてある配列
    vector<int> b(n);
    b = a;
    rep(i, n) b[i] = min(b[i], mx - b[i]);

    //comb(a, b)のbの最大値を求める
    int val = 0;
    rep(i, n) val = max(val, b[i]);
    //最大値のインデックスを調べる
    int index = 0;
    rep(i, n) if(b[i] == val) index = i;

    //出力
    cout << mx << " " << a[index] << endl;
    return 0;
}

Measured memory_bytes: 4060
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define br printf("\n")
#define pi acos(-1)

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n, m;
    cin >> n >> m;
    ll sum = 0;
    for (int i = 0; i < m; ++i) {
        int val;
        cin >> val;
        n -= val;
    }
	if (n < 0) {
        cout << -1 << endl;
    } else {
        cout << n << endl;
    }
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long int ll;

void solve()
{
	ll n, d;
	cin >> n >> d;
	ll count = 0;
	while (n--)
	{
		ll x, y;
		cin >> x >> y;
		if (((x * x) + (y * y)) <= (d * d))
			count++;

	}
	cout << count;
}



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

#ifndef ONLINE_JUDGE
	freopen("1input.txt", "r", stdin);
	freopen("1output.txt", "w", stdout);
#endif

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 3624
from collections import deque
n = int(input())

que = deque(['7','5','3'])
semi = []

while que:
    x = que.popleft()
    if int(x) <= n:
        semi.append(x)
        for new_x in [x+c for c in ['7','5','3']]:
            que.append(new_x)

cnt = 0
for i in semi:
    if all(i.count(c)>0 for c in ['7','5','3']):
        cnt += 1
print(cnt)

Measured memory_bytes: 15648
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	long long k;
	cin >> k;
	int n = 50;
	cout << n << endl;
	long long num = k / 50;
	long long num2 = k % 50;
	for (int i = 0; i < 50; i++) {
		if (i < num2) {
			cout << num + 50;
		}
		else cout << num + 49 - num2;
		if (i != 50 - 1)cout << " ";
		else cout << endl;
	}
	//system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int CUM[33333][10]; // 数字の累積出現数.
int dp[10][10][10]; // 暗証番号設定.

int main(){

    // 1. 入力情報.
    int N;
    char c[33333];
    scanf("%d %s", &N, c);
    
    // 2. 数字をカウント.
    rep(i, N){
        rep(j, 10) CUM[i + 1][j] = CUM[i][j];
        CUM[i + 1][c[i] - '0']++;
    }
    // rep(i, 5){
    //     rep(j, 10) printf("%d ", CUM[i][j]);
    //     printf("\n");
    // }
    
    // 3. 暗証番号の種類は？
    // 左(l), 中央(m), 右(r) で 確認.
    // m を 決めて, 
    // l は, CUM[m][l] が 0 より大きい場合に, l を 設定可能 と見る.
    // r は, CUM[N][r] - CUM[m + 1][r] が 0 より大きい場合に, r を 設定可能 と見る.
    // 
    // 中央(c[m] は '0' ～ '9' の いずれか).
    repx(m, 1, N - 1){
        // 左(0 ～ 9).
        rep(l, 10){
            // 右(0 ～ 9).
            rep(r, 10){
                if(CUM[m][l] > 0 && CUM[N][r] - CUM[m + 1][r] > 0) dp[l][c[m] - '0'][r]++;
            }
        }
    }
    
    // 4. 出力.
    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) if(dp[i][j][k] > 0) ans++;
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void) {
  int N;
  scanf("%d\n",&N);
  char s[N];
  int i; /* index */

  for (i = 0;i < N; ++i) {
    scanf("%c",&s[i]);
    /* printf("%c\n",s[i]);*/
  }

  /* printf("%c\n",s[0]);*/
  int countR = 0;
  int countB = 0;
  for (i = 0; i < N; ++i) {
    if (s[i] == 'R') {
      ++countR;
    } else if (s[i] == 'B') {
      ++countB;
    } else {
      break;
    }
    /* printf("%d countR = %d countB = %d\n",i,countR,countB);*/
  }

  if (countR > countB) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> H(N);
	rep(i, N) cin >> H.at(i);
	sort(H.begin(), H.end());
	int64_t ans = 0;
	rep(i, N - K) ans += H.at(i);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;
int shus(int x)
{
    for(int i=2; i<=sqrt(x); i++)
    {
        if(x%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    cin>>n;
    for(int i=11; n; i+=10)
    {
        if(shus(i))
        {
            if(n==1)
            {
                cout<<i;
                n--;
            }
            else
            {
                cout<<i<<" ";
                n--;
            }
        }
    }
    return 0;
}


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

int main(){
	int n; cin>>n;
	ll sum=0;
	vector<int> v(n+2);
	vector<int> d(n+1);
	for(int i=1; i<n+2; i++){
		cin>>v[i];
		d[i-1]=abs(v[i-1]-v[i]);
		sum+=d[i-1];
	}
	for(int i=1; i<n+1; i++){
		cout<<sum-(d[i-1]+d[i])+abs(v[i-1]-v[i+1])<<endl;
	}
}

Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

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

 int n = 0;
 cin >> n;

 set<string> dic;

 for(int i = 0; i < n; i++){
  string buf1, buf2;
  cin >> buf1 >> buf2;
  if(buf1 == "insert"){
    dic.insert(buf2);
  }else{
   if(dic.find(buf2) != dic.end()){
    cout << "yes" << '\n';
   }else{
    cout << "no" << '\n';
   }
  }
 }
 return 0;
}

Measured memory_bytes: 27056
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=(1<<30)-1;
const int MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll n;
bool flag = true;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    ll px = 0LL, py = 0LL, pt = 0LL;
    rep(i, 0, n) {
        ll t, x, y;
        cin >> t >> x >> y;
        if (px == x && py == y) {
            flag = false;
            break;
        } else if (abs(x-px) + abs(y-py) <= t-pt && (t-pt)%2 == (abs(x-px) + abs(y-py))%2) 
            flag = true;
        else {
            flag = false;
            break;
        }
        px = x, py = y, pt = t;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

ll a[maxn], b[maxn], c[maxn], f[maxn][5];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    int n;

    cin >> n;

    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

    f[1][1] = a[1];
    f[1][2] = b[1];
    f[1][3] = c[1];

    for(int i = 2; i <= n; i++){
        f[i][1] = max(f[i - 1][2], f[i - 1][3]) + a[i];
        f[i][2] = max(f[i - 1][1], f[i - 1][3]) + b[i];
        f[i][3] = max(f[i - 1][1], f[i - 1][2]) + c[i];
    }

    cout << max(f[n][1], max(f[n][2], f[n][3])) << endl;

    return 0;
}

Measured memory_bytes: 9860
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;

int main() {
	while (true) {
		int n;	cin >> n;
		if (n == 0)	break;
		vint a(n, 0);
		rep(i, n)	cin >> a[i];
		vector<ll> sum(n + 1, 0);
		rep(i, n)	sum[i + 1] = sum[i] + a[i];
		ll ret = -1e18;
		REP(i, n)	rep(j, i)	ret = max(ret, sum[i] - sum[j]);
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
#include<iostream>
using namespace std;
long long a,b,n,x[100050],tot;
int main()
{
	cin>>n>>a>>b>>x[1];
	for(int i=2;i<=n;++i)
	{
		cin>>x[i];
		tot+=min(b,a*(x[i]-x[i-1]));
	}
	cout<<tot;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 20000005
#define ll long long
#define mod 998244353
int n, m, ans;
int fac[N], inv[N], mul1[N], mul2[N];
int ksm(int a, int k)
{
	if (!k)
		return 1;
	int p = ksm(a, k / 2);
	if (k & 1)
		return (ll)p * p % mod * a % mod;
	return (ll)p * p % mod;
}
int C(int n, int m){return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;}
int main()
{
	fac[0] = 1;
	for (int i = 1; i <= N - 5; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[N - 5] = ksm(fac[N - 5], mod - 2);
	for (int i = N - 5; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	scanf("%d%d", &n, &m);
	mul1[0] = 1;
	for (int i = 1; i <= m; i++)
		mul1[i] = (ll)mul1[i - 1] * (n + 1) % mod;
	mul2[0] = 1;
	for (int i = 1; i <= n; i++)
		mul2[i] = (ll)mul2[i - 1] * (m + 1) % mod;
	for (int i = 0; i <= min(n, m); i++)
	{
		if (i & 1)
			ans = (ans - (ll)C(n, i) * C(m, i) % mod * fac[i] % mod * mul1[m - i] % mod  * mul2[n - i]) % mod;
		else
			ans = (ans + (ll)C(n, i) * C(m, i) % mod * fac[i] % mod * mul1[m - i] % mod  * mul2[n - i]) % mod;
	}
	if (ans < 0)ans += mod;
	printf("%d\n", ans);
}


Measured memory_bytes: 163200
n=int(input())
llist=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n-i-1):
        for k in range(n-i-j-2):
            ii=llist[i]
            ji=llist[i+j+1]
            ki=llist[i+j+k+2]
            if ji != ii and ji != ki and ii != ki:
                if max(ii,ji,ki)*2 < ji+ii+ki:
                    ans+=1

print(ans)

Measured memory_bytes: 74036
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: isize,
    }
    if n >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);


const int INF = INT_MAX;


int main() {
    int N,W; cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    
    vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));

    ll ans = 0;
    rep(i, N) {
        rep(j, W+1) {
            if(j >= w[i]) {
                dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
            ans = max(ans, dp[i+1][j]);
        }
    }

    cout << ans << endl;

    return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli a,b;
    cin2(a,b);
    if (a == 1)
        a += 100;
    if (b == 1)
        b += 100;
    if (a < b)
        cout << "Bob" << endl;
    else if ( a > b )
        cout << "Alice" << endl;
    else
        cout << "Draw" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe");
}


Measured memory_bytes: 3608
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];
 
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  int n;
  cin>>n;
  int ans=(double)n/1.08;
  int p=ans*1.08;
  int q=(ans+1)*1.08;
  if(p==n) cout<<ans;
  else if(q==n) cout<<ans+1;
  else cout<<":(";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long int n;
	long long int min = 10000000;
	long long int max = -10000000;
	long long int sum = 0;
	scanf("%lld\n",&n);
	long long int ai[n];
	for(int i = 1;i <= n;i++){
		scanf("%lld",&ai[i]);
		if(min > ai[i]){
			min = ai[i];
		}
		if(max < ai[i]){
			max = ai[i];
		}
		sum = sum += ai[i];
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}
/*mohankaitou
5
10 1 5 4 17

1 17 37
2147483648
5019101515
*/



Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
  
  cout << b+100*max(10-a,0) << endl;
  
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
const ll MOD=1e9+7;

int re[555][555];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	int n,m,d;
	cin>>n>>m>>d;
	rep(i,n)rep(j,m){
		int x=i+j,y=i-j+555;
		re[i][j]=(x/d%2)*2+(y/d%2);
	}
	rep(i,n){rep(j,m)cout<<"RGBY"[re[i][j]];cout<<endl;}
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A')      return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else               return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(int i = 0; i < strlen(str); i++){
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return key % M;
}

int h2(int key){
    return 1 + (key % (M - 1));
}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for (int i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(int i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, str);

        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}

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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template<typename T>
T read() {
    T res;
    cin >> res;
    return res;
}

template<typename T>
V<T> readV(int n) {
    V<T> res((size_t) n);
    for (int i = 0; i < n; ++i) {
        res[i] = read<T>();
    }
    return res;
}

template<typename T>
Vv<T> readVv(int n, int m) {
    Vv<T> res((size_t) n, V<T>((size_t) m));
    for (int i = 0; i < n; ++i) {
        res[i] = readV<T>(m);
    }
    return res;
}

// *** SOLUTION BEGIN ***

void solve() {
    int a, b;
    cin >> a >> b;
    Vs map(100, string(100, '.'));
    for (int r = 0; r < 50; ++r) {
        fill(begin(map[r]), end(map[r]), '#');
    }
    for (int c = 0; c < 100; c += 2) {
        map[50][c] = '#';
    }
    a--;
    b--;
    for (int r = 0; a > b; r += 2) {
        for (int c = 0; c < 100 && a > b; c += 2) {
            map[r][c] = '.';
            a--;
        }
    }
    for (int r = 99; b > a; r -= 2) {
        for (int c = 0; c < 100 && b > a; c += 2) {
            map[r][c] = '#';
            b--;
        }
    }
    for (int r = 51; a > 0; ++r) {
        for (int c = r & 1; c < 100 && a > 0; c += 2) {
            map[r][c] = '#';
            a--;
        }
    }
    cout << "100 100\n";
    for (auto s : map) {
        cout << s << '\n';
    }
}

// *** SOLUTION END ***

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

# if (Y > N * 10000) or (Y < N * 1000):
#     print("{} {} {}".format(-1, -1, -1))

found = False

for x in range(N+1):
    for y in range(N+1):
        if (x + y) > N:
            continue
        z = N - x - y
        if z < 0:
            continue
        if (x * 10000 + y * 5000 + z * 1000) == Y:
            ans_x = x
            ans_y = y
            ans_z = z
            found = True

if found:
    print("{} {} {}".format(ans_x, ans_y, ans_z))
else:
    print("{} {} {}".format(-1, -1, -1))
    



Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int mn = *min_element(all(a));
    int mnid = min_element(all(a)) - a.begin();
    int mx = *max_element(all(a));
    int mxid = max_element(all(a)) - a.begin();
    vector<P> ans;
    if(mn >= 0){
        rep(i,n-1){
            if(a[i] > a[i+1]){
                ans.pb(P(i+1,i+2));
                a[i+1] += a[i];
            }
        }
    }else if(mx + mn >= 0){
        rep(i,n){
            if(i != mxid){
                ans.pb(P(mxid+1,i+1));
                a[i] += a[mxid];
            }
        }
        rep(i,n-1){
            if(a[i] > a[i+1]){
                ans.pb(P(i+1,i+2));
                a[i+1] += a[i];
            }
        }
    }else{
        rep(i,n){
            if(i != mnid){
                ans.pb(P(mnid+1,i+1));
                a[i] += a[mnid];
            }
        }
        rrep(i,n-1){
            if(a[i] > a[i+1]){
                ans.pb(P(i+2,i+1));
                a[i] += a[i+1];
            }
        }
    }
    cout << len(ans) << "\n";
    rep(i,len(ans)){
        cout << ans[i].fi << " " << ans[i].se << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
h1,m1,h2,m2,k=map(int,input().split())
if m2<m1:
  ans=60*(h2-h1-1)+60-(m1-m2)-k
else:
  ans=60*(h2-h1)+m2-m1-k
if ans>=0:
  print(ans)
else:
  print(0)

Measured memory_bytes: 9176
N=int(input())
true_flg = True
list=[input() for i in range(N)]
for key, element in enumerate(list):
    t, x, y = map(int, element.split())
    if key == 0:
        a = t - (abs(x) + abs(y))
        if a < 0 or a % 2 == 1:
            true_flg = False
            break
    else:
        pre_t, pre_x, pre_y = map(int, list[key-1].split())
        a = (t - pre_t) - (abs(x - pre_x) + abs(y - pre_y))
        if a < 0 or a % 2 == 1:
            true_flg = False
            break
if true_flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 60248
#include<iostream>
using namespace std;
long long b,a[100000000],s,m,n,t;
int main()
{
	cin>>b>>m>>n;
	for(int i=1;i<=b;i++)
		cin>>a[i];
	for(int i=1;i<=b-1;i++)
	{
		t=(a[i+1]-a[i])*m;
		s+=t>n?n:t; 
	}
	cout<<s;
	return 0;
} 

Measured memory_bytes: 1024
#初期入力
import sys
N = int(input())
A=[int(i) for i in input().split()]
#


if 1 not in A:
    print(-1)
    exit
else:
    i=1 #探す数字
    brick_remain =set() #「1」は入っていること上記で確かめた
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)

Measured memory_bytes: 26012
import sys
readline = sys.stdin.readline

def main():
	s = input()
	n = len(s)

	ans = [0 for _ in range(n)]
	field = [0 for _ in range(n)]
	for i in range(n):
		if s[i] == 'L' and s[i-1] == 'L':
			field[i] = field[i-1] + 1

	for i in reversed(range(n)):
		if s[i] == 'R' and s[i+1] == 'R':
			field[i] = field[i+1] + 1

	for i in range(n):
		if s[i] == 'L':
			if field[i] % 2 == 0:
				ans[i - field[i]] += 1
			else:
				ans[i - field[i] - 1] += 1
		else:
			if field[i] % 2 == 0:
				ans[i + field[i]] += 1
			else:
				ans[i + field[i] + 1] += 1

	ans = [str(i) for i in ans]
	print(" ".join(ans))

if __name__ == '__main__':
	main()

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

#define ll long long
#define mp make_pair
#define pb push_back
#define loop(i, n)      for(int i = 0 ; i < n ; ++i)
#define rloop(i, n)     for(int i = int(n)-1 ; i >= 0 ; --i)
#define loopOne(i, n)   for(int i = 1 ; i <= n; ++i)
#define range(i, a, b)  for(int i = int(a) ; i <= int(b) ; ++i)
#define sz(x)   int(x.size())

void GO(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
const ll N = 1e5+100, OO = 1e9;
int mx = -OO, mn = OO;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

int arr[N], n, memo[N];
int k;
int Solve(int idx){
    if(idx == n-1)    return 0;
    if(memo[idx] != -1)    return memo[idx];
    int res = OO;
    for(int i = 1; i <= k; ++i) {
        if (idx + i < n)
            res = min(res, abs(arr[idx] - arr[idx + i]) + Solve(idx + i));
        else
            break;
    }
    return memo[idx] = res;
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    GO();
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; ++i){
        scanf("%d", arr+i);
    }
    memset(memo, -1, sizeof(memo));
    printf("%d", Solve(0));
    return 0;
}

Measured memory_bytes: 12388
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
using namespace std;
int main(void){
    int N;
    cin>>N;

    double ans=0;
    double b;
    for(int i=0;i<N;i++){
       cin>>b;
       ans+=1/b;
    }

    cout<<1/ans<<endl;
   
    
    return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int ans = stoi(c);
	string ou = "No";

	FOR(i, 1, 1000) {
		if (i*i == ans) {
			ou = "Yes";
			break;
		}
	}
	cout << ou << endl;


	return 0;
}

Measured memory_bytes: 256
r1, c1, r2, c2 = map(int, input().split())
mod = int(1e+9) + 7
def inved(x):
  a, b, c, d, k, l = 1, 0, 0, 1, x, mod
  while l != 0:
    a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)
    k, l = l, k % l
  return a % mod
frac = [1]
for i in range(r2 + c2 + 2):
  frac.append(((i+1) * frac[i]) % mod)
fracr2c2 = frac[r2 + c2 + 2]
fracr1c2 = frac[r1 + c2 + 1]
fracr2c1 = frac[r2 + c1 + 1]
fracr1c1 = frac[r1 + c1]
fracr2 = frac[r2 + 1]
fracr1 = frac[r1]
fracc2 = frac[c2 + 1]
fracc1 = frac[c1]
g = 0
g += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod
g %= mod
g += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod
g %= mod
g -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod
g %= mod
g -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod
g %= mod
print(g)


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

int main()
{
  int n,k;
  cin>>n>>k;
  //cout<<n;

  if ((n-1)*(n-2)<k*2){
    cout<<-1;
    return 0;
  }

  vector<P> v;
  //cout<<'k';
  for(int i=1;i<n;i++)v.push_back(make_pair(0,i));
  int now=(n-1)*(n-2)/2;
//  cout<<now;

  for (int i=1;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(now>k){
        v.push_back(make_pair(i,j));
        now--;
      }
    }
  }
  int temp=v.size();
cout<<temp<<endl;
  rep(i,temp){

    cout<<v[i].first+1<<' '<<v[i].second+1<<endl;
  }





}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <math.h>
long long int gcd (long long int a,long long int b) {
    return (b?gcd(b,a%b):a);

}
int main ()
{
    long long int n, k, c=0, gcd2;
    scanf ("%lld %lld", &n, &k);
    long long int a[n];
    for (long long int i=0;i<n;i++) {
        scanf ("%lld", &a[i]);
        if (k<=a[i])c=1;
        if (i==0) gcd2 = a[i];
        else gcd2 = gcd(gcd2, a[i]);
    }
    if (k%gcd2==0 && c==1) printf ("POSSIBLE");
    else printf ("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 2404
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t=1;cin>>t;
    while(t--){
       solve();
    }*/
    ll n,m; cin >> n >> m;
    vll k(n);
    vvll a(n,vll());
    int msk = 0;
    msk = 1 << 30;
    msk--;

    forn(i,n){
        cin >> k[i];
        a[i].resize(k[i]);
        int t = 0;
        forn(j,k[i]){
            cin >> a[i][j];
            t += 1 << (a[i][j] - 1);
        }
        msk &= t;
    }
    cout << __builtin_popcount(msk);
}

Measured memory_bytes: 256
x,y = map(int,input().split())
suma = abs(abs(x)-abs(y))
if x == 0:
    if y < 0:
        suma += 1
elif y == 0:
    if x > 0:
        suma += 1
elif abs(x) == abs(y):
    if x*y < 0:
        suma += 1
elif abs(x) < abs(y):
    if x < 0:
        suma += 1
        if y < 0:
            suma += 1
    else:
        if y < 0:
            suma += 1
else:
    if x < 0:
        if y < 0:
            pass
        else:
            suma += 1
    else:
        if y < 0:
            suma += 1
        else:
            suma = min(x+y,(x-y)+2)
print(suma)

Measured memory_bytes: 3064
def swap(x1, y1, x2, y2):
    x1, x2 = (x1, x2) if x1 < x2 else (x2, x1)
    y1, y2 = (y1, y2) if y1 < y2 else (y2, y1)
    return (x1, y1, x2, y2)
    
for _ in xrange(input()):
    gx, gy = map(int, raw_input().split())
    dp = [[0] * (gx + 2) for _ in xrange(gy + 2)]
    mttb = [swap(*map(int, raw_input().split())) for _ in xrange(input())]
    dp[0][0] = 1
    for y in xrange(gy + 1):
        for x in xrange(gx + 1):            
            if not (x - 1, y, x, y) in mttb:
                dp[y][x] += dp[y][x - 1]
            if not (x, y - 1, x, y) in mttb:
                dp[y][x] += dp[y - 1][x]
    print "Miserable Hokusai!" if dp[gy][gx] == 0 else dp[gy][gx]

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

int main(){
    int a[5];
    rep(i, 5){
        cin >> a[i];
        if(a[i] == 0) cout << i+1 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll Xi;
    vector<ll> X;
    for(int i=0;i<M;i++){
        cin >> Xi;
        X.push_back(Xi);
    }
    sort(X.begin(), X.end());

    if(N>=M){
        cout<<0<<endl;
        return 0;
    }

    vector<ll> Y(M-1);
    for(int i=0;i<M-1;i++){
        Y[i] = X[i+1] - X[i];
    }
    sort(Y.begin(), Y.end(), greater<ll>());

    ll res = X.back() - X.front();
    for(int i=0;i<N-1;i++){
        res -= Y[i];
    }

    cout<<res<<endl;

    return 0;
}

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

int main() {
    /* Input */
    int N, K;
    cin >> N >> K;
    
    vector<bool> snukes(N);
    rep(i, N) snukes.at(i) = false;

    rep (i, K) {
        int d;
        cin >> d;
        rep (j, d) {
            int a;
            cin >> a;
            snukes.at(a - 1) = true;
        }
    }
    int ans = 0;
    rep(i, N) if(!snukes.at(i)) ans++;

    /* Output */
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    int ans = 1000;
    for (int i = 0; i < s.size() - (3-1); ++i)
    {
        int num = atoi(s.substr(i, 3).c_str());
        ans = min(ans, abs(num - 753));
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,a,b,c,d,e,minn;
int main()
{
  cin>>n>>a>>b>>c>>d>>e;
  minn = min(a,b);
  minn = min(minn,c);
  minn = min(minn,d);
  minn = min(minn,e);
  long long ans;
  ans = n / minn + 5;
  if (n % minn == 0) ans -=1;
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int j = 1;

  // ここにプログラムを追記
  for (int i; i<N; ++i) {
    if (j <= K) {
      j *= 2;
    }else {
      j += K;
    }
  }
  cout << j << endl;
}


Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys
 
 
n,k = map(int, input().split())
 
ans = 0
for b in range(k+1,n+1):
  ans += (n+1)//b*(b-k)+max(0,(n+1)%b-k)
if k == 0:
  ans = n**2
print(ans)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==0){
      if(a%3!=0&&a%5!=0){
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import product

N, *ABC = map(int, input().split(" "))
L = [int(input()) for _ in range(N)]

min_num = 10**18
for i in range(4**N):
    abcz = [[] for _ in range(4)]
    for j in range(N):
        abcz[i//(4**j)%4].append(L[j])
    if [] in abcz[:3]:
        continue
    # print(abcz)
    m = 0
    for l, x in zip(abcz, ABC): 
        m += 10*(len(l)-1) + abs(sum(l)-x)
    # if m < min_num:
    #     print(abcz, m)
    min_num = min(min_num, m)

print(min_num)


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

const ll Mod=1e9+7;
ll a[200010];
int n,k;
bool pd;

bool cmp(ll A,ll B){
	return abs(A)>abs(B);
}

int main() {
	scanf("%d%d",&n,&k);
	pd=1;
	for (int i=1;i<=n;++i) {
		scanf("%lld",&a[i]);
		if (a[i]>=0) pd=0;
	}
	if (n==k) {
		ll ans=1;
		for (int i=1;i<=n;++i)
		ans=ans*a[i]%Mod;
		printf("%lld\n",(ans+Mod)%Mod);
		return 0;
	}
	if (k==1) {
		ll ans=-1e9+10;
		for (int i=1;i<=n;++i)
		ans=max(ans,a[i]);
		printf("%lld\n",(ans+Mod)%Mod);
		return 0;
	}
	sort(a+1,a+1+n,cmp);
	if (pd) {
		ll ans=1;
		if (k&1) {
			for (int i=n;i>=n-k+1;--i)
			ans=ans*a[i]%Mod;
		} else  {
			for (int i=1;i<=k;++i)
			ans=ans*a[i]%Mod;
		}
		printf("%lld\n",(ans+Mod)%Mod);
		return 0;
	}
	
	ll f1=-1,f2=1,ans=1;
	for (int i=1;i<=k;++i) {
		if (a[i]>=0) {ans=ans*abs(f1)%Mod;f1=a[i];}
		if (a[i]<0) {ans=ans*f2%Mod;f2=a[i];} 
	}
	if (ans*abs(f1)%Mod*f2%Mod>=0) printf("%lld\n",ans*abs(f1)%Mod*f2%Mod);
	else {
		ll ans1=-1e9+10,ans2=ans1;
		if (f1!=-1) {
			for (int i=k+1;i<=n;++i)
			if (a[i]>=0) {ans1=f1*a[i];break;}
		} else {
			for (int i=k+1;i<=n;++i)
			if (a[i]>=0) {
				ans1=a[i];break;
			}
		}
		if (f2!=1&&f1!=-1) {
			for (int i=k+1;i<=n;++i)
			if (a[i]<=0) {ans2=f2*a[i];break;}
		}
		if (ans1>ans2) printf("%lld\n",ans1%Mod*ans%Mod);
		else printf("%lld\n",ans2%Mod*ans%Mod);
	}
	return 0;
}

Measured memory_bytes: 5316
#include <iostream>                                             
#include <cmath>                                                
using namespace std;                                            
                                                                
int main(void) {                                                
  int n;                                                        
  cin >> n;                                                     
  int R[n];                                                     
  for (int k=0; k<n; k++) {                                     
    cin >> R[k];                                                
  }                                                             
  int max = -pow(10,9);                                         
  int min = R[0];                                               
  for (int j=1; j<n; j++) {                                     
    max = std::max(max,R[j]-min);                               
    min = std::min(min,R[j]);                                   
  }                                                             
  cout << max << endl;                                          
  return 0;                                                     
}                        

Measured memory_bytes: 3860
def cut2(cut_place, width, height):
    part1 = [width, cut_place]
    part2 = [width, height - cut_place]
    if height - cut_place >= cut_place:
        output = [part1, part2]
    else:
        output = [part2, part1]
    return output

def cut1(cut_place, width, height):
    part1 = [cut_place, height]
    part2 = [width - cut_place, height]
    if width - cut_place >= cut_place:
        output = [part1, part2]
    else:
        output = [part2, part1]
    return output


while True:

    headder = input().split(" ")
    n = int(headder[0])
    w = int(headder[1])
    h = int(headder[2])


    if n == 0 and h == 0 and w == 0:
        break

    slices = [[w,h]]

    for i in range(n):
        how = input().split(" ")
        part_id = int(how[0])
        cut_place = int(how[1])

        piece_obj = slices[part_id-1]
        width = piece_obj[0]
        height = piece_obj[1]

        seiki_cut_place = cut_place%(2*(width+height))

        if seiki_cut_place < width:
            result = cut1(seiki_cut_place,width,height)
        elif seiki_cut_place < width + height and seiki_cut_place > width:
            cp = seiki_cut_place - width
            result = cut2(cp, width, height)
        elif seiki_cut_place < 2*width + height and seiki_cut_place > width + height:
            cp = seiki_cut_place - width - height
            result = cut1(cp, width, height)
        elif seiki_cut_place < 2*width + 2*height and seiki_cut_place > 2*width + height:
            cp = seiki_cut_place - 2*width - height
            result = cut2(cp, width, height)

        #あとはここでlinkedlistを使うようにする
        #だいたい問題を解くのに50分かかった。多分急いで４０分。
        slices = slices[0:part_id-1] + slices[part_id:] + result

    answers = []
    for ele in slices:
        answers.append(ele[0]*ele[1])

    sub = ""
    answers.sort()
    for ele in answers:
        sub += str(ele)
        sub += " "

    print(sub[0:-1])



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int a, b; char c; cin >> a >> c >> b;
  if(c == '+') cout << a + b << endl;
  else cout << a - b << endl;
  return 0;
}

Measured memory_bytes: 256