akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int X;
    cin >> X;
    cout << ((X & 1 && X >= 3 && X <= 7) ? "YES" : "NO") << endl;
}

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

int main(){
  int N;
  int result = 0;

  cin >> N;
    
  for(int i = 0; i < N; i++){
      int l, r;
      cin >> l;
      cin >> r;
      result += (r-l+1);
  }

  cout << result << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
  int n,m,i,a,b,c[100010]={};
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d",&a);
    while(a--){
      scanf("%d",&b);
      c[b]=1;
    }
  }
  for(i=a=0;i<n;i++)a+=1-c[i+1];
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 2076
require "set"

n, m = gets.split(" ").map(&:to_i)
edges = {}
nodes = Set.new
m.times do |i|
  a, b = gets.split(" ").map(&:to_i)
  edges[a] ||= []
  edges[a] << b
  edges[b] ||= []
  edges[b] << a
  nodes << a
  nodes << b
end

def one_line s, n, nodes, edges
  # p "[debug] set: #{s}, node: #{n}"
  new_s = s.clone
  new_s << n
  if new_s == nodes then
    return 1
  end

  res = 0
  ((edges[n] || []) - new_s.to_a).each do |b|
    res += one_line new_s, b, nodes, edges
  end
  return res
end

puts one_line(Set.new, 1, nodes, edges)

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define ll  long long
#define ld  long double
#define endl "\n"
#define ull  unsigned long long
#define pb push_back
#define all(v) ((v).begin()),((v).end())
#define vi   vector<ll>
#define INF 1000000000
#define M ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
	M
	ll n,dp[100001]={};
	vi v;
	cin>>n;
	for(int i=0;i<n;i++){
		ll in; cin>>in; v.pb(in);
	}
	dp[0]=0;
	for(int i=1;i<=n;i++)
		dp[i]=INF;
	for(int i=0;i<n;i++){
		if(i+1<n) dp[i+1]=min(dp[i+1],dp[i]+abs(v[i]-v[i+1]));

		if(i+2<n) dp[i+2]=min(dp[i+2],dp[i]+abs(v[i]-v[i+2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    vector<ll> h(n,0);
    rep1(i, n) cin >> h[i];
    ll ans = 0, res = 0;
    rep1(i, n-1){
        if (h[i]>=h[i+1]){
            ++res;
        }
        else{
            ans = max(res, ans);
            res = 0;
        }
    }
    ans = max(res, ans);
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string ans = a * b % 2 == 0 ? "No" : "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut solver = Solver::new(n);
    for i in 0..n {
        let a: usize = scan(tokens);
        for _ in 0..a {
            let x: usize = scan(tokens);
            let y: usize = scan(tokens);
            solver.add_edge(i, x - 1, y);
        }
    }
    println!("{}", solver.solve());
}

#[derive(Debug)]
struct Solver {
    n: usize,
    edges: Vec<Vec<(usize, usize)>>,
}

impl Solver {
    fn new(n: usize) -> Solver {
        Solver {
            n: n,
            edges: vec![Vec::new(); n],
        }
    }
    fn add_edge(&mut self, i: usize, j: usize, t: usize) {
        self.edges[i].push((j, t));
    }
    fn solve(&mut self) -> usize {
        let state = vec![2; self.n];
        self.dfs(0, 0, &state)
    }
    fn dfs(&mut self, i: usize, count: usize, state: &Vec<usize>) -> usize {
        if i == self.n {
            count
        } else if state[i] == 0 {
            self.dfs(i + 1, count, state)
        } else if state[i] == 1 {
            let mut state1 = state.clone();
            let mut ok = true;
            for &(j, t) in &self.edges[i] {
                if state1[j] == t {
                    // ok
                } else if state1[j] == 1 - t {
                    ok = false;
                    break;
                } else {
                    state1[j] = t;
                }
            }
            if ok {
                self.dfs(i + 1, count + 1, &state1)
            } else {
                0
            }
        } else {
            let mut state0 = state.clone();
            state0[i] = 0;
            let tmp = self.dfs(i + 1, count, &state0);
            let mut state1 = state.clone();
            state1[i] = 1;
            let mut ok = true;
            for &(j, t) in &self.edges[i] {
                if state1[j] == t {
                    // ok
                } else if state1[j] == 1 - t {
                    ok = false;
                    break;
                } else {
                    state1[j] = t;
                }
            }
            if ok {
                std::cmp::max(tmp, self.dfs(i + 1, count + 1, &state1))
            } else {
                tmp
            }
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int fact(long long int n){
    int c=0;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            c++;
            n/=i;
        }
    }
    if(n>1)
        c++;
    return c;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin>>n;
  long long int th=0;
    if(n>=500){
  long long int fh=n/500;
    n%=500;
   th+=(1000*fh);
    }
  long long int f=n/5;
    th+=(5*f);
    cout<<th;
}


Measured memory_bytes: 3692
a = input()

if len(a) < 6:
    print("INVALID")
else:
    m = 0
    n = 0
    l = 0
    for i in range(len(a)):
        if 48 <= ord(a[i]) <= 57:
            m += 1
        if 97 <= ord(a[i]) <= 122:
            n += 1
        if 65 <= ord(a[i]) <= 90:
            l += 1
    if m == 0 or n == 0 or l == 0:
        print("INVALID")
    else:
        print("VALID")


Measured memory_bytes: 5560
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N, M, s, c;
    bool ans=true, z=false;
    cin >> N >> M;
    int a[N];
    for (int i=0; i<N; i++){
        a[i] = -1;
    }
    for (int i=0; i<M; i++){
        cin >> s >> c;
        s = s - 1;
        if (a[s] == -1) a[s] = c;
        else if (a[s] != c) {
            ans = false;
        }
    }
    if (a[0]==0) ans = false;
    if ((a[0] ==0 || a[0]==-1) && N==1) {
        ans = true;
        z=true;
    }
    for (int i=0; i<N; i++){
        if (a[i]==-1 && i!=0) a[i]=0;
        else if (a[i]==-1 && i== 0) a[i] = 1;
    }
    if (ans){
        if (not z){
            for (int i=0; i<N; i++){
                cout << a[i];
            }
        }
        else cout << 0;
    }
    else cout << -1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };



int main() {

	ll a, b, x;
	cin >> a >> b >> x;

	if (a == 0) {
		cout << b / x + 1  << endl;
	}
	else {
		cout << b / x + 1 - ((a - 1) / x + 1) << endl;
	}

	return 0;
}


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

int digit(int n) {
  int d = 0;
  while(n > 0) {
    d++;
    n /= 10;
  }
  return d;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) if(digit(i) % 2) ans++;
  cout << ans << endl; 
  return 0;
}


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

namespace ABC049C
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            str = string.Concat(str.Reverse());
            string[] words = {"maerd", "esare", "resare", "remaerd"};
            var flag = true;
            for (var i = 0; i <=str.Length-1 ;)
            {
                var flag2 = false;
                var remainlength = str.Length - i;
                var k = 4;
                if (remainlength<=4)
                {
                    flag = false;
                    break;
                }
                else switch (remainlength)
                {
                    case 5:
                        k = 2;
                        break;
                    case 6:
                        k = 3;
                        break;
                }

                for (var j = 0; j < k; ++j)
                {
                    if (!Equals(str.Substring(i, words[j].Length),words[j])) continue;
                    flag2 = true;
                    i += words[j].Length;
                    break;
                }

                if (flag2) continue;
                flag = false;
                break;
            }

            Console.WriteLine(flag ? "YES" : "NO");
            Console.Read();
        }
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a.begin(),a.end());

    for(int i = 0;i < n;i++){
        cout << a[i].second + 1 << " ";
    }

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, x;
    cin >> n >> x;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    for (int i = 1; i < n; ++i) {
        a[i] += a[i - 1];
    }
    lint ret = inf;
    for (int k = 1; k <= n; ++k) {
        lint temp = (n + k) * x;
        for (lint j = 1; j <= (n + k - 1) / k; ++j) {
            lint y = (j == 1 ? 5 : (2 * j + 1));
            temp += y * (a[min(j * k - 1, n - 1)]);
            if (j != 1)
                temp -= y * (a[(j - 1) * k - 1]);
            if (temp > inf)
                break;
        }
        if (temp > inf)
            continue;
        ret = min(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
from math import cos, radians

a, b, h, m = map(int, input().split())
# H : 30/h, M : 360/h
# H : 0.5 / m, M : 6 / m
h = (h * 30) + (m * 0.5)
m *= 6
A = abs(h - m)
ans_p = a ** 2 + b ** 2 - 2 * a * b * cos(radians(A))
ans = ans_p ** 0.5
print(f"{ans:.9f}")

Measured memory_bytes: 62440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)



int main(){
    int A[3],ans;
    rep(i,3) cin >> A[i];
    sort(A,A+3);
    ans = abs(A[2] - A[0]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
S=gets.chomp

sum=0
i = 0
while i < S.length
    l=0
    r=0
    while S[i] == '<'
        i += 1
        l += 1
    end
    while S[i] == '>'
        i += 1
        r += 1
    end
    min,max=[l,r].minmax
    sum += (min-1)*min/2 
    sum += max*(max+1)/2
end
puts sum


Measured memory_bytes: 2948
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

int cnt[26];

int dp[5005][4];

signed main() {
	int n; cin >> n;
	int a[n+1];
	REP (i,n) cin >> a[i]; a[n] = 0;
	REP (i,5005) REP (j,4) dp[i][j] = INF;
	dp[1][0] = 0;
	dp[1][1] = 1;
	dp[1][2] = 2;
	dp[1][3] = 3;
	REP (i,4) dp[0][i] = 0;
	FOR (i,1,n) {
		REP (j,4) {
			REP (k,4) {
				//1個前j回これをk回
				if (a[i-1] <= j + k) {
					dp[i+1][k] = min(dp[i+1][k],dp[i][j] + 2 * k);
				}
			}
		}
	}
	REP (i,4) {
		dp[n][i] += max(0LL,a[n-1]-i);
	}
	int ans = INF;
	REP (i,4) {
		dp[n][i];
		ans = min(ans,dp[n][i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 3288
#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 rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    int n; cin >> n;
    vint a(n);
    bool b[100005]; fill_n(b, 100005, false);
    rep(i, n) { cin >> a[i]; a[i]--; }
    int cnt = 0;
    rep(i, n) {
        if(i == a[a[i]] && !b[i]) {
            b[i] = b[a[i]] = true;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <cmath>

using namespace std;
string s;

int main() {
    cin >> s;
    int mod = 0;
    for (auto c : s) {
        mod += (c - '0');
    }
    mod %= 9;
    if (mod == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main (){
 
 int P,Q,R;
 cin >> P >> Q >> R;
 
 if(P <= Q && R <= Q){
     cout << P + R << endl;
 }
else if(Q <= P && R <= P){
     cout << Q + R << endl;
}
else if(Q <= R && P <= R){
      cout << Q + P << endl;
}
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
const int N = 303;
int n;
ll a[N][N];
ll ans = 0;
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			scanf("%lld", &a[i][j]);
		}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < i; j++) {
			ll w = a[i][j] + 1;
			for (int k = 0; k < n; k++) {
				if (i == k || j == k) continue;
				w = min(w, a[i][k] + a[k][j]);
			}
			if (w < a[i][j]) {
				printf("-1\n");
				return 0;
			}
			if (w > a[i][j]) ans += a[i][j];
		}
	printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define DEBUG(x) cout << #x << " : " << x << endl;
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
//check the limits, man
// read the constraint properly (ll vs int)
const int N = 1e5+5;
typedef long long int ll;
int main()
{
    int n,a;
    in(n);
    a=(n+1)>>1;
    double d=a;
    cout << setprecision(8) << fixed;
    d/=n;
    llout(d);
}





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

int main() {  
	int n, d;
    cin >> n >> d;
if(n% (2 *d+1) == 0) {
	cout << n / ( (2*d+1)) << endl;
}
  else cout << n / (2*d+1) + 1 << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

bool asc(pll a,pll b) {
  if(a.first != b.first){
    return a.first < b.first;
  }else{
    return a.second > b.second;
  }
}


int main() {
  ll N,M,left,ans,lef;
  cin >> N>>M;
  vector<pll> P(N);
  REP(i,N){
		int x,y;
		cin >> x>>y;
		P[i].first = x;
    P[i].second = y;
	}
  sort(P.begin(),P.end(),asc);
  lef = M;
  ans = 0;
  REP(i,N){
    if(P[i].second<=lef){
      ans=ans+P[i].first*P[i].second;
      lef = lef-P[i].second;
    }else{
      ans = ans+P[i].first*lef;
      lef = 0;
    }
    if(lef ==0) break;
  }
  cout << ans<< endl;
  return 0;
}

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

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  vec a(N); rep(i, N) cin >> a[i];

  sort(ALL(a)); reverse(ALL(a));

  int sum1 = 0, sum2 = 0;
  rep(i, N) {
    if(i%2==0) sum1+=a[i];
    else sum2+=a[i];
  }

  cout << sum1-sum2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    int x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    for(int i=0; i<5;i++){
        if(x[i] == 0){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> g(n + 2), h(n + 2);
	g[0] = a[0];
	h[n - 1] = a[n - 1];
	for (int i = 1; i < n; i++) g[i] = gcd(g[i - 1], a[i]);
	for (int i = n - 2; i >= 0; i--) h[i] = gcd(h[i + 1], a[i]);
	int ans = max(g[n - 2], h[1]);
	for (int i = 1; i < n - 1; i++) {
		ans = max(ans, gcd(g[i - 1], h[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
def m_of_f(seat,m_max,m_min,seat_0):
    global seat_check, n_max, n_min
    print(seat)
    s=input()

    if seat%2==0:
        if s==seat_0:
            n_min=seat
            seat=int(0.5*(m_max+seat))
            seat_check=seat
            
        else :
            n_max=seat
            seat=int(0.5*(m_min+seat))
            seat_check=seat
            
    else:
        if s!=seat_0:
            n_min=seat
            seat=int(0.5*(m_max+seat))
            seat_check=seat
        else :
            n_max=seat
            seat=int(0.5*(m_min+seat))
            seat_check=seat


n_max=int(input())
n_min=0

print(0)
seat_zero=input()
seat_check=int(0.5*n_max)

for i in range(19):
    m_of_f(seat_check, n_max, n_min, seat_zero)


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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

bool dp[100100];

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

    int i = 0;
    while( ( i = S.find("?",i))>=0){
        S.replace(i,1,"D");
    }

    cout << S << endl;

}



Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n,m;cin>>n>>m;
    string s;cin>>s;
    vector<ll> res;
  	ll pos = n;
  	ll idx = m;
    while(pos > 0){
        while(1){
          	//cout << pos << " " << idx << " " << s[pos-idx] << endl;
          	if(pos==0)break;
            if(idx==0){
                cout << -1 << endl;
                return 0;
            }
            if(pos-idx >= 0 && s[pos-idx] == '0'){
                res.pb(idx);
              	pos -= idx;
              	idx = m;
                break;
            }else{
                idx--;
            }
        }        
    }
    rrep(i,0,res.size()) cout << res[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1528
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if((a==1 && b==2) || (a==2 && b==1)){
       printf("3");
    }
    else if((a==1 && b==3)|| (a==3 && b==1)){
        printf("2");
    }
    else{
        printf("1");
    }

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

std::vector<unsigned int>
get_primes(unsigned int MaxPrime) {
  std::vector<unsigned int> primes;
  std::vector<bool> is_prime(MaxPrime+1, true);
  is_prime[0] = false;
  is_prime[1] = false;

  for (size_t i=2; i<=std::sqrt(MaxPrime); i++) {
    if (is_prime[i]) {
      primes.push_back(i);
      for (size_t j=i*i; j<=MaxPrime; j+=i) {
        is_prime[j] = false;
      }
    }
  }

  for (size_t i=std::sqrt(MaxPrime)+1; i<=MaxPrime; i++) {
    if (is_prime[i]) {
      primes.push_back(i);
    }
  }

  return primes;
}

std::map<unsigned int, size_t>
get_prime_factors(unsigned int N) {
  std::map<unsigned int, size_t> prime_factors;

  if (N<2) {
    prime_factors.insert(std::make_pair(N, 1));
    return prime_factors;
  }

  for (auto const p : get_primes(std::sqrt(N))) {
    while (N % p == 0) {
      prime_factors[p]++;
      N /= p;
    }
  }

  if (N > 1) prime_factors[N]++;

  return prime_factors;
}

std::vector<unsigned int>
get_factors(unsigned int N) {
  std::vector<unsigned int> factors(1, 1);

  for (auto const p : get_prime_factors(N)) {
    unsigned int const prime = std::get<0>(p);
    unsigned int const exp = std::get<1>(p);

    std::vector<unsigned int> mult_space(factors.size());
    std::copy(factors.begin(), factors.end(),
              mult_space.begin());

    for (size_t i=0; i<exp; i++) {
      std::transform(mult_space.begin(), mult_space.end(),
                     mult_space.begin(),
                     [=](unsigned int a){return a * prime;});
      std::copy(mult_space.begin(), mult_space.end(),
                std::back_inserter(factors));
    }
  }

  return factors;
}

int main() {
  unsigned int N, M;

  std::cin >> N >> M;

  auto factors = get_factors(M);
  std::sort(factors.begin(), factors.end());
  auto f = *std::find_if(factors.begin(), factors.end(),
                         [=](auto f){return f >= N;});

  std::cout << M / f << std::endl;

  return 0;
}


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


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

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

		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int maxi = -1;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] + a[i + 1] >= l) {
				maxi = i;
				break;
			}
		}

		if (maxi == -1) {
			pr.println("Impossible");
		} else {
			pr.println("Possible");
			for (int i = 0; i < maxi; i++) {
				pr.println(i + 1);
			}
			for (int i = n - 2; i >= maxi + 1; i--) {
				pr.println(i + 1);
			}
			pr.println(maxi + 1);
		}

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 31712
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int t;
	cin>>t;
	string s;
	cin>>s;
	s.push_back('@');
	int ans=0;
	for(int i=0;i<s.size()-1;++i){
		if(s[i]!=s[i+1]) ++ans;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3712
data = input().split(' ')
a = int(data[0])
b = int(data[1])
c = int(data[2])
d = int(data[3])
takahashi_turn = False
while a > 0 and c > 0:
    takahashi_turn = not takahashi_turn
    if takahashi_turn:
        c -= b
    else:
        a -= d
if takahashi_turn:
    print('Yes')
else:
    print('No')

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

namespace abc_057_B
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[,] sx = new long[a[0],2];
            long[,] flag = new long[a[1],2];

            for (long i = 0; i < a[0]; i++)
            {
                long[] dye = Console.ReadLine().Split().Select(long.Parse).ToArray();
                sx[i, 0] = dye[0];
                sx[i, 1] = dye[1];
            }
            for(long i = 0; i < a[1]; i++)
            {
                long[] dy = Console.ReadLine().Split().Select(long.Parse).ToArray();
                flag[i, 0] = dy[0];
                flag[i, 1] = dy[1];
            }
            for (long i = 0; i < a[0]; i++)
            {
                bool flags = true;
                long manha = 0; long saikuoban = 0;
                long manKARI = 0;
                for (long k = 0; k < a[1]; k++)
                {
                    long sei1 = sx[i, 0] - flag[k, 0];
                    long sei2 = sx[i, 1] - flag[k, 1];
                    if (sei1 < 0)
                    { sei1 *= -1; }
                    if (sei2 < 0) { sei2 *= -1; }
                    manKARI = sei2 + sei1;
                    if (k == 0 && flags)
                    {
                        manha = manKARI; saikuoban = 1;
                        flags = false;
                    }
                    else
                    {
                        if (manha > manKARI) { saikuoban = k + 1; }
                        manha = Math.Min(manha, manKARI);

                    }

                }    Console.WriteLine(saikuoban);
                
            }Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
from collections import deque
n , k = map(int, input().split())
a = list(map(int, input().split()))
que = deque()
for i in range(k):
    que.append(a[i])
for i in range(k, n):
    if a[i] > que.popleft():
        print("Yes")
    else:
        print("No")
    que.append(a[i])

Measured memory_bytes: 95404
sub f{my$d=pop;
	$c[$_]//=$';
	if($d>$d[$_]&&$d>0){
		$d[$_]=$d;
		f($d-1)for@$_
	}
}
($N,$M)=glob<>;
map{push@$_,$_[--$|]for@_=<>=~/\d+/g}1..$M;
<>;
for(reverse<>){
	$_*=/ .* /;
	f$&
}
print$_+0,$/for@c[1..$N]


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


int l[52], t[52], r[52], b[52];
ll field[150][150];
int H, W;
const int dd[] = {0, 1, 0, -1, 0};

void dfs(int y, int x){
  ll c = field[y][x];
  field[y][x] = -1;
  for(int k=0;k<4;k++){
    int ny = y + dd[k], nx = x + dd[k + 1];
    if(ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
    if(field[ny][nx] == c){
      dfs(ny, nx);
    }
  }
}

int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;

    set<int> sx, sy;
    for(int i=0;i<n;i++){
      cin >> l[i] >> t[i] >> r[i] >> b[i];
      sx.insert(l[i]);
      sx.insert(r[i]);
      sy.insert(t[i]);
      sy.insert(b[i]);
    }

    map<int, int> mx, my;
    W = 1;
    for(int x : sx){
      mx[x] = W++;
    }
    H = 1;
    for(int y : sy){
      my[y] = H++;
    }
  
    for(int i=0;i<n;i++){
      l[i] = mx[l[i]];
      r[i] = mx[r[i]];
      t[i] = my[t[i]];
      b[i] = my[b[i]];
    }

    memset(field, 0, sizeof(field));
    for(int i=0;i<n;i++){
      for(int x=l[i];x<r[i];x++){
	for(int y=b[i];y<t[i];y++){
	  field[y][x] |= (1LL << i);
	}
      }
    }

    int ans = 0;
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	if(field[y][x] != -1){
	  ans++;
	  dfs(y, x);
	}
      }
    }

    cout << ans << endl;
  }

  return 0;
}

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

struct edge { ll to, cost; };

int main() {
	ll n, m, r;
	cin >> n >> m >> r;
	vector<ll> v(r);
	for (ll i = 0; i < r; ++i) {
		cin >> v[i];
		--v[i];
	}
	sort(v.begin(), v.end());
	vector<vector<ll>> g(n, vector<ll>(n, 1e15));
	for (ll i = 0; i < n; ++i)g[i][i] = 0;
	for (ll i = 0; i < m; ++i) {
		ll a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		g[a][b] = c;
		g[b][a] = c;
	}
	for (ll k = 0; k < n; ++k) {
		for (ll i = 0; i < n; ++i) {
			for (ll j = 0; j < n; ++j) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	ll ans = 1e18;
	do {
		ll preans = 0;
		for (ll i = 1; i < r; ++i) {
			preans += g[v[i - 1]][v[i]];
		}
		ans = min(ans, preans);
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void wri(ll x){write(x);pc(' ');}
inline void writeln(ll x){write(x);pc('\n');}
int main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	string t = s;
	reverse(t.begin(),t.end());
	s += t;
	string mi = s;
	rep(i,0,n)
		mi = min(mi,s.substr(i,n));
	k--;
	while(k--){
		char c=mi[0];
		int cs=0;
		while(cs<n && mi[cs] == c) cs++;
		if(cs==n) break;
		mi = (mi.substr(0,cs) + mi).substr(0,n);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

#define NMAX 200001

int v[NMAX], cost[NMAX];
__int128 s[NMAX];

__int128 solve(int k, int n) {
    __int128 sum = 0;
    int i = max(n - k + 1, 1);
    int j = n;
    int cnt = 1;
    while (i <= j && i >= 1 && j >= 1) {
        sum = sum + (__int128) cost[cnt] * (s[j] - s[i - 1]);
        j = i - 1;
        i = max(1, j - k + 1);
        cnt++;
    }
    return sum;
}

string to_string128(__int128 x) {
    string str;
    if (x == 0) {
        return "0";
    }
    while (x > 0) {
        str.push_back(x % 10 + '0');
        x = x / 10;
    }
    reverse(str.begin(), str.end());
    return str;
}

int main()
{
    int n, x;
    ios::sync_with_stdio(false);
    // ifstream cin("code.in");
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }

    for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] + (__int128) v[i];
    }
    cost[1] = 5;
    for (int i = 2; i <= n; i++) {
        cost[i] = 2 * i + 1;
    }

    __int128 sol = ((__int128)5) * s[n] + (__int128) n * x;
    for (int i = 1; i < n; i++) {
        __int128 aux = solve(i, n) + (__int128) i * x;
        sol = min(sol, aux);
    }

    cout << to_string128(sol + (__int128) n * x);

    return 0;
}


Measured memory_bytes: 4992
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;

vector<vector<vector<double>>> dp;

double dfs(ll a,ll b,ll c){
    if(dp[a][b][c]!=-1){return dp[a][b][c];}
    ll sum=a+b+c;
    if(sum==0){return dp[a][b][c]=0;}
    dp[a][b][c]=(double)n/sum;
    if(a!=0){dp[a][b][c]+=dfs(a-1,b,c)*(double)a/sum;}
    if(b!=0){dp[a][b][c]+=dfs(a+1,b-1,c)*(double)b/sum;}
    if(c!=0){dp[a][b][c]+=dfs(a,b+1,c-1)*(double)c/sum;}
    return dp[a][b][c];
}




int main(){
    cin>>n;
    dp.resize(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
    ll a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        ll k;
        cin>>k;
        if(k==1){a++;}
        if(k==2){b++;}
        if(k==3){c++;}
    }
    cout<<fixed<<setprecision(12)<<dfs(a,b,c)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 216960
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

struct panel {
	string name;
	int x1, y1, x2, y2;
	vector<panel> children;

	panel(const string &name_, int x1_, int y1_, int x2_, int y2_):name(name_), x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}

	void add_child(const panel &p) {
		children.emplace_back(p);
	}

	bool in_range(int x, int y) const {
		return x1 <= x && x <= x2 && y1 <= y && y <= y2;
	}

	string search(int x, int y) const {
		for(const auto &child : children) {
			if(child.in_range(x, y)) return child.search(x, y);
		}
		return name + ' ' + to_string(children.size());
	}
};

int number(string::const_iterator &it) {
	assert(isdigit(*it));
	int res = 0;
	while(isdigit(*it)) {
		res = res * 10 + *it - '0';
		++it;
	}
	return res;
}

panel parse(string::const_iterator &it) {
	assert(*it == '<');
	++it;

	string name;
	while(*it != '>') {
		name += *it;
		++it;
	}
	++it;

	const int x1 = number(it);
	assert(*it == ',');
	++it;
	const int y1 = number(it);
	assert(*it == ',');
	++it;
	const int x2 = number(it);
	assert(*it == ',');
	++it;
	const int y2 = number(it);

	panel res(name, x1, y1, x2, y2);
	while(true) {
		assert(*it == '<');
		if(*(it + 1) == '/') break;
		res.add_child(parse(it));
	}

	while(*it != '>') ++it;
	++it;
	return res;
}

string solve(const panel &root) {
	int x, y;
	cin >> x >> y;
	return root.in_range(x, y) ? root.search(x, y) : "OUT OF MAIN PANEL 1";
}

int main() {
	for(int n; cin >> n && n;) {
		string s;
		cin >> s;
		auto it = s.cbegin();
		const panel root = parse(it);

		for(int i = 0; i < n; ++i) {
			cout << solve(root) << endl;
		}
	}

	return EXIT_SUCCESS;
}

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

#define REP(i,n) for(int i = 0;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 INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int a,b,k;
    cin>>a>>b>>k;
    int counter=0;
    int ans=0;
    for(int i=b*a;counter<k;i--){
        if(a%i==0&&b%i==0){
            counter++;
        }
        ans=i;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	string Y[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string S; cin >> S;

	int cnt = 0;
	for(int i = 0; i < 7; ++i){
		if(Y[i] == S) cnt = i;
	}

	cout << 7-cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
int mod = 998244353;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
#define int long long
signed main() {
    int N, K; cin >> N >> K;
    vector<int>h(N);
    rep(i, N)cin >> h[i];
    sort(h.begin(),h.end());
    long long ans = 100000000000;
    for (int i = 0; i < N - K+1; i++) {
        ans = min(ans, h[i + K-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4060
fun main(args: Array<String>) {
    val h = readInteger()
    val w = readInteger()
    val n = readInteger()

    val t = Math.max(h, w)
    println((n + t - 1) / t)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 30044
//--------------------------------------//
#include <bits/stdc++.h>
//-------------------------------------//
#define faster  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define cs(i) printf("Case %d: ", i);
#define test int t; cin >>t; while(t--)
#define forI(n) for(i=0; i<n; i++)
#define eofstr string s; while(cin >>s)
#define eof int n; while(cin>>n)
#define Y cout <<"YES" <<endl;
#define N cout <<"NO" <<endl;
#define cube(x) (x*x*x)
#define sqr(x) (x*x)
#define pi acos(-1)

//-------------------------------------//
typedef unsigned long long ull;
typedef long long int lld;
typedef long double ld;
using namespace std;
//------------------------------------//
lld i, j, f, k, p;

int main()
{
    faster;
    lld n;
    cin >>n;
    lld ac=0, wa=0, tle=0, re=0;
    forI(n)
    {
        string s;
        cin >>s;
        if(s=="AC")
        {
            ac++;
        }
        else if(s=="WA")
        {
            wa++;
        }
        else if(s=="TLE")
        {
            tle++;
        }
        else if(s=="RE")
        {
            re++;
        }

    }
    cout <<"AC x " <<ac <<endl;
    cout <<"WA x " <<wa <<endl;
    cout <<"TLE x " <<tle <<endl;
    cout <<"RE x "<<re <<endl;
    return 0;
}



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

int main(void) {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int count = 0;

    for (int a = 0; a <= A; a++) {
        for (int b = 0; b <= B; b++) {
            for (int c = 0; c <= C; c++) {
                if (a * 500 + b * 100 + c * 50 == X) count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

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

int main(void)
{
	int A, B, C;
	int tmp;
	
	cin >> A;
	cin >> B;
	cin >> C;

	if (A >= B) {
		tmp = A;
		A = B;
		B = tmp;
	}
	if (C >= B) {
		tmp = C;
		C = B;
		B = tmp;
	}
	if (A == 5 && B == 7 && C == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;
const ll linf = 1LL<<60;

int main() {
  int n; ll k; cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -linf, r = linf;
  while(l + 1 < r) {
    ll x = (l+r) / 2;
    bool ok = [&] {
      ll tot = 0;
      rep(i, n) {
        if(a[i] < 0) {
          int l = -1, r = n;
          while(l + 1 < r) {
            int c = (l+r) / 2;
            if(a[c] * a[i] < x) r = c; else l = c;
          }
          tot += n - r;
        } else {
          int l = -1, r = n;
          while(l+1 < r) {
            int c = (l+r) / 2;
            if(a[c] * a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if(a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if(ok) l = x; else r = x;
  }
  cout << l << endl;

  return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    int p[MAX];
    bool s[MAX][MAX];
    bitset<10> light[MAX];
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int sw; cin >> sw;
            light[i].set(sw-1);
        }
    }

    for(int i = 0; i < m; i++){
        cin >> p[i+1];
    }

    int e = pow(2,n);
    int ans = 0;
    for(int i = 0; i < e; i++){
        bitset<10> bits(i);
        bool f = true;

        for(int j = 0; j < m; j++){
            if(p[j+1] != (bits & light[j]).count()%2) f = false;
        }
        if(f) ans ++;
    }

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

Measured memory_bytes: 256