akhauriyash/Code-Regression huggingface dataset:
#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,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ll now,val;
		cin>>now>>val;
		a[now]+=val;
	}
	ll cnt=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        cnt+=itr->second ;
        if(cnt>=k){
        	cout << itr->first;
        	return 0;
        }
    }	
	return 0;
}

Measured memory_bytes: 4224
package main

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

func oneLineInt(s string) []int {
	temp := strings.Split(s, " ")
	// fmt.Println(len(temp))
	ints := []int{}
	for _, elem := range(temp) {
		int_elem, _ := strconv.Atoi(elem)
		ints = append(ints, int_elem)
	}
	return ints
}

func coinCount(ints []int) int {
	cons := ints[0]
	bonus := ints[1]
	target := ints[2]
	count := 0
	day := 0
	var dc int
	for day_count, _ := range(make([]int, target)) {
		day++
		if day % 7 == 0 {
			count += bonus
		}
		count += cons
		if count >= target {
			dc = day_count + 1
			break
		}
	}
	return dc
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var txt string
	if scanner.Scan() {
		txt = scanner.Text()
	}
	ints := oneLineInt(txt)
	// fmt.Println(ints[1])
	// fmt.Println(reflect.TypeOf(ints[0]))
	result := coinCount(ints)
	fmt.Println(result)
}


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

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

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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    int ans = 0;
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    vector<ll> a_r(n + 1);
    a_r[0] = 0;
    vector<ll> b_r(m + 1);
    b_r[0] = 0;
    for (int i = 1; i <= n; i++) a_r[i] += a_r[i - 1] + a[i - 1];
    for (int i = 1; i <= m; i++) b_r[i] += b_r[i - 1] + b[i - 1];

    rep(i, n + 1) {
        int num = k - a_r[i];
        if (num < 0) break;
        int ok = 0, ng = m + 1;
        while (ng - ok > 1) {
            int mid = (ng + ok) / 2;
            if (num - b_r[mid] >= 0) {
                ok = mid;
            }
            else {
                ng = mid;
            }
        }

        ans = max(ans, i + ok);
    }

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

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

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

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 7972
#include <cstdio>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int r, D; cin >> r >> D;
    int n = 11;
    vi x(n); cin >> x[0];

    rep(i, 1, n){
        x[i] = r * x[i-1] - D;
        cout << x[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
bool judge(int a)
{
	return a>0;
}
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((judge(a)!=judge(b))||a==0||b==0)
	{
		printf("Zero\n");
		return 0;
	}
	if(a>0)
	{
		printf("Positive\n");
		return 0;
	}
	if((b-a)%2)
		printf("Positive\n");
	else
		printf("Negative\n");
}

Measured memory_bytes: 128
#!/usr/bin/env python

if __name__ == '__main__':
    n = int(input())
    a1 = list(map(int, input().split()))
    a2 = list(map(int, input().split()))

    res = 0
    for i in range(n):
        res = max(res, sum(a1[:i+1]) + sum(a2[i:]))

    print(res)


Measured memory_bytes: 3060
n = int(input())

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

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
ans = float('inf')
for a in l:
    b  = n//a
    ans = min(ans, a+b-2)
print(ans)

Measured memory_bytes: 39188
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int[][] arr = new int[3][3];
      int[] a = new int[3];//𝑎1, 𝑎2, 𝑎3,
      int[] b = new int[3];//𝑏1, 𝑏2, 𝑏3
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          arr[i][j] = sc.nextInt();
        }
      }

      // 1つ分かれば（ex. 𝑎1=xと仮定すると）他のa,bもxの式で表せられる
      // それで、a1=x+?=0となるxがあるとすると、a1=と仮定して他のa,bもxの式で表せられる・・・はず
      a[0] = 0;
      for (int i = 0; i < 3; i++)
        b[i] = arr[0][i] - a[0];// 𝑏𝑖 = 𝑐1,𝑖 − 𝑎1
      for (int i = 0; i < 3; i++)
        a[i] = arr[i][0] - b[0];

      boolean isGood = true;
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (arr[i][j] != a[i] + b[j]) {
            isGood = false;
          }
        }
      }
      System.out.println(isGood ? "Yes" : "No");
    }

  }
}


Measured memory_bytes: 23508
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

int main() {
   int N;
   cin >> N;
   ll ans = 0;
   ll AB[N];
   int tmp1, tmp2;
   for (int i = 0; i < N; i++) {
      cin >> tmp1 >> tmp2;
      ans -= tmp2;
      AB[i] = tmp1 + tmp2;
   }
   sort(AB, AB + N);
   reverse(AB, AB + N);
   for (int i = 0; i < N; i++) {
      if (i % 2 != 0) continue;
      ans += AB[i];
   }
   cout << ans << endl;
   return 0;
}


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

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

    vector<vector<int>> x(n, vector<int>(d));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int length_square = 0;
            for(int k=0; k<d; k++){
                length_square += pow(x[i][k] - x[j][k], 2);
            }
            int root = sqrt(length_square);
            if(root * root == length_square) ans += 1;
        }
    }    

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

Measured memory_bytes: 256
M = 10 ** 9 + 7

n, k = map(int, input().split())

# invert
def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

def fact(a):
	n = 1
	
	for i in range(1, a + 1):
		n = (n * i) % M
	
	return n

facts = [None]
facts_i = [None]
f = 1
for i in range(1, n * 2):
	f = (f * i) % M
	facts.append(f)
	facts_i.append(calc_inverse(f, M))

def calc_count(men, room):
	if room == 1:
		return 1
	else:
		return facts[men + room - 1] * calc_inverse(facts[men], M) * calc_inverse(facts[room - 1], M) % M

def c(a, b):
	return facts[a] * facts_i[a - b] * facts_i[b] % M;

if k >= n:
	print(calc_count(n, n))
else:
	
	count = 0
	for i in range(1, k + 1):
#		print(i, ">", c(n, i), calc_count(i, n - i) % M, "=", c(n, i) * calc_count(i, n - i) % M)
		count = (count + c(n, i) * calc_count(i, n - i)) % M
	
	if k > 1:
		count += 1
	
	print(count)


Measured memory_bytes: 111964
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[17];
    a[0] = 1;
    rep(i, 17) a[i + 1] = a[i] * 2;
    int N, K;
    cin >> N >> K;
    double sum = 0;
    int ff = 0;
    int ddd = 0;
    for(int i = 1; i < N + 1; i ++){
        double sum_1 = 0;
        if(i >= K) {
            ff ++;
            ddd = i;
            break;
            sum += 1.0 / double(N);
        }
        else{

            int gg = K / i;
            int gg_1 = K % i;
            if(gg_1 == 0){
                int q = 0;
                rep(j, 18){
                    if(a[j] >= gg){
                        q = j;
                        break;
                    }
                }
                sum += 1.0 / (double (N) * a[q]);

            }
            else{
                int q = 0;
                rep(j, 18){
                    if(a[j] >= gg + 1){
                        q = j;
                        break;
                    }
                }
                sum += 1.0 / (double (N) * a[q]);



            }

        }

    }
    if(ff == 1) sum += double(N - ddd + 1) / double(N);
    cout << setprecision(10)<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N, Q;
ll c[501000];
vector<ll> v[505000];
ll idx[501000];
ll l[501000], r[501000];
vector<ll> query[501000];
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 500100;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void add(int x, int val) {
        x += (n - 1);
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr);
    }
};

ll ans[501000];

void print(SegmentTree seg) {
    for(int i = 0; i <= N; i++) {
        cerr << seg.getsum(i, i + 1) << " ";
    }
    cerr << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Q;
    for(int i = 0; i < N; i++) {
        v[i].push_back(-1);
    }
    for(int i = 0; i < N; i++) {
        cin >> c[i];
        c[i]--;
        v[c[i]].push_back(i);
    }
    for(int i = 0; i < N; i++) {
        v[i].push_back(N);
    }
    SegmentTree seg;
    for(int i = 0; i < N; i++) {
        idx[i]++;
        seg.add(v[i][idx[i]], 1);
    }
    for(int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
        query[l[i]].push_back(i);
    }
    for(int i = 0; i < N; i++) {
        seg.add(i, -1);
        if(i > 0) {
            idx[c[i-1]]++;
            seg.add(v[c[i-1]][idx[c[i-1]]], 1);
        }
        //print(seg);
        for(auto q : query[i]) {
            ans[q] = 1 + seg.getsum(i, r[q] + 1);
        }
    }
    for(int i = 0; i < Q; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 87092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long N, K, x;
  cin >> N >> K;
  x = N % K;
  if (abs(x - K) < x) {
    cout << abs(x - K) << endl;
  }
  else {
    cout << x << endl;
  }
}

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

bool triCheck(long long a, long long b, long long c){
    bool flag = true;
    if(a == b || b == c || c == a) flag = false;
    if(a + b <= c || a + c <= b || b + c <= a) flag = false;
    return flag;
}

int main(){
    int n;
    cin >> n;
    vector<long long> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);
    long long c = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(triCheck(array.at(i),array.at(j),array.at(k))) c++;
            }
        }
    }
    cout << c/6 << endl;
}

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

using namespace std;

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

struct MinimumBoundingBox {
    const ld INF = numeric_limits<ld>::max();
    const ld NINF = numeric_limits<ld>::lowest();

    int n;
    vector<ld> x, y;
    vector<char> d;

    MinimumBoundingBox(int _n) : n(_n), x(n), y(n), d(n) {}

    void input() {
        for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> d[i];
    }

    ld solve() {
        ld min_v = f(0), lb = 0, ub = 1e9;
        for (int i = 0; i < 200; ++i) {
            const ld t1 = (2.0 * lb + ub) / 3.0;
            const ld t2 = (lb + 2.0 * ub) / 3.0;

            min_v = min(min_v, f(t1));
            min_v = min(min_v, f(t2));

            if (f(t1) > f(t2)) lb = t1;
            else ub = t2;
        }
        return min_v;
    }

    ld f(const ld t) {
        pair<ld, ld> dx(INF, NINF), dy(INF, NINF);
        for (int i = 0; i < n; ++i) {
            ld vx = x[i], vy = y[i];

            if (d[i] == 'R') vx += t;
            else if (d[i] == 'L') vx -= t;
            else if (d[i] == 'U') vy += t;
            else if (d[i] == 'D') vy -= t;

            dx.first = min(dx.first, vx);
            dx.second = max(dx.second, vx);
            dy.first = min(dy.first, vy);
            dy.second = max(dy.second, vy);
        }
        return (dx.second - dx.first) * (dy.second - dy.first);
    }
};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(10) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    MinimumBoundingBox mbb(n);
    mbb.input();
    cout << mbb.solve() << endl;

    return 0;
}


Measured memory_bytes: 3456
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def solve(li, n, s, total, cnt):
    for i in li:
        value = i * n + total
        if value > s:
            break
        if n - 1:
            subli = li[:]
            subli.remove(i)
            r = range(n - 1, 0, -1)
            minimum = value + sum(i * j for i, j in zip(r, subli))
            maximum = value + sum(i * j for i, j in zip(r, subli[::-1]))
            if minimum <= s <= maximum: 
                solve(subli, n - 1, s, value, cnt)
        elif value == s:
            cnt[0] += 1
            break

cnt = [0]
for line in stdin:
    n, s = (int(s) for s in line.split())
    cnt[0] = 0

    solve(list(range(10)), n, s, 0, cnt)
    print(cnt[0])

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

int main(){
    int x, y;
    cin >> x >> y;

    int a[4] = {4, 6, 9, 11};
    int frag = 0;

    if(x == 2 || y == 2){
        cout << "No" << endl;
    }else{
        for(int i = 0; i < 4; i++){
            if(x == a[i] || y == a[i]){
                frag++;
            }
        }
        if(frag == 2){
            cout << "Yes" << endl;
        }else if(frag == 1){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

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

typedef struct _Node{
	int key;
	struct _Node *next, *prev;
}Node;

Node *nil;

Node* listSearch(int key){
	Node *cur = nil -> next;
	while(cur != nil && cur -> key != key){
		cur = cur -> next;
	}
	return cur;
}

void init(void){
	nil = (Node *)malloc(sizeof(Node));
	nil -> next = nil;
	nil -> prev = nil;
}

void printList(void){
	Node *cur = nil -> next;
	int isf = 0;
	while(1){
		if(cur == nil)break;
		if(isf++ > 0) printf(" ");
		printf("%d", cur -> key);
		cur = cur -> next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t == nil) return;
	t -> prev -> next = t -> next;
	t -> next -> prev = t -> prev;
	free(t);
}

void deleteFirst(void){
	deleteNode(nil -> next);
}

void deleteLast(void){
	deleteNode(nil -> prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x -> key = key;
	x -> next = nil -> next;
	nil -> next -> prev = x;
	nil -> next = x;
	x -> prev = nil;
}

int main(void){
	int key, n, i;
	int size = 0;
	int np = 0, nd = 0;
	char com[20];
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if(com[0] == 'i'){
			insert(key);
			np++;
			size++;
		}else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F')
				deleteFirst();
				else if(com[6] == 'L')
				deleteLast();
			}else{
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 32944
#include<bits/stdc++.h>
using namespace std;
int D[123];
vector<int>ans;
int main()
{
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&D[i]);
	for(int i=0;i<n;i++){
		int res=-1;
		for(int j=0;j<n-i;j++)
			if(j+1==D[j])res=max(j,res);
		if(res==-1)return cout<<-1<<'\n',0;
		ans.push_back(D[res]);
		for(int j=res+1;j<n-i;j++)D[j-1]=D[j];
	}for(int k=ans.size()-1;k>-1;k--)cout<<ans[k]<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

const ll mod = 1e9+7;
ll power(ll x, ll y, ll m=mod) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2ll, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

ll modInverse(ll a, ll m = mod) 
{ 
    return power(a, m-2ll, m); 
} 

/*void solve() {
    ll n, k, i, j, p, q, ans = 0;
    n = 3;
    cin>>k;
    ll a[k+1];
    Fo(i,1,k+1) {
        a[i] = power(k/i, n);
    }
    for(i=k;i>0;i--) {
        j = 2*i;
        while(j<=k) {
            a[i] = ( a[i] - a[j] + mod ) % mod;
            j += i;
        }
        ans = ( ans + a[i] * i ) % mod;
        // debug2(i,a[i]);
    }
    ans = (ans+mod)%mod;
    cout<<ans;
}*/

/*void solve() {
    ll n, i, j, k, ans = 0, r[4001], g[4001], b[4001];
    string s;
    cin>>n>>s;
    fo(i,n)r[i]=g[i]=b[i]=0;
    ans = n * ( n-1ll ) * ( n-2ll ) / 6ll;
    fo(i,n) {
        if(s[i]=='R') {
            r[i] = 1;
        }
        if(s[i]=='G') {
            g[i] = 1;
        }
        if(s[i]=='B') {
            b[i] = 1;
        }
        if(i>0) {
            r[i] += r[i-1];
            g[i] += g[i-1];
            b[i] += b[i-1];
        }
    }
    fo(i,n) {
        Fo(k,i+2,n) {
            if(s[i]==s[k]) {
                ans -= (k-i-1);
            } else {
                if(s[i]=='R')ans -= r[k-1] - r[i];
                if(s[i]=='G')ans -= g[k-1] - g[i];
                if(s[i]=='B')ans -= b[k-1] - b[i];
                if(s[k]=='R')ans -= r[k-1] - r[i];
                if(s[k]=='G')ans -= g[k-1] - g[i];
                if(s[k]=='B')ans -= b[k-1] - b[i];
            }
            if((k+i)%2==0) {
                j = (k+i)/2;
                if(s[i]!=s[j] and s[k]!=s[j] and s[i]!=s[k])ans--;
            }
        }
    }
    cout<<ans<<endl;
}*/

/*void solve() {
    ll n, i, j, k, a[200001], e = 0, o = 0, ans = -1e16;
    cin>>n;
    fo(i,n) {
        cin>>a[i];
        if(i%2==0)e+=a[i];
        else o+=a[i];
    }
    ll arr[200001];
    arr[0] = a[0];
    Fo(i,1,n) {
        arr[i] = a[i];
        if(i>=2 and i%2!=0)arr[i] = a[i] + arr[i-2];
        if(i>=3)arr[i] = max(arr[i], a[i]+arr[i-3]);
        debug2(i,arr[i]);
    }

    ans = *max_element(arr,arr+n);
    cout<<ans;
}*/

void solve() {
    ll n;cin>>n;string ans = "No";
    while(n>0) {
        if(n%10==7)ans="Yes";
        n/=10;
    }
    cout<<ans;
}

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3616
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main() {
    int Q;
    vector<int>a(1000004,0);
    cin >> Q;

    for(int i=1; i<1000004; i+=2){
        if(IsPrime(i) && IsPrime((i+1)/2))
            a[i]++;
    }

    for(int i=0; i<1000003; i++){
        a[i+1]=a[i+1]+a[i];
    }

    int l,r;
    for(int i=0; i<Q; i++){
        cin >> l >> r;
        cout << a[r]-a[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 4480
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;
/*Question
/n ????????????????????????????????§????????°???????????°???????¨?????????£??????????????????????????????s1, s2 ... sn??¨????????¨??????????¨??????????????±???????????????°????????????????????????
/?????????????????????m??¨????????°????????£?±2?????\???????????§????????????:
/?±2 = (???ni=1(si - m)2)/n
/?????£?????£????????????????¨???????????±??¨?????????
*/
/*Input
/?????°??????????????????????????\?????¨????????????????????????
/??????????????????????????\????????¢?????§???????????????:
/???????????° n s1 s2 ... sn
/n ??? 0 ?????¨?????\?????????????????¨?????????
*/

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		//????????¨
		StringBuffer b = new StringBuffer();
		//????¨??????\??????double t??????????????\??????double m????????£?????\??????double o????¨???????????????\??????double p
		double t = 0;
		double m,p;
		double o = 0;
		while (true){
			/*??\?????¨
			/?????????????????°?????£??\
			*/
			int n = Integer.parseInt(sc.readLine());
			if(n==0)
				break;
			String[] st = sc.readLine().split(" ");
			int[] z = new int[st.length];
			for(int i = 0;i < st.length;i++){
				z[i] = Integer.parseInt(st[i]);
			}
			//????¨?????¨????
			for(int i:z)
				t += i;
			//??????????¨????
			m = t/n;
			//?????£????¨????
			for(int i:z)
				o += Math.pow(i - m,2);
			o /= n;
			//?¨??????????????¨????
			p = Math.sqrt(o);
			b.append(String.format("%.8f",p)+"\n");
			//t:????¨????o:?????£???????????¢????????????????????¨??£?????????????????????
			t = 0;
			o = 0;
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 25016
//
// Created on 2018-12-08.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<(n);++i)
#define RFOR(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define PB push_back
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vs> vvs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n;
    cin >> n;

    vector<int> v;
    int t;
    REP(_, n){cin >> t; v.PB(t);}

    int ans = accumulate(v.begin(), v.end(), 0);
    ans -= *max_element(v.begin(), v.end())/2;

    cout << ans << endl;

    return 0;

}

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

using namespace std;

int main()
{
    char s[10];
    scanf("%s", s);
    sort(s, s + 4);
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=1145141919,m=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A')n=min(n,i);
		if(s[i]=='Z')m=max(m,i);
	}
	cout<<max(0,m-n+1)<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>

#define INT_MAX 2147483647

using namespace std;

int main(){
    int x;
    for(int i = 1; i < INT_MAX; i++){
        cin>>x;
        if(x!=0){
            cout<<"Case "<<i<<": "<<x<<endl;
        }
        else{
            break;
        }
    }
        
      
   
    
}


Measured memory_bytes: 3064
# input process
N = int(input())
inputData = input().split()
D = [int(x) for x in inputData]
D.sort()
if D[int((N/2 - 1))] == D[int((N/2))]:
    print("0")
    exit()
print(D[int((N/2))] - D[int((N/2 - 1))])

Measured memory_bytes: 14428
#!/usr/bin/env python3
#ABC114 C

import itertools
import bisect

n = int(input())
l = len(str(n))
ans = []
for i in range(3,l+1):
    for x in itertools.product("357",repeat = i):
        s = ''
        if x.count('7')*x.count('5')*x.count('3') == 0:
            continue
        for j in x:
            s += j
        ans.append(int(s))
ans.sort()
print(bisect.bisect_right(ans,n))


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int res = 0;
    while(true){
        if(*max_element(h.begin(),h.end()) == 0) break;
        int i = 0;
        while(i < n){
            if(h[i] == 0)i++;
            else{
                res++;
                while(i < n && h[i] > 0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout << res << endl;
}

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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	string s, t;
	cin >> s >> t;

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] < t[j])
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	set<char> s_set, t_set;
	for (int i = 0; i < s.size(); i++) {
		s_set.insert(s[i]);
	}
	for (int i = 0; i < t.size(); i++) {
		t_set.insert(t[i]);
	}

	if ((s_set.size() == t_set.size()) && s.size() < t.size())
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

MAX = 4000
fact = [0] * MAX
invfact = [0] * MAX
fact[0] = 1
for i in range(1, MAX):
    fact[i] = fact[i - 1] * i % MOD
invfact[MAX - 1] = pow(fact[MAX - 1], MOD-2, MOD)
for i in range(MAX - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % MOD

def nCk(n, k):
    if k < 0 or n < k: return 0
    return (fact[n] * invfact[k] % MOD) * invfact[n-k] % MOD

ans = 0
red = N - K
for i in range(1,1+K):
    ans = nCk(red+1, i) * nCk(K-1, i-1)
    ans %= MOD
    print(ans)



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

const int max_N = 2e3 + 21;

const int mod = 1e9 + 7;

int n,k,f[max_N][max_N];

int fac[max_N*max_N],_fac[max_N*max_N],inv[max_N*max_N];

inline void init(int n){
	inv[1]=1;
	for(int i=2;i<=n;++i){
		inv[i]=1ll*(mod/i)*inv[mod%i]%mod;
		if(inv[i])inv[i]=mod-inv[i];
	}
	fac[0]=_fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1ll*fac[i-1]*i%mod;
		_fac[i]=1ll*_fac[i-1]*inv[i]%mod;
	}
}

inline int C(int n,int m){
	return 1ll*fac[n]*_fac[m]%mod*_fac[n-m]%mod;
}

int calc(int i,int j){
	if(~f[i][j])return f[i][j];
	int&res=f[i][j];
	res=0;
	if(i)res=calc(i-1,j);
	if(j>i)
		res=(res+1ll*C(i+j*(k-1)-1,k-2)*calc(i,j-1))%mod;
	return res;
}

int main(){
	scanf("%d%d",&n,&k);
	if(k==1)return puts("1"),0;
	init(n*k);
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)
			f[i][j]=-1;
	f[0][0]=1;
	int ans=1ll*calc(n,n)*fac[n]%mod;
	printf("%d\n",ans);
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k, l[50];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> l[i]; }
	
	sort(l, l + n, greater<int>());
	int s = 0;
	inc(i, k) { s += l[i]; }
	
	cout << s << endl;
	
	return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

bool check(const vll& a, const vll& f, ll x, ll k) {
    ll sum = 0;
    rep(i, 0, a.size()) {
        if (a[i] * f[i] <= x) { continue; }

        sum += a[i] - x / f[i];
        if (sum > k) { return false; }
    }
    return true;
}

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

    ll n, k;
    cin >> n >> k;

    ll sum_a = 0;
    vll a(n), f(n);
    rep(i, 0, n) {
        cin >> a[i];
        sum_a += a[i];
    }
    rep(i, 0, n) { cin >> f[i]; }

    if (sum_a <= k) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(a));
    sort(all(f), greater<ll>());

    ll max_ans = 0;
    rep(i, 0, n) { max_ans = max(max_ans, a[i] * f[i]); }

    // O(log(max_ans) * n)
    ll ng = 0, ok = max_ans;
    while (ng + 1 != ok) {
        ll mid = (ng + ok) / 2;
        if (check(a, f, mid, k)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
int main()
{
    ll x,y,a,W,H,N,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
      cin>>W>>H>>N;
      ll Xmax=0, Xmin=W;
      ll Ymax=0, Ymin=H;
     while(N--)
    {
      cin>>x>>y>>a;
      if(a==1)
      {
          Xmax=max(Xmax,x);
      }
      else if(a==2)
      {
          Xmin=min(Xmin,x);
      }
      else if(a==3)
      {
          Ymax=max(Ymax,y);
      }
      else if(a==4)
      {
          Ymin=min(Ymin,y);
      }
    }
    p=W-(Xmax+(W-Xmin));
    q=H-(Ymax+(H-Ymin));
      if(p>0 && q>0) cout<<p*q<<endl;
      else cout<<0<<endl;
}





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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
//---------------------------------------------------------------
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int main(){
  ll N,X,ans,D;
  cin>>N>>X;
  vecll x(N);
  rep(i,N){
    cin>>x.at(i);
    x.at(i)=abs(x.at(i)-X);
  }
  D = x.at(0);
  REP(i,1,N){
    D=gcd(D,x.at(i));
  }

  cout<<D<<endl;

}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    cout << min(N%K, K-N%K) << endl;
    return 0;
}

Measured memory_bytes: 256
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;

int main(){
	int f, s, n;
	vector<int> a;
	int i, ho;
	cin >> n;
	rep(i, n){
		cin >> ho;
		a.pback(ho);
	}
	vector<int> b = a;
	sort(b.begin(), b.end());
	f = b[n-1];
	s = b[n-2];
	rep(i, n){
		if(a[i] == f) cout << s << endl;
		else cout << f << endl;
	}
}


Measured memory_bytes: 4940
<?php
// https://atcoder.jp/contests/abc045/tasks/abc045_b

// fgets(STDIN)で標準入力,trimで改行を削除
$A = str_split(trim(fgets(STDIN)));
$B = str_split(trim(fgets(STDIN)));
$C = str_split(trim(fgets(STDIN)));

$next = "a";
$ans = "A";

while ($next){
  switch($next){
    case "a":
      $next = array_shift($A);
      $ans = "A";
      break;
    case "b":
      $next = array_shift($B);
      $ans = "B";
      break;
    case "c":
      $next = array_shift($C);
      $ans = "C";
      break;
  }
}

echo $ans."\n";

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

int main()
{
    int a, flag=0;
    cin >> a;
    
    for (int i=1; i<=9; i++) {
        if (a%i==0 && a/i > 0 && a/i < 10) {
            flag = 1;
            break;
        }
    }
    
    if (flag == 0) cout << "No";
    else cout << "Yes";
    
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    string S; cin >> S;
    
    vector<ll> white(N+1);
    vector<ll> black(N+1);
    for(int i = 0;i < N;i++){
        black[i+1] = black[i] + (S[i]=='#');
    }
    for(int i = N-1; i >= 0; i--){
        white[i] = white[i+1] + (S[i]=='.');
    }
    
    res = INF;
    for(int i = 0; i <= N;i++){
        // [0,i)までを白
        // [i,N-1]までを黒にする
        
        res = min(res,black[i]+white[i]);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(){
 
  string S;
  cin >> S;
  
  int count = 0;
  int max = 0;
  for(int i = 0; i < 3; i++){
    if (S[i] == 'R'){ 
      count++;
      if(max < count) max = count;
    }
    else count = 0;
  }
  cout << max << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    //fsscan();
    int n,d,x;
    cin>>n;
    cin>>d>>x;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        
    }
    for(int i=0;i<n;i++)
    {
        sum+=((d-1)/a[i])+1;
    }
    cout<<sum+x;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
#include <bitset>

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

using namespace std;

typedef bitset<100> B;

int n;
vector<int> g[100];
int a;

void dfs(int k, B s){
	bool b = true;
	for(auto& v: g[k]){
		if(!s[v]){
			B t = s;
			t[v] = 1;
			dfs(v, t);
			b = false;
		}
	}
	if(b){
		a = max((int)s.count(), a);
	}
}

int main(){
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}

		rep(i, n){
			int a, b;
			scanf("%d%d", &a, &b);
			g[--a].push_back(--b);
			g[b].push_back(a);
		}

		rep(i, 100){
			B s;
			s[i] = 1;
			dfs(i, s);
		}
		printf("%d\n", a);

		rep(i, 100){
			g[i].clear();
		}
		a = 0;
	}
	return 0;
}

Measured memory_bytes: 2572
import numpy as np
N = int(input())
vs = np.zeros(N)
for i in range(N):
    x,u = input().split()
    if u == "BTC":
        vs[i] = float(x)*380000.0
    elif u == "JPY":
        vs[i] = int(x)
sum_v = vs.sum()
print(sum_v)

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

int main() {
  int a,b,c,x,y;
  cin >> a>>b>>c>>x>>y;
  int minimum=1000000000;
  for(int i=0;i<=max(x,y);i++){
    int sum=0;
    sum += 2*i*c;
    sum+=max(0,(x-i)*a)+max(0,(y-i)*b);
    minimum =min(minimum,sum);
  }
cout<<minimum<<endl;
}


Measured memory_bytes: 256