akhauriyash/Code-Regression huggingface dataset:
X,N = map(int,input().split())
#p = [0]*N
p = list(map(int,input().split()))
ans = 0
tmp = []
tmpans = 0

for i in range(102):
    if i in p:
        continue
    else:
        if abs(X-ans)>abs(X-i):
            ans = i
            tmp.append(i)
            # if i < tmpans:
            #     ans = i
            # tmpans = ans
            # if ans == 0:
            #     ans = i
            # else:
            #     if ans > i:
            #         ans = i




print(ans)
#print(tmp)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
long long k,a,b;
int main()
{
	scanf("%lld%lld%lld",&k,&a,&b);
	if(k<=a) return printf("1\n"),0;
	if(a<=b) return printf("-1\n"),0;
	return printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1),0;
}

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

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
 int a,b,c,d;
  cin >> a >> b >> c >>d;
    cout << max(a*b,c*d);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;
 
signed main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    int count = 1;
    while (true) {
        if (count >= B) {
            cout << ans << endl;
            return 0;
        }
        count += A;
        --count;
        ++ans;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string S;
int main(){
    cin>>N>>S;
    ll ans=0;
    for(ll i=0;i<N;i++){
        unordered_map<char,ll> mp1,mp2;
        for(ll j=0;j<i;j++){
            mp1[S[j]]++;
        }
        for(ll j=i+1;j<N;j++){
            mp2[S[j]]++;
        }
        if(S[i]=='R'){
            ans+=mp1['G']*mp2['B']+mp1['B']*mp2['G'];
        }
        if(S[i]=='B'){
            ans+=mp1['R']*mp2['G']+mp1['G']*mp2['R'];
        }
        if(S[i]=='G'){
            ans+=mp1['R']*mp2['B']+mp1['B']*mp2['R'];
        }
        for(ll j=1;i+j<N && 0<=i-j;j++){
            if(S[i+j]!=S[i-j] && S[i+j]!=S[i] && S[i-j]!=S[i]){
                ans--;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3640
a = [[0, int(input())] for i in range(5)]

for i in range(5):
    a[i][0] = a[i][1] % 10
    if a[i][0] == 0:
        a[i][0] = 10
        a[i][1] -= 10

a.sort(reverse=True)

ans = 0
for i in range(4):
    if a[i][0] == 10:
        ans += a[i][1] + 10
    else:
        ans += a[i][1] + (10 - a[i][0])

ans += a[4][1]
if a[4][0] == 10:
    ans += 10

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();

		long A[][] = new long[n][m];
		long B[][] = new long[m][l];
		long C[][] = new long[n][l];

		for (int i=0; i<n; i++) {
			for (int j=0; j<m; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		for (int i=0; i<m; i++) {
			for (int j=0; j<l; j++) {
				B[i][j] = sc.nextInt();
			}
		}

		for (int i=0; i<n; i++) {
			for (int j=0; j<l; j++) {
				for (int k=0; k<m; k++) {
					C[i][j] += A[i][k] * B[k][j];
				}
			}


		}
		for (int i=0; i<n; i++) {
			for (int j=0; j<l; j++) {

				if (j ==0) {
					System.out.print(C[i][j]);
				}else {
					System.out.print(" " + C[i][j]);
				}
			}
			System.out.println();
		}

	}
}

//あとで


Measured memory_bytes: 53348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string str;
    string str2;
    ll count=0;
    cin>>str;
    cin>>str2;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]!=str2[i])
        {
            count++;
        }
    }
    cout<<count<<'\n';
    return 0;
}

Measured memory_bytes: 3920
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
	int n = s.nextInt();
	Card[] A = new Card[n];
	StringBuilder sb = new StringBuilder();

	for(int i = 0;i < n;i++) {
		A[i] = new Card();
		A[i].suit = s.next();
		A[i].n = s.nextInt();
		A[i].id = i;
	}
	quicksort(A,0,n-1);
	if(judge(A) == true) {
		sb.append("Stable\n");
		}else {
			sb.append("Not stable\n");
		}
	for(int i = 0;i < n;i++) {
		sb.append(A[i].suit + " " + A[i].n + "\n");
	}
	System.out.print(sb.toString());
	}

static int partition(Card[] a,int p,int r) {
		Card x = a[r];
		int i = p-1;

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

		return i+1;
		}

static void quicksort(Card[] A,int p,int r) {
	if(p < r) {
		int q;
		q = partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
}

static boolean judge(Card[] A){
    for(int i = 0; i < A.length; i++){
        for(int j = i + 1; j < A.length; j++){
        if(A[i].n == A[j].n && A[i].id > A[j].id)
            return false;
        }
    }
        return true;
}
}

class Card{
	String suit;
	int n;
	int id;
}


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

using namespace std;

int n , m , v[300005];

int main()
{
    cin >> n >> m;
    for(int i = 1 ; i <= m ; i ++)
        cin >> v[i];
    int sum = 0;
    for(int i = 1 ; i <= m ; i ++)
        sum += v[i];
    cout << max(-1 , n - sum);
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s, f;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s >> f;
  int ans = 0;
  REP(i, s.size()) {
    if(s[i] != f[i]) ans++;
  }


  cout << ans << endl;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,tmp;
  cin >> N;
  vector<int> num(N,0);
  for(int i=1;i<N;i++) {
	cin >> tmp;
    num.at(tmp-1)++;
  }
  for(int i=0;i<N;i++) {
    cout  << num.at(i) << endl;
  }
}

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

int main() {
  int N;
  int x = 999999999;
  cin >> N;

  for(int i=0; i<N; i++){
    int a;
    int y = 0;
    cin >> a;

    while(a % 2 == 0){
      a /= 2;
      y++;
    }

    if(x > y)
      x = y;
  }

  cout << x << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        xl: [(i64, i64); n],
    }

    let mut lr = vec![];

    for (x, l) in xl {
        lr.push((x-l, x+l));
    }

    lr.sort_by_key(|&(_l, r)| r);
    let mut last = None;

    let mut count = 0;

    for (l, r) in lr {
        if let Some((_ll, rl)) = last {
            if l < rl {
                continue;
            }
        }
        last = Some((l, r));
        count += 1;
    }

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


Measured memory_bytes: 7228
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;

//const int MAXN = (int)1e5 + 5;

long long solve(long long x) {
    if (x == 1)
        return 1;
    return 2 * solve(x / 2) + 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, k;
    cin >> n >> k;
    vector<double> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        arr[i] = (arr[i] * (arr[i] + 1) / 2) / arr[i];
//        cout << arr[i] << ' ';
        if (i > 0)
            arr[i] += arr[i - 1];

    }

    double ans = arr[k - 1];
    for (int i = k; i < n; ++i) {
        ans = max(ans, arr[i] - arr[i - k]);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4756
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#""# => r#""#,

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        a: usize,
        b: usize,
        c: usize,
    }

    if a + b + c >= 22 {
        "bust"
    } else {
        "win"
    }.to_string()
}

Measured memory_bytes: 4352
s, c = map(int, input().split())
count = s
a1 = int((c-2*s)/2)
a2 = int(a1/2)
#print(a2)
s_add = int((int((c-2*s)/2))/2)
if 2 * s <= c: 
  print(s + s_add)
else:
  print(c // 2)

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] x = new long[(int)(N)];
        long[] y = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                x[i] = sc.nextLong();
                y[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, x, y);
    }
}

class Solver {
    public void solve(long N, long[] x, long[] y) {
        StringBuilder builder = new StringBuilder();
        for (int i = 1; i <= N; i++) {
            builder.append(i);
        }

        List<String> permutations = new LinkedList<>();
        allPermutations("", builder.toString(), permutations);

        double total = 0.0;
        for (String pattern : permutations) {
            for (int i = 0; i < pattern.length() - 1; i++) {
                int from = pattern.charAt(i) - '1';
                int to = pattern.charAt(i + 1) - '1';

                double inside = Math.pow(x[from] - x[to], 2.0) + Math.pow(y[from] - y[to], 2.0);
                total += Math.sqrt(inside);
            }
        }
        System.out.println(total / kaijo(N));
    }

    private long kaijo(long n) {
        if (n == 1) return 1;
        return n * kaijo(n - 1);
    }

    private void allPermutations(String prefix, String str, List<String> ans) {
        int n = str.length();
        if (n == 1) {
            ans.add(prefix + str);
        }
        else {
            for (int i = 0; i < n; i++)
                allPermutations(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1), ans);
        }
    }
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> work[m+2];
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (m+1 < a) continue;
    work[a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  rep(i, m+1) {
    for (int b:work[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

bool solve(int X,int Y) {

	if (X <= 1 && Y <= 1)return false;
	for (int i = 1; 2 * i <= X; i++) {
		if (solve(X - 2 * i, Y + i) == false)return true;
	}	for (int i = 1; 2 * i <= Y; i++) {
		if (solve(X+i,Y-2*i) == false)return true;
	}
	return false;
}

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

	int X, Y;
	cin >> X >> Y;
	cout << ( abs(X - Y) <= 1 ? "Brown" : "Alice") << endl;

	//rep(x, 10) {
	//	rep(y, 10)cout << (solve(x, y) ? "A" : "B");
	//	cout << endl;
	//}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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 int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    ll ans = 0;
    rep(i,N){
        if(A[i] % 2 == 1 && i % 2 == 0)ans++;
    }
    cout << ans << endl;
}


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

int main(){
	unordered_set<int> s;
	int x,n;
	cin>>x>>n;
	for(int i=0;i<n;i++){
		int v;
		cin>>v;
		s.insert(v);
	}
	for(int i=0;i<=100;i++){
		if(s.find(x-i)==s.end()){
			cout<<x-i<<endl;
			break;
		}else if(s.find(x+i)==s.end()){
			cout<<x+i<<endl;
			break;
		}
	}
	
	
	return 0;
}


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

#define int long long
using namespace std;

int32_t main() {

    int n , k;
    cin >> n >> k;

    vector<int> h(n + 1, 0), dp(n, LLONG_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    for (int i = 0; i < n; i++) {
        for (int j = i ; j <= i+k ;j++) {
            if (j < n)
                dp[j] = min(dp[j], abs(h[i] - h[j]) + dp[i]);
        }
    }
    cout << dp[n - 1];
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
string s;

void solve(){
	ll size = s.size();
	ll ans = 1 + size * (size + 1) / 2;
	rep(i, 26){
		char m = 'a' + i;
		ll c = 0;
		rep(j, size){
			if(s[j] == m)
				c++;
		}
		ans -= c * (c + 1) / 2;
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>s;
		solve();
	return 0;
}


Measured memory_bytes: 720
from math import sqrt
def isPrime(number):
    divisor = 3
    if number == 2:
        return True
    if number % 2 == 0:
        return False
    while divisor <= sqrt(number):
        if number % divisor == 0:
            return False
        divisor += 2
    return True

def main():
    N = eval(input())
    count = 0
    for i in range(0, N):
        number = eval(input())
        if (isPrime(number)):
            count += 1
    print(count)

main()



Measured memory_bytes: 5644
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String answer = "No";
    for (int i = 0; i <= n; i++) {
      if (answer == "Yes") break;
      for (int j = 0; j <= n; j++) {
        int sum = i * 4 + j * 7;
        if (sum == n) {
          answer = "Yes";
          break;
        }
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 35556
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	puts(string(byte(next()[0]) + 1))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
//In the name of god
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 300;
int mat[maxn][maxn];
int main(){
	ios_base::sync_with_stdio(0) , cin.tie(0);
	int n,m,r;
	cin >> n >> m >> r;
	int u,v,c;
	vector<int> per;
	int a;
	for (int i = 0;i < r;i++){
		cin >> a;
		per.pb(a);
	}
	sort(per.begin(),per.end());
	for (int i = 0;i < m;i++){
		cin >> u >> v >> c;
		mat[u][v] = mat[v][u] = c;
	}
	for (int i = 1;i <= n;i++){
		for (int j = 1;j <= n;j++){
			if (i == j) continue;
			if (mat[i][j] == 0) mat[i][j] = 1e9;
		}
	}
	for (int k = 1;k <= n;k++){
		for (int i = 1;i <= n;i++){
			for (int j = 1;j <= n;j++){
				mat[i][j] = min(mat[i][j],mat[i][k] + mat[k][j]);
			}
		}
	}
	ll minv = 1e16;
	ll cc;
	do {
		cc = 0;
		for (int i = 1;i< r;i++){
			cc += mat[per[i - 1]][per[i]];
		}
		minv = min(minv,cc);
	}while (next_permutation(per.begin(),per.end()));
	cout << minv << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define ll long long
#define M 1000000007
using namespace std;

ll n,m;

ll kaijyo(ll from, ll till, ll r){
  ll result=r;
  for(ll i=from+1;i<= till ;i++){
    result *=i;
    result %=M;
  }

  return result;
}
int main(){

  ll result = 1;
  ll tmp;
  
  cin >> n >> m;

  if(m<n){
    tmp = n;
    n=m;
    m=tmp;
  }           //n<m
  
  if((m-n)>1){
    cout << "0" << endl;
    return 0;
  }
  if(m-n==0)result = 2;


  tmp= kaijyo(1,n,1);
  
  result *= tmp;
  result %= M;
  result *= kaijyo(n,m,tmp);
  result %= M;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<pair<int, int>> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i + 1;
	}
	sort(A.begin(), A.end());

	for (const auto &e : A) cout << e.second << " ";

	return 0;
}

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

int main(void){

    int N, K;

    scanf("%d%d", &N, &K);

    int ans = 1;

    for(int i = 0; i < N; i++){
        if(2*ans < ans + K){
            ans *= 2;
        }else{
            ans += K;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)

int main() {
    double R;
    cin >> R;
    cout << 2 * R * 3.14159265 << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int c)
{
   if(a<b)
   swap(a,b);
   int r=0,ans=0;
   while(1)
   {
    r=a%b;
    if(r==0)
    {
    	ans=b;
    	break;
	}
	else
	{
		a=b;
		b=r;
	}
   }
   if(ans>c)
   swap(ans,c);
   while(1)
   {
   r=ans%c;
   if(r==0)
   {
   return c;	
   }
   else
   {
   	ans=c;
   	c=r;
   }
   } 
}
int main()
{
	int k;
	cin>>k;
	long long sum=0;
	for(int i=1;i<=k;i++)
	for(int j=1;j<=k;j++)
	for(int k1=1;k1<=k;k1++)
	{
	   sum+=gcd(i,j,k1);
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
#define ull unsigned long long  
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
//ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	int a,b,c,d;
 	cin>>a>>b>>c>>d; 
 	while(1)
 	{
 		c-=b;
 		if(c<=0){
 			cout<<"Yes";
 			break;
		 }
		 a-=d;
		 if(a<=0){
		 	cout<<"No";
		 	break;
		 }
		 
	 }
 	
}

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

const double eps = 1e-9;
bool equal(double a, double b) { return abs(a-b) < eps;}

struct V {
  double x, y;
  V(double x=0, double y=0) : x(x), y(y) {}
  V operator+(const V& p) const { return V(x+p.x, y+p.y);}
  V operator-(const V& p) const { return V(x-p.x, y-p.y);}
  V operator*(double a) const { return V(x*a, y*a);}
  double sqrNorm() const { return x*x+y*y;}
  double norm() const { return sqrt(sqrNorm());}
  V rotate90() const { return V(y, -x);}
};

struct Circle {
  V o; double r;
  Circle(V o=V(), double r=0) : o(o), r(r) {}
  vector<V> xp(const Circle& c) {
    V v = c.o-o;
    double l = v.norm();
    if (equal(l, 0)) return {};
    if (equal(l+r+c.r, max({l,r,c.r})*2)) {
      return {o + v*(r/l)};
    }
    if (l+r+c.r < max({l,r,c.r})*2) return {};
    double x = -(c.r*c.r - l*l - r*r) / (2*l);
    double y = sqrt(r*r - x*x);
    V mid = o + v*(x/l);
    v = v.rotate90();
    return {mid + v*(y/l), mid - v*(y/l)};
  }
  bool isInside(const V& p) {
    return (p-o).norm() < r+eps;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<Circle> c(n);
  rep(i,n) {
    cin >> c[i].o.x >> c[i].o.y >> c[i].r;
  }
  double l = 0, r = 400000;
  rep(ti,100) {
    double x = (l+r)/2;
    vector<V> ps;
    rep(i,n) ps.push_back(c[i].o);
    rep(i,n)rep(j,i) {
      Circle a = c[i], b = c[j];
      a.r = x/a.r;
      b.r = x/b.r;
      auto tmp = a.xp(b);
      ps.insert(ps.end(), tmp.begin(), tmp.end());
    }
    bool ok = false;
    for (V p : ps) {
      int cnt = 0;
      rep(ci,n) {
        Circle nc = c[ci];
        nc.r = x/nc.r;
        if (nc.isInside(p)) cnt++;
      }
      if (cnt >= k) ok = true;
    }
    if (ok) r = x; else l = x;
  }
  printf("%.10f\n", r);
  return 0;
}


Measured memory_bytes: 3868
#include <iostream>
using namespace std;
int main(){
  int h,w,x,i,j,xcom,hout,wout,flag,xmin;
  while(1){
    flag=0;
    cin >> h >> w;
    if(h==0&&w==0) break;
    x=h*h+w*w;
    xmin=100000;
    for(i=1;i<151;i++){
      for(j=i+1;j<151;j++){
	xcom=i*i+j*j;
        if(x==xcom&&h<i){
          hout=i;
	  wout=j;
	  flag=1;
	  break;
	}
	if(x<xcom&&xcom<xmin){
	  hout=i;
	  wout=j;
	  xmin=xcom;
	}
      }
      if(flag==1) break;
    }
    cout << hout << ' ' << wout << endl;
  }
  return 0;
}

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


int main() {
int n;
cin >> n;
vector<string> s(n);
rep(i,n) cin >> s[i];
set<string>sums;
int ans;
rep(j,n){
        sums.insert(s[j]);
        ans = sums.size();
    }
cout<< ans << endl;    
}

Measured memory_bytes: 25112
#include <bits/stdc++.h>
using namespace std;
int N, seg[262144]; 
int INF = 2147483647; 
void init(){
	for(int i = 0; i < 262144; i++) seg[i] = INF; 
}
void update(int k, int a){
	k += 131071; 
	seg[k] = a; 
	while(k > 0){
		k = (k - 1) / 2; 
		seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]); 
	}
}
int query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return INF; 
	if(a <= l && b >= r) return seg[k]; 
	else{
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2); 
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r); 
		return min(vl, vr); 
	}
}
int main(){
	int Q; cin >> N >> Q; init(); 
	while(Q--){
		int C, X, Y; 
		cin >> C >> X >> Y; 
		if(C == 0) update(X, Y); 
		else cout << query(X, Y + 1, 0, 0, 131072) << endl; 
	}
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 2e3 + 100;
pii p[N];
int n;

bool cmp(pii a, pii b) {
    return a.first > b.first;
}

ll dp[N][N];

ll clac(int cnt, int l, int r) {
    if (l > r)return 0;
    if (~dp[l][r])return dp[l][r];
    ll ans = 1ll * p[cnt].first * abs(p[cnt].second - l) + clac(cnt + 1, l + 1, r);
    ans = max(ans, 1ll * p[cnt].first * abs(p[cnt].second - r) + clac(cnt + 1, l, r - 1));
    return dp[l][r] = ans;
}

int main() {
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        p[i] = {x, i};
    }
    sort(p + 1, p + n + 1, cmp);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", clac(1, 1, n));
    return 0;
}

Measured memory_bytes: 38408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	if(a>b)swap(a,b);
	int tmp1=a/k,tmp2=b/k;
	if(a%k)tmp1++;
	if(tmp1>tmp2)cout<<"NG";
	else cout<<"OK";
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>S;
    N = S.size();
    vec num(26,0);
    rep(i,N) ++num[S[i] - 'a'];
    ll ans = (N - 1) * N / 2 + 1;
    rep(i,26) if(num[i] > 1) ans -= num[i] * (num[i] - 1) / 2;
    cout<<ans<<endl;
}

Measured memory_bytes: 644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}

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

//func nextUint64() uint64 {
//	sc.Scan()
//	i, e := strconv.ParseUint(sc.Text(), 10, 64)
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func main() {
	n := nextInt()
	a := make([]int, n, n)

	for i := 0; i < n; i++  {
		a[i] = nextInt()
	}

	temp := 0
	ans := 0

	for i := 0; i < n; i++ {
		if temp > a[i] {
			ans += temp - a[i]
		} else {
			temp = a[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6424
n=int(input())
a=list(map(int,input().split()))
c=sum(a)
d=c/2
cnt=0
count=0
for i in range(n):
    cnt+=a[i]
    if cnt>=d:
        if abs(cnt-a[i]-d)<abs(cnt-d):
            cnt-=a[i]
            count=i
        else:
            count=i
        break
print(abs(2*cnt-c))
#print(count,cnt)
    

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

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	map<int,int> m;
	long long ans=0;
	for(int i=n;i>=1;i--){
		ans+=m[i+a[i]];
		m[i-a[i]]++;
	}
	cout<<ans<<endl;
}

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

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

  if (d == 25) cout << "Christmas" << endl;
  else if (d == 24) cout << "Christmas Eve" << endl;
  else if (d == 23) cout << "Christmas Eve Eve" << endl;
  else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  Int n;cin >> n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin >> a[i];
  sort(a.rbegin(),a.rend());
  Int ans = 0;
  for(Int i=0;i<n;i++) ans+=a[i];
  ans-=a[0]/2;
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pp pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>

using namespace std;

ll knapsack(vi& profit,vi& wt,ll maxwt){
    vvi dp(profit.size()+1,vi(maxwt+1,0));
    for(int i=1;i<=profit.size();i++){
        for(int j=1;j<=maxwt;j++){
            if(j-wt[i-1]>=0){
                dp[i][j]=max(dp[i-1][j],profit[i-1]+dp[i-1][j-wt[i-1]]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    ll ans=dp[wt.size()][0];
  	for(int i=1;i<=maxwt;i++) {
      ans=max(ans,dp[wt.size()][i]);
    }
    return ans;
}

int main(){
  ll n,W;
  cin>>n>>W;
  vector<ll> p(n);
  vector<ll> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i]>>p[i];
  }
  cout<<knapsack(p,w,W);
}


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

typedef long long int lli;
int main(int argc, char *argv[]){
  int n, m;
  cin >> n >> m;
  int dist[n], weather[m];
  for (int i = 0; i < n; i++) {
    cin >> dist[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> weather[i];
  }
  lli dp[m + 1][n + 1];
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = 1e9;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      dp[i + 1][j]     = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1],
                             dp[i][j] + dist[j]*weather[i]);
    }
  }
  lli ans = 1e9;
  for (int i = 0; i <= m; i++) {
    ans = min(ans, dp[i][n]);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 7484
#include <stdio.h>

int main() {
   long int a, b, k;
   scanf("%ld %ld %ld", &a, &b, &k);

   if (a >= k) {
      a -= k;
   }else if (a + b >= k) {
      k -= a;
      a = 0;
      b -= k;
   } else {
      a = b = 0;
   }
   printf("%ld %ld\n", a, b);
   return 0;
}


Measured memory_bytes: 1688
#include<stdio.h>

int main()
{
	int A,B,c;
	scanf("%d %d",&A,&B);
	c = A - 2 * B;
	if(A >= 1&&A <= 100&&B >= 1&&B <= 100){
		if(c > 0)
	{
		printf("%d\n",c);
    }
    else
    {
    	printf("0");
	}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define int               long long
#define M                 1000000007
#define MM                998244353
#define popf              pop_front
#define popb              pop_back
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define piii              pair<int,pii>
#define mx                -1000000007
#define f(i,a,b)           for(int i=a;i<b;i++)
#define rf(i,a,b)          for(int i=a;i>=b;i--)

	signed main() {
	
		   int t=1;
		  //cin>>t;
		   while(t--)
		   {
		   		
		   	int n,k,w,sum=0,d=0,c=0;
		             string  s,r;
		             int a1=0,b1=0,xx=0;
		             int n0=0,n1=0,n2=0;
		   cin>>s;
		   cin>>r;
		   n=s.length();
		   for(int i=0;i<n;i++)
		   	if(s[i]!=r[i]){c=1;break;}
		   if(c)cout<<"No"<<endl;
		   else cout<<"Yes"<<endl;
		         

		                         
}


	} 

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

#define N 400
#define INF 100000000

#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)

struct Edge {
  int to, cost;
};
typedef vector<Edge> Graph;

Graph g[N];
int cost[N];

int solve(int s) {
  int cmax = 0;
  if(cost[s]!=-1) return cost[s];
  for(int i=0; i<g[s].size(); ++i) {
    Edge e = g[s][i];
    cmax = max(cmax, solve(e.to)+e.cost);
  }
  return cost[s] = cmax;
}

int main() {
  int n ,m;
  cin >> n >> m;
  for(int i=0; i<m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    g[b].push_back((Edge){a, c});
  }
  fill(cost, cost+n, -1);
  cout << solve(n-1) << endl;
  
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define ll long long int
#define REP(i,n) for(ll i=1;i<=n;i++)
#define SZ(v) (ll)v.size()
#define endl "\n"
#define ff first
#define ss second
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll INF=1e29;
const ll MOD=1000000007;
const ll nxm=2e7+5;
bool c(pair<ll,ll> a,pair<ll,ll> b)
{
return a.ff<b.ff;
}
void solve()
{
ll a,b;
cin>>a>>b;
ll x=a*b;
cout<<x;
}
int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[201010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;


int main() {
	cin>>A>>B>>Q;
	vector<ll> s(A);
	vector<ll> t(B);

	rep(i,0,A){
		cin>>s[i];
	}
	rep(i,0,B){
		cin>>t[i];
	}
	rep(i,0,Q){
		ll x;
		cin>>x;
		ans=INF;
		ll num;
		ll smin;
		ll smax;
		ll tmin;
		ll tmax;
		if(x<s[0]){
			smin=-INF;
		}else{
			smin=*(upper_bound(s.begin(),s.end(),x)-1);
		}

		if(x>s[A-1]){
			smax=INF;
		}else{
			smax=*lower_bound(s.begin(),s.end(),x);
		}
		
		if(x<t[0]){
			tmin=-INF;
		}else{
			tmin=*(upper_bound(t.begin(),t.end(),x)-1);
		}

		if(x>t[B-1]){
			tmax=INF;
		}else{
			tmax=*lower_bound(t.begin(),t.end(),x);
		}

		num=max(smax,tmax);
		ans=min(num-x,ans);

		num=min(smin,tmin);
		ans=min(x-num,ans);

		num=(x-smin)*2+(tmax-x);
		ans=min(num,ans);

		num=(x-tmin)*2+(smax-x);
		ans=min(num,ans);

		num=(smax-x)*2+(x-tmin);
		ans=min(num,ans);

		num=(tmax-x)*2+(x-smin);
		ans=min(num,ans);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll a,b;
  cin>>a>>b;

  int ans=0;
  if(a<=0&&b>=0) ans=0;
  else if(a==0||b==0) ans=0;
  else if(a>0) ans=1;
  else{
    if((a%2+b%2)%2) ans=1;
    else ans=-1;
  }

  if(ans==0) cout<<"Zero"<<endl;
  else if(ans<0) cout<<"Negative"<<endl;
  else cout<<"Positive"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j,k,l;
  int n;
  cin>>n;
  int a[101][101]={};
  for(i=0;i<n;++i){
    for(j=0;j<n;++j){
      cin>>a[j+1][i+1];
      a[j+1][i+1]+=a[j][i+1]+a[j+1][i]-a[j][i];
    }
  }
  int mx=-100000000;
  for(i=1;i<=n;++i)
    for(j=1;j<=n;++j)
      for(k=0;k<n-i+1;++k)
        for(l=0;l<n-j+1;++l)
          mx=max(mx,a[i+k][j+l]-a[k][j+l]-a[i+k][l]+a[k][l]);
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define INF 100000000
using namespace std;
int main(void){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k)cout<<"Yay!";
  else cout<<":(";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/


long long powmod(long long x, long long n) {
	long long ret = 1;
	while (n > 0) {
		if (n & 1) ret = ret * x % MOD;  // n の最下位bitが1ならば(nが奇数ならば) x^(2^i) をかける
		x = x * x % MOD;
		n >>= 1;  // n を1bit 左にずらす
	}
	return ret%MOD;
}



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll N;
	cin >> N;
	if (N < 2)cout << 0 << endl;
	else {
		ll ans = powmod(10, N)%MOD - 2*powmod(9,N)%MOD+powmod(8,N)%MOD;
		if(ans>=0)cout << ans%MOD << endl;
		else cout<<(ans+MOD)%MOD<<endl;;
	}







	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
typedef struct Dice{
	int d[6];
	int r[6];
	int b[6];
}dice;
int main(void)
{
	dice num;
	int q,i,c;
	int u[24],p[24],re[24]={0};
	for(i=0;i<6;i++){
		scanf("%d",&num.d[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d",&u[i],&p[i]);
	}
	for(int k=0;k<6;k++){
		num.b[k]=num.d[k];
	}
	for(i=0;i<q;i++){
		c=0;
		for(int k=0;k<6;k++){
			num.r[k]=num.d[k];
		}
		for(int j=0;j<4;j++){
			for(int k=0;k<6;k++){
				num.r[k]=num.b[k];
			}
			num.r[2]=num.b[0];
			num.r[3]=num.b[5];
			num.r[5]=num.b[2];
			num.r[0]=num.b[3];
			for(int k=0;k<6;k++){
				num.b[k]=num.r[k];
			}
			if(num.r[0]==u[i]){
				c=1;
				break;
			}

		}
		if(c==0){
			for(int j=0;j<4;j++){
				for(int k=0;k<6;k++){
					num.r[k]=num.b[k];
				}
				num.r[1]=num.b[0];
				num.r[4]=num.b[5];
				num.r[5]=num.b[1];
				num.r[0]=num.b[4];
				for(int k=0;k<6;k++){
					num.b[k]=num.r[k];
				}
				if(num.r[0]==u[i]){
					c=1;
					break;
				}
			}
		}
		for(int j=0;j<4;j++){
			for(int k=0;k<6;k++){
				num.r[k]=num.b[k];
			}
			num.r[1]=num.b[3];
			num.r[4]=num.b[2];
			num.r[2]=num.b[1];
			num.r[3]=num.b[4];
			for(int k=0;k<6;k++){
				num.b[k]=num.r[k];
			}
			if(num.r[1]==p[i]){
				re[i]=num.r[2];
				break;
			}

		}


	}
	for(i=0;i<q;i++){
		printf("%d\n",re[i]);
	}
	return 0;
}

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

int main() {
	int N, M, T[100], P, X;
	int sum = 0;
	cin >> N;
	for (int i = 0;i < N;++i) {
		cin >> T[i];
		sum += T[i];
	}int x = sum;
	cin >> M;
	for (int i = 0;i < M;++i) {
		cin >> P >> X;
		sum += X- T[P-1];
		cout << sum << endl;
		sum = x;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            var input = int.Parse(Console.ReadLine());
            var ans = "No";
            if (input >= 30)
            {
                ans = "Yes";
            }
           
            Output(ans.ToString());
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }

    }

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

int a, b, c;

int main() {
  cin >> a >> b >> c;
  if (a == b && b == c) cout << "Yes";
  else cout << "No";
}


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

int N, M;
int path[100][100];
int cost[100][100];

void init(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            path[i][j] = 200000;
            cost[i][j] = 200000;
        }
    }
}

int main(){

    init();

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        path[a][b] = c;
        path[b][a] = c;
        cost[a][b] = c;
        cost[b][a] = c;
    }
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            if(path[i][j] == 200000)continue;
            if(path[i][j] > cost[i][j])ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

x, y = MAP()
print(gcd(x, y))



Measured memory_bytes: 5680