akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }

int main(){
    ll n,q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i,0,n){
        ll a;
        cin >> a;
        fw.add(i,a);
    }

    ll t,u,v;
    rep(i,0,q){
        cin >> t >> u >> v;
        if(t == 0){
            fw.add(u,v);
        }
        else{
            cout << fw.sum(u,v) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8216
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			char[] ch = scanner.next().toCharArray();
			Deque<Character> deque = new ArrayDeque<Character>();
			deque.push(ch[0]);
			for (int i = 1; i < ch.length; i++) {
				if (ch[i] == '>') {
					if (!deque.contains(ch[i + 1]))
						deque.offer(ch[i + 1]);
				} else if (ch[i] == '<') {
					if (!deque.contains(ch[i + 2]))
						deque.push(ch[i + 2]);
				}
			}
			for (Character c : deque) {
				System.out.print(c);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 21144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >>b;
  bool ans = true;
  for(int i=0;i<=a+b;i++){
    char s;
    cin >>s;
    if( i  == a ){
      if( s !='-'){
        ans =false;
      }
    }
    else if( s < '0' || s > '9'){
      ans = false;
    }
  }
  cout << (ans ? "Yes":"No");
      
}

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

int main(){
 int n;
  cin>>n;
  vector<int>p(n),q(n);
  rep(i,n)cin>>p[i];
  rep(i,n)cin>>q[i];
  vector<int>a(n);
  rep(i,n)a[i]=i+1;
  map<vector<int>,int>mp;
  do{
   mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    int c1 = 0;
    int c2 = 0;
    rep(i, 0, N)
    {
        if (S.at(i) == '0')
        {
            c1++;
        }
        else
        {
            c2++;
        }
    }
    if (c1 < c2)
    {
        cout << 2 * c1 << endl;
    }
    else
    {
        cout << 2 * c2 << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n;
int a[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    }
    sort(a, a + n);
    int g = a[n - 1];
    int best = a[0];
    for(int i = 0; i < n; i++){
    	int d = abs(g - 2 * a[i]);
    	if(d < abs(2 * best - g)){
    		best = a[i];
    	}
    }
    cout << a[n - 1] << " " << best;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
S = input()
SS = S + S[::-1]
D = []
for i in range(N):
  D.append(SS[i:i+N])
D.sort()
B = D[0]
for i in range(N):
  if B[i] != B[0]:
    break
if i * 1 << (K - 1) > N:
  print(B[0] * N)
else:
  print((B[0] * (i * (1 << (K - 1))) + B[i:])[:N])

Measured memory_bytes: 256136
#include<bits/stdc++.h>
using namespace std;
#define itn int


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

Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
const int MAX_N = 200000 +10;

struct BIT{
    int N;
    LL a[MAX_N];

    void clear(int n){
        N = n;
        for (int i=0;i<=N;i++) a[i] = 0;
    }
    int lowbit(int x){
        return x & (-x);
    }
    void update(int x){
        while (x <= N){
            a[x]++;
            x += lowbit(x);
        }
    }
    LL sum(int x)
    {
        LL ret = 0LL;
        while (x){
            ret += a[x];
            x -= lowbit(x);
        }
        return ret;
    }
} tree;

LL b[MAX_N],s[MAX_N];
map<LL,int> mp;

int main()
{
    int n, m, x;
    scanf("%d%d",&n,&m);

    mp.clear();
    tree.clear(n);
    LL ans = 0LL;

    for (int i=1;i<=n;i++){
        scanf("%d",&x);
        s[i] = s[i - 1] + x - m;
        if (s[i] < 0) ans++;
        b[i] = s[i];
    }
    sort(b+1,b+n+1);

    for (int i=1;i<=n;i++)
       if (mp[b[i]] == 0) mp[b[i]] = i;

    for (int i=n;i>=1;i--){
        x = mp[s[i]];
        ans += tree.sum(x);
        tree.update(x+1);
    }
    printf("%lld\n",1LL * n * (n + 1) / 2 - ans);
}


Measured memory_bytes: 18816
from collections import defaultdict
v_num, e_num, source = (int(n) for n in input().split(" "))
conn = []
cost = [float("inf") for n in range(v_num)]
cost[source] = 0
for _ in range(e_num):
    s1, t1, weight = (int(n) for n in input().split(" "))
    conn.append([s1, t1, weight])

def bellman_ford(source, conn, v_num, cost):
    for i in range(v_num):
        for s, t, weight in conn:
            if cost[t] > cost[s] + weight:
                if i == v_num - 1:
                    return True
                cost[t] = cost[s] + weight
    return False

if bellman_ford(source, conn, v_num, cost):
    print("NEGATIVE CYCLE")
else:
    cost = ["INF" if n == float("inf") else n for n in cost]
    for c in cost:
        print(c)

Measured memory_bytes: 8636
#include <bits/stdc++.h>
using namespace std;
int solve(int i,int a[],vector<int> &dp,int n,int k)
{
  	int m=1e9;
	if(i>n-2)
		return 0;
  	if(dp[i]!=-1)
      	return dp[i];
	if(i==n-2)
	{
		return dp[i]=abs(a[n-1]-a[n-2]);
	}
  	for(int j=i+1; j<=i+k && j<n;j++)
  		m=min((abs(a[i]-a[j])+solve(j,a,dp,n,k)),m);
  	dp[i]=m;
  return m;
}
int main()
{
	int n;
	cin>>n;
	int a[n];
  	int k;
  	cin>>k;
	vector<int> dp(n,-1);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int m=solve(0,a,dp,n,k);
	cout<<m;
	return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<cstdio>
#define maxn 100005
using namespace std;
int a[100000 + 100];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int minx = 0;
	for (int i = 1;i <= m;i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		if (minx == 0)
			minx = x;
		if (minx > x)
			minx = x;
		int min = a[x];
		if (min == 0)
			a[x] = y;
		else if (min > y)
			a[x] = y;
	}
	int flag = 1;
	int k = a[minx];
	for (int i = 1;i <= n;i++)
	{
		if (a[i] == 0)
			continue;
		if (i >= k)
		{
			flag++;
			k = a[i];
		}
		else if (k > a[i])
			k = a[i];
	}
	printf("%d\n", flag);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

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

	ll lnum = 0, rnum = 0;

	REP(i, S.length()) {
		if (rnum >= 0 && S[i] == '(') rnum++;
		else if (rnum > 0 && S[i] == ')') rnum--;
	}
	REP(i, rnum) {
		S += ")";
	}
	IREP(i, S.length()) {
		if (lnum >= 0 && S[i] == ')') lnum++;
		else if (lnum > 0 && S[i] == '(') lnum--;
	}
	REP(i, lnum) {
		S = "(" + S;
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  V<char> ans;
  REP(i, s.size()) {
    if (s[i] == 'B') {
      if (ans.size() == 0) continue;
      else ans.pop_back();
    } else ans.push_back(s[i]);
  }
  REP(i, ans.size()) cout << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 52
#define MMAX 52

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};
char A[NMAX][MMAX];
int B,C,N,M,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};



void solve(){
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			if(A[i][j] == '#'){
				cout << '#';
			}else{
				int sum = 0;
				for (int k = 0; k < 8; ++k)
				{
					if(i+dx[k] >= 0 && i+dx[k] < N && j+dy[k] >= 0 && j+dy[k] < M){
						if(A[i+dx[k]][j+dy[k]] == '#'){
							sum++;
						}
					}
				}
				cout << sum;
			}
		}
		cout << "\n";
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			cin >> A[i][j];
		}
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll s,t,x[3],y[3],p,q;
	int i;
	x[0] = 0ll; y[0] = 0ll;
	cin >> s;
	t = ((ll)(1e18))-s;
	p = t / ((ll)(1e9));
	q = t % ((ll)(1e9));
	x[0] = 0ll; y[0] = 0ll;
	x[1] = ((ll)(1e9)) - p; y[2] = ((ll)(1e9));
	x[2] = 1ll; y[1] = q;
	for(i=0; i<3; ++i){
		cout << ((i)?" ":"") << x[i] << " " << y[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	int aa, bb;
	aa = bb = 0;
	for (int i = 0; i < b; i++) {
		aa += a * (int)pow(10, i);
	}
	for (int i = 0; i < a; i++) {
		bb += b * (int)pow(10, i);
	}
	if (to_string(aa) < to_string(bb)) {
		cout << aa << endl;
	}
	else {
		cout << bb << endl;
	}
}



Measured memory_bytes: 384
///***###                               بسم الله الرحمن الرحيم                            ###***///


/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 31 May,2020;
*/

///************************Start Of Template*************************///


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include <iomanip>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll=long long;
const int N=2e5+5;

int main()
{
    Read_Fast
    ll t;
    ll ans=1;
    int a=0;
    cin >>t;
    while (t--)
    {
        ll n;
        cin >>n;
        if (n==0 || ans==0)
        {
            a=0;
        }
        else if (n>1000000000000000000/ans)
        {
           a=1,ans=1;
        }
        ans=ans*n;
    }
    if (ans>1000000000000000000 || a==1)
    {
        cout << -1 << endl;
    }
    else
    {
        cout <<ans<< endl;
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int n; cin >> n;
  vector< pair<int, int> > job;
  rep(i,0,n-1) { int l, d; cin >> l >> d; job.emplace_back(d, d-l); }
  sort(job.begin(), job.end() );

  int cur=0;
  rep(i, 0,n-1) {
      if (cur <= job[i].second); else END("No");
      cur += job[i].first - job[i].second;
  }

  END("Yes");
}


Measured memory_bytes: 2420
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())

if S[2] == S[3] and S[4] == S[5]:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 5576
N = int(input()) - 1
rst = ''
for i in range(1, 10 ** 15):
    if N >= 26 ** i:
        N -= 26 ** i
        continue
    for j in range(i):
        rst += chr(ord('a') + N % 26)
        N //= 26
    print(rst[::-1])
    break

Measured memory_bytes: 9116
#include <stdio.h>

int calc(int x, int y, int z)
{
    int ans;
    
    ans = x*x + y*y + z*z + x*y + y*z + z*x;
    
    if(ans <= 10000)
      	return (ans);
    else
        return (0);
}

int	main(void)
{
  	int	n;
  	int x;
  	int y;
  	int z;
  	int	a[10002];
  	int	i;
  	int max;
  	int ans;
  	
  	max = 1000;
  	
  	scanf("%d", &n);
  
  	for(i=0; i<10001; i++)
  	{
  		a[i] = 0;
  	}
  
  	for(x=1; x<max; x++)
    {
        for(y=1; y<max; y++)
        {
            for(z=1; z<max; z++)
            {
                ans = calc(x,y,z);
                a[ ans ]++;
            }
        }
    }
  
    for(i=1; i<=n; i++)
      	printf("%d\n", a[i]);
  	
  	return (0);
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(ll, n, x);
	vec(int, a, n);
	sort(all(a));
	int cnt = 0;
	each(b, a) {
		if (x >= b)
			++cnt;
		x -= b;
	}
	if (x > 0)
		--cnt;
	print(cnt);
	return 0;
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    long long int A,B;

    cin>>A>>B;

    if((A+B)%2==0){
        cout<<(A+B)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [list(map(int,input().split())) for i in range(M)]
for i in range(M):
  PY[i].append(i)
  
PY.sort(key=lambda x:x[1])
pcount = {i:0 for i in range(1,N+1)}
ID = {i:"" for i in range(1,M+1)}

for i in range(M):
  pcount[PY[i][0]] += 1
  PY[i].append("{:0=6}".format(PY[i][0]) + "{:0=6}".format(pcount[PY[i][0]]))
PY.sort(key=lambda x:x[2])
for i in range(M):
  print(PY[i][3])

Measured memory_bytes: 58396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
int N;
int field = 0;
const int CARDS = 100;
const int MAX_PLAYERS = 10;
vector<int> Hand(CARDS);
vector<char> Draw(MAX_PLAYERS);
while (1) {
field = 0;
cin >> N;
if(N == 0) {
break;
}
Hand.clear();
Draw.clear();
vector<int>::iterator HandI = Hand.begin();
vector<char>::iterator DrawI = Draw.begin();
for(int i = 0; i < CARDS; i++) {
char card;
cin >> card;
Draw.push_back(card);
}
for (int i = 0; i < N; i++) {
Hand.push_back(0);
}
for (DrawI = Draw.begin(); DrawI != Draw.end(); ++DrawI) {
if (*DrawI == 'S') {
++*HandI;
field += *HandI;
*HandI = 0;
}
else if (*DrawI == 'L') {
++*HandI;
*HandI += field;
field = 0;
}
else {
++*HandI;
}
++HandI;
if(HandI == Hand.end()) {
HandI = Hand.begin();
}
}
sort (Hand.begin(), Hand.end());
for (HandI = Hand.begin(); HandI != Hand.end(); ++HandI) {
cout << *HandI << " ";
}
cout << field <<"\n";
}
return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int k; cin >> k;

	queue<ll> q;
	REP(i, 9) q.push(i + 1);

	ll num = 0;
	REP(i, k) {
		num = q.front();
		ll rem = num % 10;
		q.pop();
		if (rem != 0)
			q.push(10 * num + rem - 1);
		q.push(10 * num + rem);
		if (rem != 9)
			q.push(10 * num + rem + 1);
	}
	cout << num << '\n';
    return 0;
}


Measured memory_bytes: 4768
#include <stdio.h>
#define max 100
 
int arr[max][max];
int d[max],f[max];
int count = 0,n;
 
void dfs(int i){
 
  int j;
  count++;
  d[i] = count;
 
  for(j = 0 ; j < n ; j++){
    if(arr[i][j] != 0 && d[j] == 0)dfs(j);
  }
 
  count++;
  f[i] = count;
}
 
 
int main(){
  int i,j;
  int u,k,v;
 
  scanf("%d",&n);
 
  for(i  = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      arr[u-1][v-1] =1;
    }
  }
 
  for(i = 0 ; i < n ; i++)if(d[i] == 0)dfs(i);
 
  for(i = 0 ; i < n ; i++)printf("%d %d %d\n",i+1 , d[i] , f[i]);
  return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;


int main(){
   int A,B,C;
   cin >> A >> B >> C;
   cout << min(C, B/A) << endl; 
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n; cin >> n;
  int i,j,tmp,max=0;
  ll d[n]={0};
  ll ans = 1;
  ll MOD = 998244353;
  rep(i,n){
      cin >> tmp;
      if(i == 0 && tmp != 0){cout << 0 << endl;return 0;}
      d[tmp]++;
      if(tmp>max){max=tmp;}
  }

  if(d[0] != 1){cout << 0 << endl; return 0;}
  repd(i,1,max){
      if(d[i]==0 || d[i+1]==0){cout << 0 << endl;return 0;}
    rep(j,d[i+1]){ans *= d[i]; ans %= MOD;}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
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; }

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

  ll n, m;
  cin >> n >> m;
  vector<ll> p(m), y(m);
  rep(i, 0, m) cin >> p[i] >> y[i], p[i]--;

  vector<vector<ll>> ids(n);
  rep(i, 0, m) ids[p[i]].pb(y[i]);
  rep(i, 0, n) sort(all(ids[i]));

  rep(i, 0, m){
    int pp = p[i]+1;
    printf("%06d", pp);
    int id = lower_bound(all(ids[p[i]]), y[i]) - ids[p[i]].begin();
    printf("%.6d\n", id+1);
  }
  return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+7;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    int n;
    cin>>n;
    int a[N];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    ll ans=a[1];
    int pos=2;
    for(int i=2;i<n;i++)
    {
        if(i%2)
            ans+=a[pos++];
            else
                ans+=a[pos];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4364
import sys
import copy

N = int(input())
table = []
for i in range(N):
    A = [int(j) for j in input().split()]
    table.append(A)
tas = copy.deepcopy(table)
for k in range(N):
    for i in range(N):
        for j in range(N):
            tas[j][i] = min(tas[j][i], tas[j][k] + tas[k][i])

for y in range(N):
    for x in range(y+1, N):
        if table[y][x] != tas[y][x]:
            print(-1)
            sys.exit()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        flag = True
        for k in range(N):
            if i == k or j == k:
                continue
            if table[j][i] >= table[j][k] + table[k][i]:
                flag = False
        if flag:
            ans += table[j][i]
print(ans)





Measured memory_bytes: 58588
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;


int countmap[2][2000][2000];


int getScore(int i, int x, int y, int k) {
    if (x < 0 || y < 0 || x - k + 1 >= 2 * k || y - k + 1 >= 2 * k)
        return 0;

    int x1 = min(x - k, 2 * k - 1);
    int y1 = min(y, 2 * k - 1);

    int x2 = min(x, 2 * k - 1);
    int y2 = min(y - k, 2 * k - 1);

    int x3 = min(x - k, 2 * k - 1);
    int y3 = min(y - k, 2 * k - 1);

    x = min(x, 2 * k - 1);
    y = min(y, 2 * k - 1);

    int score = countmap[i][x][y];

    if (x1 >= 0 && y1 >= 0)
        score -= countmap[i][x1][y1];

    if (x2 >= 0 && y2 >= 0)
        score -= countmap[i][x2][y2];

    if (x3 >= 0 && y3 >= 0)
        score += countmap[i][x3][y3];

    return score;
}


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

    REP(i, n) {
        int xi, yi;
        string ci;
        cin >> xi >> yi >> ci;
        countmap[(ci[0] == 'W') ? 0 : 1][xi % (2 * k)][yi % (2 * k)]++;
    }

    REP(p, 2) REP(q, 2 * k) REP(r, 2 * k) {
        if (q > 0)
            countmap[p][q][r] += countmap[p][q - 1][r];
        if (r > 0)
            countmap[p][q][r] += countmap[p][q][r - 1];
        if (q > 0 && r > 0)
            countmap[p][q][r] -= countmap[p][q - 1][r - 1];
    }

    int best = 0;

    REP(p, 2 * k) REP(q, 2 * k) {
        int current = 0;

        int index = 0;
        REP(i, 5) REP(j, 5) {
            current += getScore(index, p - 2 * k + k * i, q - 2 * k + k * j, k);
            index ^= 1;
        }

        best = max(best,current);
    }
    
    cout << best << endl;
    
    return 0;
}


Measured memory_bytes: 31616
fun main(args: Array<String>) {
    readLine()!!
    val list = readLine()!!.split(" ").map(String::toInt)
    val ave = list.average()
    val pointMin = Math.ceil(ave).toInt()
    val pointMax = ave.toInt()
    val resultA = list.asSequence().map { it - pointMin }.map { it * it }.sum()
    val resultB = list.asSequence().map { it - pointMax }.map { it * it }.sum()
    println(Math.min(resultA, resultB))
}

Measured memory_bytes: 36004
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

const int H = 4;
const int W = 10;

int minoH[4], minoW[4];
char mino[4][4][5];

bool A[4][11];

set<ll> ss;

void gen(int now = 0, int use = 0) {

  if (use == now) gen(now+1, use);

  if (use >= 3) {
    ll bit = 0;

    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
        bit = (bit << 1) + A[i][j];

    assert(__builtin_popcountll(bit) == 4 * 3);
    ss.insert(bit);

    return;

  } else {
    for(int y=0; y+minoH[now]<=4; y++) {
      for(int x=0; x+minoW[now]<=10; x++) {
        bool ok = true;

        for(int i=0; i<minoH[now]; i++)
          for(int j=0; j<minoW[now]; j++)
            ok &= !A[y+i][x+j] || mino[now][i][j] == '.';

        if (!ok) continue;

        for(int i=0; i<minoH[now]; i++)
          for(int j=0; j<minoW[now]; j++)
            A[y+i][x+j] |= mino[now][i][j] == '#';

        gen(now+1, use+1);

        for(int i=0; i<minoH[now]; i++)
          for(int j=0; j<minoW[now]; j++)
            A[y+i][x+j] ^= mino[now][i][j] == '#';
      }
    }

  }
}

int main(){
  int N;
  char B[4][11];

  for(int i=0; i<4; i++) {
    scanf("%d%d", minoH+i, minoW+i);

    for(int j=0; j<minoH[i]; j++)
      scanf("%s", mino[i][j]);
  }

  gen();

  debug(ss.size());

  scanf("%d", &N);

  for(int i=0; i<N; i++) {
    ll bit = 0;
    for(int j=0; j<H; j++) {
      scanf("%s", B[j]);

      debug(B[j]);
      for(int k=0; k<W; k++)
        bit = (bit << 1) + (B[j][k] == '#');
    }


    bit ^= (1LL << (W * H)) - 1;

    if (ss.find(bit) != ss.end()) {
      puts("Yes");
    } else {
      puts("No");
    }
  }

  return 0;
}



Measured memory_bytes: 4104
# include <iostream>

using namespace std;

long long f(int n){
    if (n==1) return 1;
    if (n==2) return 2;
    return n*f(n-1);
}

int main(){
    int n;
    cin>>n;      
    cout<<f(n)<<endl;
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    ll N; cin >> N;
    ll dp[62][3]; REP(i,62)REP(j,3) dp[i][j] = 0;

    dp[0][0] = 1;
    REP(i,61){
        if((N>>(60-i)) & 1){
            (dp[i+1][0] += dp[i][0]) %= MOD;
            (dp[i+1][1] += dp[i][0]) %= MOD;
            (dp[i+1][1] += dp[i][1]) %= MOD;
            (dp[i+1][2] += dp[i][1]*2) %= MOD;
        }
        else{
            (dp[i+1][0] += dp[i][0]) %= MOD;
            (dp[i+1][0] += dp[i][1]) %= MOD;
            (dp[i+1][1] += dp[i][1]) %= MOD;
            (dp[i+1][2] += dp[i][1]) %= MOD;
        }
        (dp[i+1][2] += dp[i][2]*3) %= MOD;
    }

    int ans = 0; REP(i,3) (ans += dp[61][i]) %= MOD;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3652
#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;
 

int main() {
  int N,Q;
  cin>>N>>Q;
  string s;
  cin >> s;
  vector<int>l(Q),r(Q);
  rep(i,Q) {    
    cin >> l.at(i)>>r.at(i);
    l.at(i)--;
    r.at(i)--;
  }
  int d=0;
  vector<int>data(N);
  data.at(0)=0;
  rep2(i,1,N){
    if(s.at(i-1)=='A'&&s.at(i)=='C'){
      d++;
    }
      data.at(i)=d;    
  }
      
  rep(i,Q) {    
    cout<<data.at(r.at(i))-data.at(l.at(i))<<endl;
  }
}

Measured memory_bytes: 2176
unittest
{
	assert( [ "4", "1 -3 1 0" ].parse.expand.solve == 4 );
	assert( [ "5", "3 -6 4 -5 7" ].parse.expand.solve == 0 );
	assert( [ "6", "-1 4 3 2 -5 4" ].parse.expand.solve == 8 );
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ps = 0L;
	auto pd = 0L;
	auto ms = 0L;
	auto md = 0L;
	
	foreach( i, a; as )
	{
		ps += a;
		ms += a;
		if( i % 2 == 0 )
		{
			if( ps <= 0 ) pd -= ps - 1, ps -= ps - 1;
			if( 0 <= ms ) md += ms + 1, ms -= ms + 1;
		}
		else
		{
			if( 0 <= ps ) pd += ps + 1, ps -= ps + 1;
			if( ms <= 0 ) md -= ms - 1, ms -= ms - 1;
		}
	}
	
	return min( pd, md );
}


Measured memory_bytes: 6660
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>

using namespace std;


int main() {
	int N, L;

	cin >> N >> L;

	int min = 99999, tmp;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		if (min > L + i - 1) {
			min = abs(L + i - 1);
			tmp = L + i - 1;
		}

		sum += L + i - 1;
	}

	cout << sum - tmp << endl;


	/*
	string s;
	cin >> s;

	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
	*/

	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FManySlimes {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        multiset<int> S;
        REP(i, 1<<N){
            int s;
            in>>s;
            S.insert(s);
        }
        vc<int> vec = {*S.rbegin()}, r;
        S.erase(prev(S.end()));
        REP(i, N){
            for(auto& v : vec){
                auto itr = S.lower_bound(v);
                if(itr==S.begin()){
                    out<<"No\n";
                    return;
                }
                --itr;
                r.pb(*itr);
                S.erase(itr);
            }
            for(auto& rr : r) vec.pb(rr);
            r.clear();
        }
        out<<"Yes\n";
    }
};


int main() {
	FManySlimes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    string S; cin >> S;
    int T = S.size();
    vector<int> rights,rightl, lefts,leftl;
    vector<int> res(T,0);
    bool state = 0;
    rights.push_back(0);
    for(int i = 0; i < S.size(); i++){
        if(state == 0){
            if(S[i] == 'L'){
                rightl.push_back(i-1);
                lefts.push_back(i);
                state = 1;
            }
        }else{
            if(S[i] =='R'){
                leftl.push_back(i-1);
                rights.push_back(i);
                state = 0;
            }
        }
    }
    leftl.push_back(S.size()-1);
    int N = rights.size();
    for(int i = 0; i < N; i++){
        res[rightl[i]] += (rightl[i] - rights[i] + 2)/2 + (leftl[i] - lefts[i]+1)/2;
        res[lefts[i]] += (rightl[i] - rights[i] + 1)/2 + (leftl[i] - lefts[i]+2)/2;
    }
    for(int i = 0; i < T; i++){
        if(i != 0) cout << " ";
        cout << res[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2004
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;


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


int main(){
  double T,X;
  cin >> T >> X;
  double b;
  b = T / X;
  cout << b << endl;
}


Measured memory_bytes: 256
def main():
    A, B, C, D = input()
    for i in range(2**3):
        op = ['+', '+', '+']
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break
if __name__  == '__main__':
    main()

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

int main()
{
    int a, b, c, m, ans;
    cin >> a >> b >> c;
    m = max(a, max(b,c));
    if((3*m-a-b-c)%2){
        ans = ((m+1)*3 - a -b -c)/2;
    }else{
        ans = (m*3 - a -b -c)/2;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int m,n,a;
    cin>>n>>m;
    for(int i = 0 ; i< m; i++)
    {
        cin>>a;
        n = n - a;
    }
    if(n<0)
    {
        n= - 1;
    }
    cout<<n<<endl;
}


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

using namespace std;


#define ll              long long
#define pb              push_back
#define nn           cout << "\n";



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t,a,b,i,j,c,d,e,f,n,k,m,w;

    
      
    cin>>n>>k;
    
      int dp[n+5],ht[n+5];
      
    for(i=1;i<=n;i++)
    {
        cin>>a;
        ht[i]=a;

    }
  memset(dp,0,sizeof(dp));
    dp[n]=0;
    for(i=n-1;i>=1;i--)
    {
        dp[i]=INT32_MAX;
        for(j=1;j<=k&&(i+j)<=n;j++)
        {


        dp[i]=min(dp[i],(dp[i+j]+abs(ht[i]-ht[i+j])));
        }
    }

    cout<<dp[1]<<endl;
    return 0;
}


Measured memory_bytes: 4392
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
process.stdin.on('data', function(input){
    input.trim().split('\n').forEach(function(val){
        var N = parseInt(val);
        if( N === 1 ){
            console.log(0);
        }
        else if(N===2){
            console.log(1);
        }
        else{
            var prime = new Array(N);
            var sq, i, j, found, cnt;
            sq = Math.sqrt(N);
            cnt = 1;
            prime[0] = 2;
            
            for(i=3;i<=N;i+=2){
                found = 1;
                for(j=0;prime[j]<=sq;++j){
                    if( i % prime[j] === 0 ){
                        found = 0;
                        break;
                    }
                }
                if( found ){
                    prime[cnt++] = i;
                }
            }
            console.log(cnt);
        }
    });
});

Measured memory_bytes: 27048
#include <cstdio>

using namespace std;

char s[59];

int main() {
  int n;
  scanf("%d%s", &n, s);
  int ans = 0;
  for (int i = 0; i <= n - 3; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      ++ans;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	string st;
	cin >> st;
	if (st.size() & 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < st.size(); i += 2) {
		if (st[i] != 'h' || st[i + 1] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll unsigned long long
#define mx 10000256
using namespace std;
ll a[mx];
int main()
{
    ll n, res = 0, cnt, nod = 1;
    scanf("%llu", &n);
    for(int i = 2; i <= n; i++)
    {
        for(int j = i; j <= n; j+=i)
        {
            a[j]++;
        }
    }
    a[1] = 0;
    for(int i = 1; i <= n; i++)
    {
        res += ((a[i]+1)*i);
    }
    cout<<res<<endl;
}



Measured memory_bytes: 81760
<?php

$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$hs = [];
foreach ($input as $v) {
	$hs[] = (int)$v;
}
$max = 0;
$cnt = 0;
foreach ($hs as $h) {
	$max = max($h, $max);
	if ($h >= $max) {
		++$cnt;
	}
}
echo $cnt;

Measured memory_bytes: 4728
#include <stdio.h>

char map[105][105];

int main() {

	int A,B;

	scanf("%d %d",&A,&B);

	A--;
	B--;

	int i,j;

	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			if(i>=50){
				map[i][j]='#';
			}
			else{
				map[i][j]='.';
			}
		}
	}

	for(i=99;i>=0;i-=2){
		for(j=0;j<100;j+=2){
			if(A==0){break;}
			map[i][j]='.';
			A--;
			if(A==0){break;}
		}
		if(A==0){break;}
	}

	for(i=0;i<100;i+=2){
		for(j=0;j<100;j+=2){
			if(B==0){break;}
			map[i][j]='#';
			B--;
			if(B==0){break;}
		}
		if(B==0){break;}
	}
	printf("100 100\n");

	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			printf("%c",map[i][j]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 128
N = int(input())
H = list(reversed(list(map(int, input().split(' ')))))

for i in range(1, N):
    if H[i - 1] < H[i]:
        H[i] -= 1

    if H[i - 1] < H[i]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 15020
import math

def a():
    h1, m1, h2, m2, k = map(int, input().split())
    t1 = h1 * 60 + m1
    t2 = h2 * 60 + m2

    if t1 < t2:
        print(t2 - t1 - k)
    else:
        print(1440 - (t1 - t2) - k)


def b():
    print('')



def c():
    print('')



def d():
    print('')


a()

Measured memory_bytes: 9212
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N; cin >> N&&N;) {
		vector<int> taro(N); rep(i, 0, N) { cin >> taro[i]; }
		vector<int> hana;
		rep(i, 1, 2 * N + 1) {
			if (count(all(taro), i))continue;
			hana.emplace_back(i);
		}
		sort(all(taro));
		sort(all(hana));
		int prev = 1;
		while (taro.size() && hana.size()) {
			dump(taro);
			dump(hana);
			int cur = 0;
			bool flag = true;
			if (prev == 0) {
				auto h = upper_bound(all(hana), cur);
				if (h != hana.end()) {
					cur = *h;
					hana.erase(h);
					flag = true;
					prev = 1;
				}
			}
			while (flag) {
				flag = false;
				auto t = upper_bound(all(taro), cur);
				if (t == taro.end()) {
					prev = 0;
					break;
				}
				else {
					cur = *t;
					taro.erase(t);
					flag = true;
				}
				auto h = upper_bound(all(hana), cur);
				if (h == hana.end()) {
					prev = 1;
					break;
				}
				else {
					cur = *h;
					hana.erase(h);
					flag = true;
				}
			}
		}
		cout << hana.size() << endl;
		cout << taro.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
n, k = map(int, input().split())
import numpy
res = numpy.cumsum(range(n+2))
s=0
for i in range(k, n+2):
	s += (res[n+1] - res[n+1-i] - res[i] +1)%(10**9 +7)
print(s%(10**9 +7))

Measured memory_bytes: 36312
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int sum = 0;
    int n = sc.nextInt();
    int[] a = new int[n-1];
    int[] b = new int[n];
    for(int i = 0;i < n-1; i++){
      a[i] = sc.nextInt();
      if(i == 0){
        b[i] = a[i];
        b[i+1] = a[i];        
      }else if(a[i] > a[i-1]){
        b[i+1] = a[i];
      }else{
        b[i] = a[i];
        b[i+1] = a[i];
      }
    }
    for(int i =0;i<n;i++){
      sum += b[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(a[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if a.count(x) == a.count(y) == a.count(z):
        if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)

Measured memory_bytes: 14212