akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define LD long double
#define FOR(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define RFOR(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define int LL
using namespace std;

const int MX = 1e5+1;
bool vis[MX];

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int a[n],b[n];
    FOR(i,0,n-1)
        cin>>a[i]>>b[i];
        
    pair<int,int> p[n];
    FOR(i,0,n-1)
        p[i] = MP(a[i] + b[i],i);
    
    sort(p,p+n);
    
    
    for(int i=n-1;i>=0;i-=2)
       vis[p[i].S] = true;
        
    int ans = 0;
    
    FOR(i,0,n-1)
        if(vis[i])
            ans += a[i];
        else
            ans -= b[i];
            
     cout<<ans;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 998244353;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
 ios::sync_with_stdio(false);
 
 ll n,m;
 cin>>n>>m;
 ll k;
 cin>>k;

ll a[n+1];
ll b[m+1];
rep(i,n){
	cin>>a[i];
}
rep(i,m){
	cin>>b[i];
}

a[0]=0;
b[0]=0;
for(int i=2;i<=n;i++){
a[i]=a[i-1]+a[i];
}
for(int i=2;i<=m;i++){
b[i]=b[i-1]+b[i];
}

ll ans=0;

for(int i=0;i<=n;i++){
	ll val=a[i];
	val=k-val;

ll left=0;
ll right=m;
ll half;
	for(int j=1;j<=50;j++){
		half=(left+right)/2;
		if(b[half]<=val){
			left=half;
		}
		else right=half;
	}
	if(half!=m){
		if(b[half+1]<=val)half++;
	}
if(val>=0){
ans=max(ans,i+half);}
}

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




Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int N;
  cin >> N;
  vint V(N);
  cin >> V;
  
  sort(V.begin(),V.end(),greater<int>());
  stack<double> st;
  for(auto v : V){
    st.push((double)v);
  }
  
  while(st.size() != 1){
    double a = st.top();
    st.pop();
    double b = st.top();
    st.pop();
    st.push((a+b)/2.0);
  }
  
  cout << st.top() << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
//it gives the lexicographically smallest string//


void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
 ll n,sum=0;
 cin>>n;
 map<ll,ll> m;
 for(int i=0;i<n;i++)
 {
  ll x;
  cin>>x;
  sum+=x;
  m[x]++;
 }
 ll q;
 cin>>q;
 while(q--)
 {
  ll x,y;
  cin>>x>>y;
  if(m.find(x)!=m.end())
  {
    sum+=m[x]*(y-x);
    m[y]+=m[x];
    m[x]=0;
  }
  cout<<sum<<endl;
 }
  }
}

int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
  solve();
  return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() > k){
		rep(i,k){
			cout << s[i];
		}
		cout << "..." << endl;
	}
	else {
		cout << s << endl;
	}
}


Measured memory_bytes: 3628
N,*A = $<.read.split.map! &:to_i
b,M,X = 1,(1<<27)-1,1<<64
(N+1).times {|n|
  exit 0&p(-1)  if 0 > (b -= a=A[n])
  b = X-1  if b >= X
  A[n] = (b<<27)+a
  b += b
}
v=c = M&A[N]
(N-1).downto(0) {|n|
  a,b = M&A[n], A[n]>>27
  v += c = a + [b,c].min
}
p v

Measured memory_bytes: 23236
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	ll a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;

	if(e-a<=k && d-a<=k && c-a<=k && b-a<=k){
		cout<<"Yay!"<<endl;
	}
	else{
		cout<<":("<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	if a > b || (n == 1 && b-a > 1) {
		fmt.Println(0)
		return
	}

	min := a*(n-1) + b
	max := a + b*(n-1)
	fmt.Println(max - min + 1)
}


Measured memory_bytes: 512
/**
 *    author:  tourist
 *    created: 29.12.2019 22:14:41       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> cnt(26, 123);
  for (int i = 0; i < n; i++) {
    string y;
    cin >> y;
    vector<int> z(26, 0);
    for (char c : y) z[c - 'a'] += 1;
    for (int j = 0; j < 26; j++) cnt[j] = min(cnt[j], z[j]);
  }
  for (int j = 0; j < 26; j++) for (int i = 0; i < cnt[j]; i++) cout << (char) ('a' + j);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007

ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for (ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    map<long,long> A;
    vector<long> a(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> a[i];
        A[a[i]]++;
    }

    ll total_counter = 0;
    long comb;
    for(auto itr = A.begin(); itr != A.end(); ++itr) {
        if(itr->second < 2)
        {
            comb = 0;
        }
        else
        {
            comb = combination(itr->second, 2);
        }
        total_counter += comb;
    }
    for(size_t i=0;i<a.size(); i++)
    {
        cout << total_counter - (A[a[i]] - 1) << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 11136
from itertools import groupby, accumulate, product, permutations, combinations
from collections import Counter
def solve():
    N = int(input())
    dics = [[0]*N for _ in range(26)]
    S = [input() for _ in range(N)]
    for i in range(N):
        for s in S[i]:
            dics[ord(s)-ord('a')][i]+=1
    ans = ''
    for i in range(26):
        ans += chr(i+ord('a'))*min(dics[i])
    return ans
print(solve())


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] strings = line.split(" ");
		int a = Integer.parseInt(strings[0]);
		int b = Integer.parseInt(strings[1]);
		System.out.println(a * b + " " + 2 * (a + b));
	}

}

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

int main() {
	int a,b;
    cin >> a >> b;
    if(a+b==15){
      cout << "+" << endl;
    }
    else if(a*b==15){
      cout << "*" << endl;
    }
    else{
      cout << "x" << endl;
    }
}


Measured memory_bytes: 256
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

LL gcd(LL x, LL y){
	while(y){
		LL r = x % y;
		x = y;
		y = r;
	}
	return x;
}

LL solve(){
	int n;
	LL m;
	scanf("%d%lld", &n, &m);
	vector<LL> as(n);
	for(int i = 0; i < n; ++i){
		LL t;
		scanf("%lld", &t);
		as[i] = t / 2;
	}

	LL l = 1;
	for(LL a : as){
		l *= a / gcd(l, a);
		if(l > m){ return 0; }
	}
	for(LL a : as){
		if((l / a) % 2 == 0){ return 0; }
	}
	return (m / l + 1) / 2;
}

void mainmain(){
	printf("%lld\n", solve());
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    float t, a;
    cin >> t >> a;
    vector<int> h = vector<int>(n);
    float mind = 1000;
    int mini = -1;
    for (int i = 0; i < n; i++) {
        float hh;
        cin >> hh;
        float d = (t - hh * 0.006) - a;
        if (d < 0) {
            d *= -1;
        }
        if (d < mind) {
            mind = d;
            mini = i + 1;
        }
    }
    cout << mini << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int x,y;
    cin>>x>>y;
    if (x>0&&y>0) cout<<"Positive";
    else if (max(x,y)>=0&&min(x,y)<=0||x==0||y==0) cout<<"Zero";
    else 
    {
        if ((abs(min(x,y))-abs(max(x,y)))%2==0) 
        cout<<"Negative";
        else cout<<"Positive";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import math

a, b, c = map(float, sys.stdin.readline().split())
radian = c*math.pi / 180

height = abs(b * math.sin(radian))
pos_x = b * math.cos(radian)
edge_x = (height**2 + (pos_x-a)**2) ** 0.5

print(round(a * height / 2, 6))
print(round(a + b + edge_x, 6))
print(round(height, 6))



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

int main() {
  int a, b, X;
  cin >> a >> b;
  X = a * b % 2;
  if (X == 1) {
  cout << "Odd" << endl;
  }
  else {
  cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;
    
    int n = s.length();
    bool ok = true;

    for(int i = 0; i < n; i++) {
        if (s[i] != s[n-1-i]) ok = false;    
    }
    for(int i = 0; i < (n-1)/2; i++) {
        if (s[i] != s[(n-1)/2-1-i]) ok = false;    
    }
    for(int i = (n-1)/2; i < n; i++) {
        if (s[i] != s[n-1-i]) ok = false;    
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j) 
			cin >> a[i][j];
	}
	ll res = (1LL << 60);
	for (int f = 1; f < (1 << n); ++f) {
		ll cost = 0;
		vector<int> us(m, 0);
		for (int i = 0; i < n; ++i) {
			if (f & (1 << i)) {
				cost += c[i];
				for (int j = 0; j < m; ++j)
					us[j] += a[i][j];
			}
		}
		bool ok = true;
		for (int j = 0; j < m; ++j)
			ok &= us[j] >= x;
		if (ok) res = min(res, cost);
	}
	if (res == (1LL << 60)) cout << -1 << endl;
	else cout << res << endl;
	return 0;
}

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

int main() {
    int n;
    set<string> S;
    string item;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> item;
        S.insert(item);
    }

    cout << S.size() << endl;

}


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

int main(){
  string s, t; cin >> s >> t;
  bool ok = true;
  for (volatile int i = 0; i < (int)s.size(); ++i) if (s[i] != t[i]) ok = false;
  cout << (ok?"Yes":"No");
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<chrono>
#include<ctime>

#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define f(x) for(int i = 0; i < x; ++i)
#define MOD (1e9 + 7)

using namespace std;
using namespace chrono;

int main(){
    ios::sync_with_stdio(0);

    int n, tot = 0, cont = 0;

    cin >> n;

    vi v(n);

    f(n){
        cin >> v[i];
        tot += v[i];
    } 

    sort(all(v));

    cout << v[n/2] - v[n/2 -1] << endl;

    return 0;
}


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

int main(){

for (int i =1; i < 10; i++){
 for (int i2 = 1; i2 < 10; i2++){
  
 cout << i << "x" << i2 << "=" << i * i2 << endl;
 }
}
    return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

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

class modInt{
    ll value;
    static const ll mod = 998244353;

public:
    modInt(ll x=0): value{x % mod}{}

    inline modInt& operator+=(modInt x){
        value = (value + x.value) % mod;
        return *this;
    }

    inline modInt& operator-=(modInt x){
        value = (value + mod - x.value) % mod;
        return *this;
    }

    inline modInt& operator*=(modInt x){
        value = (value * x.value) % mod;
        return *this;
    }


    inline modInt operator/=(modInt x){
        *this *= x.inv();
        return *this;
    }

    inline modInt pow(ll n){
        modInt res = modInt(1LL);
        modInt x{value};
        while(n > 0){
            if(n & 1)   res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    inline modInt inv(){
        modInt res = pow(mod-2);
        return res;
    }

    inline ll get(){
        return value;
    }
};

modInt operator+(modInt x, modInt y){
    return x += y;
}

modInt operator-(modInt x, modInt y){
    return x -= y;
}

modInt operator*(modInt x, modInt y){
    return x *= y;
}

modInt operator/(modInt x, modInt y){
    return x /= y;
}

ostream& operator<<(ostream& os, modInt x){
    return os << x.get();
}


class modIntCombinations{
    vector<modInt> factArray;

    void make_fact(ll x){
        for(auto i = factArray.size(); i <= x+1; i++){
            modInt y = factArray[i-1] * i;
            factArray.push_back(y);
        }
    }

public:
    modIntCombinations(){
        factArray.emplace_back(1);
    }

    modInt fact(ll x){
        if(factArray.size() < x+1){
            make_fact(x);
        }
        return factArray[x];
    }

    modInt comb(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k) / fact(n - k);
        }
    }

    modInt perm(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k);
        }
    }
};


int main(){
    int n;  cin >> n;
    int res = INT32_MAX;
    for(int i = 1; i < n; i++){
        int a = i;
        int b = n - a;
        int resTmp = 0;
        while(a > 0){
            resTmp += a % 10;
            a /= 10;
        }
        while(b > 0){
            resTmp += b % 10;
            b /= 10;
        }
        res = min(res, resTmp);
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 384
from heapq import heappush,heappop
x,y,z = map(int,input().split())
n = x+y+z
abc = [list(map(int,input().split())) for i in range(n)]
abc.sort(key = lambda t:t[0]-t[1],reverse=True)
xls = []
ansx = 0
for i in range(x):
  a,b,c = abc[i]
  heappush(xls,(a-c,i))
  ansx += a
yls = []
ansy = 0
for i in range(n-y,n):
  a,b,c = abc[i]
  heappush(yls,(b-c,i))
  ansy += b
ansls = [[0 for i in range(2)] for j in range(z+1)]
ansls[0][0] = ansx
ansls[-1][1] = ansy
for d,ls,w,ans in (0,xls,range(x,x+z),ansx),(1,yls,(range(n-y-1,x-1,-1)),ansy):
  for i in w:
    a,b,c = abc[i]
    if d == 0:
      heappush(ls,(a-c,i))
    else:
      heappush(ls,(b-c,i))
    p,q = heappop(ls)
    ans += -p
    if d == 0:
      ans += a
      ansls[i-x+1][0] = ans
    else:
      ans += b
      ansls[i-n+y+z][1] = ans
print(max([sum(ansls[i]) for i in range(z+1)]))

Measured memory_bytes: 92556
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define input(x) ll x; cin >> x;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  input(n);
  int cnt = 0;
  rep(i,n) {
    input(p); p--;
    if (p != i) cnt++;
  }
  if (cnt==0 || cnt==2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

const int MAXN = 3e5 + 10;

int a[MAXN];
int n;
long long ans;

int main() {
    cin >> n;
    for (int i = 0; i < 3 * n; i++)
        cin >> a[i];
    sort(a, a + 3 * n, greater<int>());
  	for (int i = 1; i < 2 * n; i += 2)
        ans += a[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
string L="ABCDEFGHIJKLMNOPQRSTUVWXYZ",A=" ',-.?"+L,C=L+" .,-'?";
string B = "101 000000 000011 10010001 010001 000001 100101 10011010 "
	"0101 0001 110 01001 10011011 010000 0111 10011000 "
	"0110 00100 10011001 10011110 00101 111 10011111 1000 "
	"00110 00111 10011100 10011101 000010 10010010 10010011 10010000";
int bin2dec(string s){
	int x=0,i;
	for(i=0;i<s.size();i++)x=x*2+s[i]-'0';
	return x;
}
int main(){
	vector<string>x(32);
	stringstream ss(B);
	string s,s1;
	int i,n;
	for(i=0;i<32;i++){
		ss>>s;
		x[i]=s;
	}
	while(getline(cin,s)){
		s1="";
		for(i=0;i<s.size();i++)s1+=x[A.find(s[i])];
		n=s1.size()%5;
		if(n)s1+=string(5-n,'0');
		s="";
		for(i=0;i<s1.size();i+=5)s+=C[bin2dec(s1.substr(i, 5))];
		cout<<s<< endl;
	}
}

Measured memory_bytes: 1212
class SegTree:
    
    def __init__(self, A, intv, initialize = True):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.dep = self.N0.bit_length()
        if initialize:
            self.data = [intv]*(self.N0-1) + A + [intv]*(self.N0 - self.N + 1)
            for i in range(self.N0-2, -1, -1):
                self.data[i] = max(self.data[2*i+1], self.data[2*i+2]) 
        else:
            self.data = [intv]*(2*self.N0)
    
    def segf(self, a, b):
        return max(a, b)
    
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        for _ in range(self.dep - 1):
            k = (k-1)//2
            self.data[k] = max(self.data[2*k+1], self.data[2*k+2])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = max(s, self.data[R-1])
            if L & 1:
                
                s = max(s, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s

N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = SegTree([0]*(max(H)+1), 0, False)

for h, a in zip(H, A):
    dp.update(h, a+dp.query(0, h))
print(dp.data[0])


Measured memory_bytes: 121040
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
int n;
int main()
{
	bool tf=false;
	int n;
	scanf("%d",&n);
	for (int u=1;u<=n;u++)
	{
		int x;
		scanf("%d",&x);
		tf|=(x&1);
	}
	if (tf) printf("first\n");
	else printf("second\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;

int main(){
	int N;
	cin >> N;
	char s[N], t[N];
	for(int i=0; i<N; i++){
		cin >> s[i];
	}
	for(int i=0; i<N; i++){
		cin >> t[i];
	}
	for(int i=0; i<2*N; i++){
		if(i%2==0) cout << s[i/2];
		else cout << t[i/2];
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
bool mem[12][12],cop[12][12],done[12][12];

int main(){
  int n;cin>>n;
  while(n--){
    lol(i,10)lol(j,10)cin>>mem[i][j];
    bool flag[10],tmp[10]={0};
    for(int p=1;p<=1024;p++){
      lol(i,10)flag[i]=tmp[i];
      lol(i,10)lol(j,10)cop[i][j]=mem[i][j];
      for(int k=0;k<10;k++){
	lol(i,10){
	  if(!flag[i])continue;
	  for(int j=max(0,i-1);j<=min(9,i+1);j++)cop[k][j]^=1;
	  cop[k+1][i]^=1;
	}
	lol(i,10)done[k][i]=flag[i];
	lol(i,10)flag[i]=cop[k][i];
      }
      bool na=false;
      lol(i,10)na|=flag[i];
      if(!na){
	lol(i,10){
	  lol(j,10){
	    if(j)cout<<" ";
	    cout<<done[i][j];
	  }
	  cout<<endl;
	}
	break;
      }
      for(int i=0;i<10;i++){
	int r=pow(2,i);
	if(p%r==0)tmp[i]^=1;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main(void) {
    int64_t N, x;
    cin >> N >> x;
    vector<int64_t> a(N+1);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    vector<int64_t> s(N);
    for(int i=0; i<N; i++) {
        s[i] = max(a[i] + a[i+1] - x, 0L);
    }

    int64_t ans = 0;
    for(int i=0; i<N; i++) {
        ans += s[i];
        s[i+1] = max(s[i+1] - s[i], 0L);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
from sys import stdin
input = stdin.readline
s = input().rstrip()
for i in range(len(s)):
	if i <= len(s)-2 and s[i] == s[i+1]:
		print(i+1, i+2)
		break
	elif i <= len(s)-3 and s[i] == s[i+2]:
		print(i+1, i+3)
		break
else:
	print(-1, -1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<cstring>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int           long long
#define umapii        unordered_map<int,int>
#define ps(x,y)       fixed<<setprecision(y)<<x // sets precision upto required digits
#define arr(a,n)      int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define outarr(a,n)   for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define mod           1000000007
#define ff            first
#define big           1e15
#define ss            second
#define add           push_back
#define remove        pop_back
#define mapii         map<int,int>
#define large         *max_element
#define small         *min_element
#define float         double
#define pqi           priority_queue<int>
#define mpqi          priority_queue<int,vector<int>,greater<int>>
#define in(n)         int n;cin>>n;
#define w(t)          int t;cin>>t;while(t--)
#define vi            vector<int>
#define vivi          vector<vector<int>>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;


int getprice(vivi a, int n, int m, int i, int x) {
    int k = 0;
    int price = 0;
    vi temp(m, 0);
    while (i > 0) {
        if (i & 1) {
            price += a[k][0];
            for (int j = 1; j <= m; j++) {
                temp[j - 1] += a[k][j];
            }
        }
        i = i >> 1;
        k++;
    }
    bool flag = true;
    for (int i = 0; i < temp.size(); i++) {
        if (temp[i] < x) {
            flag = false;
            break;
        }
    }
    if (flag == false) {
        return -1;
    }
    return price;
}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output3.txt", "w", stdout);
#endif

    in(n); in(m); in(x);
    vivi v(n, vi(m + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= m; j++) {
            cin >> v[i][j];
        }
    }
    int ans = INT_MAX;
    for (int i = 1; i < (1 << n); i++) {
        int price = getprice(v, n, m , i, x);
        if (price != -1) {
            ans = min(ans, price);
        }
    }
    if (ans == INT_MAX) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }


}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int digit = log10(N) + 1;

  if (digit % 2 != 0) {
    int a = pow(10, digit-1);
    sum += N - a;
    sum++;
  }
  digit--;

  while (digit>0) {
  	if (digit % 2 != 0) {
	  sum += pow(10, digit) - pow(10, digit-1);
    }
    digit--;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
long long nn;
long long kaik[2000000];
long long j(long long a){
    return (a*a)%nn;
}
long long rui(long long a,long long b){
    if(b==0)return 1;
    if(b==1)return a%nn;
    if(b>1){
        if(b%2==0)return j(rui(a,b/2));
        if(b%2==1)return (j(rui(a,(b-1)/2))*a)%nn;
    }
}
long long c(long long n,long long m){
    long long x;
    x=(kaik[n-m]*kaik[m])%nn;
    long long y;
    y=(kaik[n]*rui(x,nn-2))%nn;
    return y;
}

int main(void){
    long long i,j,k,x,y,z,n,m,w;
    nn=1000000007;
    kaik[0]=1;
    for(i=1;i<2000000;i++){
        kaik[i]=(kaik[i-1]*i)%nn;
    }
    scanf("%lld",&n);
    x=(kaik[n-1]*(n-1))%nn;
    m=(n-2)/2;
    for(i=1;i<=m;i++){
        z=(c(n-i-2,n-2*i-2)*kaik[n-1-i])%nn;
        w=(z*kaik[i])%nn;
        x-=w;
        if(x<0)x+=nn;
    }
    printf("%lld\n",x);
}

Measured memory_bytes: 15872
w,h,n=map(int,input().split())
p,q=[0,w],[0,h]
for _ in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    p[0]=max(p[0],x)
  elif a==2:
    p[1]=min(p[1],x)
  elif a==3:
    q[0]=max(q[0],y)
  else:
    q[1]=min(q[1],y)
s=(p[1]-p[0])*(q[1]-q[0])
print(s if p[0]<=p[1] and q[0]<=q[1] else 0)

Measured memory_bytes: 3064
import sys
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
origin = sum(A)
heapq.heapify(A)

BC = [list(map(int, input().split())) for _ in range(M)]
BC = sorted(BC, reverse=True, key=lambda x: x[1])

count = 0

for i in range(M):
    b = BC[i][0]
    c = BC[i][1]
    for _ in range(b):
        smallest = heapq.heappop(A)
        tmp = c - smallest
        if tmp <= 0:
            heapq.heappush(A, smallest)
            break
        else:
            heapq.heappush(A, c)
            origin += tmp
            count += 1
            if count >= N:
                print(origin)
                sys.exit()

print(origin)


Measured memory_bytes: 100760
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
class FC{
public:
    int p[31];
    int n;
    bool is_over(){
        return p[1]==p[2]&&p[2]==p[3]&&p[3]==p[4]&&p[4]==p[5]&&
            p[5]==p[6]&&p[6]==p[7]&&p[7]==p[8]&&p[8]==p[9]&&
            p[10]==p[11]&&p[11]==p[12]&&
            p[13]==p[14]&&p[14]==p[15]&&
            p[16]==p[17]&&p[17]==p[18]&&
            p[19]==p[20]&&p[20]==p[21]&&
            p[22]==p[23]&&p[23]==p[24]&&p[24]==p[25]&&p[25]==p[26]&&
            p[26]==p[27]&&p[27]==p[28]&&p[28]==p[29]&&p[29]==p[30];
    }
    void rot1(){
        swap(p[7],p[22]);
        swap(p[8],p[23]);
        swap(p[9],p[24]);
        swap(p[13],p[18]);
        swap(p[10],p[12]);
    }
    void rot2(){
        swap(p[1],p[28]);
        swap(p[2],p[29]);
        swap(p[3],p[30]);
        swap(p[15],p[16]);
        swap(p[19],p[21]);
    }
    void rot3(){
        swap(p[1],p[24]);
        swap(p[4],p[27]);
        swap(p[7],p[30]);
        swap(p[10],p[21]);
        swap(p[16],p[18]);
    }
    void rot4(){
        swap(p[3],p[22]);
        swap(p[6],p[25]);
        swap(p[9],p[28]);
        swap(p[12],p[19]);
        swap(p[13],p[15]);
    }
};
int main(){
    int N;
    cin>>N;
    for(int i=0; i<N; i++){
        FC now;
        for(int j=1; j<=30; j++){
            cin>>now.p[j];
        }
        now.n=0;

        queue<FC> que;
        que.push(now);
        while(!que.empty()){
            now=que.front();
            que.pop();
            if(now.is_over()){
                cout<<now.n<<endl;
                break;
            }
            FC nex1=now; nex1.rot1(); nex1.n++; que.push(nex1);
            FC nex2=now; nex2.rot2(); nex2.n++; que.push(nex2);
            FC nex3=now; nex3.rot3(); nex3.n++; que.push(nex3);
            FC nex4=now; nex4.rot4(); nex4.n++; que.push(nex4);
        }
    }
    return 0;
}



Measured memory_bytes: 13884
import itertools

N = input()
a = [int(i) for i in input().split()]
list = []

for j in range(len(a)):
    S1 = sum(a[0:j+1])
    S2 = sum(a[j+1:len(a)+1])
    S = abs(S1-S2)
    list.append(S)


print(min(list))


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

#define int long long
int a, b;

int so(int a, int b)
{
    int res = 0;
    for(int i = 1; i <= b; i++)
    {
        res = res * 10 + a;
    }
    return res;
}

signed main()
{
    cin >> a >> b;
    cout << max(so(a, b), so(b, a));

}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N;
	void Solve()
	{
		var I = G;
		N = I[0];
		WriteLine(ToString(Calc(Get(), Get(), I[1] - 1)));
	}
	int[] Get() => G.Select(i => i - 1).ToArray();
	string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
	int[] Calc(int[] p, int[] q, int K)
	{
		if (K == 0) return p;
		if (K == 1) return q;
		if (K < 6) return Calc(q, Mult(q, Inv(p)), K - 1);
		int[] ip = Inv(p), iq = Inv(q), x = Mult(q, ip, iq, p), y = Mult(ip, q, p, iq);
		switch (K % 6)
		{
			case 0: return Mult(Pow(x, K / 6), q, p, iq, Pow(y, K / 6 - 1));
			case 1: return Mult(Pow(x, K / 6), q, Pow(y, K / 6));
			case 2: return Mult(Pow(x, K / 6), q, ip, Pow(y, K / 6));
			case 3: return Mult(Pow(x, K / 6), q, ip, iq, Pow(y, K / 6));
			case 4: return Mult(Pow(x, K / 6 + 1), iq, Pow(y, K / 6));
			default: return Mult(Pow(x, K / 6 + 1), p, iq, Pow(y, K / 6));
		}
	}
	int[] Pow(int[] a, int b)
	{
		var p = MakeArray(N, i => i);
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = Mult(p, x);
			b >>= 1;
			x = Mult(x, x);
		}
		return p;
	}
	int[] Inv(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	int[] Mult(params int[][] a)
	{
		if (a.Length == 0) return MakeArray(N, i => i);
		var x = a[0];
		for (var i = 1; i < a.Length; i++) x = Mult(x, a[i]);
		return x;
	}
	int[] Mult(int[] a, int[] b)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[i] = a[b[i]];
		return c;
	}
}


Measured memory_bytes: 45844
import collections


def main():
    n = int(input())
    L = sorted(list(map(int, input().split())))
    counter = collections.Counter(L)
    keys = list(counter.keys())
    lenKeys = len(keys)
    if lenKeys < 3:
        print(0)
        return
    cnt = 0
    for a in range(lenKeys - 2):
        for b in range(a + 1, lenKeys - 1):
            for c in range(b + 1, lenKeys):
                if keys[a] + keys[b] > keys[c]:
                    cnt += counter[keys[a]] * \
                        counter[keys[b]] * counter[keys[c]]
    print(cnt)


if __name__ == '__main__':
    main()


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
const ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll a){
    if(a == 1) return x;
    if(a % 2) return (x * mod_pow(x, a - 1)) % MOD;
    ll t = mod_pow(x, a / 2);
    return (t * t) % MOD;
}

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

    ll ans = mod_pow(10, n) - 2 * mod_pow(9, n) + mod_pow(8, n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	int x = 0, y = 0, t = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l, j, k;
		cin >> l >> j >> k;
		if (abs(x - j) + abs(y - k) > abs(l - t)) {
			cout << "No" << endl;
			return 0;
		}
		else if (abs(x - j) + abs(y - k) == abs(l - t)) {
			x = j;
			y = k;
			t = l;
		}
		else {
			if (abs(x - j) + abs(y - k) - abs(l - t) % 2 == 0) {
				x = j;
				y = k;
				t = l;
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    
    long long int n,i,j,x,l,y,min=1;
    map<long long int ,long long int> m;
    map<long long int ,long long int>:: iterator it;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x>>l;
        y=x+l;
        if(m.find(y)!=m.end())
        {
            if(m[y]>l)
             m[y]=l;
        }
        else
         m[y]=l;
    }
    if(n==1)
     cout<<"1";
    else
    {
    it=m.begin();
     j=it->first;
     it++;
    while(it!=m.end())
    {
        if((it->first)-2*(it->second)>=j)
        {
            min++;
            j=it->first;
        }
        it++;
    }
    cout<<min;
    }
}


Measured memory_bytes: 6528
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto n = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);
    import std.container;

    DList!long b;

    foreach (i, a; as) {
        if (i & 1) b.insertFront(a);
        else b.insertBack(a);
    }

    if (n & 1) b.array.retro.map!(to!string).join(" ").writeln;
    else b.array.map!(to!string).join(" ").writeln;
}



Measured memory_bytes: 24688
n = io.read("*n")
t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
r = 0
c = 1
while c <= n do
  if t[c] == c then
    r, c = r + 1, c + 2
  else
    c = c + 1
  end
end
print(r)

Measured memory_bytes: 4288
def func(num, memo):
    if memo[num] != -1:
        return memo[num]

    ans = 0
    if num == 0:
        return 1

    if num < 3:
        return ans

    for i in range(3, num + 1):
        ans += func(num - i, memo)
        ans %= 10 ** 9 + 7

    memo[num] = ans
    return ans


s = int(input())

memo = [-1] * (s + 1)

if s < 3:
    print(0)
else:
    print(func(s, memo))


Measured memory_bytes: 68832
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    int K;
    string S;
    string result;

    cin >> K;
    cin >> S;

    if( S.length() <= K ){
        result = S;
    }
    else{
        result = S.substr(0,K) + "...";
    }

    cout << result << endl;
    return 0;
}

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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define debug(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);
#define tl cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n"


typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc()); x*=f;
    return x;
}

const int N = 110;
int a[N][2], dp[N][2], n;

int solve(int x, int y){
    if(x == n || y == 2) return 0;
    int& ans = dp[x][y];
    if(~ans) return ans;
    return ans = a[x][y] + max(solve(x+1, y), solve(x, y + 1));
}

int main(){
    n = nxt();
    memset(dp, -1, sizeof dp);
    rep(i,0,n) a[i][0] = nxt();
    rep(i,0,n) a[i][1] = nxt();
    cout << solve(0,0) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using std::begin;
using std::end;

int main() {
  int n;
  std::vector<int> l;
  std::cin >> n;
  for(int i{0}; i < n; ++i) {
    int t;
    std::cin >> t;
    l.push_back(t);
  }

  for(int i{0}; i < n; ++i) {
    int v{l[i]};
    int j{i - 1};
    while(j >= 0 && l[j] > v) {
      l[j + 1] = l[j];
      --j;
    }
    l[j + 1] = v;

    bool lastp{false};
    for(auto const e: l){
      if(!lastp) {
        lastp = true;
      } else {
        std::cout << ' ';
      }
      std::cout << e;
    }
    std::cout << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3124
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N, W, w0 := scanInt(), scanInt(), scanInt()

	L := [4][]int{}
	for i := 0; i < 4; i++ {
		L[i] = make([]int, 0)
	}
	L[0] = append(L[0], scanInt())

	for i := 1; i < N; i++ {
		w, v := scanInt(), scanInt()
		L[w-w0] = append(L[w-w0], v)
	}

	num := [...]int{len(L[0]), len(L[1]), len(L[2]), len(L[3])}
	for i := 0; i < 4; i++ {
		sort.Sort(sort.Reverse(sort.IntSlice(L[i])))
		for j := 1; j < num[i]; j++ {
			L[i][j] += L[i][j-1]
		}
		L[i] = append([]int{0}, L[i]...)
	}

	ans := 0
	for a := 0; a <= num[0]; a++ {
		for b := 0; b <= num[1]; b++ {
			for c := 0; c <= num[2]; c++ {
				tmpW := w0*a + (w0+1)*b + (w0+2)*c
				if tmpW > W {
					continue
				}

				d := intMin((W-tmpW)/(w0+3), num[3])
				tmpV := L[0][a] + L[1][b] + L[2][c] + L[3][d]
				ans = intMax(ans, tmpV)
			}
		}
	}
	fmt.Println(ans)
}


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

int main() {
  int a,b;
  string s ,t ,u;
  cin>>s>>t>>a>>b>>u;
  if(u == s){
    a --;
  }else{
    b --;
  }
  cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\,
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int cnt[100000];

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int x=1;x*x<=n;x++){
        for(int y=1;x*x+y*y+x*y<=n;y++){
            for(int z=1;x*x+y*y+x*y+z*z+x*z+y*z<=n;z++){
                cnt[x*x+y*y+x*y+z*z+x*z+y*z]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout << cnt[i] << endl;


}

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

int main() {
  int X, Y, s, b;
  for(int i = 1; i < 3001; i++){
      cin >> X >> Y;
      if (X == 0 && Y == 0){
          break;
      }
      else {
          s = min(X,Y);
          b = max(X,Y);
          cout << s << " " << b << endl;
      }
  }
}


Measured memory_bytes: 3008