akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1)
    {
    }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main()
{
    int n, M;
    cin >> n >> M;
    map<int,int> v1;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        v1[a]++;
    }
    map<int,int> t;
    map<int,int> v;
    for(auto r : v1)
    {
        v[r.first % M] += r.second;
        t[r.first % M] += r.second / 2;
    }
    int r = 0;
    for (int i = 0; i <= M-i; ++ i) {
        if (i == 0 || i == M-i) {
            r += v[i] / 2;
        } else {
            int p = min(v[i], v[M-i]);
            r += p;
            v[i] -= p;
            v[M-i] -= p;
            r += min(v[i]/2, t[i]);
            r += min(v[M-i]/2, t[M-i]);
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n, d;
	cin >> n >> d;
	int x[20][20];
	double t = 0, count = 0;
	double y[20][20];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int k = i + 1; k < n; k++) {
			for (int j = 0; j < d; j++) {
			
	
				if (i == n - 1) {
					t += pow(abs(x[i][j] - x[0][j]), 2);
				}
				else {
					t += pow(abs(x[i][j] - x[k][j]), 2);

				}
			}
			y[i][k] = sqrt(t);
			t = 0;
			int a = y[i][k];
			if (a - y[i][k] == 0) {
				count++;
			}

		}
		
	}
	cout << count << endl;

	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N, M; cin >> N >> M;
  int a = 1, tmp=1; bool used[N+1] = {};
  if(N%2){
    rep(i, M){
      cout << i+1 << " " << N-i << endl;
    }
  }
  else{
    rep(i, min(N/4, M)){
      cout << i+1 << " " << N-i << endl;
    }
    rep(i, M - min(N/4, M)){
      cout << min(N/4, M)+1+i << " " << N-i-min(N/4, M)-1 << endl;
    }
  }
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e5 + 5 ;
const int inf = 0x3f3f3f3f ;
int n ;
int solve(int i , int j , int k)
{
	int x = 1 ;
	int ans = 0 ;
	for(int p = 1 ; p <= k ; p ++)  x *= 10 ;
	i *= x ;
	for(int p = 0 ; p <= x - 1 ; p ++)
	  if((i + p) * 10 + j <= n)  ans ++ ;
	return  ans ;
}
int cal(int i , int j)
{
	if(i * 10 + j > n)  return 0 ;
	int ans = 1 ;
	for(int k = 1 ; k <= 4 ; k ++)
	  ans += solve(i , j , k) ;
	return ans ; 
}
int main()
{
	ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    cin >> n ;
    if(n <= 9)  cout << n << '\n' ;
    else
    {
    	int ans = 9 ;
    	for(int i = 1 ; i <= 9 ; i ++)
    	  for(int j = 1 ; j <= 9 ; j ++)
			ans += cal(i , j) * cal(j , i) ;
		for(int i = 1 ; i <= 9 ; i ++)
		  ans += cal(i , i) * 2 ;
		cout << ans << '\n' ;
	}
	return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    int n,k;cin>>n>>k;
    int a[n]={};
    rep(i,k){
        int d;cin>>d;
        rep(j,d){
            int b;cin>>b;
            a[b-1]++;
        }
    }
    int cnt=0;
    rep(i,n){
        if(a[i]==0) cnt++;
    }

    cout<<cnt<<"\n";
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int a,b;
    cin>>a>>b;

    cout<< max(a+b,max(a-b,a*b))<<endl;

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

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
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; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const int INF = 1 << 28;



typedef ll number;
typedef vector<number> Vect; //縦ベクトル
typedef vector<Vect> matrix;

ll L, A, B, M;

matrix identity(int n) {
    matrix A(n, Vect(n));
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}

Vect mul(const matrix &A, const Vect &x) {
    Vect y(A.size());
    for (int i = 0; i < A.size(); ++i)
        for (int j = 0; j < A[0].size(); ++j)
            y[i] = (y[i] + (A[i][j] * x[j]) % M ) % M;
    return y;
}

matrix mul(const matrix &A, const matrix &B) {
    matrix C(A.size(), Vect(B[0].size()));
    for (int i = 0; i < C.size(); ++i)
        for (int j = 0; j < C[i].size(); ++j)
            for (int k = 0; k < A[i].size(); ++k)
                C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % M ) % M;
    return C;
}


matrix pow(const matrix &A, ll e) {
    return e == 0 ? identity(A.size())  :
           e % 2 == 0 ? pow(mul(A, A), e / 2) : mul(A, pow(A, e - 1));
}


ll powten[20];
ll C[20];
void init () {
    powten[0] = 1;
    rep(i, 19) {
        powten[i + 1] = (powten[i] * 10) % M;
    }

    C[0] = 0;
    rep(i, 18) {
        ll x = (ll)pow(10, i + 1) - 1;
        ll y = (ll)pow(10, i) - 1;
        if (A + B * (L - 1) > x) {
            C[i + 1] = ( x >= A ? (x - A) / B + 1 : 0 )
                       - ( y >= A ? (y - A) / B + 1 : 0);
        }
        else {
            C[i + 1] = L - ( y >= A ? (y - A) / B + 1 : 0);
            break;
        }
    }
}



int main() {
    cin >> L >> A >> B >> M;
    init();

    Vect S{0, A % M, 1};

    vector<matrix> R(20, matrix(3, Vect(3, 0)));
    for (int d = 1; d <= 18 ; d++) {
        R[d][0][0] = powten[d];
        R[d][1][2] = B % M;
        R[d][0][1] = R[d][1][1] = R[d][2][2] = 1;
        S = mul(pow(R[d], C[d]) , S);
    }

    cout << S[0] << endl;

}






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

int main()
{
	int n;
	cin>>n;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin>>temp;
		if((temp&1) && (i&1)) cnt++;
	}
	cout<<cnt<<endl;
}


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

typedef long long ll;
const int maxn = 1e5+10;
double node[maxn];

int main()
{
	ll n,k;
	cin>>n>>k;
	ll a = n%k;
	ll b = k-a;
	cout<<min(a,b)<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
vector<ll> sil(1000000);

ll Pot(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (b % 2 == 0)
    {
        ll p = Pot(a, b / 2);
        return p * p % MOD;
    }
    else
        return Pot(a, b - 1) * a % MOD;
}

ll Inv(ll a)
{
    return Pot(a, MOD - 2);
}

ll C(ll n, ll k)
{
    return sil[n] * (Inv(sil[n - k]) * Inv(sil[k]) % MOD) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    map<int, int> p;
    int t = m;
    for (int d = 2; d * d <= m; ++d)
    {
        int wyk = 0;
        while (t % d == 0)
        {
            ++wyk;
            t /= d;
        }
        if (wyk != 0)
            p[d] += wyk;
    }
    if (t != 1)
        ++p[t];
    ll odp = 1;
    sil[0] = 1;
    for (ll i = 1; i < 1000000; ++i)
        sil[i] = (sil[i - 1] * i) % MOD;
    for (map<int, int>::iterator it = p.begin(); it != p.end(); ++it)
    {
        ll ile = it->second;
        ll c = 0;
        for (ll i = 1; i <= n; ++i)
            if (i <= ile)
                c = (c + C(ile - 1, i - 1) * C(n, i) % MOD) % MOD;
        odp = (odp * c) % MOD;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 8064
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def ti(): return tuple(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

## DP

def solve(N):
    A = ti()
    dp = dp2(0, N, N)

    for i in range(N-1):
        if abs(A[i]-A[i+1]) < 2:
            dp[i][i+1] = 2
    
    for h in range(2, N): #hは(区間の長さ)-1
        for i in range(N):
            if i+h >= N:
                break
            j = i+h
            # 区間の長さが偶数の場合
            if h % 2:
                if abs(A[i]-A[j]) < 2 and dp[i+1][j-1] == h-1:
                    dp[i][j] = h + 1
                    continue
                else:
                    dp[i][j] = max(tuple(dp[i][k]+dp[k+1][j] for k in range(i, j)))
            # 区間の長さが奇数の場合
            else:
                dp[i][j] = max(dp[i+1][j], dp[i][j-1])
        else:
            continue

    print(dp[0][N-1])

while True:
    N = ii()
    if N == 0:
        exit()
    solve(N)


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int n, k;
vector<int> g[100005];

int modPow(long long a, long long n, long long p) {//0でバグる
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

ll fact(ll a) {
	ll res = 1;
	for (int i = 1; i <= a; ++i) (res *= i) %= mod;
	return res;
}

ll perm(ll a, ll b) {
	if (a < 0 || a < b) return 0;
	return comb(a, b) * fact(b) % mod;
}

ll ans;

void dfs(int s, int p = -1) {
	for (auto& c : g[s]) {
		if (c == p) continue;
		dfs(c, s);
	}
	int nk = (p == -1) ? k : k - 2;
	int nc = (p == -1) ? g[s].size() + 1 : g[s].size() - 1;
	(ans *= perm(nk, nc)) %= mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	ans = 1;
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn=1, Kr=1, Knr=1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int X, A;

	cin >> X >> A;
	if (X < A) cout << 0;
	else cout << 10;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
  T ans=0,f=1;
  char ch=getchar();
  while(!isdigit(ch)&&ch!='-')ch=getchar();
  if(ch=='-')f=-1,ch=getchar();
  while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
  return ans*f;
}
template<typename T>void write(T x,char y)
{
  if(x==0)
  {
      putchar('0'),putchar(y);
      return;
  }
  if(x<0)
  {
      putchar('-');
      x=-x;
  }
  static char wr[20];
  int top=0;
  for(;x;x/=10)wr[++top]=x%10+'0';
  while(top)putchar(wr[top--]);
  putchar(y);
}
void file()
{
  #ifndef ONLINE_JUDGE
      freopen("test.in","r",stdin);
      freopen("test.out","w",stdout);
  #endif
}
const int N=1e5+5;
int n,m;
char s[N],t[N];
void input()
{
	n=read<int>(),m=read<int>();
	scanf("%s%s",s+1,t+1);
}
ll tot;
void work()
{
	int tmp=__gcd(n,m);
	tot=1ll*n*m/tmp;
	//long long d=tot/tmp;
	for(int i=1,j=1;i<=n&&j<=m;i+=n/tmp,j+=m/tmp)
	{
		if(s[i]!=t[j]){puts("-1");return;}

	}
	printf("%lld\n",tot);
}
int main()
{
	//file();
	input();
    work();
	return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int dig(ll t){

	int digit=0;
	    while(t!=0){
	        t /= 10;
	        digit++;
	    }
	    return digit;
}

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

	int s,w;cin>>s>>w;

	if( s <=w){
		writeln("unsafe");
	}else {
		writeln("safe");
	}

}




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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

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

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

int main() {
source:
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll len = lcm(n, m);
    map<ll, char> ans;

    rep(i, n) {
        ll index = (len / n) * i;
        ans[index] = s[i];
    }
    rep(i, m) {
        ll index = (len / m) * i;
        if (ans[index] != '\0' && ans[index] != t[i]) {
            cout << -1 << endl;
            return 0;
        } else {
            ans[index] = t[i];
        }
    }
    cout << len << endl;
    return 0;
}



Measured memory_bytes: 10880
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std ;
int main()
{
    int x,a,b ;
    cin >> x ;
    a=x/100;b=x%100;
    if(a>=1 && a<=12)
    {
        if(b>=1 && b<=12){cout<< "AMBIGUOUS" << endl;}
        else{cout<< "MMYY"<< endl;}
    }
    else
    {
        if(b>=1 && b<13){cout<< "YYMM" << endl;}
        else{cout<< "NA" << endl;}
    }
}



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

long long n;
long long d;

int main(){
scanf("%lld%lld",&n,&d);
long long ans = 0;
ans += n;
long long width = d;
long long dist = n-d;
while (dist%width!=0){
    ans += 2LL * width * (dist/width);
    long long t = dist%width;
    dist = width;
    width = t;
}
ans += 2LL*width * (dist/width-1);
ans += width;
printf("%lld",ans);
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc163/tasks/abc163_b

#include <iostream>

int main() {
	int days, tasks;
	std::cin >> days >> tasks;

	for (int i = 0; i < tasks; ++i) {
		int a;
		std::cin >> a;
		days -= a;
	}
	if (days < 0)
		days = -1;
	std::cout << days << std::endl;
}

Measured memory_bytes: 3168
n = int(input())
ans = 0
tmp = 0
for _ in range(n):
  a,b = map(int,input().split())
  if a==b:
    tmp += 1
  else:
    ans = max(ans,tmp)
    tmp = 0
ans = max(ans,tmp)
print('Yes' if ans>=3 else 'No')

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	long long sum1=a[0],sum2=accumulate(a+1,a+n,0ll),ans=abs(sum2-sum1);
	for(int i=1;i<n-1;i++){
		sum1+=a[i];
		sum2-=a[i];
		ans=min(ans,abs(sum2-sum1));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left"<<endl;
    else if(a+b<c+d) cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
}


Measured memory_bytes: 256
import math

A, B = map(int, input().split())
big = math.floor(max(A, B) / 0.08)
sma = math.floor(min(A, B) / 0.1)
num_list = [int(i) for i in range(sma - 1, big + 2)]

for i in num_list:
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define int long long
using namespace std;
signed main(){
    string s;
    cin>>s;
    int r1=0,r2=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='0')r1++;
            else r2++;
        }else{
            if(s[i]=='0')r2++;
            else r1++;
        }
    }
    cout<<s.size()-max(r1,r2)<<endl;
    return 0;
}


Measured memory_bytes: 512
def ans3():
    # x + y + z = N
    # 10000x + 5000y + 1000z = Y
    # 9000x + 4000y = Y - 1000N
    # x : for文でぶん回す
    # y = (Y - 1000N - 9000x) // 4000
    # z = N - x - y
    hasAnswer = False
    N, Y = map(int, input().split(" "))
    for x in range(Y // 10000 + 1):
        y = (Y - 1000 * N - 9000 * x) // 4000
        z = N - x - y
        nt = x + y + z
        ny = 10000 * x + 5000 * y + 1000 * z
        if y >= 0 and z >= 0 and nt == N and ny == Y:
            print(x, y, z, sep=" ")
            hasAnswer = True
            break
    if hasAnswer == False:
        print(-1, -1, -1, sep=" ")

ans3()

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i=a; i<=b; i++){
        bool flag = true;
        string k = to_string(i);
        for(int j=0; j<k.size()/2; j++){
            if(k[j]!=k[k.size()-j-1]){
                flag = false;
                break;
            }
        }
        if(flag){
            ans++;
        }
    }

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

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

using namespace std;

typedef long long int ll;

const int MOD=1e9+7,MAX=1e5+100;

string S;

ll N,dp[MAX][15];

ll solve(int idx,int rem)
{
    if(idx==N&&rem==5)return 1LL;
    if(idx==N)return 0LL;
    
    ll &res=dp[idx][rem];
    if(~res)return res;
    res=0;
    if(S[idx]!='?'){
            rem = (rem*10 + (S[idx]-'0') ) %13;
            res += solve(idx+1,rem);
            res%=MOD;
    }
    else{
        for(int i=0;i<10;i++){
                res += solve(idx+1,(rem*10 + i)%13);
                res%=MOD;
            }
    }
   return res;
}
int main ()
{
    memset(dp,-1,sizeof dp);
    
    cin >> S;
    
    N=S.size();
    
    cout<<solve(0,0)<<endl;
    
    return 0;
}


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

int main(){
  int N;
  int S[200100];
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S,S+N);
  for (int i = 0; i < N - 1; i++){
    if (S[i] == S[i + 1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String a=sc.next();
        String b=sc.next();
        if (a.equalsIgnoreCase(b.substring(0,b.length()-1))){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 35460
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rep2(i,j,k) for(int i=j;i>=k;i--)
#define mo 998244353
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmod(T &x,T y){x=(x+y>=mo)?(x+y-mo):(x+y);}
int co[3010];int dp[3010][3010];

int main(){
	int n,s;read(n);read(s);
	rep(i,1,n)read(co[i]);
	
	dp[0][0]=1;
	rep(i,1,n){
		rep2(j,s,0){
			int p=(2ll*dp[i-1][j])%mo;chkmod(dp[i][j],p);
			if(j>=co[i])chkmod(dp[i][j],dp[i-1][j-co[i]]);
		}
	}
	write(dp[n][s]);
	return 0;
}

Measured memory_bytes: 38928
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }
    lli fi=-1, se=-1;
    rep(i,n){
        if(fi==-1||a[fi]<a[i]){ 
            se=fi;
            fi=i;
        
        }
        else if(se==-1||a[se]<a[i]){ 
            se=i;
        }
    }
    rep(i,n){
        if(i==fi){ 
            out(a[se]);
        }
        else{ 
            out(a[fi]);
        }
    }
}

Measured memory_bytes: 4764
#include <stdio.h>
#include <string.h>
void sim(char *s,int i,int l,int *k){
	int t=26-(s[i]-'a');
	if(i==l&&*k>0){
		int c=(*k)%26;
		s[i-1]=(char)(s[i-1]+c);
	}
	else if(t<=*k&&t!=26){
		*k=*k-t;
		s[i]='a';
	}
}

int main(void){
	int k,i,l;
	char s[100001];
	scanf("%s %d",s,&k);
	l=strlen(s);
	for(i=0;i<=l;i++){
		sim(s,i,l,&k);
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 384
x,y = map(int,input().split())
if x>=0 and y>=0 and x<=y:
    print(y-x)
elif x>=0 and y>0 and x>y:
    print(x-y+2)
elif x>=0 and y==0 and x>y:
    print(x-y+1)
elif x>=0 and y<0:
    print(abs(x+y)+1)
elif x<0 and y>0:
    print(abs(x+y)+1)
elif x<0 and y == 0:
    print(-x)
elif x<0 and y<0 and x>y:
    print(x-y+2)
else:
    print(y-x)

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

const int INF = 1001001001;

int main(){
    int h,n;    cin >> h >> n;
    vector<pair<int, int> >a(n);
    rep(i, n)   cin >> a[i].first >> a[i].second;
    int Maxhp = max_element(a.begin(), a.end())->first;
    vector<int>dp(h + Maxhp + 1);
    for(int i = 1; i <= h+Maxhp; i++){
        int cost = INF;
        rep(j, n){
            if(a[j].first >= i){
                if(cost > a[j].second){
                    cost = a[j].second;
                }
            }else{
                if(cost > dp[i - a[j].first] + a[j].second){
                    cost = dp[i - a[j].first] + a[j].second;
                }
            }
        }
        dp[i] = cost;
    }
    int ans = INF;
    for(int i = h; i <= h+Maxhp; i++)  ans = min(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int N;
void dfs(string s, char mx) {
  if (s.size() == N) {
    cout << s << endl;
  } else {
    for (char c = 'a'; c <= mx+1; c++) {
      char ma='a'-1;
      dfs(s + c, max(mx,c));
    }
  }
}
int main() {
  cin >> N;
  dfs("a", 'a');
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ran 303333
int n;char s[ran];
int sw[ran],se[ran];
int main(){
	scanf("%d%s",&n,s+1);
	for(int i=1; i<=n; i++){
		sw[i] = sw[i-1] + (s[i] == 'W');
		se[i] = se[i-1] + (s[i] == 'E');
	}
	int res = 22222222;
	for(int i=1; i<=n; i++){
		res = min(res, sw[i-1] + se[n] - se[i]);
	}
	printf("%d\n",res);
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 1;
    int count = a;
    if(b == 1) {
        ans = 0;
    } else {
        while(count < b) {
            ans++;
            count += a - 1;
        }
    }
    // cout << count << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x,a,b;
    scanf("%d", &x);
    scanf("%d", &a);
    scanf("%d", &b);
    x=x-a;
    while(x>=b)
    {
        x=x-b;
    }
    printf("%d",x);
    return 0;
}

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

using namespace std;

int main(){
  
  long long int n;
  cin>>n;
  
  long long int ac_cnt=0;
  long long int wa_cnt=0;
  long long int tle_cnt=0;
  long long int re_cnt=0; 

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

  for(int i=0; i<n; i++){
    if(s[i]=="AC") ac_cnt++;
    else if(s[i]=="WA") wa_cnt++;
    else if(s[i]=="TLE") tle_cnt++;
    else if(s[i]=="RE") re_cnt++;
  }

  cout<<"AC x"<<" "<<ac_cnt<<endl;
  cout<<"WA x"<<" "<<wa_cnt<<endl;
  cout<<"TLE x"<<" "<<tle_cnt<<endl;
  cout<<"RE x"<<" "<<re_cnt<<endl;

  
}


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

int main() {
  
  int a, b, C;
  cin >> a >> b >> C;
  
  double Crad;
  Crad = (double)2*acos(-1)*C/360;
  
  double S, L, h, c;
  
  S = (double)(a*b)*0.5*sin(Crad);
  c = sqrt(a*a + b*b - 2*a*b*cos(Crad));
  L = a+b+c;
  h = (double)2*S/a;
  
  printf("%f\n%f\n%f\n", S, L, h);
  
  return 0;
}




Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
 
int main()
{
  int N;
  cin>>N;
  vector <long long int> T(N), A(N);
  long long int anst=1, ansa=1;
  for(int i=0;i<N;i++){
    cin>>T[i]>>A[i];
    long long int tmp=max((anst-1)/T[i],(ansa-1)/A[i])+1;
    anst=T[i]*tmp;
    ansa=A[i]*tmp;
  }
  
  cout<< anst+ansa <<endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n,d,c=0;
	cin >> n >> d;
	c=n/(2*d+1);
	if((n%(2*d+1)) != 0 )
	{	c++;}
	cout <<c;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int C[200010] = {}; 
	vector<int> F[200010] = {}; 
  long long int dp[200010] = {}; 
	dp[0] = 1; 
	for(int i = 1; i <= N; i++){
		cin >> C[i]; 
		F[C[i]].push_back(i); 
      if(i >= 2 && C[i-1] == C[i]){
        	dp[i] = dp[i-1]; continue; 
      }
      if(F[C[i]].size() > 1){
		dp[i] += dp[F[C[i]].at(F[C[i]].size()-2)]; 
      }
		dp[i] = (dp[i-1] + dp[i]) % 1000000007; 
	}
  cout << dp[N] << endl; 
  }

Measured memory_bytes: 13568
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;


int main() {
	string s;
	while (cin >> s, s[0] != '#') {
		int lef;
		if ('a' <= s[0] && s[0] <= 'g' || 'q' <= s[0] && s[0] <= 't' || s[0] == 'v' || s[0] == 'w' || s[0] == 'x' || s[0] == 'z')
			lef = 1;
		else
			lef = 0;
		int count = 0;
		for (int i = 1; i < s.size(); i++)
			if ('a' <= s[i] && s[i] <= 'g' || 'q' <= s[i] && s[i] <= 't' || s[i] == 'v' || s[i] == 'w' || s[i] == 'x' || s[i] == 'z')
				if (!lef) {
					count++;
					lef = 1;
				}
				else
					lef = 1;
			else
				if (lef) {
					count++;
					lef = 0;

				}
				else
					lef = 0;
		cout << count << endl;




	}

	return 0;

}

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

const int maxn=3*1e5+5;
int res,n,m,sum[maxn],ok[maxn],a[maxn];

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,n)
	{
		int x;
		scanf("%d",&x);
		a[i]=x;
		sum[x]++;
		if(x-sum[x]+1>=1)
		{
			ok[x-sum[x]+1]++;
			if(ok[x-sum[x]+1]==1)res++;
		}
	}
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);x--;
		int p=a[x]-sum[a[x]]+1;
		if(p>=1)
		{
			if(ok[p]==1)res--;
			ok[p]--;
		}
		
		sum[a[x]]--;
		a[x]=y;
		sum[y]++;
		p=y-sum[y]+1;
		if(p>=1)
		{
			if(ok[p]==0)res++;
			ok[p]++;
		}
		printf("%d\n",n-res);
	}
}

Measured memory_bytes: 3712
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int m = ni();
		int[][] map = new int[m][];
		for(int i = 0; i < m; i++) {
			int k = ni();
			map[i] = new int[k];
			for(int j = 0; j < k; j++) {
				map[i][j] = ni();
			}
		}
		int[] p = na(m);
		int result = 0;
		
		int max = (int)Math.pow(2, n);
		for(int i = 0; i < max; i++) {
			boolean isMatch = true;
			char[] ca = String.format("%0" + n + "d",Integer.parseInt(Integer.toBinaryString(i))).toCharArray();
			for(int j = 0; j < m; j++) {
				int k = map[j].length;
				int cnt = 0;
				for(int l = 0; l < k; l++) {
					if(ca[map[j][l] - 1] == '1') {
						cnt++;
					}
				}
				if(cnt % 2 == p[j]) {
					continue;
				} else {
					isMatch = false;
					break;
				}
			}
			result += isMatch ? 1:0;
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 27088
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String x = sc.next();
            int p = x.length();
            int a = 0;

            if(x.equals("0")){
                break;
            }else{
                for(int i=0;i<p;i++){
                    a += (x.charAt(i) - '0');
                }
                System.out.println(a);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26272
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        x: isize,
    }
    for i in -120..120_isize {
        for j in -120..120_isize {
            if i.pow(5) - j.pow(5) == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}


Measured memory_bytes: 2172
N= int(input())
_l = [1, 6, 6**2, 6**3, 6**4, 6**5, 6**6, 6**7, 9, 9**2, 9**3, 9**4, 9**5, 9**6]
_l.sort()
#print(_l)

answer=[0]*(N+1)

for i in range(1, N+1):
  answer[i] = min([answer[i-l] +1 if i-l>=0 else 1000000 for l in _l])

print(answer[N])

Measured memory_bytes: 3828
import java.util.Scanner;

class Main{
   public void yatary() {  
     int x,a,b;
       String op;
     Scanner sc = new Scanner(System.in);
     sc.useDelimiter("\\s");

       boolean sw = true;

       while(sw == true){
           a = sc.nextInt();
           op = sc.next();
           b = sc.nextInt();
           if (op.equals("+")){
               x = a + b;
               System.out.println(x);
           }else if(op.equals("-")){
               x = a - b;
               System.out.println(x);
           }else if(op.equals("*")){
               x = a * b;
               System.out.println(x);
           }else if(op.equals("/")){
               x = a / b;    
               System.out.println(x);
           }else{
                sw = false;     
           }
       }
  }

public static void main(String[] args){ 
    new Main().yatary();   
  }
} 

Measured memory_bytes: 18004
#include <iostream>

using namespace std;

const int mod = 1000000007;

// a=0, c=1, g=2, t=3
long long dp[101][5][5][5];

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

  dp[0][4][4][4] = 1;

  for (int p = 0; p < n; p++) {
    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 5; j++) {
        for (int k = 0; k < 5; k++) {
          if (dp[p][i][j][k] == 0) continue;
          for (int q = 0; q < 4; q++) {
            if (j == 0 && k == 2 && q == 1) continue;
            if (j == 2 && k == 0 && q == 1) continue;
            if (j == 0 && k == 1 && q == 2) continue;
            if (i == 0 && k == 2 && q == 1) continue;
            if (i == 0 && j == 2 && q == 1) continue;
            dp[p + 1][j][k][q] += dp[p][i][j][k];
            dp[p + 1][j][k][q] %= mod;
          }
        }
      }
    }
  }

  long long ans = 0;

  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      for (int k = 0; k < 5; k++) {
        ans += dp[n][i][j][k];
        ans %= mod;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int n; cin >> n;
   vector<pair<string,pair<int,int>>> v(n);
   for (int i = 0; i < n; ++i) {
      string s;
      int p;
      cin >> s >> p;
      v[i] = make_pair(s, make_pair(-p, i+1));
   }

   sort(v.begin(), v.end());

   for (int i = 0; i < n; ++i) {
      cout << v[i].second.second << endl;
   }

   return 0;
}


Measured memory_bytes: 256
using System;

namespace Atcoder
{
    class ABC161_B
    {
        static void Main(string[] args)
        {
            int count = 0;
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            int n = int.Parse(str1[0]);
            int m = int.Parse(str1[1]);
            int[] str = new int[n];
            int sum = 0;

            for (int i = 0; i < str2.Length; i++)
            {
                str[i] = int.Parse(str2[i]);
                sum += str[i];
            }
            double z;
            z = (double)sum/ (m * 4);
            for(int i = 0; i < str.Length; i++)
            {
                if(str[i] >= z)
                {
                    count += 1;
                }
                if(count == m)
                {
                    Console.WriteLine("Yes");
                    break;
                }
                if(i == str.Length-1)
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 13140
ABCD = list(map(int, list(input())))

plus_minus = ["+", "-"]
for op1 in plus_minus:
    for op2 in plus_minus:
        for op3 in plus_minus:
            formula = str(ABCD[0]) + op1 + str(ABCD[1]) + op2 + str(ABCD[2]) + op3 + str(ABCD[3])
            if eval(formula) == 7:
                print(formula + "=7")
                exit()

Measured memory_bytes: 3060
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
sum=0
for i in range(n):
  sum+=l[i][1]
dp=[[999999999999 for i in range(sum+1)] for j in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
  for j in range(sum+1):
    dp[i][j]=min(dp[i-1][max(j-l[i-1][1],0)]+l[i-1][0],dp[i-1][j])
for i in range(sum,-1,-1):
  if dp[n][i]<=w:
    print(i)
    break

Measured memory_bytes: 171528
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  vector<ll>v;
  for(int i=1;i<=9;i++)
    v.push_back(i);
  int ptr=0;
  while(v.size()<1e5+3)
  {
    ll num=v[ptr];ptr++;
    ll d=num%10;
    if(d-1>=0)
      v.push_back(num*10+(d-1));
    v.push_back(num*10+d);
    if(d+1<=9)
      v.push_back(num*10+(d+1));
  }
  ll x;
  cin>>x;
  cout<<v[x-1]<<"\n";
  return 0;
}


Measured memory_bytes: 1400
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    println!("{}", v.iter().sum::<i64>() - v.iter().max().unwrap());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=1e3+5;
char s[maxn][maxn];
int ans[maxn][maxn],vis[maxn][maxn],n,m,fx,fy,tx,ty;
int dir[4][2]={1,0,-1,0,0,1,0,-1};

struct node
{
    int x,y,step=0;
};
deque<node> Q;

int main()
{
    n=read(),m=read();
    fx=read(),fy=read();
    tx=read(),ty=read();
    REP(i,1,n) scanf("%s",s[i]+1);
    REP(i,1,n) REP(j,1,m) ans[i][j]=-1;
    Q.push_back((node){fx,fy,0});
    while(!Q.empty())
    {
        node nd=Q.front(); Q.pop_front();
        int x=nd.x,y=nd.y,step=nd.step;
        if(vis[x][y]) continue;
        //cout<<x<<' '<<y<<endl;
        vis[x][y]=1;
        ans[x][y]=step;
        for(int i=0;i<4;i++)
        {
            int xx=x+dir[i][0],yy=y+dir[i][1];
            if(xx>0 && xx<=n && yy>0 && yy<=m && !vis[xx][yy] && s[xx][yy]=='.')
                Q.push_front((node){xx,yy,step});
        }
        for(int xx=x-2;xx<=x+2;xx++)
            for(int yy=y-2;yy<=y+2;yy++)
            {
                if(xx>0 && xx<=n && yy>0 && yy<=m && !vis[xx][yy] && s[xx][yy]=='.')
                    Q.push_back((node){xx,yy,step+1});
            }
    }
    if(ans[tx][ty]<0) puts("-1");
    else printf("%d\n",ans[tx][ty]);

    return 0;
}


Measured memory_bytes: 13088
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: -1 * int(x), input().split()))

heapq.heapify(A)
for _ in range(M):
    a = -1 * heapq.heappop(A)
    a //= 2
    heapq.heappush(A, -1 * a)

print(-1 * sum(A))


Measured memory_bytes: 14184
n,k,*a=map(int,open(0).read().split())
b=[[]for _ in range(max(a)+1)]
l=[]
for i,v in enumerate(a):
  b[v]+=i,
  l+=len(b[v]),
s=a[0]
i=c=0
while 1:
  t=b[s]
  m=len(t)
  j=l[i]
  c+=j==m
  i=t[j%m]+1
  if i==n:break
  s=a[i]
k%=c+1
s=a[0]
i=c=0
while c<k-1:
  t=b[s]
  m=len(t)
  j=l[i]
  c+=j==m
  i=t[j%m]+1
  s=a[i]
r=[]
while 1:
  t=b[s]
  m=len(t)
  j=l[i]
  if j==m:
    r+=s,
    i+=1
  else:i=t[j]+1
  if i==n:break
  s=a[i]
print(*r)

Measured memory_bytes: 49148
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}
	sum := 1
	for i := 1; i < len(h); i++ {
		ok := true
		for j := 0; j < i; j++ {
			if h[i] < h[j] {
				ok = false
				break
			}
		}
		if ok {
			sum++
		}
	}
	fmt.Println(sum)
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  int64 ans = 0;
  FOR(i,1,n+1){
    ans += i * (n-i+1);
  }
  REP(i,n-1){
    int32 u,v;
    cin >> u >> v;
    if(u > v)swap(u,v);
    ans -= u * (n - v + 1);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3660