akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

ll div_ll (ll a, ll b) {
    if (a >= 0) return a / b;
    else return a / b - (a % b != 0);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    rep (_, t) {
        ll a, b, c, d; cin >> a >> b >> c >> d;
        if (a < b || b > d) {
            cout << "No\n";
        } else if (b <= c) {
            if (b < d) cout << "Yes\n";
            else cout << "No\n";
        } else {
            ll g = gcd(b, d), f;
            f = a % g;
            if (div_ll(b - 1 - a, g) > div_ll(c - a, g)) {
                cout << "No\n";
            } else {
                cout << "Yes\n";
            }
        }
    }
    return 0;
}

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

int main() {
	int H,W,cnt;
	cin>>H>>W;
	int X[H][W];
	int Y[H][W]={0};
	cnt=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>X[i][j];
			if(X[i][j]%2==0)X[i][j]=-1;
			else X[i][j]=1;
          	Y[i][j] = 0;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(X[i][j]<1){
				
			}
			else if(j==W-1){
				if(i==H-1)break;
				else {
					X[i][j]*=-1;
					X[i+1][j]*=-1;
					Y[i][j]=2;
					//cout<<i+1<<" "<<j+1;
					//cout<<i+2<<" "<<j+1<<endl;
					cnt++;
				}
			}else{
				X[i][j]*=-1;
				X[i][j+1]*=-1;
				Y[i][j]=1;
				//cout<<i+1<<" "<<j+1;
				//cout<<i+1<<" "<<j+2<<endl;
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(Y[i][j]==2){
				cout<<i+1<<" "<<j+1<<" "<<i+2<<" "<<j+1<<endl;
			}else if(Y[i][j]==1){
				cout<<i+1<<" "<<j+1<<" "<<i+1<<" "<<j+2<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int n, m, x;
vector<int> c(0);
vector<vector<int> > a(0);
int ans = -1;

void dfs(vector<int> a_array) {
    if (a_array.size() == n) {
        int money = 0;
        vector<int> abi(m, 0);
        rep(i, n) {
            if (a_array[i] == 0) continue;
            money += c[i];
            rep(j, m) {
                abi[j] += a[i][j];
            }
        }
        int flag = 0;
        rep(i, m)
            if (abi[i] >= x)
                flag++;
        if (flag == m)
            if (ans == -1)
                ans = money;
            else
                ans = min(ans, money);
    }
    else {
        rep(i, 2) {
            a_array.emplace_back(i);
            dfs(a_array);
            a_array.erase(a_array.begin() + a_array.size() - 1);
        }
    }
}

int main() {
    cin >> n >> m >> x;
    rep(i, n) {
        int ci;
        cin >> ci;
        c.emplace_back(ci);
        vector<int> kari(m);
        rep(j, m) cin >> kari[j];
        a.emplace_back(kari);
    }
    vector<int> a_array(0);
    dfs(a_array);

    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int k;
    scanf("%d", &k);
    if (k%2 == 0) printf("%d\n", (k/2)*(k/2));
    else printf("%d\n", (k/2)*(k/2+1));
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<complex>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
#define per(i,n) for(int i=n-1;i>=0;i--)
typedef long double ld;

vector<int> v = { 13,17,19,23 };
int trans(int x) {
	rep(j, 4)if (x == v[j])return j;
	return -1;
}
const int mn = 55440;
int n;
void solve() {
	vector<int> memo(mn, 0);
	vector<vector<int>> memo2(4);
	rep(i, 4)memo2[i].resize(v[i], 0);
	rep(i, n) {
		int d, t; cin >> d >> t;
		vector<int> a(d); rep(j, d)cin >> a[j];
		int z = trans(d);
		if (z < 0) {
			rep(j, mn) {
				memo[j] += a[(j + t) % d];
			}
		}
		else {
			rep(j, d)memo2[z][j] += a[(j+t)%d];
		}
	}
	int ans = 0;
	rep(i, mn)ans = max(ans, memo[i]);
	rep(i, 4) {
		int ma = 0;
		rep(j, v[i])ma = max(ma, memo2[i][j]);
		ans += ma;
	}
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	while(cin>>n,n)solve();
	//stop
		return 0;
}



Measured memory_bytes: 3400
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int n, y;
        read n >> y;
        y /= 1000;
        for ( int i = 0; i <= n; i++ ) {
            for ( int j = 0; i+j <= n; j++ ) {
                int su = i * 10 + j * 5 + ( n-i-j );
                if ( su == y ) {
                    echo i _ j _ (n-i-j) fin;
                    return 0;
                }
            }
        }
        echo -1 _ -1 _ -1 fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


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

int main() {
  string s; cin >>s;
  string ans = "No";
  sort(s.begin(), s.end());
  if (s.at(0)==s.at(1) && s.at(2)==s.at(3) && s.at(0)!=s.at(2)){
    ans = "Yes";
  }
  cout <<ans;
  cout <<endl;
}


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

int main() {
    long long x;
    cin >> x;
  
    long long p = 100, step = 0;
  
    while(p < x) {
        p += p / 100;
        step++;
    }

    cout << step << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll=long long;
#include <set>
using namespace std;
ll gcd(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d=c-(a-b);
    if(d>=0){
        cout<<d<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
# そのまま入力文字列の入力
x = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return set(divisors)

def is_prime(n):
    yakusu_set = make_divisors(n)
    return (n in yakusu_set) and len(yakusu_set) == 2


yakusu_set = make_divisors(x)
yakusu_set.remove(1)

if x in yakusu_set and len(yakusu_set) == 1:
    print(x)
else:
    next_num = x
    while True:
        next_num += 1
        if is_prime(next_num):
            print(next_num)
            break



Measured memory_bytes: 3064
@num = 1
loop do
  w = gets.to_i
  break if w == 0
  n = gets.to_i
  arr = n.times.map { gets.split(',').map(&:to_i) }

  dp = Array.new(n+1) { Array.new(w+1) }
  dp[0][0] = 0

  mw, mv = w, 0
  arr.each_with_index do |ia, i|
    (0..w).to_a.reject{ |wi| dp[i][wi].nil? }.each do |wi|
      t = dp[i+1][wi] = [dp[i][wi], dp[i+1][wi]||0].max
      mw, mv = wi, t if mv < t || (mv == t && mw > wi)
      if wi+ia[1] <= w
        t = dp[i+1][wi+ia[1]] = [dp[i][wi]+ia[0], dp[i+1][wi+ia[1]]||0].max
        mw, mv = wi+ia[1], t if mv < t || (mv == t && mw > wi+ia[1])
      end
    end
  end
  puts "Case #{@num}:", mv, mw
  @num += 1
end

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    int mx = -1e8, mi = 1e8;
    for (auto& x: a) {
        cin >> x;
        mx = max(mx, x);
        mi = min(mi, x);
    }
    vector<pair<int, int>> res;
    auto pos = [&](){
        for (int i = 1; i < n; i++) {
            res.emplace_back(i,i+1);
        }
    };
    auto neg = [&](){
        for (int i = n-1; i >= 1; i--) {
            res.emplace_back(i+1, i);
        }
    };
    if (mi >= 0) pos();
    else if (mx <= 0) neg();
    else {
        if (mx >= -mi) {
            int k = max_element(a.begin(), a.end()) - a.begin();
            k++;
            for (int i = 1; i <= n; i++) {
                if (i != k) res.emplace_back(k, i);
            }
            pos();
        } else {
            int k = min_element(a.begin(), a.end()) - a.begin();
            k++;
            for (int i = 1; i <= n; i++) {
                if (i != k) res.emplace_back(k, i);
            }
            neg();
        }
    }
    cout << res.size() << "\n";
    for (auto& p: res) {
        int x,y;
        tie(x,y) = p;
        cout << x << ' ' << y << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.next();
			if(s.compareTo("0")==0)break;
			
			String t = "";
			int[] c = new int[6];
			for(int i=1;i<7;i++){
				t = s.substring(i,i+1);
				if(t.compareTo("a")==0){
					c[i-1] = 10;
				}else if(t.compareTo("b")==0){
					c[i-1] = 11;
				}else if(t.compareTo("c")==0){
					c[i-1] = 12;
				}else if(t.compareTo("d")==0){
					c[i-1] = 13;
				}else if(t.compareTo("e")==0){
					c[i-1] = 14;
				}else if(t.compareTo("f")==0){
					c[i-1] = 15;
				}else{
					c[i-1] = Integer.valueOf(t);
				}
			}
			int r = c[0]*16 + c[1];
			int g = c[2]*16 + c[3];
			int b = c[4]*16 + c[5];
			
			int count=0;
			int sum=0;
			double[] d = new double[8];
			double[] e = new double[8];
			for(int i=0;i<2;i++){
				for(int j=0;j<2;j++){
					for(int k=0;k<2;k++){
						sum = (r-i*255)*(r-i*255)+(g-j*255)*(g-j*255)+(b-k*255)*(b-k*255);
						d[count] = Math.sqrt(sum);
						e[count] = d[count];
						count++;
					}
				}
			}
			Arrays.sort(e);
			for(int i=0;i<8;i++){
				if(d[i]==e[0]){
					sum = i;
					break;
				}
			}
			
			if(sum==0){
				System.out.println("black");
			}else if(sum==1){
				System.out.println("blue");
			}else if(sum==2){
				System.out.println("lime");
			}else if(sum==3){
				System.out.println("aqua");
			}else if(sum==4){
				System.out.println("red");
			}else if(sum==5){
				System.out.println("fuchsia");
			}else if(sum==6){
				System.out.println("yellow");
			}else if(sum==7){
				System.out.println("white");
			}		
			
		}
	}	
}

Measured memory_bytes: 25300
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
int a[N],n;
ll k;
set<int> s;
int STR,END;
vector<int> from,cir;
void dfs1(int u)
{
	if(STR && END)	return;
	if(!s.count(u))
	{
		s.insert(u);
		dfs1(a[u]);
		if(STR && !END)
			END = u;
	}
	else
	{
		STR = u;
		return;
	}
}
void dfs2(int u)
{
	if(u == STR)	return;
	from.push_back(u);
	dfs2(a[u]);
}
void dfs3(int u)
{
	if(u == END)	return;
	cir.push_back(u);
	dfs3(a[u]);
}
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i = 1;i <= n;++i)	scanf("%d",&a[i]);
	if(a[1] == 1)	
	{
		cout << 1;
		return 0;
	}
	dfs1(1);
	//cout << STR << " " << END << endl;
	if(STR != 1)	dfs2(1);
    dfs3(STR);
    cir.push_back(END);
    if(STR == 1)
    {
    	//for(int i = 0;i < cir.size();++i)	cout << cir[i] << " ";
    	//cout << endl;
    	printf("%d",cir[k % cir.size()]);
    }
    else
    {
    	//cout << STR << endl;
    	//for(int i = 0;i < from.size();++i)	cout << from[i] << " ";
    	//cout << endl;
    	if(from.size() > k)	printf("%d\n",from[k]);
    	else if(from.size() == k)	printf("%d",STR);
    	else
    	{
			printf("%d",cir[(k - from.size()) % cir.size()]);
    		//for(int i = 0;i < cir.size();++i)	cout << cir[i] << " ";
    		//cout << endl;
    	}
    }	
    return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> A;

int main()
{
	scanf("%d",&N);
	A.assign(N,0);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}

	deque<int> ans;
	bool rev = false;
	FOR(i,0,N){
		if(rev == false){
			ans.push_back(A [i]);
		}
		else{
			ans.push_front(A [i]);
		}
		rev = !rev;
	}
	if(rev){
		reverse(ans.begin(),ans.end());
	}
	FOR(i,0,N){
		printf("%d%s",ans [i],i + 1 == N ? "\n" : " ");
	}

	return 0;
}


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

a,p = [1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def dfs(N,X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1+a[N-1]:
        return dfs(N-1,X-1)
    else:
        return p[N-1]+1+dfs(N-1,X-2-a[N-1])

print(dfs(N,X))

Measured memory_bytes: 3064
// https://atcoder.jp/contests/dp/tasks/dp_n
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

const int N =  405;
const int MOD = int(1e9)+7;
const int INF = int(2e9)+5;
const ll INF64 = 1e18;

ll dp[N][N],a[N],presum[N];

int main () {
    int n;cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        presum[i] = presum[i-1] + a[i];
        dp[i][i] = 0;
    }
    memset(dp,0,sizeof(dp));
    for (int l=1;l<=n;l++) {
        for (int i=1;i<n-l+1;i++) {
            int j = i+l;
            dp[i][j] = INF64;
            for (int k = i;k<j;k++) {
                dp[i][j] = min(dp[i][j],(dp[i][k] + dp[k+1][j] + presum[j] - presum[i-1]));
            }
        }
    }
    cout<<dp[1][n]<<endl;
    // for (int i=1;i<=n;i++) {
    // 	for (int j=1;j<=n;j++) {
    // 		cout<<dp[i][j]<<" ";
    // 	}
    // 	cout<<endl;
    // }
    return 0;
}


Measured memory_bytes: 1536
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if p[i]-1 == i:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

if p[-1] == n:
    ans+=1

print(ans)

Measured memory_bytes: 14008
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: i64,
        n: i64,
        p: [i64;n]
    }

    let mut set = HashSet::new();

    for &i in &p {
        set.insert(i);
    }

    //println!("{:?}", set);

    let mut ans = 0;
    for i in 0..100 {
        let minus_num = x - i;
        if !set.contains(&minus_num) {
            ans = minus_num;
            break;
        }

        let plus_num = x + i;
        if !set.contains(&plus_num) {
            ans = plus_num;
            break;
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2252
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

const int M = 1 << 19;
int S[M * 2+10];

void update(int k, int h) {

	S[k + M] += h;

	int p = (k + M) / 2;

	while (p >= 1) {

		if (S[p * 2] >= S[p * 2 + 1]) { S[p] = S[p * 2]; }
		else { S[p] = S[p * 2 + 1]; }
		p /= 2;
	}

}

int Q(int a, int b, int l=0, int r=M-1, int k=1) {

	if (b < l || r < a) { return 0; }

	if (a <= l && r <= b) { return S[k]; }

	int tmp1 = Q(a, b, l, (l + r) / 2, k * 2);

	int tmp2 = Q(a, b, (l + r) / 2 + 1, r, k * 2 + 1);

	return max(tmp1, tmp2);
}

int N;
int A[200005], B[200005];

int C[200005];

set<int> G[200005];

int D[200005];

int CHECK(void) {

	for (int i = 1; i <= N; i++) {
		if (A[i] == D[i]) { return -1; }
	}

	return 1;

}

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	for (int i = 1; i <= N; i++) {
		cin >> B[i];
		C[B[i]]++;
		update(B[i], 1);
	}

	for (int i = 1; i <= N; i++) {
		if (C[i] > 0) { G[C[i]].insert(i); }

	}


	/*for (int i = 1; i <= N; i++) {
		cout << "G[" << i << "]: ";
		for (auto y : G[i]) { cout << " " << y; }cout << endl;
	}*/


	/*for (int i = 1; i <= 3; i++) {
		cout << "Q(" << i << "," << N << ")= " << Q(i, N) << endl;
	}*/

	for (int i = 1; i <= N; i++) {
		int num = Q(A[i] + 1, N);
		if (num == 0) { num = Q(1, A[i]-1); }

		//cout << "num= " << num << endl;

		if (num == 0) { cout << "No" << endl; return 0; }
		
		auto it = G[num].end(); it--;
		if (*it == A[i]) { it--; }
		D[i] = *it;
		//cout << "D["<<i<<"]= " << D[i] << endl;
		G[num].erase(D[i]);
		if (num > 1) { G[num - 1].insert(D[i]); }

		//cout << "check" << endl;
		update(D[i], -1);
	}

	/*for (int i = 1; i <= N; i++) {
		cout << " " << D[i];
	}cout << endl;
	*/

	if (CHECK() == -1) { cout << "No" << endl; }
	else {
		cout << "Yes"<<endl;
		for (int i = 1; i <= N; i++) {
			if (i != 1) { cout << " "; }
			cout << D[i];
		}cout << endl;
	}
	return 0;
}

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

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

int X,Y,n;
int b[15],k[15],s[10][10];
int sx[15],sy[15],ans[10][10];
bool ansFlg;

bool isAns(void){
	rep(i,Y) rep(j,X) if(s[i][j] == 0) return false;
	return true;
}

bool settable(int y,int x,int h,int w){
	REP(i,y,y+h) REP(j,x,x+w) if(s[i][j]!=0) return false;
	return true;
}

void setLand(int y,int x,int h,int w,int val){
	REP(i,y,y+h) REP(j,x,x+w) s[i][j] = val;
}

bool solve(int idx){
	if(idx == -1){
		if(isAns()){
			if(ansFlg) return true;
			ansFlg = true;
			memcpy(ans,s,sizeof(s));
		}
		return false;
	}

	REP(h,1,k[idx]+1){
		if(k[idx] % h != 0) continue;
		int w = k[idx] / h;

		REP(i,sy[idx]-h+1,sy[idx]+1){
			REP(j,sx[idx]-w+1,sx[idx]+1){
				if(i<0 || j<0 || i+h>Y || j+w>X) continue;

				s[sy[idx]][sx[idx]] = 0;
				if(settable(i,j,h,w)){
					setLand(i,j,h,w,idx+1);
					if(solve(idx-1)) return true;
					setLand(i,j,h,w,0);
				}
				s[sy[idx]][sx[idx]] = idx+1;
			}
		}
	}

	return false;
}

int main(void){
	while(cin>>X>>Y>>n && (X||Y||n)){
		rep(i,n) cin>>b[i]>>k[i];
		rep(i,Y) rep(j,X){
			cin>>s[i][j];
			if(s[i][j] != 0){
				sx[s[i][j]-1] = j;
				sy[s[i][j]-1] = i;
			}
		}

		ansFlg = false;

		if(!solve(n-1) && ansFlg){
			rep(i,Y){
				rep(j,X-1) cout<<ans[i][j]<<" ";
				cout<<ans[i][X-1]<<endl;
			}
		}
		else{
			cout<<"NA\n";
		}
	}

	return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;

main() {
    cin >> a >> b;
    ct(max(max(a+b,a-b),a*b))
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char W[10+1];
    char T[1000+1];
    int cnt=0;
    
    scanf("%s",W);
    
    while(1){
        scanf("%s",T);
        if(!(strcmp(T,"END_OF_TEXT")))break;
        
        for(int i=0;i!='\n';i++){
            if('A'<=T[i]&&T[i]<='Z')T[i]=(char)(T[i]+('a'-'A'));
        }
        
        if(!(strcmp(W,T))){
            cnt++;
        }
    }
    printf("%d\n",cnt);
}



Measured memory_bytes: 2748
s=STDIN.gets.split[0]
n=STDIN.gets.split[0].to_i
n.times{
  q=STDIN.gets.split
  a=q[1].to_i
  b=q[2].to_i
  if(q[0]=="replace")
    s[a,b-a+1]=q[3]
  elsif (q[0]=="reverse")
    s[a,b-a+1]=s[a,b-a+1].reverse
  elsif (q[0]=="print")
    puts s[a,b-a+1]
  end
  }

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int v[55];
  for(int i=0;i<n;i++){
    cin>>v[i];

  }
  sort(v,v+n);
  float sum=v[0];
  for(int i=1;i<n;i++){
    sum +=(float)v[i];
    sum =sum/2;

  }
  cout<<sum;


}



Measured memory_bytes: 256
nl = list(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
total=0
for v in nl:
    v2=int(v)
    total+=v2
if total%9==0:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "Rainy") {
    cout << "Sunny" << endl;
  } else if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else {
    cout << "Rainy" << endl;
  }
}

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

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

int main()
{
    string n;
    cin >> n;
    rep(i, 3){
        if(n[i] == '1'){
            cout << 9;
        }else if(n[i] == '9'){
            cout << 1;
        }else{
            cout << n[i];
        }
    }
    cout << endl;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

ll mm[10][10];

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

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            mm[i][j] = 0;
        }
    }

    for(int i = 1; i <= n; i++){
        string str = to_string(i);
        mm[str[0]-'0'][str[str.length()-1]-'0']++;
    }

    ll ans = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            ans += mm[i][j] * mm[j][i];
        }
    }

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

Measured memory_bytes: 3660
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	ull d[] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};
	ull n;
	cin >> n;
	int f = 0;
	int c = 0;

	//桁
	for (int i = 0;; i++) {
		if (n / d[i] == 0) {
			c = i + 1;
			break;
		}
	}

	rep(i, 0, c) {
		if (i == 0) {
			f += n % 10;
		}
		else {
			f+= n % d[i] / d[i - 1];
		}
	}
	
	if (n%f == 0) {
		Yes;
	}
	else {
		No;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())


def dfs(s):
    # 上限を超えない範囲で再帰する
    if int(s) > n:
        return 0
    # s自身が条件を満たすか確認
    ret = 1 if all(s.count(c) > 0 for c in '357') else 0
    # 1文字増やして再帰
    for c in '357':
        ret += dfs(s + c)
    return ret


print(dfs('0'))

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

var g [][]bool
var n, m int

func main() {
	sc.Split(bufio.ScanWords)
	n, m = nextInt(), nextInt()
	g = make([][]bool, n)
	for i := 0; i < n; i++ {
		g[i] = make([]bool, n)
	}
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		g[a][b] = true
		g[b][a] = true
	}

	visted := make([]bool, n)
	visted[0] = true
	fmt.Println(dfs(0, visted))
}

func dfs(v int, visted []bool) int {
	can := true
	for i := 0; i < n; i++ {
		if !visted[i] {
			can = false
		}
	}

	if can {
		return 1
	}

	ret := 0

	for i := 0; i < n; i++ {
		if !g[v][i] {
			continue
		}

		if visted[i] {
			continue
		}

		visted[i] = true
		ret += dfs(i, visted)
		visted[i] = false
	}

	return ret
}


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

int main() {
  int A,B;
  char op;
  cin>>A>>op>>B;
  if(op=='+') cout<<A+B<<endl;
  if(op=='-') cout<<A-B<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int n , k;
long double a[N];
int main() {
    abdelrahman010
    cin >> n >> k;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
        a[i] = log(a[i]);
        if(i)
            a[i] += a[i - 1];
    }
    long double lst = a[k - 1];
    for(int i = k;i < n;i++) {
        long double c = a[i] - a[i - k];
        (c - lst > 1e-10) ? cout << "Yes\n" : cout << "No\n";
        lst = c;
    }
    return 0;
}


Measured memory_bytes: 6912
function Main(input) {
  	input = input.trim();
	var len = parseInt(input.split("\n")[0]);
  	var list = input.split("\n")[1].split(" ");	
  var nextList = list[0];
  var flag = 0;
  if(len % 2 == 0){
     nextList = list[1] + " " + nextList;
    flag = 1;
     }
  for(var i = 1 + flag; i < len; i = i + 2){
        nextList += " " + list[i];
    	nextList = list[i + 1] + " " + nextList;
     }
  console.log(nextList);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 60208
import java.lang.Math.*

fun main(args: Array<String>){
    val (X, Y) = readLine()!!.split(" ").map { it.toLong() }
    if(Y == 0L){
        println(abs(X) + if(X > 0) 1 else 0)
    }else if(X >= 0 && Y > 0){
        if(Y >= X){
            println(Y - X)
        }else{
            println(X - Y + 2)
        }
    }else if(X >= 0 && Y < 0){
        if(-X <= Y){
            println(X - abs(Y) + 1)
        }else{
            println(abs(Y) - X + 1)
        }
    }else if(X < 0 && Y > 0){
        if(X <= -Y){
            println(abs(X) - Y + 1)
        }else{
            println(Y - abs(X) + 1)
        }
    }else{
        if(Y >= X){
            println(Y - X)
        }else{
            println(X - Y + 2)
        }
    }
}

Measured memory_bytes: 35984
#include <bits/stdc++.h> /**  I'm Klaus, NicKlaus :v **/
using namespace std;
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define ld long double
ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
const int nax = 3002;
string s, t;
int n, m;
int dp[nax][nax];
int go(int i, int j){
	if( i == n || j == m) return 0;
	int& ans = dp[i][j];
	if( ans != -1 ) return ans;
	ans = -1e9;
	if(s[i] == t[j]){
		ans = max(ans, go(i+1,j+1)+1);
	}else{
		ans = max(ans, go(i+1,j));
		ans = max(ans, go(i,j+1));
	}
	return ans;
}
string res = "";
void getdp(int i, int j){
	if( i == n || j == m) return;
	int ans = dp[i][j];
	if(s[i] == t[j]){
		res += s[i];
		getdp(i+1,j+1);
	}else{
		if(dp[i+1][j] == ans) getdp(i+1,j);
		else if(dp[i][j+1] == ans) getdp(i,j+1);
	}
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifdef LOCAL_JUDGE
		//freopen("in_out/in.txt", "rt", stdin);
		//freopen("int_out/out.txt", "wt", stdout);
	#endif
	ms(dp,-1);
	cin>>s>>t;
	n = s.size();
	m = t.size();
	int ans = go(0,0);
	//cout<<ans<<endl;
	getdp(0,0);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 35712
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int b = 0;
    for(int cnt = 0; cnt < n; cnt++){
      b |= sc.nextInt();
    }
    System.out.println(Integer.numberOfTrailingZeros(b));
    sc.close();
  }
}

Measured memory_bytes: 36192
#include <iostream>
#include <vector>
#include <algorithm>
#include <initializer_list>

using namespace std;

int main()
{
    int m, e, y, z;
    int min;
    while (cin >> e, e) {
        m = min = 1000000;
        for (z = 0; z <= 100; z++) {
            if (z*z*z > e)
                break;
            for (y = 0; y <= 1000; y++) {
                if (y*y + z*z*z > e) {
                    y--;
                    m = y + z + (e-y*y-z*z*z);
                    min = m < min ? m : min;
                    break;
                }
            }
        }
        cout << min << endl;
    }

    return 0;
}

Measured memory_bytes: 3052
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
//using Bint = mp::cpp_int;

ll N;
ll num4dev(ll n)
{
	ll y=N/n;
	return y*(y+1)*n/2;
}


int main()
{
	cin>>N;
	ll res=0;
	for(ll i=1;i<=N;i++)
	{
		res+=num4dev(i);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3624
import Foundation

func main() {
  let n = Int(readLine()!)!
  let inputString = readLine()!
  var split: [Int] = inputString.components(separatedBy: " ").map{Int(String($0))!}

  var i = 0
  var res = 0
  for i in 1 ... n {
    var s = split[i-1]
    while(s%2==0) {
      s = s/2
      res += 1
    }
  }
  
  print(res)
}

main()

Measured memory_bytes: 14444
#include <iostream>
#include <string>
using namespace std;
 
class Dice{
public:
    int dice[6];
    int buff1, buff2, buff3;
    void south(){
        buff1 = dice[0];
        buff2 = dice[1];
        buff3 = dice[5];
        dice[0] = dice[4];
        dice[4] = buff3;
        dice[5] = buff2;
        dice[1] = buff1;
    }
    void north(){
        buff1 = dice[0];
        buff2 = dice[1];
        buff3 = dice[5];
        dice[0] = buff2;
        dice[1] = buff3;
        dice[5] = dice[4];
        dice[4] = buff1;
    }
    void west(){
        buff1 = dice[0];
        buff2 = dice[2];
        buff3 = dice[5];
        dice[0] = buff2;
        dice[2] = buff3;
        dice[5] = dice[3];
        dice[3] = buff1;
    }
    void east(){
        buff1 = dice[0];
        buff2 = dice[2];
        buff3 = dice[5];
        dice[2] = buff1;
        dice[5] = buff2;
        dice[0] = dice[3];
        dice[3] = buff3;
    }
};
 
int main()
{
    Dice d;
    for(int n = 0; n < 6; n++)
        cin >> d.dice[n];
 
    string command;
    string::iterator itr;
    char direction;
    cin >> command;
    for(itr = command.begin(); itr != command.end(); itr++){
        direction = *itr;
        if(direction == 'N')
            d.north();
        if(direction == 'S')
            d.south();
        if(direction == 'E')
            d.east();
        if(direction == 'W')
            d.west();
    }
    cout << d.dice[0] << endl;
}

Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  //入力
  int n;
  cin>>n;
  vector<int> x(n),store(n);
  for(int i=0;i<n;i++) { cin>>x[i]; store[i]=x[i]; }

  sort(x.begin(),x.end());
  int left=x[n/2-1],right=x[n/2];

  for(int i=0;i<n;i++)
  {
    if(store[i]<=left) cout<<right<<endl;
    else if(store[i]>=right) cout<<left<<endl;
  }

}


Measured memory_bytes: 3712
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_5-C: Koch Curve

#include <cstdio>
#include <cmath>

struct Point {
  const double x, y;
  Point(double x, double y) : x(x), y(y) { }
  Point rotate(double degree) const;
};

Point Point::rotate(double degree) const
{
  auto sin = std::sin(M_PI*degree/180.0);
  auto cos = std::cos(M_PI*degree/180.0);
  return Point(x*cos - y*sin, x*sin + y*cos);
}

Point operator +(const Point& a, const Point& b) { return Point(a.x+b.x, a.y+b.y); }
Point operator -(const Point& a, const Point& b) { return Point(a.x-b.x, a.y-b.y); }
Point operator *(const double a, const Point& b) { return Point(a*b.x, a*b.y); }
Point operator /(const Point& a, const double b) { return Point(a.x/b, a.y/b); }

void print_point(const Point& p) { std::printf("%.8f %.8f\n", p.x, p.y); }

void print_koch(unsigned int n, const Point& a, const Point& b)
{
  if (n == 0) return;

  Point s = (2.0*a + 1.0*b)/3.0;
  Point t = (1.0*a + 2.0*b)/3.0;
  Point u = (t-s).rotate(60) + s;

  print_koch(n-1, a, s); print_point(s);
  print_koch(n-1, s, u); print_point(u);
  print_koch(n-1, u, t); print_point(t);
  print_koch(n-1, t, b);
}

int main()
{
  unsigned int n;
  std::scanf("%d", &n);

  auto a = Point(0.0, 0.0);
  auto b = Point(100.0, 0.0);

  print_point(a);
  print_koch(n, a, b);
  print_point(b);
}

// eof

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

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

  if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;

int main() {
	ll N, M;
	cin >> N >> M;

	vector<tuple<ll, ll, ll>> data(M);

	for (ll i = 0; i < M; ++i) {
		ll p, y;
		cin >> p >> y;
		data[i] = make_tuple(y, p, i);
	}

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

	vector<ll> cnt(N + 1);


	pair<ll, ll> id[M];
	// 各市の(属する県、県の中で誕生した順番)

	for (ll i = 0; i < M; ++i) {
		ll y, p, idx;
		tie(y, p, idx) = data[i];
		++cnt[p];
		id[idx] = make_pair(p, cnt[p]);
	}

	for (ll i = 0; i < M; ++i) {
		// setwで文字数、setfillで埋める文字を指定
		// iomanipをincludeする必要があるので注意
		cout << setw(6) << setfill('0') << id[i].first;
		cout << setw(6) << setfill('0') << id[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 6144
import math
import sys


def lcm(a, b):
  return a * b // math.gcd(a, b)


input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
LCM = 1
ans = 0
MOD = 1000000007
for x in A:
  LCM = lcm(LCM, x)
for x in A:
  ans += LCM // x

print(ans%MOD)

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

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

template <typename T> struct BIT {
    vector<T> v;
    BIT(int n) { v.assign(n + 1, 0); }
    // [0, k]
    T sum(int k) {
        T res = 0;
        for(++k; k > 0; k -= k & -k) {
            res += v[k];
        }
        return res;
    }
    // [l, r)
    T sum(int l, int r) {
        return (l == 0 ? sum(r - 1) : sum(r - 1) - sum(l - 1));
    }
    void add(int k, T x) {
        for(++k; k < v.size(); k += k & -k) {
            v[k] += x;
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    BIT<int> bit(n);
    while(q--) {
        int t, x, y;
        cin >> t >> x >> y;
        if(t == 0) {
            bit.add(x - 1, y);
        } else {
            cout << bit.sum(x - 1, y) << "\n";
        }
    }
}


Measured memory_bytes: 3360
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);
            double sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += 1.0 / (double)A[i];
            }
            var res = 1.0 / sum;
            Console.WriteLine(res);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
n=int(input())
a=list(map(int,input().split()))
cnt1=0
cnt2=0
cnt4=0
if n==2:
    if a[0]*a[1]%4==0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
for i in range(n):
    if a[i]%4==0:
        cnt4+=1
    elif a[i]%2==0:
        cnt2+=1
    else:
        cnt1+=1
if cnt1 == 0 or (cnt2 == 0 and cnt4+1 >= cnt1) or (cnt2 >= 1 and cnt4 >= cnt1):
    print("Yes")
else:
    print("No")



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n, k;
	cin >> m >> n >> k;
	
	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];

	vvl b(m,vl(n));
	FOR(i,0,m) FOR(j,0,n) if (a[i][j] == '#') {
		b[i][j] = k--;
	}
	
	FOR(i,0,m) {
		FOR(j,0,n-1) if (b[i][j] && !b[i][j+1]) b[i][j+1] = b[i][j];
		FORD(j,1,n)  if (b[i][j] && !b[i][j-1]) b[i][j-1] = b[i][j];
	}
	FOR(j,0,n) {
		FOR(i,0,m-1) if (b[i][j] && !b[i+1][j]) b[i+1][j] = b[i][j];
		FORD(i,1,m)  if (b[i][j] && !b[i-1][j]) b[i-1][j] = b[i][j];
	}
	
	FOR(i,0,m) FOR(j,0,n) cout << b[i][j] << " \n"[j+1==n];

}



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

int main() {
  int k;
  cin>>k;
  queue<long long>lun;
  for(int i=1;i<=9;i++) lun.push(i);
  for(int i=0;i<k-1;i++){
    long long a=lun.front();
    lun.pop();
    if(a%10==0){
      lun.push(10*a);
      lun.push(10*a+1);
    }
    else if(a%10==9){
      lun.push(10*a+8);
      lun.push(10*a+9);
    }
    else{
      int b=a%10;
      lun.push(10*a+b-1);
      lun.push(10*a+b);
      lun.push(10*a+b+1);
    }
  }
  cout<<lun.front()<<endl;
}

Measured memory_bytes: 1792