akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	int n;
	cin >> n;
	vector<ll>a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	ll ans = 0;
	vector<ll>x(n), y(n);
	rep(i, n) {
		ll a2 = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		ll c2 = c.end() - upper_bound(c.begin(), c.end(), b[i]);
		ans += a2 * c2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}

ll cou[1000006];
int main()
{
    Fast
 ll n;
 cin>>n;

 vector<ll>sura;
 for(ll i=0;i<n;i++)
 {
     ll k;
     cin>>k;
     cou[k]++;
     sura.push_back(k);

 }
 if(n==1)
 {
     cout<<1<<endl;
     return 0;
 }
 ll ans=0;
 for(ll i=0;i<n;i++)
 {
     ll x=sura[i];
     ll y=n-1;
     for(ll j=1; j*j<=x;j++)
     {
        if(x%j==0)
        {
            if(j!=x/j)
            {
                

                      if(x==j)
                    y-=cou[j]-1;
                    else
                    {
                          y-=cou[j];
                    }
                     if(x==x/j)
                    y-=cou[x/j]-1;
                    else
                    {
                          y-=cou[x/j];
                    }
                      
                
            }
            else
            {
                  if(x==j)
                    y-=cou[j]-1;
                    else
                    {
                          y-=cou[j];
                    }
            }
            
        }
     }
    
     if(y==n-1 )
     ans++;
 }
 cout<<ans<<endl;

}



   
      
    
        



Measured memory_bytes: 13084
fun min(x: Int, y: Int): Int {
    return if (x < y) x else y
}

fun max(x: Int, y: Int): Int {
    return if (x > y) x else y
}


fun main(args: Array<String>) {
    val s = readLine()!!
    val n = s.length
    var ans = n
    for (i in 0..(n-2)) {
        if (s[i] != s[i + 1]) {
            ans = min(max(i + 1, n - i - 1), ans)
        }
    }
    println(ans)
}

Measured memory_bytes: 33956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			if ((i + 1) % 2 == 1 && a % 2 == 1)
				count++;
		}
		System.out.println(count);
	}

}


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

int main(void){
    int ans=0;
    int m=0;
    int n=0;

    cin >> n;
    cin >> m;
    for(int i=1; i<n; i++){
        ans += n-i;
    }
    for(int i=1; i<m; i++){
        ans += m-i;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split()))+[0]

SUM=0
for i in range(1,N+2):
  SUM+=abs(A[i]-A[i-1])


  
COST=[None]*N

for i in range(N):
  COST[i]=SUM+abs(A[i+2]-A[i])-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1])
  print(COST[i])


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

typedef long long ll;

vector<ll> length, pnum;

ll burger(ll n, ll x){
    ll ret = 0;
    if(n == 0){
        return 1;
    }else{
        x--;
        if(x >= length.at(n-1)){
            ret += pnum.at(n-1);
            x -= length.at(n-1);
            if(x > 0){
                ret++;
                x--;
            }
        }
        if(x > 0){
            ret += burger(n-1, x);
        }
    }
    return ret;
}

int main(void){
    int n;
    ll x;
    cin >> n >> x;
    length.resize(n+1);
    pnum.resize(n+1);
    length.at(0) = 1;
    pnum.at(0) = 1;
    for(int i=1; i<=n; i++){
        length.at(i) = length.at(i-1)*2 + 3;
        pnum.at(i) = pnum.at(i-1)*2 + 1;
    }

    cout << burger(n,x) << endl;
    
    return 0;
}

Measured memory_bytes: 256
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [x, y] = input.trim().split(" ");
  return parseInt(x, 16) < parseInt(y, 16)
    ? "<"
    : parseInt(x, 16) > parseInt(y, 16)
    ? ">"
    : "=";
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func gcd(a, b uint64) uint64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b uint64) uint64 {
	return a * b / gcd(a, b)
}

func mLcm(n ...uint64) uint64 {
	var ret uint64
	for i, v := range n {
		if i == 0 {
			ret = v
		} else {
			ret = lcm(ret, v)
		}
	}
	return ret
}

func main() {
	var N int
	fmt.Scan(&N)
	var a uint64
	var sum uint64

	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		sum += a
	}
	fmt.Println(sum - uint64(N))

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        for (int i = 0; i < N; i++) {
            if ((int) Math.sqrt(N - i) * (int) Math.sqrt(N - i) == N - i) {
                System.out.println(N - i);
                break;
            }
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(v) (v).begin(),(v).end()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h, m;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

int main()
{
	cin >> h >> w;
	vector<string> vs;
	REP(i,h)
	{
		cin >> s;
		cout << s << endl << s << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

n = int(input())
h = list(map(int, input().split()))

flag = True
for i in reversed(range(1,n)):
    if h[i-1] <= h[i]: continue
    if h[i-1]-1 <= h[i]: h[i-1] -= 1
    elif h[i] < h[i-1]-1:
        flag = False
        break

if flag: print("Yes")
else: print("No")


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for(int i = 1; i <= 2000; ++i) {
    if((int)(i * 0.08) == A && (int)(i * 0.10) == B) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n,m;
    int x[100005],y[100005];
    cin>>n>>m;
    for(int i=0;i<m;i++) {
        cin>>x[i];
    }
    sort(x,x+m);
    for(int i=0;i<m-1;i++){
        y[i]=abs(x[i+1]-x[i]);
    }
    sort(y,y+(m-1));
    int ans=0;
    for(int i=0;i<m-n;i++){
        ans+=y[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> B(N-1);
	for (int i = 0; i < N-1; ++i)
		cin >> B[i];
	
	int ans = B[0] + B[N-2];
	for (int i = 1; i < N-1; ++i)
		ans += min(B[i], B[i-1]);
	cout << ans << '\n';
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b < c) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d < 0) {
		cout << "No" << endl;
		return 0;
	}
	ll e = 4 * a * b;
	// cout << d << endl << e << endl;
	if (e < d * d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<algorithm>
#include<functional>
#include<string>
#include<unordered_map>
#include<map>
#include<cstdio>
#include<set>
using namespace std;

int c[100000];
signed main() {
	int a, b;
	cin >> a >> b;
	for (int d = 0; d < a; d++) {
		scanf("%d", &c[d]);
	}
	for (int d = 1; d < a; d++) {
		if (c[d-1] + c[d] >= b) {
			puts("Possible");
			for (int e = 1; e < d; e++) {
				printf("%d\n", e);
			}
			for (int e = a-1; e>d; e--) {
				printf("%d\n", e);
			}
			cout << d << endl;
			return 0;
		}
	}
	puts("Impossible");
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, m;
  cin >> n >> m;

  vector<P> p(m);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    int bit = 0;
    rep(j, b){
      int c;
      cin >> c;
      bit |= 1 << (c - 1);
    }
    p[i] = P(bit, a);
  }
  
  vector<int> dp(1 << n, INF);
  dp[0] = 0;
  for(int i = 0; i < m; ++i){
    int bit = p[i].first;
    int money = p[i].second;
    for(int j = 0; j < 1 << n; ++j){
      dp[(j | bit)] = min(dp[(j | bit)], dp[j] + money);
    }
  }

  if(dp[(1<<n)-1] == INF) cout << -1 << endl;
  else cout << dp[(1<<n)-1] << endl;
  return 0;
}


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

int fa[1000006], dis[1000006];

int find(int x) {
	if (fa[x] == x) return x;
	int tmpfa = find(fa[x]);
	dis[x] += dis[fa[x]];
	return fa[x] = tmpfa;
}


bool add(int L, int R, int D) {
	if (find(L) == find(R)) {
		if (dis[L] - dis[R] != -1 * D) {
			cout << "No";
			return 0;
		}
		return 1;
	}
	int faR = fa[R], faL = fa[L];
	fa[faR] = fa[faL];
	dis[faR] = dis[L] + D - dis[R];
	return 1;
}


int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	
	for (int i = 1; i <= m; ++i) {
		int L, R, D;
		scanf("%d%d%d", &L, &R, &D);
		if (!add(L, R, D)) {
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int a, b, k;
    cin >> k >> a >> b;

    while (a % k)
        a++;

    if (a > b) {
        cout << "NG\n";
    }
    else {
        cout << "OK\n";
    }

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::string S;
    std::cin >> S;

    int x = 0;
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'I') {
            x++;
        } else if (S[i] == 'D') {
            x--;
        }

        if (ans < x) {
            ans = x;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1E9 + 9;
const int INF = 1<<29; 

int main(){
    int64_t ans = 0;
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    map<string, int> cnt;
    rep(i, N){
        sort(s[i].begin(), s[i].end()); 
        cnt[s[i]]++;
    }
    for(int i = 0; i < N; i++){
        // cout << &cnt[s[i]] << endl;
        ans += cnt[s[i]] - 1;
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W;
  cin>>H>>W;
  vector<vector<int>> A(H,vector<int>(W));
  for(vector<int> &v:A)
    for(int &i:v)
      cin>>i;
  int k=0;
  vector<vector<int>> B(0);
  for(int i=0;i<H;i++){
    for(int j=0;j<W-1;j++){
      if(A[i][j]%2==1){
        k++;
        A[i][j+1]+=A[i][j];
        B.push_back({i+1,j+1,i+1,j+2});
      }
    }
    if(A[i][W-1]%2==1 && i!=H-1){
      k++;
      A[i+1][W-1]+=A[i][W-1];
      B.push_back({i+1,W,i+2,W});
    }
  }
  cout<<k<<endl;
  for(vector<int> v:B)
    cout<<v[0]<<' '<<v[1]<<' '<<v[2]<<' '<<v[3]<<endl;
}

Measured memory_bytes: 13972
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

int ans = 1, ok1 = 0, ok2 = 0;
set<int> s;
void solve()
{
    int n,k; cin>>n>>k;
    int a[n+1];
    rep(i,0,n) cin>>a[i];
    a[n] = INF;
    rep(i,0,k-1)
    {
        if(a[i]>a[i+1]) ok1++;
        s.insert(a[i]);
    }
    s.insert(a[k-1]);
    if(!ok1) ok2 = 1;
    rep(i,k,n)
    {
        if(a[i]<a[i-1]) ok1++;
        if(a[i-k]>a[i-k+1]) ok1--;
        int l = a[i-k];
        s.erase(l);
        if(a[i]<(*s.rbegin())) ans++;
        else if(l>(*s.begin()) and ok1) ans++;
        if(!ok1)
        {
            if(!ok2) ans++;
            ok2 = 1;
        }
        s.insert(a[i]);
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int wqpfs(int x)
{
	for(int i=1;i*i<=x;i++)
	  if(i*i==x)return 1;
	return 0;
}
long long a,b,a1,z,m;
int main()
{
	cin>>a>>b;a1=b;
	while(a1>0)
	{
		a1/=10;
		z++;
	}
	m=a*pow(10,z)+b;
	if(wqpfs(m))cout<<"Yes";else
	  cout<<"No";
	return 0;
}

Measured memory_bytes: 256
Tmp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nX = int(Tmp[1])


nA = 1
nP = 1
 
nAnsA = []
nAnsP = []

nAnsA.append(1)
nAnsP.append(1)
 
for i in range(nN):
  nTmpA = nA * 2 +3
  nTmpP = nP * 2 +1
  nAnsA.append(nTmpA)
  nAnsP.append(nTmpP)
  nA = nTmpA
  nP = nTmpP

nAnsA.sort(reverse=True)  
nAnsP.sort(reverse=True)  
nN += 1

nMaxA = nAnsA[0]
nMaxP = nAnsP[0]
 
nTmpA = nMaxA
nTmpP = nMaxP
 
nAns = 0

# print(nAnsA)
# print(nAnsP)


for i in range(nN):
#  print(nX)
  if i == nN - 1:
    nAns += 1
    break
  else:
    nTmpA = nAnsA[i+1] + 2
    nTmpP = nAnsP[i+1] + 1
#  print(nTmpA)
#  print(nTmpP)

  
  if nTmpA > nX:
    nX -= 1
    if (nX == 0):
      break
  elif nTmpA == nX:
    nAns += nTmpP
    break
  else:
    nAns += nTmpP
    nX -= nTmpA
#  print(nAns)
    
print(nAns)
 

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;

    int sum;
    if(b < 10) sum = a * 10 + b; 
    else if(b < 100) sum = a * 100 + b; 
    else sum = a * 1000 + b;
    
    bool ans = false;
    for(int i = 0; i * i < 100100; i++){
        if(i * i == sum) ans = true;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n = onem()
if n == 1:
    l()
    print(1)
else:
    a = []
    for i in range(n):
        a.append(l())
    aa = []
    for i in range(n-1):
        for j in range(i,n):
            if not (a[i][0] - a[j][0] == 0 and a[i][1] - a[j][1] == 0):
                aa.append([a[i][0] - a[j][0],a[i][1] - a[j][1]])
                aa.append([a[j][0] - a[i][0],a[j][1] - a[i][1]])
    aa.sort()
    c = 1
    cc = 1
    lp = aa[0]
    for i in range(1,len(aa)):
        if lp == aa[i]:
            c += 1
        else:
            if c >= cc:
                cc = c
            lp = aa[i]
            c = 1
    if c >= cc:
        cc = c


    print(n - cc )


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int x,y;

main() {
    cin >> x >> y;
    if(x<y) ct(min(y-x,abs(x+y)+1))
    else ct(min(x-y+2,abs(x+y)+1))
}


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

int main(void){
    // Your code here!
    int N; cin >> N;
    int st = 0;
    int ans = 1;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        if (s == "A") st++;
        else if (s == "Un") st--;
        else {
            cout << "Error" << endl;
            exit(1);
        }
        
        if (st < 0) {
            ans = 0;
        }
    }
    if (st != 0) ans = 0;
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

//?????????(i,j)?????????????´????????????????
int em[1000][1000]={0};

int main()
{
    int m,n;
    cin >>m >>n;

    vector<string> s(m);
    rep(i,m) cin >>s[i];

    vector<string> t(2);
    rep(i,2) cin >>t[i];

    //?????????????????§???????????????
    int def=0;
    rep(i,m-1)rep(j,n-1)
    {
        int v=1;
        rep(y,2)rep(x,2)
        {
            if(s[i+y][j+x]!=t[y][x]) v=0;
        }
        em[i][j]=v;
        def+=v;
    }

    int ans=def;
    string joi="JOI";
    //?????´??????
    rep(i,m)rep(j,n)rep(k,3)
    {
        if(s[i][j]==joi[k]) continue;

        int ct=0;
        //???????????????
        for(int y=-1; y<=0; ++y)for(int x=-1; x<=0; ++x)
        {
            int sy=i+y, sx=j+x;
            if(0<=sy&&sy<m-1 && 0<=sx&&sx<n-1)
            {
                if(em[sy][sx]) --ct;
                else
                {
                    //?´????????????£???????????????
                    char tmp=s[i][j];
                    s[i][j]=joi[k];

                    int v=1;
                    rep(p,2)rep(q,2)
                    {
                        if(s[sy+p][sx+q]!=t[p][q]) v=0;
                    }
                    ct+=v;

                    s[i][j]=tmp;
                }
            }
        }

        ans=max(ans,def+ct);
    }

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

Measured memory_bytes: 7960
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
        cin>>arr[i][j];
        }
    }
    int dp[n][3];
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<3;j++){
    //         cout<<arr[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=arr[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        }
    }
    cout<<*max_element(dp[n-1],dp[n-1]+3);
  
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i, n){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  rep(i, n){
    int x;
    x = b[n / 2];
    if(x <= a[i]) x = b[n / 2 - 1];
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 5104
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

ll dp[55][55][2505] = {0};

int main()
{
	ll n, a;
	cin >> n >> a;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	dp[0][0][0] = 1;
	rep(i, n)
	{
		rep(j,51){
			rep(k,2505){
				dp[i + 1][j][k] += dp[i][j][k];
				if (k - x[i] >= 0)
					dp[i + 1][j+1][k] += dp[i][j][k - x[i]];

			}
		}
	}
	ll ans = 0;
	rep(j,n+1){
        rep(k,2505){
            if(a*j==k&&k!=0)ans+=dp[n][j][k];
        }
    }
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 54688
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int N, A, T;
	std::cin >> N >> T >> A;
	std::vector<double> H(N);
	for (int i = 0;i < N;++i) {
		std::cin >> H[i];
	}
	std::vector<double> Y(N);
	for (int i = 0;i < N;++i) {
		Y[i] = std::abs(T - 6 * H[i] / 1000 - A);
	}
	double Q = *std::min_element(Y.begin(), Y.end());
	for (int i = 0;i < N;++i) {
		if (Q == Y[i]) {
			std::cout << i + 1 << std::endl;
		}
	}
	return 0;

}



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

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

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

    sort(a, a+n);
    
    cout << a[n-1] - a[0] << endl;

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 1e15


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

ll dp[102][8];
ll table[8]={1,2,3,5,8,13,21,34};

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            rep(r,w){
                if(j==r){
                    dp[i+1][j]+=dp[i][r]*table[max(0,j-1)]*table[max(0,w-2-j)];
                    dp[i+1][j]%=mod;
                }
                else if(j==r+1){
                    dp[i+1][j]+=dp[i][r]*table[max(0,r-1)]*table[max(0,w-2-j)];
                    dp[i+1][j]%=mod;
                }
                else if(j==r-1){
                    dp[i+1][j]+=dp[i][r]*table[max(0,j-1)]*table[max(0,w-2-r)];
                    dp[i+1][j]%=mod;
                }
            }
        }
    }
    cout<<dp[h][k-1]<<endl;


    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
ll n,q,m;
ll d[100010];
vector<PLL> v[100010];
priority_queue<PLL> pq; 
int main()
{
	cin >>n;
	for (int i=0;i<n-1;i++)
	{
		ll x,y,z;
		cin >>x>>y>>z;
		x--,y--;
		v[x].push_back(MP(y,z));
		v[y].push_back(MP(x,z));
	}
	cin >>q>>m;
	m--;
	fill(d,d+n,1e18);
	pq.push(MP(0,m));
	d[m]=0;
	while (!pq.empty())
	{
		ll x=pq.top().S;
		ll y=-pq.top().F;
		pq.pop();
		if (d[x]!=y) continue;
		for (int i=0;i<v[x].size();i++)
		{
			ll xi=v[x][i].F;
			ll yi=v[x][i].S;
			if (d[xi]>y+yi)
			{
				d[xi]=y+yi;
				pq.push(MP(-d[xi],xi));
			}
		}
	}
	for (int i=0;i<q;i++)
	{
		ll x,y;
		cin >>x>>y;
		x--,y--;
		cout <<d[x]+d[y]<<"\n";
	}
	return 0;
} 


Measured memory_bytes: 11120
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
  for j in range(N-M+1):
    flag = True
    AA = [a[j:j+M] for a in A[i:i+M]]
    for a, b in zip(AA, B):
      if a != b:
        flag = False
    if flag:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 9164
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int check(int n)
{
	if(n==0)
		return 0;
	return 1+check(n/10);
}

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

	int ans=0;
	for(int i=1;i<=N;i++)
		if(check(i)%2==1)
			ans++;
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

ll calc(vector<ll> v){
	ll ans = 0;
	ll sum = 0;
	REPS(i, v.size() - 1){
		ans += (sum += (v[i] - v[i-1]) * i % MOD) % MOD;
	}
	return ans % MOD;
}

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<ll> x(n), y(m);
	REP(i, n) cin >> x[i];
	REP(i, m) cin >> y[i];
	cout << calc(x) * calc(y) % MOD << endl;
	return 0;
}


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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

int main() {
  int n;cin>>n;
  vvi dp(n+1,vi(3,-1));rep(i,3) dp[0][i]=0;
  rep(i,n) {
    int a,b,c;cin>>a>>b>>c;
    dp[i+1][0] = max(dp[i][1],dp[i][2]) + a;
    dp[i+1][1] = max(dp[i][0],dp[i][2]) + b;
    dp[i+1][2] = max(dp[i][1],dp[i][0]) + c;
  }
  int ans = -1;
  rep(i,3) chmax(ans, dp[n][i]);
  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#include <bitset>

using namespace std;

int main(int argc, const char *argv[])
{
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s[i];
  int ans = h + w + 1;
  for (int bit = 0; bit < (1 << (h - 1)); bit++) {
    bitset<16> bs(bit);
    int x = 0, split_cnt = bs.count();
    bool ok = true;
    while (x < w && ok) {
      bool exceeded = false;
      vector<int> white_cnts(bs.count() + 1, 0);
      int left = x;
      for (; !exceeded && x < w; x++) {
        for (int y = 0, cur = 0; y < h; y++) {
          white_cnts[cur] += s[y][x] - '0';
          exceeded = exceeded || white_cnts[cur] > k;
          cur += bs[y];
        }
      }

      if (exceeded) {
        split_cnt++;
        x--;
      }

      ok = !exceeded || left != x;
    }

    ans = ok ? min(ans, split_cnt) : ans;
  }

  cout << ans << "\n";

  return 0;
}


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

int main() {
string S;
  cin >> S;

  for (int i = 0; i < S.size()-1; i++) {
      for (int j = i+1; j < S.size(); j++) {
          if(S.at(i)==S.at(j)) {
              cout << "no" << endl;
              return 0;
          }
      }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

void	solve()
{
	int n;
	cin >> n;

	cout << (2 * n) / gcd(2, n) << endl;
}

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

	solve();
}


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

int main()
{
  int t;
  cin>>t;
  for(;t--;)
    {
      int n,k;
      cin>>n>>k;
      int tmp1,tmp2;
      priority_queue<int, vector<int>, greater<int> > qu;
      //      priority_queue<int> qu;
      for(int i=0;i<n;i++)
	{
	  tmp2=tmp1;
	  cin>>tmp1;	  
	  if(i!=0)
	    {
	      qu.push(tmp1-tmp2);
	      //      cout<<tmp1-tmp2<<endl;
	     }
	 }
       int ans=0;
       //       for(int i=0;i<n-k-1;i++)
       for(;n>k;)
	 {
	   ans+=qu.top();
	   qu.pop();
	   n--;
	   //	   cout<<"loop"<<endl;
	 }
       cout<<ans<<endl;
    }
}

Measured memory_bytes: 1864
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0

if N == 1:
  print(a[0]+b[0])
else:
  for i in range(N):
    ans_candidate =sum(a[:i])+sum(b[(i-1):])
    if ans < ans_candidate:
      ans = ans_candidate
  print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
		
	String[] info = new String[number];
	for(int i = 0; i < number; i++) {
		info[i] = sc.next() + "," + (Integer.MAX_VALUE - sc.nextInt()) + "," + (i+1);
    }
    Arrays.sort(info);
    for(int j=0;j < number; j++){
        String ans = info[j].split(",")[2];
    	System.out.println(ans);
    }
  }
}
    

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int INF = 1e10;
int a[3];

int main(){
	IOS;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int ans=0;
	for(int i=0;i<2;i++){
		ans+=a[i+1]-a[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<ll> a(N);
  REP(i,N) cin >> a[i];

  vector<ll> cum(N + 1, 0);
  REP(i,N) cum[i + 1] = cum[i] + a[i];

  ll ret = 1e18;
  REP(i,N-1) {
    ll s = cum[i + 1];
    ll a = cum[N] - s;
    ret = min(ret, abs(s - a));
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>
#include <inttypes.h>

uint64_t memo[64][64];

uint64_t nCr(int n, int r) {
	if (r < 0 || n < r) return 0;
	if (r == 0 || r == n) return 1;
	if (memo[n][r]) return ~memo[n][r];
	return ~(memo[n][r] = ~(nCr(n - 1, r) + nCr(n - 1, r - 1)));
}

int main(void) {
	int N, P;
	int A[64];
	int i;

	int asumi, iguti;
	uint64_t mizuhasu;

	if (scanf("%d%d", &N, &P) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}

	asumi = iguti = 0;
	for (i = 0; i < N; i++) {
		if (A[i] % 2 == 0) asumi++; else iguti++;
	}

	mizuhasu = 0;
	for (i = (P != 0); i <= iguti; i += 2) {
		mizuhasu += nCr(iguti, i);
	}

	printf("%" PRIu64 "\n", (UINT64_C(1) << asumi) * mizuhasu);
	return 0;
}


Measured memory_bytes: 1740
#include<stdio.h>
#include<stdlib.h>

main(){
  char str[100];
  int i,index = 0;
    int St[100];

  while(scanf("%s", str) != EOF){
    if(*str == '+'){
      index--;
      St[index - 1] += St[index];
    }else if(*str == '-'){
      index--;
      St[index - 1] -= St[index];
    }else if (*str == '*'){
     index--;
      St[index - 1] *= St[index];
    }else{
      St[index++] = atoi(str);
    }
  }
  printf("%d\n", St[--index]);
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	set<int>a;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 15; j++)a.insert(i * 4 + j * 7);
	}
	if (a.count(n))cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]


    bamari = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bamari -= A[i] - B[i]
        else:
            bamari += -(-(B[i] - A[i]) // 2)
            bamari -= (B[i] - A[i]) % 2

    if bamari >= 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main(){
  string s;
  cin >> s;
  int sn,count=1,half,j;
  sn = s.size();
  vector<int>vec(sn);
  
  for(int i=0;i<sn-1;i++){
    if(s.at(i)=='R'&&s.at(i+1)=='L'&&i==sn-2){
      half = count/2;
      count = count - half;
      vec.at(i+1)+=half;
      vec.at(i)+=count;
      j=i;
      count = 1;
      vec.at(i+1)++;
    }
    else if(s.at(i)=='R'&&s.at(i+1)=='L'){
      half = count/2;
      count = count - half;
      vec.at(i+1)+=half;
      vec.at(i)+=count;
      j=i;
      count = 1;
    }
    else if(i==sn-2){
      count++;
      half = count/2;
      count = count - half;
      vec.at(j+1)+=count;
      vec.at(j)+=half;
      count = 1;
    }
    else if(s.at(i)==s.at(i+1)){
      count++;
    }
    else if(s.at(i)=='L'&&s.at(i+1)=='R'){
      half = count/2;
      count = count - half;
      vec.at(j+1)+=count;
      vec.at(j)+=half;
      count = 1;
    }
    
  }
  
  for(int i=0;i<sn;i++){
    cout << vec.at(i) << " ";
  }
  cout << endl;
  
}

Measured memory_bytes: 3848
n = int(input())
a = list(map(int, input().split()))


a.sort(reverse=True)

sum1 = 0
sum2 = 0

for i in range(0,n,2):
    sum1 += a[i]

for i in range(1, n, 2):
    sum2 += a[i]

print(sum1 - sum2)





Measured memory_bytes: 2940
#pragma GCC optimize "O3"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(LL m, LL n){
	while(m!=n){
		if(m>n)
			m=m-n;
		else
			n=n-m;
	}
	return m;
}
int lcm(LL m,LL n)
{
	return m*n/gcd(m,n);
}

int main(int argc, char *argv[]) {
	// Something to do
	int a, b;
	while(cin >> a >> b) {
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
#include <stdio.h>
int main(){
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(r <= x && x <= (W - r) &&  r <= y && y <= (H - r) ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}
  

Measured memory_bytes: 580