akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int N;
int x[10], y[10];
 
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

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

signed main(void)
{
	int n, ans;
	cin >> n;
	int s[n][3], dp[n][3];
	rep(i, n) rep(j, 3) cin >> s[i][j];
	rep(i, n) rep(j, 3) dp[i][j] = 0;
	dp[0][0] = s[0][0];
	dp[0][1] = s[0][1];
	dp[0][2] = s[0][2];
	for(int i = 0; i < n - 1; i++)
	{
		rep(j, 3) // to
		{
			rep(k, 3) // from
			{
				if (j == k) continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + s[i + 1][k]);
			}
		}
	}
	ans = 0;
	rep(i, 3) ans = max(ans, dp[n - 1][i]); 
	cout << ans << endl; 
	return 0;
}


Measured memory_bytes: 2560
if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end

N = STDIN.gets.strip.to_i
(1..9).each do |i|
  (1..9).each do |j|
    if i*j==N
      puts 'Yes'
      exit
    end
  end
end
puts 'No'

Measured memory_bytes: 1788
import java.util.Iterator;
import java.util.Scanner;
import java.util.HashSet;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
		String S = sc.next();

		HashSet hs = new HashSet();
		for (int i = 0; i < N; i++){
			hs.add(S.charAt(i));
		}

		int cnt = 0;

	    	for(int j = 1; j <= N; j++){
	    		String s1 = S.substring(0, j);
	    		String s2 = S.substring(j);
//	    		System.out.println("j= "+ j +":"+ s1);
//	    		System.out.println("j= "+ j +":"+ s2);
	            Iterator it = hs.iterator();
	            int wkcnt = 0;
	            while (it.hasNext()) {
	            	String chr = it.next().toString();
//	            	System.out.println(chr);
	                if(s1.contains(chr) && s2.contains(chr)){
	                	wkcnt++;
	                }
	            }
	            cnt = Math.max(cnt, wkcnt);
	    	}



		System.out.println(cnt);

	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define MOD (int)(1e9+7)
using namespace std;
int n;
int k;
int x;
int sum;
int dp[105][100005];
int main() {
	scanf("%d%d",&n,&k);
	dp[0][0]=1;
	for(int i=1; i<=n; i++) {
		scanf("%d",&x);
		sum=0;
		for(int j=0; j<=k; j++) {
			sum+=dp[i-1][j];
			if(j>x) sum-=dp[i-1][j-x-1];
			sum%=MOD;
			if(sum<0) sum+=MOD;
			dp[i][j]=sum;
		}
	}
	printf("%d\n",dp[n][k]);
} 

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,r; cin >> n >> r;
  if(n >= 10)cout << r << endl;
  else cout << r + 100 * (10 - n) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str=scan.next();
		String a=str.substring(0,2);
		String b=str.substring(2,4);
		boolean YYMM=false;
		boolean MMYY=false;
		int B=Integer.parseInt(b);
		int A=Integer.parseInt(a);
		if(B>0&&B<13) {
			YYMM=true;
		}
		if(A>0&&A<13) {
			MMYY=true;
		}
		if(YYMM) {
			if(MMYY) {
				System.out.println("AMBIGUOUS");
			}
			else {
				System.out.println("YYMM");
			}
		}
		else {
			if(MMYY) {
				System.out.println("MMYY");
			}
			else {
				System.out.println("NA");
			}
		}
	}
}


Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    val S = sc.next()

    if (S.filter({c -> c == '-' }).length == 1) {
        if (S[A] == '-'){
            println("Yes")
            return
        }
    }
    println("No")
}

Measured memory_bytes: 29360
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

int main(){
    vector<int> data;
    
    int i;
    int d;
    
    for(i = 0; i < 3; i++){
        cin >> d;
        data.push_back(d);
    }
    
    sort(data.begin(), data.end());
    
    int max = 0;
    
    max = data[2] * 10 + data[1] + data[0];
    
    cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main(int argc, const char * argv[]) {
  
  ll N, X; cin >> N >> X;
  vector<ll> S(N);
  for (int i=0; i<N; i++)
    cin >> S[i];
  
  sort(S.begin(), S.end(), greater<ll>());
  
  vector<vector<ll>> dp(N+1, vector<ll>(X+1, 0));
  dp[0][X] = 1;
  for (ll n=0; n<N; n++) {
    for (ll x=0; x<X+1; x++) {
      if (dp[n][x] == 0) continue;
      dp[n+1][x%S[n]] += dp[n][x];
      dp[n+1][x%S[n]] %= MOD;
      dp[n+1][x] += (N-n-1)*dp[n][x]%MOD;
      dp[n+1][x] %= MOD;
    }
  }
  
  ll ans = 0;
  for (int i=0; i<X+1; i++){
    ans += dp[N][i]*i % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  
  return 0;
}


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            /*Problem A
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            if (A >= 13)
            {
                Console.WriteLine(B);
            }
            else if (A >= 6 && A <= 12)
            {
                Console.WriteLine(B / 2);
            }
            else
            {
                Console.WriteLine("0");
            }
            */
            //Problem B

            string[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int D = int.Parse(input[1]);
            int x = int.Parse(input[2]);

            int i = 1;
            for(i = 1; i <= 10; i++)
            {
                x = r * x - D;
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int v_max = 8;
int A[v_max][v_max];

int dfs(int v, int N, int visited[]){
    bool all_visited = true;
    int ans = 0;

    for(int i=0;i<N;i++){
        if(visited[i] == 0){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }
    for(int i=0;i<N;i++){
        if(A[v][i]==1 && visited[i]==0){
            visited[i] = 1;
            ans += dfs(i, N, visited);
            visited[i] = 0;
        }
    }
    return ans;
}

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

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            A[i][j] = 0;
        }
    }

    for(int i=0;i<M;i++){
        int tmp,tmp2;
        cin >> tmp >> tmp2;
        A[tmp-1][tmp2-1] = 1;
        A[tmp2-1][tmp-1] = 1 ;
    }

    int visited[v_max];
    for(int i=0;i<v_max;i++){
        visited[i] = 0;
    }
    visited[0] = 1;

    cout << dfs(0, N, visited) << endl;
    return 0;
}

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

int main() {
  int n,q;long long k;
  cin >> n >> k >> q;
  vector<int>a(q);
  vector<long long>p(n);
  for(int i = 0;i < q;i++){
    cin >> a.at(i);
    p.at(a.at(i)-1)++;
  }
  for(int i = 0;i < n;i++){
    if(p.at(i) >= q-k+1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int A, B, C;
    int i = 1;
    int rem;

    cin >> A >> B >> C;
    set<int> rems;

    while(true){
        rem = (A * i) % B;
        if(rem == C){
            cout << "YES" << endl;
            return 0;
        }
        if(rems.count(rem) == 1){
            break;
        }
        rems.insert(rem);
        ++i;
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	private static final Integer[] primeNumberArray = getPrimeNumberArray(110000);
	private static final int[] ansArray = getAnsArray(50000);

	public static void main(String[] args) throws IOException {
		try (BufferedReader input = new BufferedReader(new InputStreamReader(System.in))) {
			while (input.ready()) {
				final int dataset = Integer.valueOf(input.readLine());
				if (dataset == 0)
					break;
				System.out.println(ansArray[dataset]);
			}
		}
	}

	private static int[] getAnsArray(final int maxNumber) {
		int ansArray[] = new int[maxNumber + 1];
		int tmp = 0;
		for (int i = 0; i < primeNumberArray.length; i++) {
			for (int j = i; j < primeNumberArray.length / 2; j++) {
				tmp = primeNumberArray[i] + primeNumberArray[j];
				if (tmp > maxNumber) {
					break;
				}
				ansArray[tmp]++;
			}
		}
		return ansArray;
	}

	public static Integer[] getPrimeNumberArray(final int maxNumber) {
		ArrayList<Integer> primeNumberList = new ArrayList<>();
		primeNumberList.add(2);
		primeNumberList.add(3);
		primeNumberList.add(5);
		primeNumberList.add(7);

		final int[] oneDigitList = { 1, 3, 7, 9 };

		int tmp;
		int sqrtTmp;
		boolean addFlag;
		for (int i = 10; i <= maxNumber; i += 10) {
			for (int oneDigit : oneDigitList) {
				addFlag = true;
				tmp = i + oneDigit;
				sqrtTmp = (int) Math.sqrt(tmp);
				for (int primeNumber : primeNumberList) {
					if (tmp % primeNumber == 0) {
						addFlag = false;
						break;
					}
					if (sqrtTmp < primeNumber) {
						break;
					}
				}
				if (addFlag) {
					primeNumberList.add(tmp);
				}
			}
		}
		return primeNumberList.toArray(new Integer[0]);
	}
}

Measured memory_bytes: 34004
#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++)
#define INF 1001001001
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll max_pizza = max(x, y);
    ll cost = INF;
    for(ll i = 0; i <= max_pizza * 2; i += 2) {
        int tmp_x, tmp_y;
        if(x - i / 2 < 0)
            tmp_x = 0;
        else
            tmp_x = x - i / 2;

        if(y - i / 2 < 0)
            tmp_y = 0;
        else
            tmp_y = y - i / 2;
        cost = min(cost, tmp_x * a + tmp_y * b + c * i);
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	char a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "<" << endl;
	}
	else if (a == b) {
		cout << "=" << endl;
	}
	else {
		cout << ">" << endl;
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200005
 
// it's swapnil07 ;)


signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n; cin>>n;
    int a[n], b[n], c[n];
    int dp[n][3];
    For(i, 0, n){
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    For(i, 1, n){
        dp[i][0]=max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][1]+c[i], dp[i-1][0]+c[i]);
    }
    int ans = max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4992
void main() {
	auto X = readAs!long;
	ulong cnt;
	long tmp = 100;
	while(X > tmp) {
		tmp *= 1.01;
		cnt++;
	}
	cnt.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2716
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto X = new long[](N);
    auto Y = new long[](N);
    auto H = new long[](N);
    foreach (i; 0 .. N)
        scan(X[i], Y[i], H[i]);
    zip(H, X, Y).sort();

    foreach (cx; 0 .. 100 + 1)
        cy: foreach (cy; 0 .. 100 + 1)
        {
            long base = H[$ - 1] + abs(X[$ - 1] - cx) + abs(Y[$ - 1] - cy);
            foreach (i; 0 .. N - 1)
            {
                long h = H[i] + abs(X[i] - cx) + abs(Y[i] - cy);
                if (H[i] == 0)
                {
                    if (h < base)
                        continue cy;
                }
                else
                {
                    if (base != h)
                        continue cy;
                }
            }
            arywrite([cx, cy, base]);
            return;
        }
}


Measured memory_bytes: 3740
#include <stdio.h>
#include <stdlib.h>

int part(int *a, int p, int r){
  int i, j, x, tmp;

  x = a[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(a[j] <= x){
      i++;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;

  return i+1;
}

int main(){
  int i, j, q, n;

  scanf("%d", &n);
  int *a;
  a = malloc(sizeof(int) * n);
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  q = part(a, 0, n-1);

  for(j = 0; j < q; j++)
      printf("%d ", a[j]);
  printf("[%d] ", a[j]);
  for(j = j+1; j < n-1; j++)
    printf("%d ", a[j]);
  printf("%d\n", a[j]);


  free(a);
  return 0;
}

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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(1000000);

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

map<ll,ll> mp;

// 一回きりの素因数分解を行う．
void factorization(const ll &n){

    ll now = n;
    for(ll i = 2; i*i <= n; i++){
        ll times = 0;
        while(now%i==0){
            times++;
            now/=i;
        }
        if(times>=1){
            mp[i] += times;
        }
        if(now==1){
            break;
        }
    }
    if(now > 1){
        mp[now]++;
    }
    return;
}

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

    factorization(n);

    mint ans = 1;
    for(auto it : mp){
        int num = it.second;
        // {num+m}C{m}
        num+=m-1;
        ans*=comb(num, (int)(m-1));
    }

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

Measured memory_bytes: 15872
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	word := nextLine()
	number, _ := strconv.Atoi(word)
	thou := number / 500
	number = number % 500
	fivr := number / 5
	fmt.Println(thou*1000 + fivr*5)

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h)
    {
        cin >> s[i];
    }
    int res = 0;
    for (int row = 0; row < 1 << h; row++)
    {
        for(int col = 0;col<1<<w;col++){
            int cnt = 0;
            rep(i,h){
                if(row&1<<i){
                    continue;
                }
                rep(j,w){
                    if(col&1<<j){
                        continue;
                    }
                    if(s[i][j]=='#'){
                        cnt++;
                    }
                }
            }
            if(cnt==k){
                res++;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;



int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l);
  rev(l);
  int sum = 0;
  repl(i,1,n) sum += l[i];
  if (l[0] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import heapq
class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        return heapq.heappop(self.hq) * self.sign
 
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
        
N,M=map(int,input().split())
A=list(map(int,input().split()))

q = Heapq(A, True)
    
for i in range(M):
    x=q.pop()
    q.push(x//2)

print(sum([q.pop() for _ in range(N)]))


Measured memory_bytes: 20720
#include <stdio.h>
int main(void) {
  int a,b,c,n,i;
  while(scanf("%d",&n)!=EOF){
    i=0;
    for(a=0;a< 10;a++)
      for(b=0;b< 10;b++)
	for(c=0;c< 10;c++) {
	  i+=0<=n-a-b-c && n-a-b-c< 10;
	}
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
    public static void main(String[] args){

	int N,K,x,flg;
	int t[] = new int[100];
	Scanner scan = new Scanner(System.in);
	while(true){
	    N=scan.nextInt();
	    K=scan.nextInt();
	    if(N==0&&K==0)break;
	    flg=1;
	    for(int i=0;i<K;i++)t[i]=scan.nextInt();
	    for(int i=0;i<N;i++){
		for(int j=0;j<K;j++){
		    x=scan.nextInt();
		    t[j]-=x;
		    if(t[j]<0)flg=0;
		}
	    }
	    if(flg==1){
		System.out.println("Yes");
	    }else{
		System.out.println("No");
	    }
	}
    }
}

Measured memory_bytes: 94936
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string s;

int main(){
  cin >> s;
  ll l = s.size();
  ll left_b[l];
  ll num_b = 0;

  REP(i, l) {
    if(s[i] == 'B') num_b++;
    left_b[i] = num_b;
  }

  ll ans = 0;

  REP(i, l) {
    if(s[i] == 'W') {
      ans += left_b[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string sd, t;
    cin >> sd >> t;

    for(int i=sd.size()-1; i>=0; i--) {
        int te = i, ts = t.size()-1;
        bool sol = false;
        if(sd[i] == t[t.size()-1] || sd[i] == '?') {  
            bool tres = true;
            while(true) {
                ts--; if(ts < 0) break;
                te--; if(te < 0) {tres = false; break;}
                if(sd[te] != t[ts] && sd[te] != '?') {tres = false; break;}
            }
            if(tres) sol = true;
        }
        if(sol) {
            FOR(j, te, i+1) sd[j] = t[j-te];
            rep(j, sd.size()) if(sd[j] == '?') sd[j] = 'a';
            cout << sd << endl;
            return 0;
        }  
    }
    
    cout << "UNRESTORABLE" << endl; 
    return 0;
}

Measured memory_bytes: 256
//半径 r の円の面積と円周の長さを求めるプログラム
#include <stdio.h>
#define PI 3.14159265359//円周率
int main()
{
	double r=0., s=0., l=0.;//実数
	scanf("%lf", &r);
	s = r * r * PI;
	l = 2 * PI * r;
	printf("%lf %lf\n", s, l);
	return 0;
}


Measured memory_bytes: 2072
//The Doc

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll mod11=1e9+7;
    vector<ull> a(n+1);
    for (int i = 1; i <=n ; ++i) {
        cin>>a[i];
    }
    a[0]=0;
    vector<ull> b(n+1);
    for (int j = 0; j <=n ; ++j) {
        b[j]=a[j];
    }
    for (int k = 1; k <=n ; ++k) {
        b[k]+=b[k-1];
    }
    ull ans=0;
    for (int i = 1; i <n ; ++i) {
        ull k=(a[i]%mod11)*((b[n]-b[i])%mod11);
        ans+=k;
        ans%=mod11;
    }
    ans%=mod11;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6320
import java.util.*

fun main(args: Array<String>) {
    solve(Scanner(System.`in`))
}

class ModInt(var value: Long) {
    override fun toString(): String = value.toString()

    // 加減乗算は結果を毎回 mod P すれば良い
    operator fun plus(b: Long): ModInt =
        ModInt((this.value + b) % MOD)

    operator fun plus(b: ModInt): ModInt =
        ModInt((this.value + b.value) % MOD)

    operator fun plusAssign(b: Long) {
        this.value += b
        this.value %= MOD
    }

    operator fun plusAssign(b: ModInt) {
        this.value += b.value
        this.value %= MOD
    }

    operator fun minus(b: Long): ModInt =
        ModInt((this.value + MOD - b) % MOD)

    operator fun minus(b: ModInt): ModInt =
        ModInt((this.value + (MOD - b.value)) % MOD)

    operator fun minusAssign(b: Long) {
        this.value += MOD - b
        this.value %= MOD
    }

    operator fun minusAssign(b: ModInt) {
        this.value += MOD - b.value
        this.value %= MOD
    }

    operator fun times(b: Long): ModInt =
        ModInt((this.value * b) % MOD)

    operator fun times(b: ModInt): ModInt =
        ModInt((this.value * b.value) % MOD)

    operator fun timesAssign(b: Long) {
        this.value *= b
        this.value %= MOD
    }

    operator fun timesAssign(b: ModInt) {
        this.value *= b.value
        this.value %= MOD
    }

    // b で割る = 1/b を掛ける
    // フェルマーの小定理から、b の逆数 1/b (mod P) = b^(P-2)
    operator fun div(b: Long): ModInt =
        this * ModInt(b).pow(MOD - 2)

    operator fun div(b: ModInt): ModInt =
        this * b.pow(MOD - 2)

    operator fun divAssign(b: ModInt) {
        this *= b.pow(MOD - 2)
    }

    operator fun divAssign(b: Long) {
        this *= ModInt(b).pow(MOD - 2)
    }

    // 累乗 (mod P)
    // 計算量は O(log p)
    fun pow(p: Long): ModInt = when {
        p == 0L -> ModInt(1)
        p % 2 == 1L -> this * this.pow(p - 1)
        else -> {
            val half = this.pow(p / 2)
            half * half
        }
    }

    companion object {
        const val MOD = 1000000007L

        // aCb (mod P)
        fun combination(a: Long, b: Long): Long =
            if (b > a - b) {
                combination(a, a - b)
            } else {
                (ModInt((0L until b).fold(1L) { acc, i -> (acc * (a - i)) % MOD })
                        / (1L..b).fold(1L) { acc, i -> ((acc * i) % MOD) }).value
            }
    }
}

fun solve(sc: Scanner) {
    val N = sc.nextLong()
    val A = sc.nextLong()
    val B = sc.nextLong()

    val n = ModInt(2).pow(N)
    n -= 1
    n -= ModInt.combination(N, A)
    n -= ModInt.combination(N, B)
    println(n)
}


Measured memory_bytes: 42520
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int x;
    cin >> x;
    string ans = x < 1200 ? "ABC" : "ARC";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n);++i)
using namespace std;
typedef long long ll;

string str[60];

int main(){
    int X, Y;
    cin >> X >> Y;
    int dx[8] = {1,1,0,-1,-1,-1,0,1};
    int dy[8] = {0,1,1,1,0,-1,-1,-1};
    rep(i, X) cin >> str[i];
    rep(i,X){
        rep(j,Y){
            if (str[i][j] == '.'){
                int cnt = 0;
                rep(k, 8)
                {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if (x >= 0 && x < X && y >= 0 && y < Y && str[x][y] == '#'){
                        cnt++;
                    }
                }
                str[i][j] = '0' + cnt;
            }
        }
    }

    rep(i,X) cout << str[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y[ohara],sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl,vi[ohara];
struct edge{int to,cost;};
V g[ohara];
queue<ll> que;
P p[ohara];
ll p_cou;
ll dp[ohara],de[ohara];
    
//------ Believe yourself as a genius!!!!!! ------


void dfs(ll now,ll dep){
    if(vi[now])return;
    vi[now]=true;
    p[p_cou++]=m_p(dep,now);
    de[now]=dep;
    rep(i,Size(g[now])){
        dfs(g[now][i],dep+1);
    }
}
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n-1)cin>>x[i]>>y[i];
    rep(i,n-1){
        x[i]--;y[i]--;
        g[x[i]].p_b(y[i]);
        g[y[i]].p_b(x[i]);
    }
    dfs(0LL,0LL);
    sort(p,p+p_cou);
    reverse(p,p+p_cou);
    rep(i,p_cou){
        ll moto=p[i].se;
        int ok=0;
        ll cost=0;
        rep(j,Size(g[moto])){
            ll to=g[moto][j];
            if(de[to]<de[moto])continue;
            cost=(cost xor dp[to]);
            ok++;
        }
        //Cout(moto);
        if(moto==0){
            if(ok==0)dp[moto]=0;
            else dp[moto]=cost;
        }
        else{
            if(ok==0)dp[moto]=1;
            else dp[moto]=cost+1;
        }
    }
    if(dp[0]==0)Cout("Bob");
    else Cout("Alice");
    return 0;
}

Measured memory_bytes: 45696
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

vl fact(1000);

ll Fact(ll n){
	if(fact[n]) return fact[n];
	if(!n) return fact[n]=1;
	return fact[n]=Fact(n-1)*n%mod;
}

ll Div(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

ll nPk(ll n,ll k){
	return Div(Fact(n),Fact(n-k));
}

ll f(vl a){
	ll n=a.size(),N=6*n,res=0;
	vvl dp(n+1,vl(N)),DP;
	dp[0][0]=1;
	vl S(n);
	for(int i=0;i<n;i++) S[i]=to_string(a[i]).size();
	for(int i=0;i<n;i++){
		for(int j=n;j>0;j--) for(int k=N-1;k>=S[i];k--) (dp[j][k]+=dp[j-1][k-S[i]])%=mod;
	}
	for(int i=0;i<n;i++){
		DP=dp;
		for(int j=1;j<=n;j++) for(int k=S[i];k<N;k++){
			DP[j][k]=(DP[j][k]-DP[j-1][k-S[i]]+mod)%mod;
		}
		for(int j=0;j<n;j++){
			ll ten=1,re=1;
			for(int k=1;k<n-j;k++) (re+=nPk(n-j-1,k))%=mod;
			for(int k=0;k<N;k++){
				(res+=DP[j][k]*ten%mod*a[i]%mod*re%mod*Fact(j))%=mod;
				(ten*=10)%=mod;
			}
		}
	}
	return res;
}

int n;
vl a,S;

int main(){
	cin>>n;
	a=vl(n);
	bool b=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(!a[i]) b=0;
	}
	if(b) cout<<f(a)<<endl;
	else{
		vl b;
		for(int i=0;i<n;i++) if(a[i]) b.push_back(a[i]);
		cout<<(f(a)-f(b)+mod)%mod<<endl;
	}
}

Measured memory_bytes: 6736
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

using namespace std;
using ll = long long;

bool is_connected(const vector<vector<int>>& g)
{
    vector<int> visited(g.size(), 0);

    queue<int> que;
    que.push(0);

    visited[0] = 1;

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (const auto& u : g[v]) {
            if (!visited[u]) {
                visited[u] = 1;
                que.push(u);
            }
        }
    }

    for (int i = 0; i < visited.size(); ++i) {
        if (!visited[i]) {
            return false;
        }
    }

    return true;
}

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

    vector<int> a(M);
    vector<int> b(M);
    vector<vector<int>> g(N);

    for (int i = 0; i < M; ++i) {
        int ai, bi;
        cin >> ai >> bi;
        --ai;
        --bi;

        a[i] = ai;
        b[i] = bi;

        g[ai].emplace_back(bi);
        g[bi].emplace_back(ai);
    }

    int ans = 0;

    for (int i = 0; i < M; ++i) {
        auto gg = g;

        // remove edge (a[i], b[i])
        gg[a[i]].erase(remove(begin(gg[a[i]]), end(gg[a[i]]), b[i]), end(gg[a[i]]));
        gg[b[i]].erase(remove(begin(gg[b[i]]), end(gg[b[i]]), a[i]), end(gg[b[i]]));

        if (!is_connected(gg)) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
mod = 10**9+7
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
ans_x = 0
ans_y = 0
for i,xi in enumerate(x):
  ans_x += i*xi-(n-1-i)*xi
  ans_x %= mod
for j,yi in enumerate(y):
  ans_y += j*yi-(m-1-j)*yi
  ans_y %= mod
print(ans_x*ans_y%mod)

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

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

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

  int N;
  vector<P> vec;
  cin >> N;
  int X, L;
  while(N--) {
    cin >> X >> L;
    vec.emplace_back(X+L, X-L);
  }
  sort(vec.begin(), vec.end());
  int cur = INT_MIN;
  int cnt = 0;
  for(auto& p: vec) {
    if(p.second >= cur) {
      cnt++;
      cur = p.first;
      }
  }

  cout << cnt << endl;

  return 0;
}



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

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

  if ('a' == S ||
      'i' == S ||
      'u' == S ||
      'e' == S ||
      'o' == S){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

int main()
{
  long long h;cin>>h;
  long long ans=0;
  long long count=1;
  while(h>1)
  {
    ans+=count;
    h/=2;
    count*=2;
  }
  ans+=count;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
from itertools import permutations

AB = [map(int, raw_input().split()) for _ in xrange(3)]

for p in permutations(range(3)):
    e1 = AB[p[0]]
    e2 = AB[p[1]]
    e3 = AB[p[2]]
    for p1 in permutations(e1):
        for p2 in permutations(e2):
            for p3 in permutations(e3):
                if p1[1] == p2[0] and p2[1] == p3[0] and p1[0] != p3[1]:
                    print "YES"
                    exit()

print "NO"


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

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

int main() {
  ll h, w, ans = 0;
  cin >> h >> w;
  string s[h];
  rep(i, h) cin >> s[i];
  unordered_map<char, ll> mp;
  rep(i, h) rep(j, w) mp[s[i][j]]++;

  if (h % 2 == 0 && w % 2 == 0) {
    bool ok = true;
    for (auto m : mp)
      if (m.second % 4) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
  } else if (h % 2 && w % 2) {
    map<ll, ll> c;
    for (auto m : mp) c[m.second % 4]++;
    if (c[3] || c[1] != 1 || c[2] > (h - 1) / 2 + (w - 1) / 2)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  } else {
    if (w % 2) swap(h, w);
    map<int, int> c;
    for (auto m : mp) c[m.second % 4]++;

    if (c[1] || c[3] || c[2] > w / 2)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N, W) = pairIntLong()
    val WV = Array(N) { pairIntLong() }
    val WVs = Array(4) { mutableListOf<Long>(0) }
    val baseW = WV[0].first.toLong()
    WV.forEach { wv -> WVs[wv.first - WV[0].first].add(wv.second) }
    WVs.forEach {
        it.sort()
        for (n in 0 until it.size - 1) it[n + 1] += it[n]
    }
    var ans = 0L
    for (n0 in (0 until WVs[0].size).reversed()) {
        val w0 = (baseW + 0) * n0
        for (n1 in (0 until WVs[1].size).reversed()) {
            val w1 = (baseW + 1) * n1
            for (n2 in (0 until WVs[2].size).reversed()) {
                val w2 = (baseW + 2) * n2
                for (n3 in (0 until WVs[3].size).reversed()) {
                    val w3 = (baseW + 3) * n3
                    if (w0 + w1 + w2 + w3 > W) continue
                    val v0 = WVs[0].last() - WVs[0][WVs[0].size - n0 - 1]
                    val v1 = WVs[1].last() - WVs[1][WVs[1].size - n1 - 1]
                    val v2 = WVs[2].last() - WVs[2][WVs[2].size - n2 - 1]
                    val v3 = WVs[3].last() - WVs[3][WVs[3].size - n3 - 1]
                    ans = Math.max(ans, v0 + v1 + v2 + v3)
                }
            }
        }
    }
    println(ans)
}
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 40772
#include <iostream>
#include<string>
#include<vector>
#include <algorithm>


using namespace std;

int main() {
    int n,x,i,j;
    bool flg;
    int min=0;
    int ans2=0;
    cin >> n >> x;
    vector<int> y(n);
    for(i=0;i<n;i++){
        cin >> y[i];
    }
    y.push_back(x);
sort(y.begin(),y.end());
  /*  for(j=0;j<=n;j+=1) {
    cout << y[j];
    }*/
    min=y[1] - y[0];
    if(n>1){
    for (i = 1; i < n; i++) {
        if ((y[i + 1] - y[i])<min) {
        min=y[i + 1] - y[i];
        }
    }}
        for(j=min;j>=1;j--) {
            flg=true;
            for (i = 0; i < n; i++) {
                if ((y[i + 1] - y[i]) % j != 0) {
                   // ans2=j;
                    flg=false;
                    break;
                }
            }
if(flg==true){
    ans2=j;
    break;
}
        }

        cout << ans2 << endl;
        return 0;
}

Measured memory_bytes: 1024
A,B,K = [int(i) for i in input().split()]
ans = set()
for i,j in zip(range(A,A+K),range(B-K+1,B+1)):
  ans.add(min(i,B))
  ans.add(max(A,j))
ans = sorted(ans)
for e in ans:
  print(e)

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k-1] = tolower(s[k-1]);
	pv(s)

	return(0);
}

Measured memory_bytes: 256
Sa=input()
Sb=input()
Sc=input()

ssa = list(Sa)
ssb = list(Sb)
ssc = list(Sc)

sssa = ([s for s in ssa if s !="a"])
sssb = ([s for s in ssb if s !="b"])
sssc = ([s for s in ssc if s !="c"])

i=0
j="a"

while i < 1:
    if j =="a":
        if len(sssa) == 0:
            print("A")
            exit()
        else:
            j = sssa[0]
            sssa = sssa[1:]
                
    elif j == "b":
        if len(sssb) ==0:
            print("B")
            exit()
        else:
            j = sssb[0]
            sssb = sssb[1:]
            
    else:
        if len(sssc) ==0:
            print("C")
            exit()
        else:
            j = sssc[0]
            sssc = sssc[1:]

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

using namespace std;

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

    char s = S[0];
    bool flag = true;
    for (int i = 1; i < 4; ++i) {
        if (s == S[i]) {
            cout << "Bad" << endl;
            flag = false;
            break;
        }
        s = S[i];
    }
    if (flag) {
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;
const int INF = 1e9;

int dp[101][50];
bool solve() {
    int T;
    cin >> T;
    if (T == 0) return false;
    vector<int> t(T);
    REP(i, T) cin >> t[i];
    int N;
    cin >> N;
    vector<pii> v(N);
    REP(i, N) { cin >> v[i].first >> v[i].second; }
    sort(all(v));
    REP(i, N + 1) REP(j, T + 1) dp[i][j] = INF;
    REP(k, v[0].first) dp[0][k%T] = 1;
    dp[0][(v[0].first - 1)%T] = 0;
    REP(i, N) {
        REP(j, T) {
            if (t[j] > v[i].second) continue;
            //飲む
            if (i < N - 1) {
                int dif = v[i + 1].first - v[i].first;
                if (dif == 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
                REP(k, dif) { dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + 1); }
            }
            //飲まない
            if (i < N - 1 && t[j] <= v[i].second) {
                dp[i + 1][(j + v[i + 1].first - v[i].first) % T] =
                    min(dp[i + 1][(j + v[i + 1].first - v[i].first) % T], dp[i][j]);
            }
        }
    }
    int ans = 1e9;
    REP(j, T) {
        if (t[j] <= v[N - 1].second) {
            ans = min(ans, dp[N - 1][j]);
        }
    }
    cout << ans << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}



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

int findSumOfDifits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int total = 0;
  for(int i = 0; i <= N; i++){
    int sum = findSumOfDifits(i);
    if(sum >= A && sum <= B){
      total += i;
    }
  }
  cout << total << endl;
}


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

using namespace std;

vector<string> ans;
bool ap[30];
string s;
int sum;

void dfs(int n,char c,string now){
//cout<<"dfs(int "<<n<<",char "<<c<<",string "<<now<<")"<<endl;
	if(n==s.size()){
		sum++;
		ans.push_back(now);
		return ;
	}
	if(ap[c-'a']==true || c=='a'){
		bool bac=ap[c-'a'];
		ap[c-'a']=true;
		dfs(n+1,s[n+1],now+c);
		ap[c-'a']=bac;
	}
	if(ap[c-'a'+1]==false && c!='z'){
		bool bac=ap[c-'a'+1];
		ap[c-'a'+1]=true;
		dfs(n+1,s[n+1],now+(char)(c+1));
		ap[c-'a'+1]=bac;
	}
}

int main(){
	while(1){
		while(!ans.empty())ans.pop_back();
		sum=0;
		cin>>s;
		if(s=="#")break;
		dfs(0,s[0],"");
		cout<<sum<<endl;

		if(sum<=10){
			for(int i=0;i<sum;i++){
				cout<<ans[i]<<endl;
			}
		}
		else{
			for(int i=0;i<5;i++){
				cout<<ans[i]<<endl;
			}
			for(int i=ans.size()-5;i<ans.size();i++){
				cout<<ans[i]<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2380
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll X;
ll T;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;
    cin >> X;
    cin >> T;

    ll ans = 0;
    for( ll ni = 0 ; ni <N ; ni+=X ){
        ans++;
    }
    cout << ans*T << endl;

    

}

Measured memory_bytes: 3664