akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define imax INT_MAX
#define imin INT_MIN
#define f(i,a,b) for(long long i=a;i<b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define tc long long t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map

ll vis[200025]={0};
set<ll> v[200025];
ll cnt=0;
void dfs(ll x){
    if(vis[x]==1) return;

    vis[x]=1;
    cnt++;
    for(auto p:v[x]){
        if(vis[p]==0) dfs(p);
    }
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ll n,m;

    cin>>n>>m;

    f(i,0,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        v[a].insert(b);
        v[b].insert(a);
    }

    ll ans=0;
    f(i,0,n){
        cnt=0;
        if(vis[i]==0){
            dfs(i);
        }
        ans=max(ans,cnt);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 39472
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	int n;
	ll ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if(i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}

	cout << ans << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3596
#include<stdio.h>
#define N 100
void swap(int *, int *);

int main(){
  int n, flag=0, i, j;
  int A[N];
  int key;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  for(i=0; i<n; i++){
    for(j=n-1; j>=i+1; j--){
      if(A[j] < A[j-1]){
      swap(&A[j],&A[j-1]);
      flag++;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }

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

  return 0;
}

void swap(int *a,int *b)
{
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, ans;
    cin >> N;
    vector<l_l> arms(N, {0,0});

    rep(i, N){
        ll X, L;
        cin >> X >> L;
        arms[i] = make_pair(X + L, X - L);
    }
    sort(arms.begin(), arms.end());

    ll lastEdge = arms[0].first;
    ans = 1;
    for(int i = 1; i < N; i++){
        if(arms[i].second >= lastEdge){
            lastEdge = arms[i].first;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int A, B, C, X;
int temp1;
int cnt = 0;

int main()
{
	scanf("%d %d %d %d", &A, &B, &C, &X);
	for(int i = 0; i <= A; i++)
	{
		for(int j = 0; j <= B; j++)
		{
			for(int k = 0; k <= C; k++)
			{
				if(500 * i + 100 * j + 50 * k == X)
				{
					cnt++;
				}
			}
		}
	}
	printf("%d\n", cnt);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
[<AutoOpen>]
module DivRem =
    type DivRem = DivRem with
        static member (/%) (x : int32,  DivRem) = fun y -> System.Math.DivRem(x, y)
        static member (/%) (x : int64,  DivRem) = fun y -> System.Math.DivRem(x, y)

    let inline (/%) x y = (x /% DivRem) y

let n = stdin.ReadLine() |> int
let array = stdin.ReadLine().Split(' ') |> Array.map int
let rec divCnt ar cnt =
    let divRems = ar |> Array.map (fun a -> a /% 2)
    if divRems |> Array.exists (fun t -> t |> snd = 1) then
        cnt
    else
        divCnt (divRems |> Array.map (fun t -> t |> fst)) (cnt + 1)
divCnt array 0 |> printfn "%d"


Measured memory_bytes: 11996
gets
t = ARGF.map(&:to_i)
max2 = max = 0
t.each do |d|
  if(d > max)
    max2 = max
    max = d
    next
  end
  if(d > max2)
    max2 = d
  end
end
t.each do |d|
  if(d!=max)
    print "#{max}\n"
  else
    print "#{max2}\n"
  end
end

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);

string s;

void read()
{
	cin >> s;
}

void solve()
{
	set<char> st;
	for(char c: s)
		st.insert(c);

	char answer = 'a';
	while(st.find(answer) != st.end())
		answer++;

	if(answer > 'z') cout << "None" << endl;
	else cout << answer << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<map>
using namespace std;
int a[10000];
int main(void) {
	int m,n;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	int all = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int key;
		cin >> key;
		for (int j = 0; j < m; j++) {
			if (a[j] == key) {
				all++;
				break;
			}
		}
	}
	cout << all << endl;
}


Measured memory_bytes: 3096
n = int(raw_input())
G = [[0 for i in range(n+1)] for j in range(n+1)]
d = [-1 for i in range(n+1)]

for i in range(n):
    v = map(int, raw_input().split())
    for j in range(v[1]):
        G[v[0]][v[2+j]] = 1

flag = [0 for i in range(n+1)]
tn = [[0 for i in range(n+1)] for j in range(n+1)]
tn[0][1] = 1
r = 0
for i in range(n):
    for j in range(1, n+1):
        if flag[j] == 0 and tn[i][j] == 1:
            flag[j] = 1
            d[j] = r
            for k in range(1, n+1):
                if G[j][k] == 1:
                    tn[i+1][k] = 1
    r += 1

for i in range(1, n+1):
    print(str(i) + " " + str(d[i]))

Measured memory_bytes: 6540
#include <stdio.h>
int main(){

  int n,q,S[10000],T[10000],i,j,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&S[i]);

  }
   scanf("%d",&q);

  for(i=0;i<q;i++){

    scanf("%d",&T[i]);
    j=0;
    while(1){
      if(S[j]==T[i]){
	count++;
	break;
      }
      j++;
      if(j==n)break; 
    
  }
  }

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

  return 0;
}

  
  



Measured memory_bytes: 2044
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1LL << 62;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<long long> s(n + 1);
	s[0] = 0;
	for (int i = 0; i < n; ++i) {
		s[i + 1] = s[i] + a[i];
	}
	long long ret = inf;
	for (int i = 2; i <= n - 2; ++i) {
		int lh = lower_bound(s.begin(), s.begin() + i, (s[i] + 1) / 2) - s.begin();
		int rh = lower_bound(s.begin() + i, s.end(), (s[i] + s[n] + 1) / 2) - s.begin();
		long long lt = inf, rt = -inf;
		if (s[lh] * 2 - s[i] < s[i] - s[lh - 1] * 2) {
			lt = min(lt, s[i] - s[lh]);
			rt = max(rt, s[lh]);
		}
		else {
			lt = min(lt, s[lh - 1]);
			rt = max(rt, s[i] - s[lh - 1]);
		}
		if (s[rh] * 2 - s[i] - s[n] < s[i] + s[n] - s[rh - 1] * 2) {
			lt = min(lt, s[n] - s[rh]);
			rt = max(rt, s[rh] - s[i]);
		}
		else {
			lt = min(lt, s[rh - 1] - s[i]);
			rt = max(rt, s[n] - s[rh - 1]);
		}
		ret = min(ret, rt - lt);
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C){
        cout << "Yes" << endl; 
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import itertools
import math

N = int(input())
input_list = [input() for i in range(N)]
count = 0
sum_length = 0

for points in itertools.permutations(input_list, N):
    length = 0
    for i in range(N-1):
        x, y = map(int, points[i].split())
        next_x, next_y = map(int, points[i + 1].split())
        length += math.sqrt((next_x - x) ** 2 + (next_y - y) ** 2)
    sum_length += length
    count += 1

print(sum_length/count)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numberOfBook = sc.nextInt();

		int output = numberOfBook % 10;

		switch (output) {
			case 0:
				System.out.println("pon");
				break;
			case 1:
				System.out.println("pon");
				break;
			case 2:
				System.out.println("hon");
				break;
			case 3:
				System.out.println("bon");
				break;
			case 4:
				System.out.println("hon");
				break;
			case 5:
				System.out.println("hon");
				break;
			case 6:
				System.out.println("pon");
				break;
			case 7:
				System.out.println("hon");
				break;
			case 8:
				System.out.println("pon");
				break;
			case 9:
				System.out.println("hon");
				break;

		}

	}
}

Measured memory_bytes: 35832
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N = int(input())
ans= 0

print(N**3)


Measured memory_bytes: 68692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
using namespace std;
const int dy[]={-1,-1,0,0,1,1};
const int dx[]={-1,0,-1,1,0,1};
int main(){

	int n,t;
	const int base=100;
	const int MAX_P=201;
	while(cin>>t>>n&&!(t==0&&n==0)){
		bool passed[MAX_P][MAX_P];
		bool isArrival[2][MAX_P][MAX_P];
		bool obj[MAX_P][MAX_P];
		memset(isArrival,0,sizeof(isArrival));
		memset(obj,0,sizeof(obj));
		memset(passed,0,sizeof(passed));
		for(int i = 0; i < n; i++){
			int x,y;
			cin>>x>>y;
			obj[y+base][x+base]=true;
		}
		int sy,sx;
		cin>>sx>>sy;
		isArrival[0][sy+base][sx+base]=true;
		passed[sy+base][sx+base]=true;
		int cnt=1;
		for(int l = 0; l < t; l++){
			for(int i = 0; i < MAX_P; i++){
				for(int j = 0; j < MAX_P; j++){
					if(isArrival[l%2][i][j]){
						for(int k = 0; k < 6; k++){
							int ny=i+dy[k];
							int nx=j+dx[k];
							if(!obj[ny][nx]){
								isArrival[(l+1)%2][ny][nx]=true;
								if(!passed[ny][nx]){
									cnt++;
									passed[ny][nx]=true;
								}
							}
						}
						isArrival[l%2][i][j]=false;
					}
				}
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
  
int main(){
    int W,H,x,y,r;
    cin >> W >>H >>x >>y >>r;

    if (x<=(W-r) && r<=x && r<=y && y<=(H-r)){
        cout<<"Yes"<<endl;
        return 0;
    }
    else {
          cout<<"No"<<endl;
        return 0;
}

} 


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
int main() {
	int n;
	double v[1000];
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		std::cin >> v[i];
	}

	bool flag = true;
	for (int i = 0; flag == true; ++i) {
		flag = false;
		for (int j = n - 1; j >= i + 1; --j) {
			if (v[j] < v[j - 1]) {
				std::swap(v[j], v[j - 1]);
				flag = true;
			}
		}
	}
	
	double tmp = v[0];
	for (int i = 1; i < n; ++i) {
		tmp = (tmp + v[i]) / 2;
	}
	std::cout << tmp << std::endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    dp = [-1]*N
    dp[0] = 0
    for i in range(1,N):
        res = -1
        for j in range(1, K+1):
            if i - j < 0:
                break
            new = dp[i-j] + abs(A[i] - A[i-j])
            if res == -1:
                res = new
                continue
            res = min(res, new)
        dp[i] = res
    print(dp[N-1])
main()

Measured memory_bytes: 52448
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    cin >> n;
    int n2 = n;
    int d = 0;
    while(n2 > 0) {
        d += n2 % 10;
        n2 /= 10;
    }
    if (n % d == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}




Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		long r=0;
		int[] b=new int[n];
		Arrays.fill(b,100000);
		for(int i=1;i<n;++i){
			int a=s.nextInt();
			b[i-1]=Math.min(b[i-1],a);
			b[i]=Math.min(b[i],a);
		}
		System.out.println(Arrays.stream(b).sum());
	}
}


Measured memory_bytes: 26836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  cin >> n ;
 VI t(n);
  VI x(n);
  VI y(n);
  rep(i,n){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  bool test=true;
  rep(i,n){
	if(i==0){
      int a,b;
      a=abs(x.at(i)-0);
      b=abs(y.at(i)-0);
      if(t.at(i)>=a+b && (t.at(i)-a-b)%2==0);
      else {
		test=false;
        break;
      }
    }
    else{
	int a,b,c;
      a=abs(x.at(i)-x.at(i-1));
      b=abs(y.at(i)-y.at(i-1));
      c=t.at(i)-t.at(i-1);
      if(c>=a+b && (c-a-b)%2==0);
      else{
        test=false;
        break;
      }
    }
  }
  if(test) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a,b[7];
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<7;i++)
		b[i]=0;
	for(int i=0;i<n;i++){
		cin>>a;
		for(int j=0;j<6;j++){
			if(a>=j*10&&a<j*10+10)
				b[j]++;
		}
		if(a>=60)
			b[6]++;
	}
	for(int i=0;i<7;i++)
		cout<<b[i]<<endl;
	}
    return 0;
}

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


int main(){
    string str;
    cin >> str;
    while(str[0]!='0'){
        int ans=0;
        for(int i=0; i<str.size(); i++){
            ans+=str[i]-'0';

        }
        cout << ans << endl;
        cin >> str;
    }

}


Measured memory_bytes: 3164
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
const ll mod = 1000;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n) { ll s = 1;while (n) { if (n & 1) { s = s * a % mod; }a = (a*a) % mod;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(long long x) { if (x <= 1)return false;if (x == 2)return true;if (x % 2 == 0)return false;long long i, m;m = sqrt(x);f(i, 2, m) { if (x % i == 0)return false; }return true; }

const int N = 2e5 + 5;

int t;

int main()
{

	//cin >> t;
	int n, dr;
	while (cin >> n >> dr)
	{
		if (n >= 10)
			cout << dr << endl;
		else cout << dr + 100 * (10 - n) << endl;
	}
	return 0;
}

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

long long calc(int h, int w) {
    long long res = 1e18;
    for (long long i = 1; i < h; ++i) {
        long long h1 = (h - i) / 2, h2 = h1 + (h - i) % 2;
        res = min(res, max(h1, max(h2, i)) * w - min(h1, min(h2, i)) * w);
        long long w1 = w / 2, w2 = w1 + w % 2;
        res = min(res, max(i * w, max(w1 * (h - i), w2 * (h - i))) - min(i * w, min(w1 * (h - i), w2 * (h - i))));
    }
    return res;
}

int main() {
  //  freopen("input.in", "r", stdin);
//    freopen("output.out", "w", stdout);

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

    //calc(w, h);
    printf("%lld\n", min(calc(h, w), calc(w, h)));

    return 0;
}


Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int dp[300][301];

int main() {
    while (true) {
        int n, *w;
        cin >> n;
        if (n == 0) return 0;
        w = new int[n];
        for (int i = 0; i < n; i++) {
            cin >> w[i];
        }
        for (auto &e:dp)for (auto &f:e)f = 0;
        for (int i = 2; i <= n; i++) {
            for (int j = 0; j + i <= n; j++) {
                if (dp[j + 1][j + i - 1] == i - 2 && abs(w[j] - w[j + i - 1]) < 2) {
                    dp[j][j + i] = dp[j + 1][j + i - 1] + 2;
                }
                for(int k = 0;k <= i;k++) {
                    dp[j][j+i] = max(dp[j][j+i],dp[j][j+k]+dp[j+k][j+i]);
                }
            }
        }
        cout << dp[0][n] << endl;
    }

}



Measured memory_bytes: 3484
/*    BAJUKA     */
#include<bits/stdc++.h>
#define lld long long int
#define ve vector
#define rep(i,a,b) for(i=a;i<b;i++) 
#define per(i,a,b) for(i=b;i>=a;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define Max 1000000000000000
#define md 1000000007

using namespace std;








int main()
{
	
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld n,i,a[10000],sum1,sum2;
    cin>>n;
    rep(i,0,n)
    cin>>a[i];
    sort(a,a+n,greater<lld>());
    for(i=0;i<n;i+=2)
    	sum1=sum1+a[i];
    for(i=1;i<n;i+=2)
    	sum2=sum2+a[i];
    cout<<sum1-sum2;


    
    
    

    
   
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;cin>>s;
  char c1 = s[5], c2 = s[6];
  int m1 = c1 - '0', m2 = c2 - '0';
  if (m1 == 0 && m2 <= 4) puts("Heisei"); else puts("TBD");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int A, B, C;
int X;
int ans, S;

int solve(){
    int i, j, k;

    for(i=0;i<=A;i++){
        for(j=0;j<=B;j++){
            for(k=0;k<=C;k++){
                S = 500*i + 100*j + 50*k;
                if(S==X){
                    ans += 1;
                }
            }
        }
    }
    return ans;
}

int main(){
    cin >> A >> B >> C >> X;
    int ans = solve();
    cout << ans << endl;
    return 0;
}

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

int main() {

	int N,X;
	cin >> N >> X;
  
    vector<int>m(N);
  	int sum=0;
  	int min=INT_MAX;
  
    for(int i=0; i<N; i++){
      cin >> m[i];
      sum += m[i];
      if(m[i] < min){
        min = m[i];
      }
    }
	
  	X -= sum;
  
    cout << X/min+N << endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

LL Sum(VEC<LL> a) {
  LL s = 0;
  REP(i, 1, a.size()) { s += abs(a[i] - a[i - 1]); }
  return s;
}
int main() {
  int n;
  cin >> n;
  VEC<LL> a(n);
  REP(i, 0, n) cin >> a[i];
  VEC<LL> b = a;
  sort(ALL(a));
  //DUMP(a);
  LL sum = 0;
  auto f = [&](int S) -> VEC<LL> {
    VEC<LL> ret;
    REP(i, 0, n) {
      if (i % 2 == S)
        ret.push_back(a[i / 2]);
      else
        ret.push_back(a[n - i / 2 - 1]);
    }
    return ret;
  };
  auto c0 = f(0);
  auto c1 = f(1);
  LL s0 = Sum(c0);
  LL s1 = Sum(c1);
  //DUMP(c0);
  //DUMP(c1);
  //DUMP(s0, s1);
  LL last0 = c0[n - 1];
  LL last1 = c1[n - 1];
  auto cand = {s0, s1, s0 + abs(c0[0] - last0) - abs(c0[n - 2] - last0),
               s1 + abs(c1[0] - last1) - abs(c1[n - 2] - last1)};
  //DUMP(VEC<LL>(cand));
  std::cout << max(cand) << endl;

  return 0;
}


Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;
ll N;
vector<vector<ll>> graph(100005, vector<ll>(0));

void dfs (ll x, vl &check, vvl &children){
    check[x]=1;
    for(ll i=0;i<graph[x].size();i++){
        if(check[graph[x][i]]==0){
            children[x].emplace_back(graph[x][i]);
            dfs(graph[x][i],check,children);
        }
    ;}
}

vector<ll> dpb(100005,-1);
vector<ll> dpw(100005,-1);

ll answ(ll x, vvl &children);

ll ansb(ll x, vvl &children){
    if(dpb[x]!=-1)return dpb[x];
    ll s=1;
    for(ll i=0;i<children[x].size();i++){
        s*=answ(children[x][i],children);
        s%=MOD;
    ;}
    return dpb[x]=s;
}
ll answ(ll x, vvl &children){
    if(dpw[x]!=-1)return dpw[x];
    ll s=1;
    for(ll i=0;i<children[x].size();i++){
        s*=answ(children[x][i],children)+ansb(children[x][i],children);
        s%=MOD;
    ;}
    return dpw[x]=s;
}

int main(){
    cin>>N;
    vector<ll> x(N-1,0);
    vector<ll> y(N-1,0);
    for(ll i=0;i<N-1;i++){
        cin>>x[i]>>y[i]
    ;}
    for(ll i=0;i<N-1;i++){
        graph[x[i]].emplace_back(y[i]);
        graph[y[i]].emplace_back(x[i]);
    ;}
    vector<vector<ll>> graph(N+1, vector<ll>(0));

    //1を根にします！

    vector<ll> check(N+1,0);
    vector<vector<ll>> children(N+1, vector<ll>(0));
    dfs(1,check,children);
    cout<<(ansb(1,children)+answ(1,children))%MOD<<endl;



    return 0;
}


Measured memory_bytes: 23040
n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])

i = 0
for t in T:
	while(D[i] < t):
		i += 1
	if D[i] == t:
		i += 1
	else:
		print("NO")
		exit(0)
print("YES")

Measured memory_bytes: 35428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int x[200010], y[200010];
char u[200010];

int main(){
    int n;
    cin >> n;
    rep(i, n){
        cin >> x[i] >> y[i] >> u[i];
    }

    // y = x + k で見る
    map<ll, multiset<ll>> mpu, mpd, mpl, mpr;
    rep(i, n){
        if(u[i] == 'U') mpu[y[i]-x[i]].insert(x[i]);
        if(u[i] == 'R') mpr[y[i]-x[i]].insert(x[i]);
        if(u[i] == 'D') mpd[y[i]-x[i]].insert(x[i]);
        if(u[i] == 'L') mpl[y[i]-x[i]].insert(x[i]);
    }
    // 各uについての最小のlを求める
    ll ans = INF;
    for(auto v : mpu){
        int kk = v.first;
        mpl[kk].insert(INF);
        for(auto e : v.second){
            ans = min((*mpl[kk].lower_bound(e) - e)*10, ans);
        }
    }
    // 各rについての最小のdを求める
    for(auto v : mpr){
        int kk = v.first;
        mpd[kk].insert(INF);
        for(auto e : v.second){
            ans = min((*mpd[kk].lower_bound(e) - e)*10, ans);
        }
    }

    // y =  - x + k で見る
    mpu.clear();
    mpr.clear();
    mpd.clear();
    mpl.clear();

    rep(i, n){
        if(u[i] == 'U') mpu[y[i]+x[i]].insert(x[i]);
        if(u[i] == 'R') mpr[y[i]+x[i]].insert(x[i]);
        if(u[i] == 'D') mpd[y[i]+x[i]].insert(x[i]);
        if(u[i] == 'L') mpl[y[i]+x[i]].insert(x[i]);
    }
    // 各rについての最小のuを求める
    for(auto v : mpr){
        int kk = v.first;
        mpu[kk].insert(INF);
        for(auto e : v.second){
            ans = min((*mpu[kk].lower_bound(e) - e)*10, ans);
        }
    }
    // 各dについての最小のlを求める
    for(auto v : mpd){
        int kk = v.first;
        mpl[kk].insert(INF);
        for(auto e : v.second){
            ans = min((*mpl[kk].lower_bound(e) - e)*10, ans);
        }
    }

    // y = k　で見る
    mpu.clear();
    mpr.clear();
    mpd.clear();
    mpl.clear();

    rep(i, n){
        if(u[i] == 'U') mpu[y[i]].insert(x[i]);
        if(u[i] == 'R') mpr[y[i]].insert(x[i]);
        if(u[i] == 'D') mpd[y[i]].insert(x[i]);
        if(u[i] == 'L') mpl[y[i]].insert(x[i]);
    }
    // 各rについての最小のlを求める
    for(auto v : mpr){
        int kk = v.first;
        mpl[kk].insert(INF);
        for(auto e : v.second){
            ans = min((*mpl[kk].lower_bound(e) - e) * 5, ans);
        }
    }

    // x = k　で見る
    mpu.clear();
    mpr.clear();
    mpd.clear();
    mpl.clear();

    rep(i, n){
        if(u[i] == 'U') mpu[x[i]].insert(y[i]);
        if(u[i] == 'R') mpr[x[i]].insert(y[i]);
        if(u[i] == 'D') mpd[x[i]].insert(y[i]);
        if(u[i] == 'L') mpl[x[i]].insert(y[i]);
    }
    // 各uについての最小のdを求める
    for(auto v : mpu){
        int kk = v.first;
        mpd[kk].insert(INF);
        for(auto e : v.second){
            ans = min((*mpd[kk].lower_bound(e) - e) * 5, ans);
        }
    }

    if (ans > 200010 * 10) cout << "SAFE" << endl;
    else cout << ans << endl;

    return 0;
}

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

using namespace std;

const int N = 3005;

int n;

double a[N], ans, dp[N][N];

int main () {
    ios_base::sync_with_stdio (0), cin.tie (0), cout.tie (0);
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }
    dp[1][1] = a[1];
    dp[1][0] = (1 - a[1]);
    for (int i = 2;i <= n;i ++) {
        for (int j = 0;j <= i;j ++) {
            dp[i][j] += dp[i - 1][j] * (1 - a[i]);
            if (j)dp[i][j]+= dp[i - 1][j - 1] * a[i];
        }
    }
    for (int i = n / 2 + 1;i <= n;i ++) {
        ans += dp[n][i];
    }cout << fixed << setprecision (10)<< ans;
}


Measured memory_bytes: 69120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>

int n;
int arr[1000000];
std::map<int, int> count;
bool isPrime[1000001];

void factorize(int val, std::set<int>& primes)
{
    if (val == 1)
        return;

    if (isPrime[val])
    {
        primes.insert(val);
        return;
    }

    int sqrt = (int)std::round(std::sqrt(val));
    if (sqrt*sqrt == val)
    {
        factorize(sqrt, primes);
        return;
    }
    
    for (int i = 2; i <= sqrt; ++i)
    {
        if (val % i == 0)
        {
            primes.insert(i);
            factorize(val / i, primes);
            return;
        }
    }
}

int main()
{
    std::fill(isPrime, isPrime+1000001, true);
    isPrime[0] = isPrime[1] = false;

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

    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%d", arr+i);
        std::set<int> primes;
        factorize(arr[i], primes);

        for (int p : primes)
            ++count[p];
    }
    
    int max = 0;
    for (auto p : count)
        max = std::max(max, p.second);

    if (max <= 1)
        printf("pairwise coprime");
    else if (max < n)
        printf("setwise coprime");
    else
        printf("not coprime");
}

Measured memory_bytes: 12112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

int main(){
    ll N, X, D;
    cin >> N >> X >> D;
    if(X == 0){
        if(D == 0) cout << 1 << endl;
        else cout << (N*(N-1)/2)+1 << endl;
        exit(0);
    }
    if(D == 0) cout << N+1 << endl, exit(0);
    if(D < 0) D *= -1, X *= -1;
    ll L = X*D/gcd(abs(X), D);
    ll s = L/X, t = L/D;
    ll m[N+1], M[N+1];
    m[0] = 0, M[0] = 0;
    rep2(i, 1, N) m[i] = m[i-1]+i-1, M[i] = M[i-1]+N-i;
    vector<P> vec[N+1];
    rep(i, N+1){
        ll j = i%s, k = (i/s)*t;
        vec[j].push_back(P(k+m[i], k+M[i]));
    }
    ll ans = 0;
    rep(i, N+1){
        sort(vec[i].begin(), vec[i].end());
        ll n = vec[i].size();
        rep(j, n){
            if(j == n-1 || vec[i][j].second < vec[i][j+1].first){
                ans += vec[i][j].second - vec[i][j].first + 1;
            }
            else{
                vec[i][j+1].first = vec[i][j].first;
                vec[i][j+1].second = max(vec[i][j].second, vec[i][j+1].second); 
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x: a) cin >> x;

  vector<ll> dp(n+2);
  dp[0] = 1;
  ll mul = 1;
  int limit = 1;
  for (int i = 1; i < n; i++) {
    mul++;
    dp[i] = (dp[i-1] * mul) % mod;

    limit += 2;
    if (a[i] < limit) {
      limit -= 2;
      mul--;
    }
  }

  ll ans = dp[n-1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll x; cin >> x;
    ll y; cin >> y;
    ll a; cin >> a;
    ll b; cin >> b;
    ll c; cin >> c;
    vector<ll> as;
    REP(i, a){
        ll aa; cin >> aa;
        as.push_back(aa);
    }
    vector <ll> bs;
    REP(i, b){
        ll bb; cin >> bb;
        bs.push_back(bb);
    }
    vector <ll> cs;
    REP(i, c){
        ll cc; cin >> cc;
        cs.push_back(cc);
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());
    priority_queue <ll> xs;
    REP(i, x){
        xs.push(as[a-1-i] * -1);
    }
    priority_queue <ll> ys;
    REP(i, y){
        ys.push(bs[b-1-i] * -1);
    }
    priority_queue <ll> zs;
    REP(i, c){
        zs.push(cs[c-1-i]);
    }
    while (true){
        priority_queue <ll> *mini;
        if (xs.top() > ys.top()){
            mini = &xs;
        } else {
            mini = &ys;
        }
        if (!zs.empty() && ((*mini).top() > zs.top()*-1)){
            (*mini).pop();
            (*mini).push(zs.top()*-1);
            zs.pop();
        } else {
            break;
        }
    }
    ll ans = 0;
    REP(i, x){
        ans -= xs.top();
        xs.pop();
    }
    REP(i, y){
        ans -= ys.top();
        ys.pop();
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using cd=complex<double>;

void solve() {
    int n; cin >> n;
    vector<cd> a(n);
    for (auto& p: a) {
        double x,y;
        cin >> x >> y;
        p = {x,y};
    }
    sort(a.begin(), a.end(), [&](auto& u, auto& v){
        return arg(u) < arg(v);
    });
    double res = 0;
    for (int i = 0; i < n; i++) {
        cd crt;
        for (int j = 0; j < n; j++) {
            crt += a[(i+j)%n];
            res = max(res, abs(crt));
        }
    }
    cout << fixed << setprecision(10) << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,k;
int x[100005],y[100005],z[100005];
long long more[100005];
long long ans;
main()
{
	scanf("%d",&a);
	for(i=0;i<a;i++)
		scanf("%d",&x[i]);
	for(i=0;i<a;i++)
		scanf("%d",&y[i]);
	for(i=0;i<a;i++)
		scanf("%d",&z[i]);
	sort(x,x+a);
	sort(y,y+a);
	sort(z,z+a);
	j=a-1;
	int now=0;
/*	for(i=0;i<a;i++)
	{
		printf("%4d %4d %4d\n",x[i],y[i],z[i]);
	}*/
	for(i=a-1;i>=0;i--)
	{
		while(y[i]<z[j]&&j>=0)
		{
			now++;
			j--;
		}
		more[i]=now+more[i+1];
	}
	now=0;
	for(i=0;i<a;i++)
	{
		while(y[now]<=x[i]&&now<a)
		{
			now++;
		}
		if(now>=a)
			break;
	//	printf("%d ",more[now]);
		ans+=more[now];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define DEBUG
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );
#define lli long long int

using namespace std;

int main()
{
	int a, b, x;
  	cin >> a >> b >> x;
  	if ( a + b < x || a > x ) {
    	cout << "NO";
      	return 0;
    }
    cout << "YES";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


void calc(vector<int> A)
{
  vector<int> dp(A.size());
  dp[0] = 0;
  dp[1] = abs(A[1]-A[0]);
  
  for(auto i=2;i<dp.size();i++)
  {
  dp[i] = min(abs(A[i]-A[i-1])+dp[i-1],abs(A[i]-A[i-2])+dp[i-2]);
  }
    
  cout << dp.back();
}

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  
  for (auto i=0;i<n;i++)
    cin >> h[i];
  
  calc(h);
}


Measured memory_bytes: 1408
def lrotate(t):
    s = t.right
    t.right = s.left
    s.left = t
    return s

def rrotate(t):
    s = t.left
    t.left = s.right
    s.right = t
    return s

def insert(t, key, pri):
    if t == None:
        return Treap(key, pri)
    if key == t.key:
        return t

    if key < t.key:
        t.left = insert(t.left, key, pri)
        if t.pri < t.left.pri:
            t = rrotate(t)
    else:
        t.right = insert(t.right, key, pri)
        if t.pri < t.right.pri:
            t = lrotate(t)
    return t

def delete(t, key):
    if t == None:
        return None

    if key == t.key:
        if t.left == None and t.right == None:
            return None
        elif t.left == None:
            t = lrotate(t)
        elif t.right == None:
            t = rrotate(t)
        else:
            if t.left.pri > t.right.pri:
                t = rrotate(t)
            else:
                t = lrotate(t)
        return delete(t, key)

    if key < t.key:
        t.left = delete(t.left, key)
    else:
        t.right = delete(t.right, key)
    return t

def find(t, key):
    if t == None:
        return -1
    if t.key == key:
        return 1
    if key < t.key:
        return find(t.left, key)
    else:
        return find(t.right, key)
    
def inorder(t):
    if t == None:
        return 
    inorder(t.left)
    print(" " + str(t.key), end="")
    inorder(t.right)

def preorder(t):
    if t == None:
        return
    print(" " + str(t.key), end="")
    preorder(t.left)
    preorder(t.right)



class Treap():
    def __init__(self, key, pri):
        self.key = key
        self.pri = pri
        self.left = None
        self.right = None
        
t = None
data = []
m = int(input())
for i in range(m):
    data.append(list(input().split()))

for i in range(m):
    if data[i][0] == "insert":
        t = insert(t, int(data[i][1]), int(data[i][2]))
    elif data[i][0] == "delete":
        t = delete(t, int(data[i][1]))
    elif data[i][0] == "find":
        result = find(t, int(data[i][1]))
        if result == 1:
            print("yes")
        else:
            print("no")
    else:
        inorder(t)
        print()
        preorder(t)
        print()




Measured memory_bytes: 112112
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	int k,a,b,d=0;
	cin>>k>>a>>b;
	if(k==1) cout<<"OK";
	else{
	    for(int i=1;i<=1000;i++){
	        int kk=k*i;
	        if(kk>=a && kk<=b) {
	            d=1;
	            break;
	        }
	    }
	    if(d==1) cout<<"OK";
	    else cout<<"NG";
	}
}


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

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


    int big=max(a,b);
    int small=min(a,b);

    int ans=small;

    while(big%small!=0){
        int amari=big%small;
        big=small;
        small=amari;

        ans=small;

    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    ll n; cin >> n;
    string s; cin >> s;
    vector<ll> btow, wtob;
    ll tmp = 0;
    REP(i,n) {
        tmp += (s[i]=='#');
        while (s[i] == s[i+1] && i+1<n) {
            i++;
            tmp += (s[i]=='#');
        }
        btow.push_back(tmp);
    }
    reverse(ALL(s));
    tmp = 0;
    REP(i,n) {
        tmp += (s[i]=='.');
        while (s[i] == s[i+1] && i+1<n) {
            i++;
            tmp += (s[i]=='.');
        }
        wtob.push_back(tmp);
    }
    reverse(ALL(wtob));
    reverse(ALL(s));
    int l = btow.size();
    ll ans = INF;
    if(l==1) ans = 0;
    else if(l==2) {
        tmp = 0;
        bool flag = (s[0]=='.');
        REP(i,n) {
            if(s[i]=='#') flag = false;
            tmp += (!flag && s[i]=='.');
        }
        ans = min(ans,tmp);
        reverse(ALL(s));
        tmp = 0;
        flag = (s[0]=='#');
        REP(i,n) {
            if(s[i]=='.') flag = false;
            tmp += (!flag && s[i]=='#');
        }
        ans = min(ans,tmp);
    }
    else {
        REP(i,l-2) {
            ans = min(ans, btow[i]+wtob[i+2]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64

int seg[1<<20];
const int INF=2147483647;
int t[1000000];//配列
int n;//セグ木の区間幅(2のさい)
int k;//区間の幅
int size;//セグ木のサイズ

void init(int _n){
	n=1;
	while(n<_n)n=n*2;

	size=n*2-1;
	rep(i,size+1)seg[i]=INF;

	//rep(i,k)seg[i+n-1]=t[i];

	
}

void update(int x,int a){
	x=x+n-1;
	seg[x]=a;
	//x=(x-1)/2;

	while(x>0){
		x=(x-1)/2;
		seg[x]=min(seg[x*2+1],seg[x*2+2]);

	}
//rep(i,size)cout<<"S"<<seg[i]<<endl;
}


int query(int a,int b,int k,int l,int r){//[l,r)を動かす
	//cout<<"Q"<<l<<" "<<r<<" "<<k<<endl;
	if(b<=l || r<=a)return INF;
	else if(a<=l&&r<=b)return seg[k];

	else{
		int v1=query(a,b,k*2+1,l,(l+r)/2);
		int v2=query(a,b,k*2+2,(l+r)/2,r);
		
		return min(v1,v2);
	}

}
int main(){

int q;
cin>>k>>q;
init(k);

while(q--){
	int f;
	cin>>f;
	if(!f){
		int x,a;
		cin>>x>>a;
		update(x,a);
	}
	else{
		int l,r;
		cin>>l>>r;
		cout<<query(l,r+1,0,0,n)<<endl;
	}
}

	return 0;
}


Measured memory_bytes: 4116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M, C;
		N = sc.nextInt();
		M = sc.nextInt();
		C = sc.nextInt();
		int B[] = new int[M];
		int A[][] = new int[N][M];

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

		int ans = 0;
		for (int i = 0; i < N; i++) {
			int sum = 0;
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
				sum += B[j] * A[i][j];
			}
			if (sum + C > 0) {
				ans++;
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
bool a[10];
bool check(int x){
	for(int j=x;j>0;j/=10){if(a[j%10]) return true;	}
	return false;
}

int main(){
    long long n,k;
    cin>>n>>k;
 
	for(int i=0;i<k;i++){ int x;cin>>x;
		a[x]=true;
	}
	int j;
	for(j=n;check(j);j++);
 
    cout<<j<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int k,n;
  cin>>k>>n;
  if(500*k>=n){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

// 入力
string s;

int main(void) {
    cin >> s;

    int p_num = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'p') p_num++;

    }

    int point = s.length() / 2 - p_num;

    cout << point << endl;
    return 0;
}

Measured memory_bytes: 512
cardcost = {}
N = int(input())
for i in range(N):
    s = input()
    scost = cardcost.get(s, 0)
    cardcost[s] = scost+1

M = int(input())
for i in range(M):
    t = input()
    tcost = cardcost.get(t, 0)
    cardcost[t] = tcost-1


ans = max(cardcost.values())
if(ans > 0):
    print(ans)
else:
    print(0)


Measured memory_bytes: 3060
n, a, b, c, d = map(int, input().split())
s = input()

if "##" in s[a:c+1] or "##" in s[b:d+1] :
  print("No")
elif c<d:
  print("Yes")
elif "..." in s[b-2:d+1] :#以下 d<c の場合
  print("Yes")
else :
  print("No")


Measured memory_bytes: 3572
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;
#define ll long long int


int main()
{
	string s;
	cin>>s;
	string s1 = {"ABC"}, s2 = {"ARC"};
	if(s.compare(s1)==0)
		cout<<s2<<endl;
	else
		cout<<s1<<endl;
	return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll r,g,b,n;
	cin>>r>>g>>b>>n;
	ll ans=0;
	for(int i=0;i<=3000;i++)for(int j=0;j<=3000;j++){
		ll k=n-i*r-j*g;
		if(k>=0&&k%b==0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

double distance(vector<int> y,vector<int> z)
{
  int sum=0;
  for(int i=0;i<(int)y.size();i++)sum+=(y[i]-z[i])*(y[i]-z[i]);
  return (double)pow(sum,0.5);
}

int main()
{
  int N,D,ans=0;scanf("%d %d",&N,&D);
  vector<vector<int>> X(N,vector<int>(D,0));
  for(int i=0;i<N;i++)for(int j=0;j<D;j++)scanf("%d ",&X[i][j]);
  for(int i=0;i<N;i++)for(int j=i;j<N;j++)
  {
    if(i==j)continue;
    if(distance(X[i],X[j])-(int)distance(X[i],X[j])==0)ans++;
  }
  printf("%d",ans);
}

Measured memory_bytes: 4228
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

vector<pair<int, int>> Link;
vector<pair<int, int>> resul;
vector<int> Node;

    int N,M;

typedef pair<int, int> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

bool pairCompare1st(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
    if (firstElof.first != secondElof.first){
        return firstElof.first < secondElof.first;
    }else{
        return firstElof.second < secondElof.second;
    }
}

void Dist(int root){
    //queueで作る
    int cnt = 1;
    vector<pair<int, int>>::iterator line_start, line_end;
    //queue<int, vector<int>> bque;
    queue<int> bque;
    bque.push(root);
    int *Visited = new int[Node.size()]();
    Visited[root] = 1;
    while (bque.size() > 0)
    {
        //cout << dstack.size() << endl; 
        //cout << bque.front() << " " << Visited[bque.front()] - 1 << endl;
        line_start = lower_bound(Link.begin(), Link.end(), make_pair(bque.front(), 0), pairCompare1st);
        line_end = lower_bound(Link.begin(), Link.end(), make_pair(bque.front() + 1, 0), pairCompare1st);
        bque.pop();
        for (int i = line_start - Link.begin(); i < line_end - Link.begin(); i++)
        {
            if (Visited[Link[i].second] == 0)
            {
                bque.push(Link[i].second);
                Visited[Link[i].second] = Visited[Link[i].first]+1;
                resul.push_back(make_pair(Link[i].second,Link[i].first));
            }
        }
    }
    delete[] Visited;
}
int main() {
  
  //Start DFS from this Node.
    int RootNode=0;

    cin >>  N >>M;
    int a,b;
    for(int i=0;i<M;i++)
    {
      cin >> a >> b;
      Link.push_back(make_pair(a-1,b-1));
      Link.push_back(make_pair(b-1,a-1));
    }
    sort(Link.begin(), Link.end(), pairCompare);
    //Define node list
    for (int i = 0; i < N; i++)
    {
        Node.push_back(i);
    }

    Dist(RootNode);

    cout << "Yes" << endl; 
    sort(resul.begin(), resul.end(), pairCompare);
    for(int i = 0; i < resul.size(); i++){
      cout << resul[i].second+1 << endl;
    }
}

Measured memory_bytes: 8820