akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    vector<pii> AB;
    REP0 (i, N)
    {
        int A, B;
        cin >> A >> B;
        AB.push_back(make_pair(A, B));
    }

    sort(AB.begin(), AB.end(), [](pii a, pii b) { return a.second < b.second; });

    LL cum = 0;
    REP0 (i, N)
    {
        cum += AB[i].first;
        if (cum > AB[i].second)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 2420
N=int(input())
D,X=map(int,input().split())
A=[int(input()) for i in range(N)]

def ans092(N:int, D:int, X:int, A:list):
    ans_int=0
    for i in range(N):
        j_count=0
        while True:
            if 1+A[i]*j_count<=D:
                ans_int+=1
                j_count+=1
                continue
            else:
                break
    return ans_int+X

print(ans092(N,D,X,A))

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    if (k > (n - 2) * (n - 1) / 2)
    {
        cout << -1 << endl;
        return 0;
    }

    // int x = 0;
    // for (int i = n - 1; i >= 1; --i)
    // {
    //     if (k > i * (i - 1) / 2 + (n - i - 1))
    //     {
    //         x = i;
    //         break;
    //     }
    // }

    int m = (n * (n - 1)) / 2 - k;
    cout << m << endl;
    rep(i, n - 1)
    {
        printf("%d %d\n", 1, i + 2);
    }
    int c = n - 1;
    for (int i = 2; i < n; ++i)
    {
        if (c >= m)
            break;
        for (int j = i + 1; j <= n; ++j)
        {
            if (c >= m)
                break;
            printf("%d %d\n", i, j);
            c++;
        }
    }

    return 0;
}

Measured memory_bytes: 3752
use proconio::input;

fn main() {
    input! {
        x: u32,
        y: u32
    }
    for a in 0..=x {
        let b = x - a;
        if 2 * a + 4 * b == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

const int N=500010;

int n,ret=LLONG_MAX;
int a[N],pf[N];

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    n=in;
    forinc(i,1,n) a[i]=in;
    forinc(i,1,n) pf[i]=pf[i-1]+a[i];
    forinc(i,1,n-1){
        int lft=pf[i],rht=pf[n]-pf[i];
        ret=min(ret,abs(lft-rht));
    }
    cout<<ret;
}



Measured memory_bytes: 5888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int main(){
    int k, a, b, x;
    scanf("%d",&k); x = k;
    scanf("%d %d",&a,&b);
    while(x<=b){
        if(x>=a&&x<=b){
            printf("OK"); return 0;
        }
        x+=k;
    } printf("NG");
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'001;
const int LOGN = 19;

int n, m, k;

vector<int> g[N];
vector<int> ans;
int was[N];

void dfs(int v) {
  was[v] = 1;
  ans.push_back(v);
  for (int u : g[v]) {
    if (was[u] == 1) {
      int sz = (int)ans.size() - 1;
      set<int> st;
      st.insert(u);
      while (ans[sz] != u) {
        st.insert(ans[sz]);
        --sz;
      }
      bool ok = true;
      for (size_t i = sz; ok && i < ans.size(); ++i) {
        int cnt = 0;
        for (int to : g[ans[i]]) {
          cnt += st.find(to) != st.end();
        }
        if (cnt != 1) {
          ok = false;
        }
      }
      if (!ok) {
        continue;
      }
      cout << ans.size() - sz << '\n';
      for (size_t i = sz; i < ans.size(); ++i) {
        cout << ans[i] + 1 << '\n';
      }
      exit(0);
    }
    else if (was[u] == 0) {
      dfs(u);
    }
  }
  ans.pop_back();
  was[v] = 2;
}

void solve(int test)
{
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
  }
  for (int i = 0; i < n; ++i) {
    if (!was[i]) {
      dfs(i);
    }
  }
  cout << "-1\n";
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 5120
h, w = [int(x) for x in input().split()]
s_list = [input() for _ in range(h)]

def count_bomb_num(i, j):
    bomb_num = 0
    for k in range(-1, 2):
        if j == 0 and k == -1:
            continue
        if j == w - 1 and k == 1:
            continue
        if s_list[i][j + k] == "#":
            bomb_num += 1
    return bomb_num

count_list = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if i == 0:
            count_list[i][j] = count_bomb_num(i, j)
        if i < h - 1:
            count_list[i + 1][j] = count_bomb_num(i + 1, j)
        
        if s_list[i][j] == "#":
            print("#", end="")
        else:
            bomb_num = count_list[i][j]
            if i > 0:
                bomb_num += count_list[i - 1][j]
            if i < h - 1:
                bomb_num += count_list[i + 1][j]
            print(bomb_num, end="")
    print()

Measured memory_bytes: 9224
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();
    int a = A.length();
    int b = B.length();
    String x = A.substring(0, 1);
    String y = B.substring(0, 1);
    if(A.equals(B)) {
      System.out.println("EQUAL");
    } else if(a > b) {
      System.out.println("GREATER");
    } else if(a < b) {
      System.out.println("LESS");
    } else {
      for(int i=0; i<a; i++) {
        if(x.equals(y)) {
          x = A.substring(i+1, i+2);
          y = B.substring(i+1, i+2);
        } else {
          if(Integer.parseInt(x) > Integer.parseInt(y)) {
            System.out.println("GREATER");
          } else {
            System.out.println("LESS");
          }
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = []
count = 0

s=input()
for si in s:
    if si=="1":
        ans.append(1)
    elif si=="0":
        ans.append(0)
    else:
        if ans:
            ans.pop()
print(*ans,sep='')


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

int dp[3][3][101] = {};

int main(){
    int n, k;
    cin >> n >> k;
    map<int,int> m;
    int a, b;

    while(k--){
        cin >> a >> b;
        m[a] = b-1;
    }

    // 2日目までの予定を入れてしまう
    for(int first = 0; first < 3; first++){
        if(m.count(1) && m[1] != first) continue;
        for(int second = 0; second < 3; second++){
            if(m.count(2) && m[2] != second)    continue;
            dp[first][second][2] += 1;
        }
    }

    for(int i = 3; i <= n; i++){
        for(int today = 0; today < 3; today++){
            if(m.count(i) && m[i] != today) continue;
            for(int a = 0; a < 3; a++){
                for(int b = 0; b < 3; b++){
                    if(a == b && b == today)    continue;
                    dp[b][today][i] += dp[a][b][i-1];
                    dp[b][today][i] %= 10000;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            ans += dp[i][j][n];
            ans %= 10000;
        }
    }

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


Measured memory_bytes: 3096
n =int(input())
count = 0
judge = 0
for i in range(n):
    nums = [int(e) for e in input().split()]
    if nums[0] == nums[1]:
        count += 1
        if count >= 3:
            judge = 1
    else:
        count = 0

if judge == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9168
MOD = int(1e9)+7

def fact(x):
    k = 1
    for i in range(1,x+1):
        k = (k*i)%MOD
    return k

def inverse(b):
    r = 1
    e = MOD -2
    while e:
        if e%2==1:
            r = (r*b)%MOD
        b = (b*b)%MOD
        e >>=1
    return r

def comb(i,j):
    if i==0 or j==0:
        return 0
    num=fact(i+j)
    num*=inverse(fact(i))
    num%=MOD
    num*=inverse(fact(j))
    num%=MOD
    return num

rc = list(map(int, input().split()))
ans = 0
ans += comb(rc[2]+1,rc[3]+1)
ans -= comb(rc[0],rc[3]+1)
ans -= comb(rc[2]+1,rc[1])
ans += comb(rc[0],rc[1])
ans += MOD
ans += MOD
ans %=MOD
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;



int main(){
    char s[4];
    int key = 0;
    for(int i = 0; i< 4;i++){
         cin >> s[i];
    }
    sort(s, s+4);
    if(s[0] == s[1] && s[2] == s[3])key = 1;
    if(s[1] == s[2]) key = 0;
     if(key) cout << "Yes" << endl;
     if(!key) cout << "No" << endl;    
}

Measured memory_bytes: 888
N, M, X = map(int, input().split())

matrix = []
c = []
ans = float("inf")

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    flg = True
    for k in range(M):
        if rikai[k] < X:
            flg = False
    if flg:
        ans = min(ans, cost)
    

if ans == float("inf"):
    print(-1)
else:
    print(ans)        

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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 dp[90][90][6410];

int main(){
    ll h,w;cin >> h >>w;
    vvl a(h,vl(w)),b(h,vl(w));
    rep(i,h)rep(j,w)cin >> a[i][j];
    rep(i,h)rep(j,w)cin >> b[i][j];
    dp[0][0][abs(a[0][0]-b[0][0])]++;
    rep(i,h){
        rep(j,w){
            if(i+1<h){
                ll x=abs(a[i+1][j]-b[i+1][j]);
                rep(k,6410){
                    if(dp[i][j][k]){
                        if(k+x<6410)dp[i+1][j][k+x]++;
                        dp[i+1][j][abs(k-x)]++;
                    }
                }
            }
            if(j+1<w){
                ll y=abs(a[i][j+1]-b[i][j+1]);
                rep(k,6410){
                    if(dp[i][j][k]){
                        if(k+y<6410)dp[i][j+1][k+y]++;
                        dp[i][j+1][abs(k-y)]++;
                    }
                }
            }
        }
    }
    /*rep(i,h){
        rep(j,w){
            rep(k,10){
                cout << dp[i][j][k] <<" ";
            }
            cout <<endl;
        }
    }*/
    rep(j,6410){
        if(dp[h-1][w-1][j]){
            cout << j <<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 359424
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n, s = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            for (int k = 1; k <= n; k++)
                s += __gcd(i, __gcd(j, k));
    cout << s;
}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D043
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string r = "-1 -1";
            for(int i = 1; i < s.Length; i++)
            {
                if (s[i] == s[i - 1])
                {
                    r = i  + " " + (i+1).ToString();
                    break;
                }
                if(i>1 && s[i] == s[i - 2])
                {
                    r = (i - 1).ToString() + " " + (i + 1).ToString();
                    break;
                }
            }
            Console.WriteLine(r);
        }

    }
}


Measured memory_bytes: 13116
import java.util.*;

public class Main {
    static final int SIZE = 40;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans;
		if (a % 2 == 0) {
		    if (b % 2 == 0) {
		        if ((b - a) % 4 != 0) {
		            ans = b ^ 1L;
		        } else {
		            ans = b;
		        }
		    } else {
		        if ((b + 1 - a) % 4 != 0) {
		            ans = 1;
		        } else {
		            ans = 0;
		        }
		    }
		} else {
		    if (b % 2 == 0) {
		        if ((b - (a + 1)) % 4 != 0) {
		            ans = a ^ b ^ 1L;
		        } else {
		            ans = a ^ b;
		        }
		    } else {
		        if ((b + 1 - (a + 1)) % 4 != 0) {
		            ans = a ^ 1;
		        } else {
		            ans = a;
		        }
		    }
		}
		System.out.println(ans);
    }
}



Measured memory_bytes: 21972
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#define LL long long
using namespace std;
const int N = 300010;
int n, a[N];
LL ans;

int main() 
{
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + 3 * n);
	for(int i = 3 * n - 1; i > n; i-= 2)
		ans += a[i];
	cout << ans << endl;
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0; i<n; i++) {
        cin >> l.at(i);
    }
    
    int ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                if (l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i)) {
                    if (l.at(i) + l.at(j) <= l.at(k) || l.at(j) + l.at(k) <= l.at(i) || l.at(k) + l.at(i) <= l.at(j)) continue;
                ans++;
                }
            }
        }
    }
    cout << ans << endl;
}   


Measured memory_bytes: 3632
import bisect
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    lower_a = bisect.bisect_left(A, b)
    upper_c = N - bisect.bisect_right(C, b)
    ans += lower_a*upper_c

print(ans)


Measured memory_bytes: 22720
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

void dfs (int v, int pr = 0, int sum = 0) {
	a[v] += sum;
	for (auto to : g[v]) if (to != pr) {
		dfs(to, v, a[v]);
	}
}

int main () {
	SpeedForce;
	cin >> n >> m;
	for (int i = 1; i < n; i ++) {
		int l, r;
		cin >> l >> r;
		g[l].pb(r);
		g[r].pb(l);
	}

	for (int i = 1; i <= m; i ++) {
		int p, s;
		cin >> p >> s;
		a[p] += s;
	}
	dfs(1);
	for (int i = 1; i <= n; i ++)
		cout << a[i] << ' ';

	return Accepted;
}

// B...a

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

using namespace std;

int n, w;
int v[110];
int g[20];

int main() {
	while (cin >> n >> w, n) {
		int div = 100 / w + 1;
		memset(g, 0, sizeof(g));
		
		for (int i = 0; i < n; i++) {
			int v; cin >> v;
			for (int j = 0; j < div; j++) {
				if (w * j <= v && v < w * (j + 1)) {
					g[j]++;
					break;
				}
			}
		}
		
		int r = div - 1;
		while (g[r] == 0) r--;
		int h = 0;
		for (int i = 0; i <= r; i++) h = max(h, g[i]);
		
		double ans = 0.01;
		double col = 1.0, sub = 1.0 / (double)r;
		for (int i = 0; i <= r; i++) {
			double rate = (double)g[i] / (double)h;
			ans += col * rate;
			col -= sub;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1) / (d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

ll Pow(ll n, ll m, int mod = MOD){
	ll res = 1,pow = n % mod;
	while(m) {
		if(m & 1LL) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

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

	int n,c[100010] = {};
	cin >> n;
	rep(i,n){
		int a; cin >> a;
		if(parity(n,a)){
			cout << 0 << endl;
			return 0;
		}else{
			if(++c[a] > 2 || (!a && c[a] > 1)){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << Pow(2,n / 2) << endl;
}





Measured memory_bytes: 640
#include <iostream>

using namespace std;
int main(int argc, char const* argv[]) {
    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (n == 100) {
            cout << 101 << endl;
            return 0;
        }
        cout << n << endl;
        return 0;
    }
    if (d == 1) {
        if (n == 100) {
            cout << 100 * 100 + 100 << endl;
            return 0;
        }
        cout << 100 * n << endl;
        return 0;
    }
    if (n == 100) {
        cout << 100 * 100 * 100 + 100 * 100 << endl;
        return 0;
    }
    cout << 100 * 100 * n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;

int main()
{
	int N; cin >> N;
	vector<LLONG> as(N), bs(N);
	REP(i, N) cin >> as[i];
	REP(i, N) cin >> bs[i];
	// 左端から順に合わせていく
	LLONG upNum = 0;
	REP(i, N)
	{
		if (as[i] > bs[i])
		{
			upNum += as[i] - bs[i];
			bs[i] = as[i];
		}
	}
	REP(i, N)
	{
		if (as[i] < bs[i])
		{
			upNum -= (bs[i] - as[i]) / 2;
		}
	}
	cout << (upNum <= 0 ? "Yes\n" : "No\n");
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int blueCount = 0;
    int redCount = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S.at(i) == '0')
        {
            redCount++;
        }
        else
        {
            blueCount++;
        }
    }
    cout << min(blueCount, redCount) * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
N,K,C = map(int,input().split())
S = input()
def solve():
    if C==0:
        a = [i+1 for i,c in enumerate(S) if c=='o']
        if len(a)==K:
            print(*a, sep='\n')
        else:
            print()
        exit()
    l = []
    y = 0
    for i,c in enumerate(S):
        if y:
            y -= 1
            continue
        if c=='o':
            y = C
            l.append(i+1)
            if len(l) == K:
                break
    r = []
    y = 0
    for i,c in enumerate(S[::-1]):
        if y:
            y -= 1
            continue
        if c=='o':
            y = C
            r.append(N-i)
            if len(r) == K:
                break

    ans = set(l) & set(r)
    print(*sorted(ans), sep='\n')
solve()

Measured memory_bytes: 15848
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))

typedef struct {
  int a;
  int b;
} PairInt;

bool operator<(const PairInt& left, const PairInt& right) {
  return left.a < right.a;
}

int main(int argc, char* argv[]) {
  int N;
  std::cin >> N;
  PairInt p;
  std::vector<PairInt> list;
  for (int i = 0; i < N; i++) {
    std::cin >> p.a >> p.b;
    list.push_back(p);
  }
  std::sort(list.begin(), list.end());
  int count = list[0].a - 1;

  for (int i = 1; i < N; i++) {
    count += MIN(list[i].a - list[i - 1].a, list[i - 1].b - list[i].b);
  }
  count += list[N - 1].b + 1;
  std::cout << count << std::endl;

  return 0;
}



Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc085/tasks/abc085_c

"""
import sys
from sys import stdin
input = stdin.readline


def calc_yukichi(n, total):
    # 五千円札と一万円札をn枚使用して、ちょうどtotal円にするときの諭吉の枚数を返す
    gap = total - (5000 * n)
    if gap < 0:
        return -1
    yukichi = gap // 5000
    ichiyou = n - yukichi
    if ichiyou >= 0:
        return yukichi
    else:
        return -1


def solve(N, Y):
    # N枚の紙幣で、ちょうどY円になるような組み合わせを探す
    dp = [[False] * (2*N+1) for _ in range(N+1)] #  x軸は5000円単位
    dp[0][0] = True             #  0枚で0円

    if Y / 1000 == N:           #  1000円札のみのケース
        return 0, 0, N

    for y in range(1, N+1):
        for x in range(y-1, y*2):
            if dp[y-1][x]:
                dp[y][x+1] = True
                dp[y][x+2] = True

                if (x+1)*5000 + (N-y)*1000 == Y or (x+2)*5000 + (N-y)*1000 == Y:
                    hideyo = N - y
                    nokori = Y - hideyo * 1000
                    yukichi = calc_yukichi(y, nokori)
                    ichiyou = N - yukichi - hideyo
                    if yukichi >= 0 and ichiyou >= 0:
                        return yukichi, ichiyou, hideyo

    return -1, -1, -1           #  有効な組み合わせが見つからなかった


def main(args):
    N, Y = map(int, input().split())
    # N, Y = 2, 2000
    ans = solve(N, Y)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 65780
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
int n;
std::vector<int> vec[100010];
int dp[100010][2];
bool used[100010];
void func(int node){
	used[node]=true;
	int ans=0,cnt=0,children=0;
	for(int i:vec[node]){
		if(!used[i]){
			children++;
			func(i);
			ans+=dp[i][1];
			chmax(cnt,dp[i][1]-dp[i][0]);
		}
	}
	if(!children){
		dp[node][0]=0;
		dp[node][1]=1;
	}
	else if(children==1){
		if(ans==cnt)dp[node][0]=0;
		else dp[node][0]=INF;
		dp[node][1]=ans;
	}
	else{
		dp[node][0]=INF;
		dp[node][1]=ans-cnt;
	}
}
int main(){
	std::cin>>n;
	rep(i,n-1){
		int a,b;
		std::cin>>a>>b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	int root=-1;
	rep(i,n){
		if(vec[i].size()>=3){
			root=i;
			break;
		}
	}
	if(root==-1){
		std::cout<<1<<std::endl;
		return 0;
	}
	func(root);
	std::cout<<dp[root][1]<<std::endl;
	return 0;
}

Measured memory_bytes: 10880
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
cnt = 0
for i in range(N):
    cnt += B[A[i]-1]
    if i < N-1:
        if A[i]+1==A[i+1]:
            cnt += C[A[i]-1]
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int i,n,m,a,c[20];
int main()
{
	for(cin>>n;i++<n;cin>>a,c[a/400]++);
	for(i=0;i<8;i++)m+=c[i]>0;
	cout<<(m?m:1)<<" "<<m+c[8]+c[9]+c[10]+c[11]+c[12];
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC069C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] vals = Console.ReadLine().Split(' ');
            int count4 = 0, count2 = 0, countOther = 0;
            int a;
            for(int i=0; i < N; i++)
            {
                a = int.Parse(vals[i]);
                if(a % 4 == 0)
                {
                    count4++;
                }
                else if(a % 2 == 0)
                {
                    count2++;
                }
                else
                {
                    countOther++;
                }

            }


            if(count4 > 0 && count2 > 0)
            {
                if(count4 >= countOther)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else if(count4 > 0 && count2 == 0)
            {
                if(count4 + 1 >= countOther)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else if(count4 == 0 && count2 > 0)
            {
                if(countOther == 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 18016
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
ab.sort(key=lambda x:x[1])
x=0
ans=0
for i in range(m):
    a,b=ab[i][0],ab[i][1]
    if a>x:
        x=b-1
        ans+=1
    else:
        continue
print(ans)


Measured memory_bytes: 29152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);




int main(){
    string s;cin>>s;
    if(s.size()%2==0){
        bool b=true;
        rep(i,0,s.size()-1){
            if(i%2==0){
                if(s[i]!='h'){
                    b=false;
                }
            }else{
                if(s[i]!='i'){
                    b=false;
                }
            }
        }
        if(b){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
import copy ; import sys ; sys.setrecursionlimit(11451419)
n=int(input())
color=[-1 for i in range(n)]
color[0]=1
G=[[] for i in range(n)]
for i in range(n-1):
  a,b,d=map(int,input().split())
  G[a-1].append([b-1,d])
  G[b-1].append([a-1,d])
  
def dfs(x):
  
  for i,dis in G[x]:
    
    if color[i] != -1: continue
    if dis %2==1:
      color[i]=1-color[x]
    else:
      color[i]=color[x]
    dfs(i)
dfs(0)
for i in range(n):
  print(color[i])
      


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

int main()
{
  string ord;
  cin >> ord;
  int price = 700;
  for (int i = 0; i < 3; i++) {
    if (ord[i] == 'o')
      price += 100;
  }
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
if n==1:a=list(range(0,10))
else:a=list(range(10**(n-1),10**n))
for i in range(m):
  s,p=map(int,input().split())
  b=[]
  for j in a:
    if str(j)[s-1]!=str(p):b.append(j)
  for j in b:
    a.remove(j)
  if not a:
    print(-1)
    break
else:
  print(a[0])

Measured memory_bytes: 9144
#include<stdio.h>
 
#define N 100
#define NUL -1
static const int MAX = 500;
static const int INFTY = (1<<21);
 
 
int main(){
  int n, i, j, e,v, sum,u = 0,min = 0;
  int c[N],key[N],p[N],M[N][N];
   
   
  scanf("%d", &n);
 
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
 
 for(i=0; i < n; i++){
   key[i] = INFTY;
   p[i] = NUL;
   c[i] = NUL;
 }
 
 key[0] = 0;
 
 while(1){
   u = NUL;
   min = INFTY;
 
   for(i=0 ; i < n; i++){
     if(key[i] < min && c[i] == NUL){
       min = key[i];
       u = i;
     }
   }
 
   if(u == NUL) break;
 
   c[u] = u;
 
   for(v=0; v <n; v++){
     if(M[u][v] < key[v] && c[v] == NUL){
       p[v] = u;
       key[v] = M[u][v];
     }
   }
 }
 
  sum = 0;
 
  for ( i = 0; i < n; i++ ){
    if ( p[i] != NUL ) sum += M[i][p[i]];
  }
 
  printf("%d\n", sum);
 
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	int L;
	cin >> L;
	N = 1;
	while ((1 << N) <= L)
		++N;
	graph G(N);
	rep(i, N - 1) {
		G[i].push_back(edge(i, i + 1, 0));
		G[i].push_back(edge(i, i + 1, 1 << i));
	}
	for (int i = N - 2; i >= 0; i--) {
		if ((L - (1 << i)) > ((1 << (N - 1)) - 1)) {
			G[i].push_back(edge(i, N - 1, L - (1 << i)));
			L -= ((1 << i));
		}
	}
	M = 0;
	rep(i, N) M += G[i].size();
	cout << N << " " << M << endl;
	rep(i, N) rep(j, G[i].size()) cout << G[i][j].from + 1 << " " << G[i][j].to + 1 << " " << G[i][j].d << endl;
	return 0;
}

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] a = new int[n];
		long[] b = new long[n+1];
		for( int i=0 ; i<n ; i++ ) {
			a[i] = sc.nextInt();
		}
		
		for( int i=0 ; i<n ; i++ ) {
			b[i+1] = a[i]*2 - b[i]; 
		}
		b[0]=b[n]/2;
		for( int i=0 ; i<n ; i++ ) {
			b[i+1] = a[i]*2 - b[i]; 
			System.out.println(b[i]);
		}
	}
}



Measured memory_bytes: 61672
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define it vector<int>::iterator
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
		a%=b;
		vi amr(1,a);
		while(1){
			a*=10;
			bool h=false;
			cout<<a/b;
			a%=b;
			if(!a){
				cout<<endl;
				break;
			}
			rep(i,amr.size())if(amr[i]==a){
				cout<<endl;
				rep(j,i)cout<<" ";
				rep(j,amr.size()-i)cout<<"^";
				cout<<endl;
				h=true;
				break;
			}
			if(h)break;
			amr.pb(a);
		}
	}
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int K;
void solve(vector<ll> &A,ll now){
    if(now>3234566667){
        return;
    }

    A.push_back(now);
    if(now%10!=0) solve(A,now*10+now%10-1);
    solve(A,now*10+now%10);
    if(now%10!=9) solve(A,now*10+now%10+1);
}

int main(){
    cin>>K;
    vector<ll> res;
    rep1(i,9){
        solve(res,i);
    }
    sort(res.begin(),res.end());
    
    cout<<res[K-1]<<endl;
}


Measured memory_bytes: 4320
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = 1000000000 + 7;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




ll pow(ll a, ll b) {


	if (b == 0) return 1;

	if (a % 2 == 1) {
		a * pow(a, b - 1);
	}
	else {
		ll ret = pow(a, b / 2);
		return ret * ret;
	}
}


ll two_num(ll a) {

	ll C = 2;
	ll num = 0;
	while (a / C != 0 && a % C == 0) {
		a /= 2;

		num += 1;

	}

	return num;
}



ll A[10005];


int main() {
	ll N, M;

	
	cin >> N;
	ll ans = 0;
	rep(i, N) {

		cin >> A[i];
		ans += two_num(A[i]);
	}


	cout << ans << endl;


	
	return 0;
}

Measured memory_bytes: 384
//In The Name Of God
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900, Inf = 3e18 + 10;


int W[N], V[N], Dp[105][N];
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, w, Ans = 0; cin >> n >> w;
      for(int i = 1; i <= n; i++)
            cin >> W[i] >> V[i];
      for(int i = 1; i <= n; i++){
            for(int j = 0; j <= w; j++){
                  if(j < W[i])
                        Dp[i][j] = Dp[i - 1][j];
                  else
                        Dp[i][j] = max(Dp[i - 1][j], Dp[i - 1][j - W[i]] + V[i]);
                  if(i == n)
                        Ans = max(Ans, Dp[n][j]);
            }
      }
      cout << Ans;
      return 0;
}



Measured memory_bytes: 79360
#include <iostream>
#include <cmath>

int main(){
  int x, y;

  while(1){
    std::cin >> x >> y;
    if(x == 0 && y == 0){ break; }
    std::cout << std::min(x, y) << " " << std::max(x, y) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3088
use std::io;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf.trim().parse::<i32>().unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let b = buf.trim().parse::<i32>().unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let c = buf.trim().parse::<i32>().unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let d = buf.trim().parse::<i32>().unwrap();

    println!("{}", min(a, b) + min(c, d));
}


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

using ll = long long;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int x;
	cin >> x;
	if(x <= 2){
		cout << 2 << endl;
		return 0;
	}
	for(long long int j=x;j<=100000000;j++){
		bool flag = true;
		for(int i=2;i<j-1;i++){
			if(j%i == 0){
				flag = false;
			}
		}
		if(flag){
			cout << j << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256