akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a-1;i>=0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
typedef map<ll, ll> MAP;
const ll mod = 1e9 + 7; //10^9+7


ll par[100002]; //親を表す
ll myrank[100002];  //木の深さを表す
ll size[100002];    //属しているへんのサイズを表す(size[find(x)]で使う)

void init(ll n) {   //初期化
    REP(i, n) {
        par[i] = i;
        myrank[i] = 0;
        size[i] = 1;
    }
}

ll find(ll x) {    //親を見つける
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unit(ll x, ll y) {    //x,yを併合
    x = find(x);
    y = find(y);
    if (x == y)return;

    if (myrank[x] < myrank[y]) {
        par[x] = y;
        size[y] += size[x];
    } else {
        par[y] = x;
        if (myrank[x] == myrank[y])myrank[x]++;
        size[x] += size[y];
    }
}

bool same(ll x, ll y) {    //x,yが同じグループか判定
    return find(x) == find(y);
}

struct edge {
    ll to;
    ll cost;
};


int main() {
    ll n, m;
    cin >> n >> m;
    VE l(m), r(m), d(m);
    VE point(n + 1);
    vector<bool> check(n + 1);
    init(n + 1);
    VE ins;
    REP(i, n + 1)point[i] = mod;
    vector<vector<edge>> v(n + 1, vector<edge>());
    REP(i, m) {
        cin >> l[i] >> r[i] >> d[i];
        v[l[i]].push_back({r[i], d[i]});
        v[r[i]].push_back({l[i], -d[i]});
        if (!same(l[i], r[i])) {
            unit(l[i], r[i]);
            if(size[l[i]] == 2)ins.push_back(l[i]);
        }
    }

    REP(i, ins.size()) {
        point[ins[i]] = 0;
        queue<ll> que;
        que.push(ins[i]);
        while (!que.empty()) {
            ll from = que.front();
            que.pop();
            if(check[from])continue;
            check[from] = true;
            REP(i, v[from].size()) {
                ll to = v[from][i].to;
                ll cost = v[from][i].cost;

                if (point[to] == mod) {
                    point[to] = point[from] + cost;
                } else if (point[to] != point[from] + cost) {
                    print("No");
                    return 0;
                }
                if(!check[to])que.push(to);
            }
        }

    }
    print("Yes");
    return 0;
}

Measured memory_bytes: 21756
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
ll n , a ;
vl v ;
ll dp[55][2750][55];
ll solve(ll curr , ll sum , ll cnt)
{
    ///cout << "curr is " << curr << " sum is " << sum << " cnt is " << cnt << el ;
    if(curr < 0) return 0 ;
    if(curr == 0){
        if(cnt == 0) return 0;
        ll res = sum % cnt ;
        if(res) return 0 ;
        ll ziz = sum / cnt ;
        if(ziz == a) return 1 ;
    }
    if(dp[curr][sum][cnt] != -1) return dp[curr][sum][cnt] ;
    ll no = solve(curr - 1 , sum , cnt) ;
   /// cout << "here curr is " << curr << " v curr is " << v[curr] << el ;
    ll yes = solve(curr - 1 , sum + v[curr] , cnt + 1) ;
    ll ans = yes + no ;
    dp[curr][sum][cnt] = ans ;
    return ans ;
}
int main()
{
    ios;
    cin >> n >> a ;
    memset(dp , -1 , so dp) ;
    v.pb(-1);
    forn(i , 1 , n ){
       ll x;
       cin >> x;
       v.pb(x);
    }
    sort(all(v));
    ll foo = solve(n ,  0 , 0) ;
    cout << foo << el ;
}

Measured memory_bytes: 65280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[200005], b[200005], vis[200005], pos = 1, p;
ll k;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	while (!vis[pos])
	{
		b[p] = pos;
		vis[pos]++;
		pos = a[pos];
		p++;
	}
	for (int i = 0; i < p; i++)
	{
		if (b[i] == pos)
		{
			if (k > i)
			{
				cout << b[(int)((k - i) % (ll)(p - i)) + i] << endl;
			}
			else
			{
				cout << b[k] << endl;
			}
			return 0;
		}
	}
}

Measured memory_bytes: 5832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  int cnt  = 0;
  for(int i=1;i<=N;i++){
    if(i%2==1) cnt++;
  }
  cout << (double)cnt / N << endl;
  return 0;
}


Measured memory_bytes: 764
<?php
  list($x, $y, $a, $b, $c) = explode(" ", trim(fgets(STDIN)));

  $p = explode(" ", trim(fgets(STDIN)));
  $q = explode(" ", trim(fgets(STDIN)));
  $r = explode(" ", trim(fgets(STDIN)));

  rsort($p);
  rsort($q);
  rsort($r);

  $f = array_slice($p,0,$x);
  for($i=0;$i<$y;$i++){
    $f[] = $q[$i];
  }
  for($i=0;$i<$c;$i++){
    $f[] = $r[$i];
  }
  rsort($f);

  $f = array_slice($f,0,$x+$y);

  echo array_sum($f);

Measured memory_bytes: 47592
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 1;
int dp[maxN] [3];
int main( ){
    int n;
    cin >> n;
    int arr[n] [3];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 3; j++)
            scanf("%d", &arr[i] [j]);
    dp[0] [0] = arr[0] [0];
    dp[0] [1] = arr[0] [1];
    dp[0] [2] = arr[0] [2];
    for(int i = 1; i < n; i++)
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[i] [j] = max(dp[i] [j], dp[i - 1] [k] + arr[i] [j]);
    int ans = 0;
    for(int i = 0; i < 3; i++)
        ans = max(ans, dp[n - 1] [i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 6064
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
//const int INF = 1001001001;
const int MOD = 1000003;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,4)if(s[i]=='+')ans++;else ans--;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
  int n,m,l,r;
  scanf("%d %d",&n,&m);
  int lmax=0,rmin=n;
  for(int i=0;i<m;i++){
    scanf("%d %d",&l,&r);
    if(lmax<l) lmax=l;
    if(rmin>r) rmin=r;
  }
  printf("%d",(rmin-lmax>=0) ? rmin-lmax+1 : 0);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

ll p[19];

ll dfs(ll l, ll i, ll x){
    if(i * 2 + 1 == l){
        if(x == 0) return 10;
        return 0;
    }
    if(i * 2 == l){
        if(x == 0) return 1;
        return 0;
    }
    ll s = p[l - i - 1] - p[i];
    ll u;
    if(l - i - 1 == 0) u = p[0] * 2;
    else u = p[l - i - 1] + p[l - i - 2] * 2;
    ll res = 0;
    for(int j = -9; j <= 9; j++){
        if(abs(x + s * j) < u){
            if(i == 0) res += dfs(l, i + 1, abs(x + s * j)) * (9 - abs(j));
            else res += dfs(l, i + 1, abs(x + s * j)) * (10 - abs(j));
        }
    }
    return res;
}

int main()
{
    ll d;
    cin >> d;
    p[0] = 1;
    for(int l = 1; l <= 18; l++) p[l] = p[l - 1] * 10;
    ll ans = 0;
    for(int l = 2; l <= 18; l++){
        if(p[l] < d) continue;
        ans += dfs(l, 0, d);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int count = 0;
		for(int i = a; i <= b; i++){
			if(c%i ==0){
			count++;
			}
		}
		System.out.println(count);
	}
}

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

int main(void){
  
  int N,Q;
  cin >> N >> Q;

  string S;
  cin >> S;
  
  int l[100000],r[100000];
  int i;
  int A[100000]={0};
  bool a[100000]={0};
  
  for(i=0;i<Q;i++)  cin >> l[i] >> r[i];
  
  for(i=0;i<N-1;i++){
    
    if(S[i]=='A'){
      if(S[i+1]=='C'){
        A[i]++;
        a[i]=1;
      }
    }
    A[i+1]=A[i];
  }
  
  int ans;
  
  for(i=0;i<Q;i++){
    ans=A[r[i]-1]-A[l[i]-1];
   
    if(a[r[i]-1]==1){
      ans--;
    }
    if(a[l[i]-1]==1){
      ans++;  
    } 
    cout << ans <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==7)
	{
		if(b==5&&c==5)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
	} 
	else if(a==5)
	{
		if(b==5&&c==7)
		cout<<"YES"<<endl;
		else if(b==7&&c==5)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
using ll = long long;
using namespace std;
int main(){
	ll n;
	cin>>n;
	vector<ll> t(n);
	for(int i=0; i<n;++i){
		cin>> t[i];
	}
	ll ans=t[0];
	for(int i=1; i<n;++i){
	  ans = t[i]/__gcd(t[i], ans)*ans;
	}
   cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long lint;

const int MAXN = 333;
lint D[MAXN][MAXN];
bool need[MAXN][MAXN];

lint solve(int N) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      need[i][j] = true;
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (k == i || k == j) continue;
        if (D[i][j] == D[i][k] + D[k][j]) {
          need[i][j] = false;
        } else if (D[i][j] > D[i][k] + D[k][j]) {
          return -1;
        }
      }
    }
  }
  lint ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (need[i][j]) {
        ans += D[i][j];
      }
    }
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> D[i][j];
    }
  }
  cout << solve(N) << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int ppp(int arr[], int N, char ccc[]){
    int counter, j, temp;
    char c;
    for(counter=0;counter<N;counter++){
        for(j=N-1; j>counter; j--){
            if (arr[j]<arr[j-1]){
                temp = arr[j];
                arr[j]=arr[j-1];
                arr[j-1]=temp;
                c = ccc[j];
                ccc[j]=ccc[j-1];
                ccc[j-1]=c;
            }
        }
    }
    for(j=0; j<N; j++){
        printf("%c%d",ccc[j],arr[j]);
        if(j != N-1) printf(" ");
    }
    printf("\nStable\n");
    return 1;
}
int xxx(int arr[], int N, char ccc[]){
    int counter, j, temp, aaa;
    char c;
    for(counter=0;counter<N;counter++){
        temp = counter;
        for(j=counter;j<N;j++){
            if (arr[j]<arr[temp]){
               temp = j;
            }
        }
            aaa = arr[counter];
            arr[counter] = arr[temp];
            arr[temp] = aaa;
            c = ccc[counter];
            ccc[counter] = ccc[temp];
            ccc[temp] = c;
    }
   for(j=0; j<N; j++){
        printf("%c%d",ccc[j],arr[j]);
        if(j != N-1) printf(" ");
    }
    return 1;
}

int main(int argc, char** argv) {
    int N = 0;
    scanf("%d",&N);
    int arr[N];
    char list[N];
    int arr_b[N];
    char list_b[N];
    int counter, j, temp, aaa;
    for(counter=0;counter<N;counter++){
        scanf(" %c %d", &list[counter], &arr[counter]);
        list_b[counter] = list[counter];
        arr_b[counter] = arr[counter];
    }

    int ppp1 = ppp(arr_b, N, list_b);
    /*for(int i=0; i<N; i++){
        arr_b[i] =  arr[i];
        list_b[i] = list[i];
    }*/
    int ppp2 = xxx(arr, N, list);

    if ((strncmp(list_b,list,N)==0)){
    printf("\nStable\n");
    }else{
    printf("\nNot stable\n");
    }
    return 0;
}



Measured memory_bytes: 2104
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


x,k,d=mdata()
x=abs(x)
if x>=k*d:
    out(x-k*d)
else:
    t=x//d
    if (t+k)%2==0:
        out(x-t*d)
    else:
        out((t+1)*d-x)

Measured memory_bytes: 72960
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////
vector<vector<int>>G;
bool visited[100100];
ll N, K;
ll ans = 1;
void rec(int v,int x,int y) {
	visited[v] = true;
	ans*=(K - x - y);
	ans %= INF;
	for (int ch : G[v]) {
		if (visited[ch])continue;
		rec(ch,1, x);
		x++;
	}
}
int main() {
	cin >> N >> K;
	G.assign(N, vector<int>());
	for (int i = 0; i < 100100; ++i)visited[i] = false;
	for (int i = 0; i < N-1; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rec(0,0,0);
	cout << ans << endl;
	return 0;
}


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

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

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

    string S; cin >> S;
    sort(S.begin(),S.end());

    if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
n,k = list(map(int,input().split()))

ans = float(0)

for i in range(1,n+1):
    p = float(1/n)
    if i > k:
        ans += float((n-i+1)/n)
        break
    for j in range(0,20):
        if i*(2**j) < k:
            p *= float(1/2)
    ans += p

print(ans)

Measured memory_bytes: 3060
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    auto d = aryread();
    auto m = lread();
    auto t = aryread();
    long[long] dd;
    foreach (i; 0 .. n)
    {
        dd[d[i]] = dd.get(d[i], 0) + 1;
    }
    // writeln(dd);
    long[long] tt;
    foreach (i; 0 .. m)
    {
        tt[t[i]] = tt.get(t[i], 0) + 1;
    }
    // writeln(tt);
    foreach (key, value; tt)
    {
        if (key in dd)
        {
            if (dd[key] < value)

            {
                writeln("NO");
                return;
            }
        }
        else
        {
            writeln("NO");
            return;
        }

    }
    writeln("YES");
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 41572
#include<stdio.h>

int main(void)
{
	int i, j, v, N;
	int c;
	scanf("%d", &N);
	
	int A[N];
	for(i=0; i<N; i++){ scanf("%d", &A[i]); }
	for(c=0; c<N; c++)
	{
		if(c==N-1){ printf("%d\n", A[c]); }
		else{ printf("%d ", A[c]); }
	}
	for(i=1; i<N; i++)
	{
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v)
		{
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for(c=0; c<N; c++)
		{
			if(c==N-1){ printf("%d\n", A[c]); }
			else{ printf("%d ", A[c]); }
		}
	}
	
	return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, x;
signed main() {
    cin >> N >> x;
    if (N == 2) {
        if (x == 2) {
            cout << "Yes" << endl;
            cout << 1 << endl << 2 << endl << 3 << endl;
        } else { cout << "No" << endl; }
        return 0;
    }
    if (x == 1 || x == 2 * N - 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vint ans(2 * N);
    vint v;
    if (x == 2 * N - 2) {
        reps(i, 2 * N - 1) { if (i != x + 1 && i != x && i != x - 1 && i != x - 2) { v.push_back(i); }}
        for (int i = 1; i <= N - 3; i++) { ans[i] = v.back(), v.pop_back(); }
        ans[N - 2] = x - 2, ans[N - 1] = x + 1, ans[N] = x, ans[N + 1] = x - 1;
        for (int i = N + 2; i <= 2 * N - 1; i++) { ans[i] = v.back(), v.pop_back(); }
    }else{
        reps(i, 2 * N - 1) { if (i != x - 1 && i != x && i != x + 1 && i != x + 2) { v.push_back(i); }}
        for (int i = 1; i <= N - 3; i++) { ans[i] = v.back(), v.pop_back(); }
        ans[N - 2] = x + 2, ans[N - 1] = x - 1, ans[N] = x, ans[N + 1] = x + 1;
        for (int i = N + 2; i <= 2 * N - 1; i++) { ans[i] = v.back(), v.pop_back(); }
    }
    reps(i, 2 * N - 1) { cout << ans[i] << endl; }
}


Measured memory_bytes: 4720
#include<stdio.h>

int main(void)
{
  int A, B, C, D;

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

  if(A < B){
    if(C < D){
      printf("%d",A + C);
    }
    else{
      printf("%d",A + D);
    }
  }
  else{
    if(C < D){
      printf("%d",B + C);
    }
    else{
      printf("%d",B + D);
    }
  }

  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    speed;
    ll h ,n;
    cin>>h>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    {
        h-=a[i];
    }
    if(h<=0)
    cout<<"Yes"<<"\n";
    else 
    cout<<"No"<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
 
 
 
 
 
// bool prime[100000];
 
// // int gcdExtended(int a, int b, int *x, int *y) ;
// ll modInverse(int a, int m) 
// { 
//     int x, y; 
//     int g = gcdExtended(a, m, &x, &y); 
//     // if (g != 1) 
//     //     cout << "Inverse doesn't exist"; 
//     // else
//     // { 
//         // m is added to handle negative x 
//         int res = (x%m + m) % m; 
//         return res; 
//     // } 
// } 
  
// // // C function for extended Euclidean Algorithm 
// int gcdExtended(int a, int b, int *x, int *y) 
// { 
//     // Base Case 
//     if (a == 0) 
//     { 
//         *x = 0, *y = 1; 
//         return b; 
//     } 
  
//     int x1, y1; // To store results of recursive call 
//     int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
//     // Update x and y using results of recursive 
//     // call 
//     *x = y1 - (b/a) * x1; 
//     *y = x1; 
  
//     return gcd; 
// } 
// ll modu(ll x)
// {
//     if(x<0)
//     {
//         x+=mod;
//     }
//     else 
//     {
//         x=x%mod;
//     }
//     return x;
// }
 
// void SieveOfEratosthenes(int n) 
// { 
//     // Create a boolean aay "prime[0..n]" and initialize 
//     // all entries it as true. A value in prime[i] will 
//     // finally be false if i is Not a prime, else true. 
     
//     memset(prime, true, sizeof(prime)); 
  
//     for (int p=2; p*p<=n; p++) 
//     { 
//         // If prime[p] is not changed, then it is a prime 
//         if (prime[p] == true) 
//         { 
//             // Update all multiples of p greater than or  
//             // equal to the square of it 
//             // numbers which are multiple of p and are 
//             // less than p^2 are already been marked.  
//             for (int i=p*p; i<=n; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
//     prime[1]=false;
  
//     // Print all prime numbers 
//     // for (int p=2; p<=n; p++) 
//     //    if (prime[p]) 
//     //       cout << p << " "; 
// } 
// ll power(ll x, unsigned ll y, ll p) 
// { 
//     ll res = 1;      // Initialize result 
  
//     x = x % p;  // Update x if it is more than or  
//                 // equal to p 
  
//     while (y > 0) 
//     { 
//         // If y is odd, multiply x with result 
//         if (y & 1) 
//             res = (res*x) % p; 
  
//         // y must be even now 
//         y = y>>1; // y = y/2 
//         x = (x*x) % p;   
//     } 
//     return res; 
// } 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,ans="yes";
  cin>>s;
  vector<int> v(26);
  for (int i=0;i<s.size();i++) {
    v[s[i]-'a']++;
    if (v[s[i]-'a']>1) {
      ans="no";
      break;
    }
  }
  cout<<ans<<endl;
}  

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

int main(){
  int n,b[1100][1100];
  string s1,s2;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    for(int j=0;j<=s1.size()+1;j++)b[j][0]=0;
    for(int j=0;j<=s2.size()+1;j++)b[0][j]=0;
    for(int j=1;j<=s1.size();j++){
      for(int k=1;k<=s2.size();k++){
	if(s1[j-1]==s2[k-1])b[j][k]=b[j-1][k-1]+1;
	else if(b[j][k-1]>b[j-1][k])b[j][k]=b[j][k-1];
	else b[j][k]=b[j-1][k];
      }
    }
    cout<<b[s1.size()][s2.size()]<<endl;
  }
  return 0;
}

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n, x, y, z;
double memo[302][302][302];
double dfs(int i, int j, int k) {
    if (i + j + k == 0) return 0.;
    if (memo[i][j][k] != -1.) return memo[i][j][k];
    double res = 0.;
    if (i > 0) res += dfs(i - 1, j, k) * i;
    if (j > 0) res += dfs(i + 1, j - 1, k) * j;
    if (k > 0) res += dfs(i, j + 1, k - 1) * k;
    res += n;
    res /= i + j + k;
    return memo[i][j][k] = res;
}

void solve() {
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (a == 1) ++x;
        else if (a == 2) ++y;
        else ++z;
    }

    fillArray(memo, -1.);
    dfs(x, y, z);
    cout << memo[x][y][z] << endl;
}

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


Measured memory_bytes: 215680
t_HP, t_A, a_HP, a_A = map(int,input().split())
ans = False
while True:
  a_HP -= t_A
  if a_HP <= 0:
    ans = True
    break
  t_HP -= a_A
  if t_HP <= 0:
    break

if ans == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-3;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define CHECK cout<<"arrived"<<endl

ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a);
    return k%2 ? (a*n) : a;
}

Mat mul(Mat &A, Mat &B){
    Mat C(A.size(), Vec(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int k=0;k<B.size();k++){
            for(int j=0;j<B[0].size();j++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j]);
            }
        }
    }
    return C;
}

Vec mulvec(Mat &A, Vec B){
    Vec C(A.size(),0);
    rep(i,A.size()){
        rep(j,B.size()) C[i]+=A[i][j]*B[j];
    }
    return C;
}
Vec gauss_jordan(const Mat &A, const Vec &b){
    ll N=A.size();
    Mat B(N,Vec(N+1,0));
    rep(i,N) rep(j,N) B[i][j]=A[i][j];
    rep(i,N) B[i][N]=b[i];
    rep(i,N){
        ll pivot=i;
        REP(j,i,N) if(abs(B[j][i])>abs(B[pivot][i])) pivot=j;
        swap(B[i],B[pivot]);
        if(abs(B[i][i])<DEL) return Vec();
        REP(j,i+1,N+1) B[i][j]/=B[i][i];
        rep(j,N) if(i!=j){
            REP(k,i+1,N+1) B[j][k]-=B[j][i]*B[i][k];
        }
    }
    Vec x(N);
    rep(i,N) x[i]=B[i][N];
    return x;
}

Mat Create(ll N, ll k, ll l){
    Mat C(N, Vec(N,1));
    vec x;
    rep(i,N+2) if(i!=k && i!=l) x.pb(i);
    rep(i,N) REP(j,1,N) C[i][j]=C[i][j-1]*x[i];
    return C;
}


ll Solving(ll N, ll k, ll l, Vec a){
    Mat C=Create(N,k,l);
    Vec b;
    rep(i,a.size()) if(i!=k && i!=l) b.pb(a[i]);
    Vec x=gauss_jordan(C,b);
    double ret=0;
    rep(i,N) ret+=x[i]*ruijou(k,i);
    //CHECK;
    if(abs(ret-a[k])<DEL) return l;
    ret=0;
    rep(i,N) ret+=x[i]*ruijou(l,i);
    if(abs(ret-a[l])<DEL) return k;
    return -1;
}

ll Solve(ll N){
    Vec a(N+2);
    rep(i,N+2) cin>>a[i];
    for(int i=0;i<N+1;i+=2){
        ll p=Solving(N,i,i+1,a);
        if(p>=0) return p;
    }
    return N+1;
}

int main(){
    vec ans;
    while(true){
        ll N; cin>>N;
        if(!N) break;
        ans.pb(Solve(N+1));
    }
    rep(i,ans.size()) cout<<ans[i]<<endl;
}




Measured memory_bytes: 3260
N, M = map(int,input().split())
P = []
for i in range(M):
    p, y = map(int,input().split())
    P.append([y, p ,i])
P.sort()

ken = [0] * N
shis = [''] * M

for y, p, i in P:
    ken[p-1] += 1
    shis[i] = str(p).zfill(6) + str(ken[p-1]).zfill(6)
    
for shi in shis:
    print(shi)

Measured memory_bytes: 32180
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string s;
  cin >> s;
  string k = "keyence";
  int n = s.size();
  for(int i=0; i<n; i++) {
    for(int j=0; j<n-i; j++) {
      string t = s;
      if(t.erase(i,j) == k) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);


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

    int a, b;

    std::cin >> a >> b;

    std::cout << std::max({ a + b,a - b,a * b }) << std::endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

template <class T>
class SegmentTree {
    using Op = std::function<T(T, T)>;

private:
    const Op op;
    const T ID;
    std::vector<T> vec;
    int sz;

public:
    explicit SegmentTree(int _n, Op _op, T _identity) noexcept : op(_op), ID(_identity) {
        sz = 1;
        while (sz < _n) sz <<= 1;
        vec.resize(sz * 2, ID);
    }
    void set_value(int _idx, T _val) {
        vec[_idx + sz] = _val;
    }
    template <class RandomIt>
    void set_array(RandomIt _begin, RandomIt _end) {
        std::copy(_begin, _end, vec.begin() + sz);
    }
    void set_array(const std::vector<T>& _newvec) {
        set_array(_newvec.begin(), _newvec.end());
    }
    void build() noexcept {
        for (int i = sz - 1; i > 0; i--) {
            vec[i] = op(vec[i * 2], vec[i * 2 + 1]);
        }
    }
    void update(int _idx, T _val) {
        _idx += sz;
        vec[_idx] = _val;
        for (_idx >>= 1; _idx > 0; _idx >>= 1) {
            vec[_idx] = op(vec[_idx * 2], vec[_idx * 2 + 1]);
        }
    }
    T query(int _l, int _r) const {
        T l_val = ID, r_val = ID;
        _l += sz, _r += sz - 1;
        for (; _l <= _r; _l >>= 1, _r >>= 1) {
            if (_l & 1) l_val = op(l_val, vec[_l++]);
            if (!(_r & 1)) r_val = op(r_val, vec[_r--]);
        }
        return op(l_val, r_val);
    }
};

using alph = bitset<26>;

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

    int N;
    string S;
    cin >> N >> S;
    int Q;
    cin >> Q;

    SegmentTree<alph> seg(N, [](alph a, alph b) { return a | b; }, 0);
    for (int i = 0; i < N; i++) {
        alph al(0);
        al.set(S[i] - 'a');
        seg.set_value(i, al);
    }
    seg.build();

    for (int i = 0; i < Q; i++) {
        int q;
        cin >> q;
        if (q == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            alph al(0);
            al.set(c - 'a');
            seg.update(--idx, al);
        }
        else {
            int l, r;
            cin >> l >> r;
            cout << seg.query(--l, r).count() << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 9116
#include "bits/stdc++.h"
using namespace std;

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
#define souwa(vec) accumulate(ASC(vec), 0)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

int main() {
	vi s(10);
	rep(i, 10) cin >> s[i];
	cout << souwa(s) << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


constexpr ll MOD=1e9+7;

int main(){
    int n;
    cin>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    ll ans=0;
    rep(i,60){
        ll cnt=0;
        rep(j,n){
            if(p[j]>>i&1) cnt++;
        }
        ll a=cnt*(n-cnt);
        rep(j,i) a=a*2%MOD;
        ans+=a;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll A,B;
    cin >> A >> B;
    ll tmp=2;
    ll i;
    ll ans=0;
    ll num;
    ll zero=0;
    for(i=0;i<40;i++){
      num=B/tmp*tmp/2+max(zero,B%tmp-tmp/2+1);
      num-=(A-1)/tmp*tmp/2+max(zero,(A-1)%tmp-tmp/2+1);
      num=num%2;
      ans+=num*tmp/2;
      tmp*=2;
    }
    if(A!=B)cout << ans;else cout << A;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define lli long long int  
#define ll  long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl   vector<lli>
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0); const int INF = 1e9 + 5;
ull power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
 //bool sortinrev(const pair<int,int> &a,   const pair<int,int> &b) {  if(a.first==b.first) return a.second>b.second;  return (a.first < b.first);} 
              
 

 void Pitch(){
  lli n;
  cin>>n;
  vl a(n),b(n),c(n);
  for(int i=0;i<n;i++)
  {
  	cin>>a[i]>>b[i]>>c[i];
  }
  int dp[n][3];
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(int i=1;i<n;i++)
  {
  	dp[i][0]=max(a[i]+dp[i-1][1],a[i]+dp[i-1][2]);
  	dp[i][1]=max(b[i]+dp[i-1][0],b[i]+dp[i-1][2]);
  	dp[i][2]=max(c[i]+dp[i-1][1],c[i]+dp[i-1][0]);

  }

  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;


 	
 }
    
       
       	 
          
                
       
 signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	lli tst;
       tst=1; 
       //cin>>tst;
       while(tst--) Pitch();
       return 0;
      } 

Measured memory_bytes: 6524
#include <stdio.h>
int main(){
	int n,l,k,j,i,m[101][101],p[101],min;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",&p[i-1],&p[i]);
	}
	for(i=1;i<=n;i++){
		m[i][i]=0;
	}
	for(l=2;l<=n;l++){
		for(i=1;i<=n-l+1;i++){
			j=i+l-1;
			m[i][j]=2000000000;
			for(k=i;k<=j-1;k++){
				min=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
				if(min<m[i][j])
					m[i][j]=min;
			}
		}
	}
	printf("%d\n",m[1][n]);
	return 0;
}



Measured memory_bytes: 2004
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (S.length() <= K) {
		cout << S << endl;
	}
	else {
		for (int i = 0; i < K; i++) {
			cout << S[i];
		}
		cout << "..." << endl;
	}
	
	
}

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

int main(){


int A,B,M;
cin>>A>>B>>M;


int amin=100000;
int bmin=100000;

int a[A],b[B];
int x[M],y[M],c[M];
int i,j,k,q,w;

for(i=0;i<A;++i){cin>>a[i];if(a[i]<amin)amin=a[i];}
for(j=0;j<B;++j){cin>>b[j];if(b[j]<bmin)bmin=b[j];}
for(k=0;k<M;++k)cin>>x[k]>>y[k]>>c[k];

int cost[M];
int f=amin+bmin;

for(int l=0;l<M;l++){

	w=x[l]-1;
	q=y[l]-1;
	cost[l]=a[w]+b[q]-c[l];
	if(cost[l]<f){f=cost[l];}
}

cout<<f<<endl;
}

Measured memory_bytes: 2560
s=input()
ans=0

if len(s)==1:
  print(s)
  exit()

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)

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

const int m = 1000000007;
int n, k;
long a[100001];

long mpow(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return b * mpow(b, e - 1) % m;
  long t = mpow(b, e / 2);
  return t * t % m;
}

int main() {
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    a[i] = mpow(k / i, n);
  }
  
  for (int i = k; i >= 1; --i) {
    for (int j = 2 * i; j <= k; j += i) {
      a[i] = (a[i] + m - a[j]) % m;
    }
  }
  
  long sum = 0;
  for (int i = 1; i <= k; ++i) {
    sum = (sum + a[i] * i) % m;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,ans=0;cin>>n;
    vector<P> v(n);
    rep(i,n){
        ll a,b;cin>>a>>b;
        v[i]=P(a,b);
    }
    sort(all(v));
    vi minb(n);
    ll mi=n-1;
    minb[n-1]=v[n-1].second;
    for(int i=n-2;i>=0;i--){
        if(v[i].second>=minb[i+1])minb[i]=minb[i+1];
        else{
            minb[i]=v[i].second;
            mi=i;
        }
    }
    rep(i,n){
      chmax(ans,max((ll)(0),v[i].second-v[i].first+1));
    }
    ans+=max((ll)(0),v[mi].second-v[n-1].first+1);
    REP(i,mi,n-1){
        chmax(ans,max((ll)(0),v[mi].second-v[i].first+1)+max((ll)(0),minb[i+1]-v[n-1].first+1));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

vector<pair<int,int>> uniq(vector<pair<int,int>> v) {
  sort(ALL(v));
  vector<pair<int,int>> res;
  for (auto p: v) {
    if (res.empty() || res.back().second < p.first) res.push_back(p);
    else res.back().second = max(res.back().second, p.second);
  }
  return res;
}

int dp[128000];

const int NUM = 320;

void solve(ll N, ll M, const vector<int> &l, const vector<int> &r) {
  assert (N <= 300000);
  assert (M <= 100000);
  REP(i,N) {
    assert(1 <= l[i]);
    assert(l[i] <= r[i]);
    assert(r[i] <= M);
  }
  REP(i,N) {
    int prev = NUM + 1;
    for (int j = NUM; j >= 1; --j) {
      if ((l[i] - 1) / j < r[i] / j) {
        ++dp[j]; --dp[j+1];
        int left = (l[i] - 1) / j + 1;
        int right = r[i] / j + 1;
        chmax(left, prev);
        chmax(right, left);
        chmax(prev, right);
        ++dp[left]; --dp[right];
        // cout << j << " " << j + 1 << endl;
        // cout << left << " " << right << endl;
      }
    }
  }
  REP(i,120000) dp[i+1] += dp[i];
  for (int i = 0; i < M; ++i) {
    cout << dp[i+1] << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll M;
	scanf("%lld", &N);
  scanf("%lld", &M);
	vector<int> r(N-1+1);
	vector<int> l(N-1+1);
  for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%d", &l[i]);
	  scanf("%d", &r[i]);
	}
	solve(N, M, l, r);
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<P> x(n);
    rep(i,n) cin >> x[i].first;
    rep(i,n) x[i].second = i;
    sort(all(x));
    vector<int> ans(n);
    rep(i,n) {
        if(i < n/2) ans[x[i].second] = x[n/2].first;
        else ans[x[i].second] = x[n/2-1].first;
    }
    rep(i,n) cout << ans[i] << endl;
}


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

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


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

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >>s;
    int ans = 0;
    for(int i = 0; i < 3; i++) if(s[i] == '1') ans++;
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }
    else if(r<2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256