akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    // fastIO();
    
    int a, b, c, cnt = 0;
    cin >> a >> b >> c;
    
    while (cnt < 32) {
        if ((a & 1) or (b & 1) or (c & 1)) break;
        int da = a/2, db = b/2, dc = c/2;
        a = db + dc, b = da + dc, c = da + db;
        ++cnt;
    }
    
    cout << (cnt == 32 ? -1 : cnt) << "\n";
    
    return 0;
}

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

inline int calc(long long x) {
	int ret = 0;
	while (x) {
		++ret;
		x /= 10;
	}
	return ret;
}

int main() {
	long long n;
	int ans = 105;
	cin >> n;

	for (long long i=1; i*i<=n; ++i) {
		if (n%i == 0) {
			int tmp = max(calc(i), calc(n/i));
			ans = min(ans, tmp);
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << endl)

using namespace std;
using ll = unsigned long long;

int main() {
	int A, B, C, X;
	IN(A);
	IN(B);
	IN(C);
	IN(X);
	int i, j, k;
	int tmp = X;
	int count = 0;
	for(i = A; i >= 0; i--) {
		if(i*500 > tmp) continue;
		tmp -= i*500;
		for(j = B; j >= 0; j--) {
			if(j*100> tmp) continue;
			tmp -= j*100;
			for(k = C; k >= 0; k--) {
				if(k*50 == tmp) count++;
			}
			tmp = X - i*500;
		}
		tmp = X;
	}
	OUT(count);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int n =1;

		for (int i=0; i<N; i++) {
			if (n*2<n+K) {
				n = n*2;
			} else {
				n = n+K;
			}
		}
		System.out.println(n);

	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
	int n,r=0;
	scanf("%i",&n);
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
	}
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=j)
		{
			r++;
		}
		else j++;
	}
	if(j==1)
	{
		printf("-1");
		return 0;
	}
	printf("%i",r);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    ll ans = 0;
    rep(i,n-1) repl(j,i+1,n) {
        ans += (v[i]*v[j]);
        // cout<<i<<" "<<j<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
  
    // 桁数
    const keta = String(N).length;

    var result = 0;
    // 1つ前の桁まで
    for (var i = 1; i < keta; i++) {
        // 奇数桁
        if (i % 2 === 1) {
            if (i === 1) {
                result += 9;
            } else {
                result += Math.pow(10, i - 1) * 9;
            }
        }
    }

    // 一番最後の桁
    // ベースとなる数
    if (keta % 2 === 1) {
        const base = Math.pow(10, keta - 1);
        result += N - base + 1;
    }

    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int n;
char s[100000][4];
int ans[4]={0};//AC WA TLE RE

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%s",s[i]);
    for(int i=0;i<n;i++)
    if(strcmp(s[i],"AC")==0) ans[0]++;
    else if(strcmp(s[i],"WA")==0) ans[1]++;
    else if(strcmp(s[i],"TLE")==0) ans[2]++;
    else ans[3]++;
    printf("AC x %d\n",ans[0]);
    printf("WA x %d\n",ans[1]);
    printf("TLE x %d\n",ans[2]);
    printf("RE x %d\n",ans[3]);
    return 0;
}

Measured memory_bytes: 2116
n,T,C[10][2],c,d,O[10][2],t,s,u,v,h,*p;D(h){p=C[s]+h;*p&&T>=O[s][h]?*p=!printf("%d%c",*p,d<n|--c?32:10):0;}main(m){for(;~scanf("%d%d",&m,&n);)for(memset(C,T=c=d=0,80);d<n|c;T++){for(s=m;s--;C[s][1]||D(0))D(1);for(;T>=d*10&d<n&c<m*2;C[s=~u?u:v][h]=++d,O[s][h]=T+t,c++)for(h=scanf("%d",&t),u=v=-1,s=m;h&&s--;)*C[s]?C[s][1]||(*O[s]<T+t?!~v||*O[s]>*O[v]?v=s:0:!~u||*O[s]<*O[u]?u=s:0):(u=s,h=0);}}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
  int H,W,h,w;
  
  scanf("%d %d",&H,&W);
  
  scanf("%d %d",&h,&w);
  
  int d = H*W + h*w - h*W -H*w;
  
  printf("%d\n", d);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 10000000000000001
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long> 
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 100005
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	io := newIo()
	defer io.flush()

	n := io.nextInt()
	S := io.nextField()

	cnt := 0
	for i := 1; i < n; i++ {
		if S[i] == 'E' {
			cnt++
		}
	}
	ans := cnt

	for i := 1; i < n; i++ {
		if S[i-1] == 'W' {
			cnt++
		}
		if S[i] == 'E' {
			cnt--
		}
		ans = min(ans, cnt)
	}
	io.println(ans)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) flush() {
	_ = io.writer.Flush()
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextField() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextField())
	return i
}

func (io *io) print(a ...interface{}) {
	fmt.Fprint(io.writer, a...)
}

func (io *io) println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


Measured memory_bytes: 2304
#include <limits.h>
#include <iostream>
#include <vector>

int main(void)
{

    std::vector<int> price(0);   // 時系列の価格
    int dataLength = 0;         // データ数

    // データ数を入力
    std::cin >> dataLength;

    // 時系列の価格を入力
    for (int t = 0; t < dataLength; t++) {
        int value = 0;
        std::cin >> value;
        price.push_back(value);
    }

    int maxProfit = INT_MIN;    // 最大利益
    int floor = price[0];       // 底

    // 
    for (int t = 1; t < dataLength; t++) {

        // 
        if (maxProfit <= (price[t] - floor)) {
            maxProfit = price[t] - floor;
        }

        if (floor > price[t]) {
            floor = price[t];
        }
    }

    std::cout << maxProfit << std::endl;

    return 0;
}


Measured memory_bytes: 3928
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};

const int Maxc = 35, Maxt = (int) 1e5 + 10;

int cnt[Maxc][Maxt];
int sum[Maxt];
vector<P> v[Maxc];

int n, m;

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
     */
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        v[c].emplace_back(P(s, t));
    }
    for (int i = 0; i < m; ++i) {
        sort(v[i].begin(), v[i].end());
        for (auto &p : v[i]) {
            int l = p.first, r = p.second;
            if (cnt[i][l] == 0) cnt[i][l - 1]++;
            else cnt[i][l] = 0;
            cnt[i][r]--;
        }
        for (int j = 0; j < Maxt; ++j) {
            sum[j] += cnt[i][j];
        }
    }

    for (int i = 1; i < Maxt; ++i) {
        sum[i] += sum[i - 1];
    }

    int x = 0;
    for (int j = 0; j < Maxt; ++j) {
        x = max(x, sum[j]);
    }
    cout << x << endl;
}


Measured memory_bytes: 13568
#! -*- coding: utf-8 -*-

import copy

n = int(raw_input())
a = map(int,raw_input().split())

ai = max(a)
a_new = copy.copy(a)

a_new.remove(ai)

aj = a_new[0]
ai_half = ai/2
for i in range(n-1):
    if abs(a_new[i] - ai_half) < abs(aj - ai_half):
        aj = a_new[i]

print ai,aj


Measured memory_bytes: 11380
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int A1 , A2 , A3 ;
  cin >> A1 >> A2 >> A3 ;
  int ans = max({A1 , A2 , A3}) - min({A1 , A2 , A3});
  cout << ans <<endl;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 200020;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

using Point = complex<double>;

char A[11][1010];
int cum[1010][12];
void solve() {
	int H, W, K; cin >> H >> W >> K;
	REP(i, H) {
		REP(j, W)cin >> A[i][j];
	}
	REP(j, W) {
		REP(i, H) {
			cum[j][i + 1] = cum[j][i];
			if (A[i][j] == '1')cum[j][i + 1]++;
		}
	}
	int ans = 1e9;
	REP(bit, 1 << (H-1)) {
		int res = __builtin_popcount(bit);
		//int res = __popcnt(bit);
		vector<int>sum(res + 1);
		vector<int>l;
		l.push_back(0);
		REP(i, H) {
			if (bit&(1 << i)) {
				l.push_back(i + 1);
			}
		}
		l.push_back(H);

		REP(j, W) {
			bool ok = true;
			REP(i, l.size() - 1) {
				sum[i] += cum[j][l[i + 1]] - cum[j][l[i]];
				if (sum[i] > K)ok = false;
			}
			if (!ok) {
				ok = true;
				res++;
				REP(i, sum.size())sum[i] = 0;
				REP(i, l.size() - 1) {
					sum[i] += cum[j][l[i + 1]] - cum[j][l[i]];
					if (sum[i] > K)ok = false;
				}
				if (!ok)goto END;
			}
		}
		ans = min(ans, res);
	END:;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// int q; cin >> q;
	// while (q--)
	solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const LL INF = 1e16 + 7;

int n, a[5005];
LL A, B;
LL dp[5005];

int main()
{
	scanf("%d%lld%lld", &n, &A, &B);
	rep1(i, n) scanf("%d", &a[i]);
	a[n + 1] = n + 1;
	n ++;
	
	dp[0] = 0;
	rep1(i, n) dp[i] = INF;
	
	rep1(i, n) {
		int cntr = 0, cmin = a[i];
		for(int j = i - 1; j >= 0; j --) {
			if(a[j] > a[i]) cntr ++;
			else {
				if(cmin > a[i]) continue;
				int cntl = i - j - 1 - cntr;
				dp[i] = min(dp[i], dp[j] + A * cntr + B * cntl);
				cmin = a[i];
			}
		}
	}
	printf("%lld\n", dp[n]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] s = new int[14];
		int[] h= new int[14];
		int[] c = new int[14];
		int[] d = new int[14];
		
		int sint = 0;
		int hint = 0;
		int cint = 0;
		int dint = 0;
		
		
		for(int i = 0;i < n;i++) {
			
			String kigou = sc.next();
			
			int kazu = sc.nextInt();
			
			
			if(kigou.equals("S")) {
				s[sint] = kazu;
				sint += 1;
			}else if(kigou.equals("H")) {
				h[hint] = kazu;
				hint += 1;
			}else if(kigou.equals("C")) {
				c[cint] = kazu;
				cint += 1;
			}else if(kigou.equals("D")) {
				d[dint] = kazu;
				dint += 1;
			}
			
			
			
				
			}
			
		
		for(int j = 1;j <= 13;j++) {
			for(int k = 0;k < 13;k++) {
				if(s[k] == j) {
					break;
					
				}
			if(k == 12) {
				System.out.println("S" + " " + j);
			}
			
			}
		}
		
		for(int j = 1;j <= 13;j++) {
			for(int k = 0;k < 13;k++) {
				if(h[k] == j) {
					break;
					
				}
			if(k == 12) {
				System.out.println("H"+ " " + j);
			}
			
			}
		}
		
		for(int j = 1;j <= 13;j++) {
			for(int k = 0;k < 13;k++) {
				if(c[k] == j) {
					break;
					
				}
			if(k == 12) {
				System.out.println("C"+ " " + j);
			}
			
			}
		}
		
		for(int j = 1;j <= 13;j++) {
			for(int k = 0;k < 13;k++) {
				if(d[k] == j) {
					break;
					
				}
			if(k == 12) {
				System.out.println("D"+ " " + j);
			}
			
			}
		}
			
		}

		

}



Measured memory_bytes: 26296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  if (n == 1 || m == 1) {
    if (n == 1) ans += m - 2;
    if (m == 1) ans += n - 2;
    if (n == 1 && m == 1) ans = 1;
  } else {
    ans += (n - 2) * (m - 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



ll res[200005];
void dodajres(int x, int gr){
    ff(i,gr,x){
        res[i] += (x - i);
    }
}
int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,x,y;
    cin >> n >> x >> y;
    if(x > y)swap(x,y);
    ff(i,1,n){
        ff(j,i + 1, n){
           int dist = abs(i - j);
           int dist2 = abs(i - x) + abs(j - y) + 1;
           int dist3 = abs(i - y) + abs(j - x) + 1;
           res[min(dist, min(dist2,dist3))]++;
        }
    }
    ff(i,1,n-1)cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int main(void){
	int n,k;
	cin>>n>>k;
	int i,j;
	for(i=1;i<=n;i++){
		cin>>h[i];
	}
	for(i=0;i<=n;i++){
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++){
			if(i+j<=n)	dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int64_t A, B, C, D, X, Y, x, y;
  cin >> A >> B >> C >> D;
  X = A * C;
  Y = B * D;
  x = A * D;
  y = B * C;
  cout << max(max(X, Y),max(x, y)) << endl;
}
    

Measured memory_bytes: 3644
import itertools
import copy

h, w, k = map(int, input().split())
l = []
ans = 0

for i in range(h):
    c = list(input())
    l.append(c)


for i in itertools.product("01", repeat = h + w):
    m = copy.deepcopy(l)
    cnt = 0
    for j in range(h + w):
        if j <= h - 1:
            if i[j] == "1":
                for p in range(w):
                    m[j][p] = "."
        else:
            if i[j] == "1":
                for o in range(h):
                    m[o][j - h] = "."
    for j in range(h):
        cnt += m[j].count("#")
    if cnt == k:
        ans += 1

print(ans)

Measured memory_bytes: 9340
k = int(input())

nums = [i for i in range(1,10)]
for i in range(k):
  a = nums.pop(0)
  
  if a%10 != 0:
    nums.append(a*10 + a%10 - 1)
    
  nums.append(a*10 + a%10)
  
  if a%10 != 9:
    nums.append(a*10 + a%10 + 1)
print(a)

Measured memory_bytes: 18508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-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;
}

const int MAX_N=51;
const int MAX_M=21;
int N,M; ll ans=0;
map<Pii,int> m;
vector<int> u(MAX_M),v(MAX_M),par(MAX_N);
vector<ll> po(MAX_N,1);
vector<vector<int>> G(MAX_N);

void dfs(int v,int p){
    for(int u:G[v]){
        if (u==p) continue;
        par[u]=v; dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        m[{a,b}]=m[{b,a}]=i;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    cin >> M;
    rep(i,M) cin >> u[i] >> v[i],--u[i],--v[i];
    vector<vector<int>> list(M);
    rep(i,M){
        fill(all(par),-1);
        dfs(u[i],-1);
        int t=v[i];
        while(t!=u[i]){
            list[i].emplace_back(m[{t,par[t]}]);
            t=par[t];
        }
    }
    rep(i,N-1) po[i+1]=po[i]*2;
    rep(bit,1<<M){
        vector<int> cnt(N-1,0);
        int flag=0;
        rep(i,M) if (bit&1<<i){
            ++flag;
            for (int e:list[i]) ++cnt[e];
        }
        int c=0;
        rep(i,N-1) if (cnt[i]==0) ++c;
        ans+=(flag%2?-po[c]:po[c]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC124C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int countKisu0 = 0;//oをカウント
            int countKisu1 = 0;//oをカウント
            int countGusu0 = 0;
            int countGusu1 = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (S[i] == '0') countGusu0++;
                    else countGusu1++;
                }
                else
                {
                    if (S[i] == '0') countKisu0++;
                    else countKisu1++;
                }
            }

            int cand1 = countKisu1 + countGusu0;
            int cand2 = countKisu0 + countGusu1;

            int ans = Math.Min(cand1, cand2);
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

int main(){
    int n,x;
    cin >> n >> x;
    int ans = 0;
    int dist = 0;
    int leap;
    for (int i = 0; i < n + 1; i++){
        cin >> leap;
        dist += leap;
        ans++;
        if (dist > x){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};


vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (int u: to[v]) {
        if (u == p) continue;
        dfs(u, d+1, v);
    }
}

vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);
    return dist;
}
int main() {
    int n; cin >> n;
    string s,t; cin >> s >> t;
    stringstream ss;
    rep(i,n) {
        ss << s[i] << t[i];
    }
    cout << ss.str() << endl;
}


Measured memory_bytes: 4352
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	s, t := sc.s(), sc.s()
	c := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			c++
		}
	}
	fmt.Println(c)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

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

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  vector<unordered_set<int>> graph(n);
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b; a--; b--;
    graph[a].insert(b); graph[b].insert(a);
  }
  string ans = "IMPOSSIBLE";
  for (auto &x : graph[0]) {
    if (graph[x].find(n - 1) != graph[x].end()) {
      ans = "POSSIBLE"; break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 31944
/*input
7777
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	string s;
	cin>>s;
	cout<<((s[1]==s[0] && s[0]==s[2])||(s[2]==s[1] && s[1]==s[3])?"Yes":"No");
}

Measured memory_bytes: 764
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> P;

double cross(P a, P b) {
  return (a.real()*b.imag()-a.imag()*b.real());
}

P vector_coord(P a, P b, P x){
  return P(-cross(b,x),cross(a,x))/cross(a,b);
}

int main(){
  double a1,b1,a2,b2,a3,b3,x1,y1;
  while(cin >>a1 >>b1 >>a2 >>b2 >>a3>>b3>>x1>>y1){
  P o=P(a1,b1);
  P a=P(a2,b2)-o;
  P b=P(a3,b3)-o;
  P x=P(x1,y1)-o;
  P v = vector_coord(a,b,x);
  if (0<v.real()&&0<v.imag()&&v.real()+v.imag()<1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  N %= 10;
  
  if(N == 3) puts("bon");
  else if(N == 0 || N == 1 || N == 6 || N == 8) puts("pon");
  else puts("hon");
  
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	vi a(5);
	rep(i, 5)cin >> a[i];
	
	int ans = INF;
	sort(all(a));
	do {
		int time = 0;
		rep(i, 4)time += (a[i] + 9) / 10 * 10;
		time += a[4];
		ans = min(ans, time);

	} while (next_permutation(all(a)));

	cout << ans << endl;
}

Measured memory_bytes: 3604
// 2020 4/15
// B Collecting Balls (Easy Version)
#include <algorithm>
#include <complex>
#include <string>
#include <deque>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <queue>
#include <utility>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x;
    rep(i, N) {
        int a;
        cin >> a;
        // cout << a << " ";
        x.push_back(a);
    }
    // cout << endl;
    sort(x.begin(), x.end());
    int ans = 0;
    // for(int b : x){
    //     cout << b << " ";
    // }
    // cout << endl;

    for (int i = 0; i < N; i++) {
        int cmp = x[i]- K;
        if (cmp < 0) cmp *= -1;
        ans += min(x[i], cmp);
    }
    
    cout << ans*2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define MAX 100000
#define NIL -1

int n, m;
vector<int> V[MAX];
int color[MAX];

void search(int s){
  // init
  queue<int> Q;

  Q.push(s);
  int c = color[s] = s;
  while (!Q.empty()){
    int u = Q.front();
    Q.pop();
    for ( int i = 0; i < V[u].size(); i++){
      if ( color[V[u][i]] == NIL ){
        Q.push(V[u][i]);
        color[V[u][i]] = c;
      }
    }
  }
}

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

  int s, t;
  for (int i = 0; i < m; i++ ){
    cin >> s >> t;
    V[s].push_back(t);
    V[t].push_back(s);
  }

  for ( int i = 0; i < n; i++){ color[i] = NIL; }
  for ( int i = 0; i < n; i++){
    if ( color[i] == NIL){
      search(i);
    }
  }

  int q;
  cin >> q;
  for ( int i = 0; i < q; i++){
    cin >> s >> t;
    if (color[s] == color[t]){ cout << "yes" << endl;}
    else { cout << "no" << endl;}
  }

  return 0;
}


Measured memory_bytes: 8964
n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in nums:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

Measured memory_bytes: 21716
//ABC101B
#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(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	if((n-1)%(k-1) == 0){
		cout << (n-1)/(k-1) << endl;
	}else{
		cout << (n-1)/(k-1)+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 640
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.weight = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def unite(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.par[px] = py
                self.weight[px] = w - self.weight[x] + self.weight[y]
            else:
                self.par[py] = px
                self.weight[py] = -w - self.weight[y] + self.weight[x]
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 各頂点間の絶対距離
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
graph = WeightedUnionFind(N)

for i in range(M):
    l, r, d = map(int, input().split())
    if not graph.same(l-1, r-1):
        graph.unite(l-1, r-1, d)
    else:
        if graph.diff(l-1, r-1) != d:
            print('No')
            quit()

print('Yes')

Measured memory_bytes: 11592
def gcd(x: int, y: int) -> int:
    return x if y == 0 else gcd(y, x % y)


def lcm(x: int, y: int) -> int:
    return (x * y) // gcd(x, y)


N = int(input())
T = [int(input()) for _ in range(N)]

ans = 1
for t in T:
    ans = lcm(ans, t)
print(ans)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int x, a;
  cin >> x >> a;
  cout << (x < a ? 0 : 10) << endl;
  return 0;
}

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

int main(){
    //入力
    string s;
    cin >> s;

    //処理
    deque<char> output;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='B'){
            if(output.empty()==false)
                output.pop_back();
        }else{
            output.push_back(s.at(i));
        }
    }
    //出力
    for(int i=0;i<output.size();i++){
        cout << output.at(i);
    }
    cout << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long n, m;
    long long count;
    
    cin >> n >> m;
    
    count = min(n, m / 2);
    m -= count * 2;
    count += m / 4;
    
    cout << count << endl;
    
    return 0;
}

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

int main(){
  int c[3][3];
  rep(i, 3){
    rep(j, 3){
      cin >> c[i][j];
    }
  }
  bool can = false;
  for(int a0 = -1000; a0 <= 1000; a0++){
    int b0 = c[0][0] - a0;
    int a1 = c[1][0] - b0;
    int a2 = c[2][0] - b0;
    int b1 = c[0][1] - a0;
    int b2 = c[0][2] - a0;
    if(a1+b1 == c[1][1] && a2+b1 == c[2][1] && a1+b2 == c[1][2] && a2+b2 == c[2][2]) can = true;
  }
  cout << (can? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int main(void) {
    set<int> d;
    int n,t;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> t;
        d.insert(t);
    }
    cout << d.size() << endl;
}


Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;
long long h,i,j,k,m,n,s,w[100005];
main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h;
	for(;h;h/=2)s+=s+1;
	cout<<s;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) cout << "error";
	else cout << A + B;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

特に解説する必要もないね
*/

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

using namespace std;

typedef long long ll;

const int N =3e3+20;

ll a[N],f[N][N];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) f[i][i]=a[i];	
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j+i-1<=n;j++)
		{
			f[j][j+i-1]=max(a[j]-f[j+1][j+i-1],a[j+i-1]-f[j][j+i-2]);
		}
	}
	cout<<f[1][n]<<endl;
}

Measured memory_bytes: 70144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

map<ll,ll>a;
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
	}
	ll ans=0;
	for(auto i=a.begin();i!=a.end();i++){
		ll now=i->first;
		ll val=i->second;
		if(now<=val){
			ans+=val-now;
		}
		else{
			ans+=val;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 6272
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
    int r;
    cin >> r;
    cout << r * r << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    double x1,y1,x2,y2,result,distance;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

    result=(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
    distance=sqrt(result);
    printf("%lf\n",distance);

    return 0;



}


Measured memory_bytes: 2040
N=io.read("n")
X=io.read("n")
x={}
for i=1,N do
  x[i]=io.read("n")
end
function d(a,b)
  while(true) do
  	local r=a%b
  	a=b
  	b=r
 	if r==0 then
    break
    end
  end
return a
end
    	
res=math.abs(X-x[1])
for i=2,N do
  res=d(res,math.abs(X-x[i]))
end
print(res)

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
inline void upa(int&a,int b){a<b?a=b:0;}
const int N=190;
int H,W,i,j,k,x,A,L[N][N][N],R[N][N][N],U[N][N][N],D[N][N][N];
int L1[N][N][N],R1[N][N][N],U1[N][N][N],D1[N][N][N];
char c[N][N];
template<typename T>inline void work(T*a,T*b,int n,int m){
	for(k=1;k<=m;++k){
		for(i=1;i<n;++i)for(j=n;j>i;--j)upa(b[k][i][j-1],b[k][i][j]);
		for(i=1;i<n;++i)for(j=i+1;j<=n;++j)upa(b[k][i+1][j],b[k][i][j]);
		for(i=1;i<=n;++i)memcpy(a[k][i]+i,b[k][i]+i,n-i+1<<2);
	}
}
inline void upd(int x1,int x2,int y1,int y2){
	upa(U1[x2][y1][y2],x2-x1+1);
	upa(D1[x1][y1][y2],x2-x1+1);
	upa(L1[y2][x1][x2],y2-y1+1);
	upa(R1[y1][x1][x2],y2-y1+1);
}
int main(){
	scanf("%d%d",&H,&W);
	for(i=1;i<=H;++i)scanf("%s",c[i]+1);
	work(L,L1,H,W);
	for(i=W;i;--i)for(j=1;j<=H;++j)for(k=j;k<=H;++k)
		R[i][j][k]=k==j || (c[k][i]==c[k-1][i] && R[i][j][k-1])?(c[k][i]==c[k][i+1]?R[i+1][j][k]:0)+1:0;
	for(i=1;i<=W;++i)for(j=1;j<=H;++j)for(k=j;k<=H;++k)
		L[i][j][k]=k==j || (c[k][i]==c[k-1][i] && L[i][j][k-1])?(c[k][i]==c[k][i-1]?L[i-1][j][k]:0)+1:0;
	for(i=H;i;--i)for(j=1;j<=W;++j)for(k=j;k<=W;++k)
		D[i][j][k]=k==j || (c[i][k]==c[i][k-1] && D[i][j][k-1])?(c[i][k]==c[i+1][k]?D[i+1][j][k]:0)+1:0;
	for(i=1;i<=H;++i)for(j=1;j<=W;++j)for(k=j;k<=W;++k)
		U[i][j][k]=k==j || (c[i][k]==c[i][k-1] && U[i][j][k-1])?(c[i][k]==c[i-1][k]?U[i-1][j][k]:0)+1:0;
	if(R[1][1][H]==W){puts("0");return 0;}
	for(A=1;;++A){
		memset(L1,0,sizeof L1);
		memset(R1,0,sizeof R1);
		memset(U1,0,sizeof U1);
		memset(D1,0,sizeof D1);
		for(i=1;i<=W;++i)for(j=1;j<=H;++j)for(k=j;k<=H;++k){
			if(x=R[i][j][k])upd(j,k,i,i+x+R[i+x][j][k]-1);
			if(x=L[i][j][k])upd(j,k,i-x-L[i-x][j][k]+1,i);
		}
		for(i=1;i<=H;++i)for(j=1;j<=W;++j)for(k=j;k<=W;++k){
			if(x=U[i][j][k])upd(i-x-U[i-x][j][k]+1,i,j,k);
			if(x=D[i][j][k])upd(i+x+D[i+x][j][k]-1,i,j,k);
		}
		work(L,L1,H,W);work(R,R1,H,W);work(U,U1,W,H);work(D,D1,W,H);
		if(R[1][1][H]==W)break;
	}
	printf("%d\n",A);
	return 0;
}

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

int main(){
int n;
  cin >> n;
int j;  
int a[100000];
  for(int i=0;i<n;i++) cin >> a[i];
sort(a,a+n);
  int res=0;
  int f;
  while(j<n){
   int cc=a[j];
   f=0;
    while(j<n && a[j]==cc){
      j++;
      f++;     
      }
    res+=f%2;
  
  }
  cout << res << endl;


}


Measured memory_bytes: 4036
n,s=int(input()),sorted(list(input()))
count=[]
cnt=0
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        count.append(cnt+2)
        cnt=0
count.append(cnt+2)
ans=1
for i in range(len(count)):
    ans*=count[i]
    ans%=10**9+7
print(ans-1)


Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 2e5+10;
int N;
ll A[MAX_N];

void solve()
{
	ll psum = 0;
	ll ans = 0;
	for(int i=1;i<=N;++i){
		(ans += psum * A[i])%=MOD;
		(psum+=A[i])%=MOD;
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for(int i=1;i<=N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 5216
def main():
    N = int(input())
    A = list(map(int, input().split()))

    sm = sum(A)
    current_sm = 0
    ans = 10 ** 10
    for ai in A[:N-1]:
        current_sm += ai
        x = abs(current_sm - (sm - current_sm))
        ans = min(ans, x)
        # print(':', ai, ans)
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 23792
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, k = inpl()
a = inpl()
data = [[abs(i), i < 0] for i in a]
data.sort(reverse=True)
last_minus = 0
last_plus = 0
ans = 1
minus_amount = 0
for i in range(k):
    elem, sign = data[i][0], data[i][1]
    if elem == 0:
        print(0)
        exit()
    ans = ans * elem % mod
    minus_amount += sign
    if sign:
        last_minus = elem
    else:
        last_plus = elem
if minus_amount % 2 == 0:
    print(ans % mod)
    exit()
if n==k:
    print(-ans % mod)
    exit()
all_minus = 0
for t in data:
    if t[1]:
        all_minus += 1
if all_minus == n:
    ans = 1
    data.sort()
    for i in range(k):
        ans = ans * data[i][0] % mod
    ans = ans * ((-1) % mod)
    print(ans % mod)
    exit()
tmp_plus = 0
tmp_minus = 0
for i in range(k, n):
    elem, sign = data[i][0], data[i][1]
    if last_plus and sign and not tmp_minus:
        tmp_minus = elem
    elif last_minus and not sign and not tmp_plus:
        tmp_plus = elem
if tmp_plus == 0 and tmp_minus == 0:
    ans = 0
elif last_plus == 0:
    ans = ans * pow(last_minus, mod - 2, mod) * tmp_plus % mod
elif last_minus == 0:
    ans = ans * pow(last_plus, mod - 2, mod) * tmp_minus % mod
elif tmp_plus * last_plus > tmp_minus * last_minus:
    ans = ans * pow(last_minus, mod - 2, mod) * tmp_plus % mod
else:
    ans = ans * pow(last_plus, mod - 2, mod) * tmp_minus % mod
print(ans)


Measured memory_bytes: 112712
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string S;
  cin>>S;
  for(int i=0;i<(int)S.size();i+=2){
    cout<<S[i];
  }
  cout<<endl;
  
}


Measured memory_bytes: 512
// Problem : A - 500 Yen Coins
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
int k,x;
cin>>k>>x;
if(500*k>=x)
cout<<"Yes\n";
else
cout<<"No\n";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


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

long long n, k;
long long w[101], v[101];

long long dp[101][100005];

long long solve(int pr, int remweight) {
	if (dp[pr][remweight] != -1) 
		return dp[pr][remweight];
	if (pr == n) {
		dp[pr][remweight] = 0;
		return 0;
	}
	if (remweight < w[pr]) {
		dp[pr][remweight] = solve(pr+1, remweight);
		return dp[pr][remweight];
	}
	dp[pr][remweight] = max(v[pr]+solve(pr+1, remweight-w[pr]), solve(pr+1, remweight));
	return dp[pr][remweight];
}

int main() {
	
	cin >> n >> k;
	for (int i=0; i<n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i=0; i<100; i++) {
		for (int j=0; j<100005; j++) {
			dp[i][j] = -1;
		}
	}
	cout << solve(0, k);
	
	
	
}


Measured memory_bytes: 78336