akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define input_i(x) scanf("%d", &x)
#define input_lli(x) scanf("%lld", &x)
#define input_s(x) scanf("%s", x)

#define BUFSIZE 100000

int main(int argc, char const *argv[]) {
    int N, i, buf= 0, ans= 0;
    input_i(N);
    long long int H, preH= 0;
    for(i= 0; i < N; i++) {
        input_lli(H);
        if(preH >= H)
            buf++;
        else
            buf= 0;
        if(ans < buf) ans= buf;
        preH= H;
    }

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

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace ABC130_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NX = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NX[0];
            var X = NX[1];
            var L = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            var temp = 0;
            for (int i = 0; i < L.Length; i++)
            {
                temp += L[i];
                ans++;
                if (temp > X) break;
            }
            if (temp <= X)
            {
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let lcm a b = a / gcd a b * b

let () = Scanf.scanf "%d\n" @@ fun n ->
  let ts = Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun t -> t in
  Printf.printf "%d\n" @@ Array.fold_left lcm 1 ts



Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
#define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int l = v[i].f;
		int r = v[i].s;

		auto it = mp.lower_bound(l);
		int mn = inf;

		while(it!=mp.end() && it->f <= r) {
			mn = min(mn, r+1-(it->f)+(it->s));
			auto it1 = it++;
			auto it2 = mini.find(it1->s);
			if(it2->s==1) mini.erase(it2);
			else it2->s --;
			mp.erase(it1);
		}

		if(r+1<=w && mn<inf) {
			if(it!=mp.end() && it->f == r + 1) {
				if(it->s > mn) {
					if(mini[it->s]==1) mini.erase(it->s);
					else mini[it->s]--;
					mini[mn]++;
					it->s = mn;
				}
			}
			else {
				mp.insert({r+1,mn});
				mini[mn]++;
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int x;
  cin >> x;
  if (x == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

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

int main(){
  int a,b;
  cin>>a>>b;
  cout<<((a*b%2)?"Odd":"Even")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct edge {
	ll to, cost;
};
vector<edge> G[100010];
int d[100010];
void dfs(int v, int parent,ll cnt) {
	d[v] = cnt;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i].to == parent) continue;
		dfs(G[v][i].to, v, cnt + G[v][i].cost);
	}
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].push_back({ v,w });
		G[v].push_back({ u,w });
	}
	dfs(0, -1, 0);
	for (int i = 0; i < N; i++) {
		if (d[i] % 2 == 0) cout << 0 << endl;
		else cout << 1 << endl;
	}
}

Measured memory_bytes: 10624
n = STDIN.gets.to_i
matrix         = Array.new(n) { Array.new(n, false) }
found_times    = Array.new(n)
complete_times = Array.new(n)

n.times do
	vertex, degree, *adj_list = STDIN.gets.split.map(&:to_i)
	degree.times do |i|
		matrix[vertex - 1][adj_list[i] - 1] = true
	end
end

time = 0
stack = []
matrix.each_index do |i|
	next unless complete_times[i].nil?

	stack.push(i)
	found_times[i] = (time += 1)

	until stack.empty?
		v   = stack.last
		adj = matrix[v].each_index { |i| break i if matrix[v][i] && found_times[i].nil? }

		# 次の隣接する頂点がない場合は上記処理で配列が返される
		if adj.is_a?(Array)
			complete_times[v] = (time += 1)
			stack.pop
			next
		end

		if found_times[adj].nil?
			found_times[adj] = (time += 1)
			stack.push(adj)
		end
	end
end

matrix.each_index { |i| puts "#{i + 1} #{found_times[i]} #{complete_times[i]}" }

Measured memory_bytes: 6180
import numpy as np

N, K = map(int, input().split())
H = np.array(list(map(int, input().split())) + [0]*K)

dp = np.full(N+K, 10**9, dtype=np.int64)
dp[0] = 0
for i in range(1, N):
  dp[i:i+K] = np.minimum(dp[i:i+K], dp[i-1] + np.abs(H[i:i+K] - H[i-1]))
print(dp[N-1])

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

int main(void)
{
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (long long i = 0; i < N - K; i++)
    {
        if (A[K+i] > A[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4836
#include <stdio.h>
int U(int n,char a){for(int i=1; i<=n; i++){printf("%c",a);}}main(void){int sx,sy,tx,ty,x,y;scanf("%d%d%d%d",&sx,&sy,&tx,&ty);x=tx-sx;y=ty-sy;U(y,'U');U(x,'R');U(y,'D');U(x,'L');U(1,'L');U(y+1,'U');U(x+1,'R');U(1,'D');U(1,'R');U(y+1,'D');U(x+1,'L');U(1,'U');puts("");}

Measured memory_bytes: 128
# 最大公約数
def gcd(a,b):
    while b != 0:
        a,b = b, a%b
    return a

# 最小公倍数

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

n = int(input())

for i in range(n):
    t = int(input())
    if i != 0:
        ans = lcm(ans,t)
    else:
        ans = t
    #print(ans)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[200005];
vector <int> v[200005];
set <int> s;
int ans[200005];

void dfs(int x,int p) {
	auto it = s.end();
	int val,val2,ch = 0;
	if(s.empty()) s.insert(a[x]);
	else {
		it--; val = *it;
		if(a[x] > val) ch = 1,s.insert(a[x]);
		else {
			it = s.lower_bound(a[x]);
			val2 = *it;
			s.erase(it);
			s.insert(a[x]);
			ch = 2;
		}
	}
	ans[x] = s.size();
	for(int i : v[x]) {
		if(i == p) continue;
		dfs(i,x);
	}
	if(!ch) s.erase(a[x]);
	if(ch == 1) s.erase(a[x]);
	if(ch == 2) {
		s.erase(a[x]);
		s.insert(val2);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i < n;i++) {
		int x,y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,-1);
	for(int i = 1;i <= n;i++) {
		cout << ans[i] << '\n';
	}
} 

Measured memory_bytes: 30464
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr;	} cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define all(x) (x).begin(), (x).end()



int problemA()
{
	int A, B, C;
	cin >> A >> B >> C;

	cout << (A ^ B ^ C) << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	problemA();
	
	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
maze = [input() for _ in range(H)]


def bfs(sty, stx):
    visited = [[-1]*W for _ in range(H)]
    q = deque()
    visited[sty][stx] = 0
    q.append((sty, stx, 0))


    def is_ok(y, x):
        if not 0 <= y <= H - 1:
            return False
        if not 0 <= x <= W - 1:
            return False
        if visited[y][x] != -1:
            return False
        if maze[y][x] == '#':
            return False
        return True


    while q:
        y, x, lv = q.popleft()
        for i in (-1, 1):
            if is_ok(y+i, x):
                visited[y+i][x] = lv+1
                q.append((y+i, x, lv+1))
            if is_ok(y, x+i):
                visited[y][x+i] = lv + 1
                q.append((y, x+i, lv+1))

    return max(max(r) for r in visited)

res = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            res = max(res, bfs(i, j))

print(res)

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

#define int long long
signed main(){
    int n;
    cin >> n;
    int a[n];
    for(int i =0;i <n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
     int k =0;
    if(n%2 ==0){
       
        for(int i =0;i<n/2-1;i++){
            k -= 2* a[i];
        }
        k -= a[(n/2)-1];
        k += a[(n/2)];
        for(int i =(n/2)+1;i<n;i++){
            k += 2*a[i];
        }
    }else{if(a[n/2]*2>a[(n/2)+1]+a[(n/2)-1]){
         for(int i =0;i<=n/2-1;i++){
            k -= 2* a[i];
        }
        k += a[n/2]+a[(n/2)+1];
        for(int i= (n/2)+2;i<n;i++){
            k += 2*a[i];
        }
    }else{for(int i =0;i<=n/2-2;i++){
            k -= 2* a[i];
        }
        k -= a[n/2]+a[(n/2)-1];
        for(int i= (n/2)+1;i<n;i++){
            k += 2*a[i];
        }

    }
    }
    cout << k;
    return 0;
}

Measured memory_bytes: 1024
let () = Scanf.scanf "%d" @@ fun n ->
  Printf.printf "%d\n" @@
  List.length @@
  List.filter (( >= ) n) @@
  List.map (List.fold_left (fun acc -> ( + ) @@ 10 * acc) 0) @@
  List.filter (fun acc ->
    List.mem 7 acc && List.mem 5 acc && List.mem 3 acc) @@
  fst @@ Array.fold_left (fun (acc, curr) ds ->
    curr @ acc, List.concat @@ List.map (fun d ->
      List.map (fun curr -> d :: curr) curr) ds) ([[]], [[]]) @@
  Array.make 10 [7; 5; 3]



Measured memory_bytes: 9600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		List<Integer> list = new ArrayList<Integer>();
		scan.close();
		if(N == 0) {
			System.out.println(0);
		}else {
			while(N != 0) {
				if(N % - 2 == 0) {
					list.add(0);
				}else {
					list.add(1);
					N = N - 1;
				}
				N = N / -2;
			}
			for(int i = list.size() - 1; i >= 0; i--) {
				System.out.print(list.get(i));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static long mod;
	public static void main(String[] args) {
		mod = (long)(Math.pow(10, 9)+7);
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		//comb array
		int c[][] = new int [2005][2005];
		for (int tmpar[]:c) {
			for(int tmp:tmpar) {
				tmp = 0;
			}
		}
		//make pascal's triangle
		c[0][0]=1;
		for(int i=0;i<2003;i++) {
			for(int j=0;j<2003;j++) {
				long tmp =  c[i][j]%mod;
				c[i+1][j]+=tmp;
				c[i+1][j+1]+=tmp;
			}
		}	
		for(int i=1;i<=K;i++){
			long tmp1 = c[N-K+1][i];
			long tmp2 = c[K-1][i-1];
			long ans = (tmp1%mod)*(tmp2%mod);
			ans %= mod;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 52564
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,Q;
    cin >> N >> Q;
    vl A(N);
    vl SUM(N+1);
    vl SUM0(N+1);
    vl SUM1(N+1);
    rep(i,N){
        cin >> A[i];
        SUM[i+1]=SUM[i]+A[i];
        if(i%2==1){
            SUM0[i+1]=SUM0[i-1]+A[i];
        }
        else{
            if(i!=0){
            	SUM1[i+1]=SUM1[i-1]+A[i];
            }
            if(i==0){
                SUM1[1]=A[0];
            }
        }
    }
    A.pb(INF);
    rep(i,Q){
        ll X;
        cin >> X;
        ll OK=N-1,NG=lower_bound(A.begin(),A.end(),X)-A.begin()-1;
        while(abs(OK-NG)>1){
            ll mid=(OK+NG)/2;
          	//cerr << mid << endl;
            ll l=lower_bound(A.begin(),A.end(),2*X-A[mid])-A.begin(),r=upper_bound(A.begin(),A.end(),A[mid])-A.begin();
          	//cerr << N-mid << ' ' << r-l << endl;
            if(N-mid<=abs(r-l)){
                OK=mid;
            }
            else{
                NG=mid;
            }
        }
      	//cerr << OK << endl;
        ll ans=(SUM[N]-SUM[OK]);//+(SUM[OK-1]-SUM[max((ll)0,2*OK-1-N)]);
      	//cerr << ans << endl;
      	//cerr << N-2*(N-OK) << endl;
        if(N-2*(N-OK)>0){
            if((N-2*(N-OK))%2==1){
                ans+=SUM1[N-2*(N-OK)];
                //if(2*OK-2-N!=0)
                //ans-=SUM1[2*OK-3-N];
            }
            else{
                ans+=SUM0[N-2*(N-OK)];
                //if(2*OK-2-N!=0)
                //ans-=SUM1[2*OK-3-N];
            }
        }
        cout << ans << endl;
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 7164
#include <iostream>
#include <cmath>
using namespace std;
int main () {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	long long dp[n];
	dp[0] = 0;
	for (int i=1; i<n; i++) {
		dp[i] = 1e11;
		for (int j=max(0, i-k); j<i; j++) {
			dp[i] = min(dp[i], dp[j]+abs(a[i]-a[j]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
fn func(input_str: &str) -> u32 {
    let iter = input_str.chars();
    let mut candidates = Vec::new();
    let mut candidate = String::new();
    for c in iter {
        match c {
            'A' | 'T' | 'C' | 'G' => {
                candidate.push(c);
            }
            _ => {
                if candidate.len() == 0 {
                    continue;
                }
                candidates.push(candidate);
                candidate = String::new();
            }
        }
    }
    candidates.iter().map(|x| x.len() as u32).max().unwrap_or(0)
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define INF 1000000000

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a;
   	double b;
	cin >> a >> b;
	double intpart, dec;
	dec = modf(b, &intpart);

	int c = b * 100 + dec;
	ll prod = (a * c) / 100; 
	cout << prod << endl;

	return 0;
				
}


Measured memory_bytes: 3764
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int M = s.size();

    for(int i = 0; i < M; i++){
        char c = s[i];
        int val = c - 'A';
        val = (val + N) % 26;
        s[i] = ('A' + val);
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

ll PowIterative(ll a, ll b) {
    ll res = 1;
    for (; b > 0; b >>= 1, a = a * a ) {
        if (b % 2 == 1) {
            res = res * a;
        }
    }
    return res;
}

ll recursion(ll level, ll pos, ll cur) {
    if (level == 0) {
        if (pos == 1) {
            return cur + 1;
        }
        else {
            cerr << "ERROR POS" << endl;
        }
    }
    else {
        ll K = PowIterative(2, level + 1) - 3;
        ll R = PowIterative(2, level) - 1;

        if (pos == 1) {
            return cur;
        }
        else if (pos < K + 2) {
            return recursion(--level, pos - 1, cur);
        }
        else if (pos == K + 2) {
            return cur + R + 1;
        }
        else if (pos < 2 * K + 3) {
            return recursion(--level, pos - 2 - K, cur + R + 1);
        }
        else if (pos == 2 * K + 3) {
            return cur + 2 * R + 1;
        }
        else {
            cerr << "ERROR IF CLAUSE" << endl;
        }
    }

    return -1;
}
int main() {
    ll N, X; cin >> N >> X;

   
    ll ans = recursion(N, X, 0);

    cout << ans << endl;
}

Measured memory_bytes: 3640
x, y =map(int, input().split())

ans = 0
if x == 3:
    ans += 100000
if x == 2:
    ans += 200000
if x == 1:
    ans += 300000

if y == 3:
    ans += 100000
if y == 2:
    ans += 200000
if y == 1:
    ans += 300000

if x == 1 and y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 38256
takahashi, aoki, count = map(int, input().split())
if takahashi >= count:
    takahashi -= count
elif takahashi < count and aoki > count - takahashi:
    aoki -= count - takahashi
    takahashi = 0
    
else:
    takahashi, aoki = 0, 0
print(takahashi, aoki)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<bool>hito(10);
    vector<bool>huta(100);
    vector<bool>mi(1000);
    for(int i=0;i<n;i++){
        int num = (int)(s[i] - '0');
        for(int j=0;j<100;j++){
            if(huta[j])mi[j*10 + num] = true;
        }
        
        for(int j=0;j<10;j++){
            if(hito[j])huta[10*j + num] = true;
        }
        
        hito[num] = true;
    }
    int ans = 0;
    for(int i=0;i<1000;i++)if(mi[i])ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

char pou[103][103];

int h=0,w=0;

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

int ans = 0;

void dfs(int y,int x,char tmp){
  pou[y][x] = 'd';

  for(int i = 0;i < 4;i++){
    int xx = x+dx[i];
    int yy = y+dy[i];
    if(xx >= 0 && yy >= 0 && xx < w && yy < h && pou[yy][xx] == tmp){
      dfs(yy,xx,tmp);
    }
  }
}





int main(){

  while(1){

    ans = 0;

    scanf("%d %d",&h,&w);

    if(h == 0) break;

    for(int i = 0;i < h;i++){
      scanf("%s",pou[i]);
    }

    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	if(pou[i][j] != 'd'){
	  ans++;
	  dfs(i,j,pou[i][j]);
	}
      }
    }

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

  }
}


Measured memory_bytes: 1504
/*２つの整数 a, b と１つの演算子 op を読み込んで、a op b を計算するプログラムを作成して下さい。
ただし、演算子 op は、"+"(和)、"-"(差)、"*"(積)、"/"(商)、のみとし、
割り算で割り切れない場合は、小数点以下を切り捨てたものを計算結果とします*/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	int a, b,result = 0;
	char op = 0;

	while (1){
		scanf("%d %c %d", &a, &op, &b);

		switch (op) {
		case '+':
			result = (a + b);
			break;
		case '-':
			result = (a - b);
			break;
		case '*':
			result = (a * b);
			break;
		case '/':
			result = (a / b);
			break;
		case '?':
			return 0;
		default:
			break;
		}
		printf("%d\n", result);
	}
	
	return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    list<char> a;
    string s;
    int q, t, f;
    bool isReverse = false;
    char c;
    cin >> s;
    rep(i, s.size()){
        a.push_back(s[i]);
    }
    cin >> q;
    rep(i, q){
        cin >> t;
        if (t == 1){
            isReverse = !isReverse;
        }
        else{
            cin >> f >> c;
            if (f == 1){
                if(isReverse){
                    a.push_back(c);
                }
                else{
                    a.push_front(c);
                }
            }
            else{
                if(isReverse){
                    a.push_front(c);
                }
                else{
                    a.push_back(c);
                }
            }
        }
    }
    if (isReverse) reverse(all(a));
    for (auto i = a.begin(); i != a.end(); ++i){
        cout << *i;
    }
    cout << endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
    cout << 48 - m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,H;
int main(){
    cin >> N;
    vector<pair<int,pair<int,int>>> info;
    rep(i,N){
        int x,y,h;
        cin >> x >> y >> h;
        info.pb(mp(h,mp(x,y)));
    }
    sort(RALL(info));
    
    repi(Cx,0,100) repi(Cy,0,100){
        bool flag = true;
        rep(i,N){
            int x = info[i].second.first;
            int y = info[i].second.second;
            int h = info[i].first;
            
            if(!i) H = h + abs(Cx-x) + abs(Cy-y);
            else if(!h){ if(H > abs(Cx-x) + abs(Cy-y)) flag = false;}
            else if(H != h + abs(Cx-x) + abs(Cy-y)) flag = false;
        }
        if(flag){
            cout << Cx << " " << Cy << " " << info[0].first + abs(Cx-info[0].second.first) + abs(Cy-info[0].second.second) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> _P;
typedef pair<_P,int> P;
int color[100][100],tmp[100][100];
bool vst[100][100];
int dx0[]={0,1,0,-1,-1,-1},dy0[]={-1,0,1,1,0,-1};
int dx1[]={1,1,1,0,-1,0},dy1[]={-1,0,1,1,0,-1};
int m,n;
int coloring(int color[100][100],int x,int y) {
	memset(vst,0,sizeof(vst));
	queue<P> Q;
	Q.push(P(_P(x,y),0));
	vst[x][y]=true;
	int sum=0;
	while(!Q.empty()) {
		P p=Q.front();Q.pop();
		_P _p=p.first;
		if(color[_p.first][_p.second]<=p.second) continue;
		color[_p.first][_p.second]=p.second;
		sum++;
		int *dx,*dy;
		if(_p.second&1) dx=dx1,dy=dy1;
		else dx=dx0,dy=dy0;
		for(int i=0;i<6;i++) {
			int nx=_p.first+dx[i],ny=_p.second+dy[i];
			if(0>nx||nx>=m||0>ny||ny>=n)continue;
			if(vst[nx][ny])continue;
			vst[nx][ny]=true;
			Q.push(P(_P(nx,ny),p.second+1));
		}
	}
	return sum;
}
int main() {
	int s,t,x,y;
	while(scanf("%d",&m),m) {
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++)color[j][i]=1<<30;
		}
		scanf("%d",&s);
		for(int i=0;i<s;i++) {
			scanf("%d %d",&x,&y);
			coloring(color,x-1,y-1);
		}
		scanf("%d",&t);
		int ans=0;
		for(int i=0;i<t;i++) {
			scanf("%d %d",&x,&y);
			memcpy(tmp,color,sizeof(color));
			ans=max(ans,coloring(tmp,x-1,y-1));
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1136
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] coins = new int[m];

        for (int i = 0; i < m; i++) {
            coins[i] = sc.nextInt();
        }
        // dp[i]をi円支払う時の最小枚数とする.
        int[] dp = new int[60030];
        Arrays.fill(dp, Integer.MAX_VALUE);

        int current = 0;
        dp[0] = 0;
        for (int i = 0; i < 50000; i++) {
            for (int coin: coins) {
                int next = i + coin;
                dp[next] = Math.min(dp[next], dp[i] + 1);
            }
        }

        System.out.println(dp[n]);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



Measured memory_bytes: 26972
#include <stdio.h>
int main(){
    int w[30],work,tate,yoko,i,i2,memo;
    int a1,a2;
    scanf("%d",&tate);
    scanf("%d",&yoko);
    for(i=0;i<tate;i++){
        w[i]=i+1;
    }
    for(i=1;i<=yoko;i++){
        scanf("%d,%d",&a1,&a2);
        for(i2=1;i2<=tate;i2++){
            if(i2==a1){
                work=w[i2-1];
                memo=i2-1;
            }
            if(i2==a2){
                w[memo]=w[i2-1];
                w[i2-1]=work;
            }
        }
    }
    for(i=0;i<tate;i++){
        printf("%d\n",w[i]);
    }
    
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int n;
	int c;
	int i;
	int cake;
	int ans = 0;

	scanf("%d %d", &n, &c);
	for (i = 0; i < c; i++) {
		scanf("%d", &cake);
		ans += cake;
	}
	if (ans % (n + 1) != 0) {
		printf("%d\n", ans / (n + 1) + 1);
	}
	else {
		printf("%d\n", ans / (n + 1));
	}

	return 0;
}


Measured memory_bytes: 2724
// AOJ 0202
#include<algorithm>
#include<iostream>
#include<cstring>

bool isprime[1000001], dp[1000001];

void sieve()
{
	std::fill( isprime, isprime + 1000000, true );
	isprime[0] = isprime[1] = false;

	for( int i = 2; i <= 1000000; ++i )
		if( isprime[i] )
			for( int j = i * 2; j <= 1000000; j += i )
				isprime[j] = false;

	return;
}

int main()
{
	int n, x;

	sieve();

	while( std::cin >> n >> x, n | x )
	{
		memset( dp, false, sizeof( dp ) );
		dp[0] = true;

		int ans = 0;
		for( int i = 0; i != n; ++i )
		{
			int p;
			std::cin >> p;

			for( int j = p; j <= x; ++j )
			{
				if( dp[j-p] )
				{
					dp[j] = true;
					if( isprime[j] )
						ans = std::max( ans, j );
				}
			}
		}

		if( ans )
			std::cout << ans << std::endl;
		else
			std::cout << "NA" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n-sum>=0)
        cout<<n-sum<<endl;
    else
        cout<<-1<<endl;
    return 0;

}


Measured memory_bytes: 3632
S = gets.chomp

wk = (/(.)\1/ =~ S)
if wk.nil? then
  wk = (/(.).\1/ =~ S)
  if wk.nil? then
    puts [-1, -1] * ' '
  else
    puts [wk+1, wk+3] * ' '
  end
else
  puts [wk+1, wk+2] * ' '
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
vector<int> v;

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


	if(n%2!=0)
	{
		cout<<0<<endl;
		return 0;
	}

	n = n/2;

	ll pot = 5,result = 0;

	while(pot <= n)
	{
		result += n/pot;
		pot *=5;
	}

	cout<<result<<endl;


	return 0;
}


Measured memory_bytes: 3604
using System;

class ITP1_6_C
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[,,] Info = new int[4, 3, 10];

        for (int i = 0; i < n; i++)
        {
            string[] Input = Console.ReadLine().Split(' ');
            Info[int.Parse(Input[0]) - 1, int.Parse(Input[1]) - 1, int.Parse(Input[2]) - 1] += int.Parse(Input[3]);
        }

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 10; k++)
                {
                    Console.Write(" " + Info[i, j, k]);
                }
                Console.WriteLine();
            }
            if (i != 3)
                Console.WriteLine("####################");
        }
    }
}

Measured memory_bytes: 9096
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  int64_t A, B, K;
  cin >> A >> B >> K;

  if (K >= A+B) {
    cout << 0 << " " << 0 << endl;
  } else if (K >= A) {
    cout << 0 << " " << B-(K-A) << endl;
  } else { // K < A
    cout << A-K << " " << B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define LL long long
const int maxn = 5e5 + 5;
using namespace std;
int n, s, x[maxn], dire;
LL ans = 0, p[maxn];
int main(){
    scanf("%d%d", &n, &s);
    for (int i = 1; i <= n; i++) scanf("%d%lld", x + i, p + i);
    int l = 1, r = n;
    while (1){
        if (x[l] >= s){
            ans += 1ll * (x[r] - s);
            break;
        }
        if (x[r] <= s){
            ans += 1ll * (s - x[l]);
            break;
        }
        if (p[l] < p[r]){
            if (dire != 1) dire = 1, ans += 1ll * (x[r] - x[l]);
            p[r] += p[l++];
        }
        else if (p[l] >= p[r]){
            if (dire != -1) dire = -1, ans += 1ll * (x[r] - x[l]);
            p[l] += p[r--];
        }
    } printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl printf("\n")
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;

int a[N];

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int n, i, ans = 0;
	cin >> n;
	fo(i,1,n+1)
		cin >> a[i];
	if(a[1] == 1)
	{
		ans++;
		swap(a[1],a[2]);
	}
	if(a[n] == n)
	{
		ans++;
		swap(a[n],a[n-1]);
	}
	fo(i,2,n)
	{
		if(a[i] == i)
		{
			ans++;
			swap(a[i],a[i+1]);
		}
	}
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll s, w;

void solve(){
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main() {
    int N, T, c, t, ans = INT_MAX;
    cin >> N >> T;
    for (int i = 0; i < N; ++i) {
        cin >> c >> t;
        if (t <= T) ans = min(c, ans);
    }
    if (ans == INT_MAX) cout << "TLE";
    else cout << ans;
}

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];
    vector<ll> B(N);
    rep(i, N)cin >> B[i];
    ll cnt1 = 0;
    ll cnt2 = 0;
    rep(i,N){
        if(A[i] == B[i])continue;
        if(A[i] > B[i])cnt1+= A[i] - B[i];
        if(A[i] < B[i])cnt2+= (B[i] - A[i]) / 2;
    }
    cout << ((cnt1 <= cnt2) ? "Yes": "No") << endl;
}


Measured memory_bytes: 3772
unittest
{
	assert( [ "3 2" ].parse.expand.solve == 1 );
	assert( [ "3 1" ].parse.expand.solve == 0 );
	assert( [ "8 5" ].parse.expand.solve == 3 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	return ( k == 1 ) ? 0L : ( n - k );
}


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

int gcd(int a,int b){
    while(a!=b){
        if(a>b){
            if(a%b==0) return b;
            else a=a%b;
        }
        else{
            if(b%a==0) return a;
            else b=b%a;
        }
    }
    return a;
}

int main(){

    int N,X;
    cin>>N>>X;
    int D;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
        if(i==0) D=abs(S.at(0)-X);
        else D=gcd(D,abs(S.at(i)-X));
    }
    cout<<D<<endl;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n, k;
int a[100000], b[100000];

int solve(int freeBitCount) {
	int i, j;
	int ret = 0;
	
	for (i = 0; i < n; i++) {
		for (j = 29; j > freeBitCount; j--) {
			if ((a[i] >> j) % 2 == 1 && (k >> j) % 2 == 0) {
				break;
			}
		}
		if (j > freeBitCount) { continue; }
		if ((freeBitCount != 0 || k % 2 == 0) && (a[i] >> freeBitCount) % 2 != 0) { continue; }
		ret += b[i];
	}
	return ret;
}

signed main()
{
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	
	int ans = 0;
	for (i = 29; i >= 0; i--) {
		if (i == 0 || (k >> i) % 2) {
			ans = max(ans, solve(i));
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n;
  cin >> n;
  vector<long> a(3*n);
  rep(i,0,a.size()) cin >> a[i];

  vll r(n+1,0),b(n+1,0);
  priority_queue<ll,vll,greater<ll>> rq;
  priority_queue<ll> bq;
  rep(i,0,n){
    r[0]+=a[i];
    rq.push(a[i]);
    b[n]+=a[a.size()-1-i];
    bq.push(a[a.size()-1-i]);
  }
  
  rep(i,0,n){
   r[i+1]=r[i]+a[n+i];
   rq.push(a[n+i]);
    r[i+1]-=rq.top();
    rq.pop();
  }
  rep(i,0,n){
   b[n-1-i]=b[n-i]+a[2*n-1-i];
   bq.push(a[2*n-1-i]);
    b[n-1-i]-=bq.top();
    bq.pop();
  }
  ll res=-1000000000000000;
  rep(i,0,n+1) res=max(res,r[i]-b[i]);
  
  cout << res << endl;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  ll n, k;
  scanf("%lld %lld", &n, &k);

  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);
    a[i] = v;
  }

  vector<ll> csum(a.size() + 1);
  for (ll i = 1; i < a.size() + 1; i++) {
    csum[i] = csum[i - 1] + a[i - 1];
  }

  // cout << m[0] << endl;

  map<ll, ll> m;

  ll ans = 0;
  for (ll i = 0; i <= n; i++) {
    if (i >= k) {
      ll p = i - k;
      ll pdf = csum[p] - p;
      pdf = ((pdf % k) + k) % k;
      m[pdf]--;
    }

    ll df = csum[i] - i;
    df = ((df % k) + k) % k;

    ll plus = m[df];
    // cout << "df:" << df << ", plus:" << plus << endl;
    ans += plus;
    m[df] += 1;
  }

  cout << ans << endl;
}


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

int main(){
    long long int a;
    long long int b;
    long long int c;
    long long d;
    long long int ans;
    scanf("%lld %lld.%lld",&a,&b,&c);
    d = b*100+c;
    ans = a*d / 100;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1720
public class Main {
  private static void solve() {
    String s = next();
    System.out.println(s.startsWith("YAKI") ? "Yes" : "No");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

int main(){
  int a,b,sa,i=0,count=1;

  std::cin >> a;
  std::cin >> b;

  sa=b-a;
  while(count<sa){
    i=i+count;
    count++;
  }

  std::cout << i-a << '\n';
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string n = Console.ReadLine();
		var ans = new StringBuilder();
        for(int i = 0; i < 3; i++)
		{
			if (n[i] == '1') { ans.Append("9"); }
            else if (n[i] == '9') { ans.Append("1"); }
			else { ans.Append(n[i].ToString());  }
		}
		Console.WriteLine(ans);
	}
}


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

using namespace std;

int main() {
    long double N, d1, x; scanf("%Lf %Lf %Lf", &N, &d1, &x);
    long double ans = 0;
    while( true ) {
        ans += (2*d1+x*(2*N-1))/2;
        if( N == 1 ) break;
        d1 += (d1/N+2.5*x/N);
        x = (2*N+1-6/N)*x/(2*N-3);
        --N;
    }
    printf("%.11Lf\n", ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

int n,K,mod,f[305][305],g[305][305],C[305][305];
int main(){
	scanf("%d %d %d",&n,&K,&mod);
    for(int i=0;i<=n;++i) C[i][0]=1;
    for(int i=1;i<=n;++i) for(int j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    for(int i=1;i<=n+1;++i) for(int j=0;j<=K;++j) f[0][j]=1,g[0][j]=K-j+1;
    for(int i=1;i<=n;++i){
        for(int k=1;k<=i;++k) for(int v=0;v<=K;++v)
            f[i][v]=(f[i][v]+1LL*g[k-1][v+1]*f[i-k][v]%mod*C[i-1][k-1])%mod;
        for(int v=K;v;--v) g[i][v]=(g[i][v+1]+f[i][v])%mod;
    }
    printf("%d\n",f[n][0]);
	return 0;
}


Measured memory_bytes: 1280