akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.nodes = n
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
        self.rank = [0] * n

    def find(self, i): # どの集合に属しているか（根ノードの番号）
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i]) # 経路圧縮
            return self.parents[i]

    def unite(self, i, j): # 二つの集合を併合
        pi = self.find(i)
        pj = self.find(j)
        if pi != pj:
            if self.rank[pi] < self.rank[pj]:
                self.sizes[pj] += self.sizes[pi]
                self.parents[pi] = pj
            else:
                self.sizes[pi] += self.sizes[pj]
                self.parents[pj] = pi
                if self.rank[pi] == self.rank[pj]:
                    self.rank[pi] += 1
    def same(self, i, j): # 同じ集合に属するかを判定
        return self.find(i)==self.find(j)

    def get_parents(self): # 根ノードの一覧を取得
        for n in range(self.nodes): # findで経路圧縮する
            self.find(n)
        return self.parents

adj = []
N, M = map(int,input().split())
for m in range(M):
    a,b = map(int,input().split())
    adj.append([a-1,b-1])

uf = UnionFind(N)
for i in range(M): # 取り除く辺番号
    uf.unite(*adj[i])
    
ans=len(set(uf.get_parents())) # 複数の集合にわかれているか確認
    
print (ans-1)

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

class Prime
{
	ll i, iLimit;

public:
	bool isPrime(ll a);
};

bool Prime::isPrime(ll a)
{
	if (a == 1) return false;

	iLimit = (int)sqrt(a);
	for (i = 2; i <= iLimit; i++) {
		if (a % i == 0) break;
	}
	if (i == iLimit + 1) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	vector<ll> resA;
	for (ll i = 1; i <= sqrt(a); ++i) {
		if (a % i == 0 && i * i != a) {
			resA.push_back(i);
			resA.push_back(a / i);
		}
		else if (a % i == 0 && i * i == a)resA.push_back(i);
	}
	vector<ll> resB;
	for (ll i = 1; i <= sqrt(b); ++i) {
		if (b % i == 0 && i * i != b) {
			resB.push_back(i);
			resB.push_back(b / i);
		}
		else if (b % i == 0 && i * i == b)resB.push_back(i);
	}
	vector<ll> ans;
	for (int i = 0; i < resA.size(); ++i) {
		for (int j = 0; j < resB.size(); ++j) {
			if (resA[i] == resB[j]) ans.push_back(resA[i]);
		}
	}
	ll res = 0;
	bool elf;
	Prime objPrime;
	rep(i, ans.size()) {
		elf = objPrime.isPrime(ans[i]);
		if (elf) res++;
	}
	cout << res + 1 << endl;
	return 0;
}

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



int main(){
    ll a,b,ans,len;
    cin >> a >> b;
    //vector<string> s(n);
    for(int i=a;i<=b;i++){
        int k1 = i/10000;
        int k2 = i/1000%10;
        int k4 = i/10%10;
        int k5 = i%10;
        if(k1==k5&&k2==k4)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll ans = 1;
    rep(i,N) {
        if (A[i]==0) {
            cout << 0 << ln;
            return 0;
        }
    }
    ll MAX = 1e18;
    rep(i,N) {
        if (A[i] >= MAX*2/ans) {
            cout << -1 << ln;
            return 0;
        }
        ans *= A[i];
    }

    if (ans > MAX) {
        cout << -1 << ln;
        return 0;
    }

    cout << ans << ln;
}


Measured memory_bytes: 3948
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, spell)
  size = queue.size
  index = queue.index{|entry| entry[0] >= spell} || size
  return queue[index][1] if index < size && queue[index][0] == spell

  return nil if index > 0 && !spell.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(spell)

  nodes = {}
  queue.insert(index, [spell, nodes])
  nodes
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << arrow
  end

  limit = n * arrows.map{|arrow| arrow.label.size}.max

  queue = [['', {start => true}]]
  until queue.empty?
    spell, nodes = queue.shift
    return spell if nodes[goal]
    return nil if spell.size > limit

    nodes.each do |node, _|
      outs[node].each do |arrow|
        new_nodes = push(queue, spell + arrow.label)
        new_nodes[arrow.sink] = true if new_nodes
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 10732
// 155 A

#include <iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && a != c) || (a != b && a == c) || (a != b && b == c)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){

int n,i;
double sum1=0,sum2=0,sum3,max=0,ans[4];

scanf("%d",&n);
double x[n],y[n];
for(i=0;i<n;i++)
     scanf("%lf",&x[i]);
for(i=0;i<n;i++)
 scanf("%lf",&y[i]);
for(i=0;i<n;i++){

    sum1+=abs(x[i]-y[i]);
    if(abs(x[i]-y[i])>max)
        max=abs(x[i]-y[i]);

    sum2+=pow(abs(x[i]-y[i]),2);
    sum3+=pow(abs(x[i]-y[i]),3);

}


printf("%lf\n",sum1);
printf("%lf\n",sqrt(sum2));
printf("%lf\n",cbrt(sum3));
printf("%lf\n",max);

}




Measured memory_bytes: 2076
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  double x[n];
  string u[n];
  double ans = 0;
  rep(i,n) {
    cin >> x[i];
    cin >> u[i]; 
  }
  rep(i,n){
    if(u[i]=="JPY"){
      ans += x[i];
    }else{
      ans = ans+x[i]*380000.0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from functools import lru_cache

T = int(input())


def resolver(a, b, c, d):
    @lru_cache(maxsize=None)
    def _resolver(n):
        if n == 0:
            return 0
        elif n == 1:
            return d
        else:
            div5f = n // 5
            div5c = n // -5 * -1
            div3f = n // 3
            div3c = n // -3 * -1
            div2f = n // 2
            div2c = n // -2 * -1
            return min(
                d * n,
                d * abs(n - div5f * 5) + c + _resolver(div5f),
                d * abs(n - div5c * 5) + c + _resolver(div5c),
                d * abs(n - div3f * 3) + b + _resolver(div3f),
                d * abs(n - div3c * 3) + b + _resolver(div3c),
                d * abs(n - div2f * 2) + a + _resolver(div2f),
                d * abs(n - div2c * 2) + a + _resolver(div2c),
            )

    return _resolver


for _ in range(T):
    N, A, B, C, D = map(int, input().split(' '))
    print(resolver(A, B, C, D)(N))


Measured memory_bytes: 20720
#002
N = int(raw_input())
S = raw_input()
result = 0
list = [0]
for i in range(N):
    if S[i] == "I":
        result+=1
        list.append(result)
    else:
        result -=1
        list.append(result)
list.sort()
print(list[N])

Measured memory_bytes: 2568
n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
max_x = max(max(x), a)
x = [-10**6] + [xx-a for xx in x]
dp = [[0]*(2*n*max_x+1) for _ in range(n+1)]
dp[0][n*max_x] = 1

# import numpy as np
# print(np.shape(dp))

for i in range(1, n+1):
    for j in range(2*n*max_x+1):
        if j-x[i] < 0 or j-x[i] > 2*n*max_x:
            dp[i][j] = dp[i-1][j]
        elif j-x[i] >= 0 and j-x[i] <= 2*n*max_x:
            dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i]]

# print(np.array(dp))
print(dp[n][n*max_x]-1)
        


Measured memory_bytes: 5612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scin = new Scanner(System.in);
		String[] baseInput = scin.nextLine().split(" ");
		
		int numberOfProcesses = Integer.parseInt(baseInput[0]);
		int timeSlotLength = Integer.parseInt(baseInput[1]);
		
		Queue<String> queue = new LinkedList<>();
		
		for (int i = 0; i < numberOfProcesses; i++) {
			queue.add(scin.nextLine());
		}
		
		//now run it
		Queue<String> finished = new LinkedList<>();
		int totalElapsedTime = 0;
		
		while (queue.isEmpty() == false) {
			String[] rawParts = queue.remove().split(" ");
			int durrationLeft = Integer.parseInt(rawParts[1]);
			String name = rawParts[0];
			
			if (durrationLeft <= timeSlotLength) {
				finished.add(name + " " +(totalElapsedTime + durrationLeft));
				totalElapsedTime += durrationLeft;
			}else {
				durrationLeft -= timeSlotLength;
				
				totalElapsedTime += timeSlotLength;
				
				queue.add(name + " " +durrationLeft);
			}
		}
		
		while (finished.isEmpty() == false) {
			System.out.println(finished.remove());
		}
	}
}



Measured memory_bytes: 113744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	int N, W;
	cin >> N >> W;

	int w0, w[100], v[100];
	rep(i, N) {
		cin >> w[i] >> v[i];
	}
	w0 = w[0];
	rep(i, N) {
		w[i] -= w0;
	}

	int dp[101][101][401] = {};
	dp[0][0][0] = 1;

	rep(i, N) {
		rep(ii, 100) {
			rep(iii, 400) {
				if (dp[i][ii][iii]) {
					dp[i + 1][ii + 1][iii + w[i]] = max(dp[i + 1][ii + 1][iii + w[i]], dp[i][ii][iii] + v[i]);
					dp[i + 1][ii][iii] = max(dp[i + 1][ii][iii], dp[i][ii][iii]);
				}
			}
		}
	}

	int saidai = 1;
	rep1(ii, N) {
		rep(iii, 401) {
			if (1ll * ii * w0 + iii <= W) {
				saidai = max(saidai, dp[N][ii][iii]);
			}
		}
	}
	co(saidai - 1);

	Would you please return 0;
}

Measured memory_bytes: 16256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{   
	    string s = Console.ReadLine();
	    if(s.Contains("a") && s.Contains("b") && s.Contains("c"))
	    {
	        Console.WriteLine("Yes");
	    }
	    else
	    {
	        Console.WriteLine("No");
	    }
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
// #include <chrono>
// #include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846
 
ll power(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}
 
int pow(int a,int b){
	if(b == 0)return 1;
	int res = pow(a,b/2);
	res = res*res;
	if(b&1)res *= a;
	return res;
}

int ceil(int a,int b){
	if(a%b == 0)return a/b;
	return a/b+1;
}


bool compare(char c,char c1){
	if(c == '1')return true;
	else if(c == '2' && c1 == '0')return true;
	return false;
}



int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
    // int t;
    //  cin >> t;
 
 //     while(t--){

 // }

int n;
cin >> n;

int a = power(10,n);
int b = power(9,n);
int c = power(8,n);
a = (a- (2*b)%mod + mod)%mod;
a = (a+c)%mod;
cout << a << endl;

return 0;
	
	}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

void print(std::vector<std::string>& array){
  bool first = true;;

  for(int i = 0; i < array.size(); ++i){
    if(!first){
      std::cout << " ";
    }else{
      first = false;
    }

    std::cout << array[i];
  }

  std::cout << std::endl;
}

int main(int argc,char* argv[]){
  int n;
  std::cin >> n;

  std::vector<std::string> bubble(n), selection(n);
  
  for(int i = 0; i < n; i++){
    std::string tmp;
    std::cin >> tmp;
    bubble[i] = selection[i] = tmp;
  }

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

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

    for(int j = i; j < n; j++){
      if(selection[j][1] < selection[min][1]){
	min = j;
      }
    }

    swap(selection[i], selection[min]);
  }
  
  bool same = true;
  for(int i = 0; i < n; i++){
    if(bubble[i] != selection[i]){
      same = false;
      break;
    }
  }

  print(bubble);
  std::cout << "Stable" << std::endl;
  print(selection);
  std::cout << (same ? "Stable" : "Not stable") << std::endl;
  return 0;
  
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, Q;
  cin >> N;
  vector <long> freq(100000, 0);
  long sum = 0L;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    freq[a - 1]++;
    sum += a;
  }
  
  cin >> Q;
  vector <long> B(Q);
  vector <long> C(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> B[i];
    cin >> C[i];
  }
  
  for (int i = 0; i < Q; ++i) {
    sum -= B[i] * freq[B[i] - 1];
    sum += C[i] * freq[B[i] - 1];
    freq[C[i] - 1] += freq[B[i] - 1];
    freq[B[i] - 1] = 0;
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	int count;
	while (cin >> n, !cin.eof())
	{
		count = 0;
		vector<int> p(n + 1, 1);
		p[1] = 0;
		for (int i = 2; i * i <= n; i++)
		{
			if (p[i] == 0) continue;
			for (int j = 2; i * j <= n; j++)
			{
				p[i * j] = 0;
			}
		}
		for (int i = 1; i <= n; i++)
		{
			count += p[i];
		}
		cout << count << endl;
	}
	return 0;
}


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

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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int h = 0;
    int g = s.size();
    rep(i, g){
        if(s[i] == 'o') h ++;
    }
    
    if(15 - g + h >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

void OutputNo() {
  cout << -1 << endl;
  exit(0);
}

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  ll x = 0;
  for (int i = 2; i < n; ++i) x ^= a[i];

  ll s = a[0] + a[1];
  vector<ll> v;
  for (ll b = 0; b < 60; ++b) if (x & (1LL << b)) {
    s -= 1LL << b;
    v.push_back(b);
  }

  vector<ll> w;
  for (ll b = 0; b < 60; ++b) if (s & (1LL << b)) {
    if (b == 0) OutputNo();
    if (find(v.begin(), v.end(), b - 1) != v.end()) OutputNo();
    w.push_back(b - 1);
  }

  //cerr << "x: " << x << endl;

  //cerr << "v: "; for (ll t : v) cerr << t << " "; cerr << endl;
  //cerr << "w: "; for (ll t : w) cerr << t << " "; cerr << endl;

  ll m = 0;
  for (ll b : w) m += 1LL << b;
  if (m > a[0]) OutputNo();
  sort(v.rbegin(), v.rend());
  for (ll b : v) if (m + (1LL << b) <= a[0]) m += 1LL << b;
  if (m == 0) OutputNo();
  //cerr << "m = " << m << endl;

  cout << a[0] - m << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,k,q,a[100005]={},cnt[100005]={},p[100005]={0};
  cin >> n >> k >> q;
  for(int i=0; i<q; i++) {
    cin >> a[i];
    p[a[i]-1]++;
  }
  for(int i=0; i<n; i++) {
    cnt[i]=k;
  }
  for(int i=0; i<n; i++) {
    if(cnt[i]-(q-p[i])>0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int debt = 100000;
        int day = in.nextInt();
        for(int i = 0; i < day; i++){
            debt = (debt * 105 / 100 + 999) / 1000 * 1000;
        }
        System.out.println(debt);
    }
}

Measured memory_bytes: 17148
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
		long k = sc.nextLong();
		System.out.println(n*k-n-k+1);


	}


	public static boolean cIstrue(BigDecimal cc){
		BigDecimal forty = new BigDecimal("140");
		BigDecimal fseventy = new BigDecimal("170");
		int yon=cc.compareTo(forty);
		int nana=cc.compareTo(fseventy);

			// System.out.println("if140  "+yon);
			// System.out.println("if170  "+nana);
		if(yon==(-1)||yon==0){
			// System.out.println("goalFalse"+cc);
			return false;
		}
		if(nana==(-1)){
			// System.out.println("goalTrue"+cc);
			return true;
		}
		if(nana==(1)||nana==0){
			BigDecimal two = new BigDecimal("2");
			return cIstrue(cc.divide(two));
		}
		return false;
	}
}

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

int main() {
  ll n, k, ans1 = 0, ans2 = 0;
  cin >> n >> k;

  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i < j && a[i] > a[j])
        ans1++;
      else if (i > j && a[i] > a[j])
        ans2++;
    }
  }

  cout << ((ans1 * k) % mod +
           (((ans1 + ans2) % mod) * (((k * (k - 1)) / 2) % mod)) % mod) %
              mod
       << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int res = 0;

    if (a > b) res += a--; 
    else res += b--;
    if (a > b) res += a--; 
    else res += b--;

    cout << res << "\n";
}

Measured memory_bytes: 256
' Imports System.Collections.Generic
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim A, B As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        A = arr(0) : B = arr(1)
        Dim ans As Integer = 0
        DIm cur As Integer = 1
        While cur < B
            ans += 1
            cur += A - 1
        End While
        Console.WriteLine(ans)
        Return
    End Sub
End Class

Measured memory_bytes: 28384
import sys


def input():
    return sys.stdin.readline().strip()


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

INF = 10 ** 9
dp = [INF] * n
dp[0] = 0
for i in range(n - 1):
    for j in range(1, k + 1):
        if j >= n - i:
            break
        dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]))
print(dp[-1])


Measured memory_bytes: 52448
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
int tz(int n) 
{ 
    int cnt = 0; 
    for (int i = 5; n / i >= 1; i *= 5) 
        cnt += n / (i); 
  
    return cnt; 
} 
void sol() {
    int n;
    cin >> n;
    if(n % 2) {
        cout << 0;
        return;
    }
    n /= 2;
    cout << tz(n);
    
    //cout << (n % 2 == 0) ? tz(n) : 0;
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H, W;
  cin >> H >> W; 
  // ここにプログラムを追記
  // (ここで"試合結果の表"の2次元配列を宣言)
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
  cin >> data.at(i).at(j);
    }
  }
  
  vector<int> width(W,0);
  vector<int> high(H,0);
  
  
  int Hsyorisuu =0;
  //横の行の検査
  for (int i = 0; i < H; i++) {
    int count=0;
    for (int j = 0; j < W; j++) {
      if(data.at(i).at(j) == '.'){count++;}
    }
    if (count == W){ 
      high.at(i) = 1;
      Hsyorisuu++;
    }
  }
  
  //行の消去
  int syorisuu=0;
  int tobasitaNo=0;
  vector<vector<char>> gyousyoridata(H-Hsyorisuu, vector<char>(W));
   for (int i = 0; i < H; i++) {
     if(high.at(i) == 1 ){ 
       tobasitaNo++;
       continue; }
    for (int j = 0; j < W; j++) {
  gyousyoridata.at(i-tobasitaNo).at(j) = data.at(i).at(j);
    }
  }
  
  int Wsyorisuu =0;
 //縦の行の検査
  for (int i = 0; i < W; i++) {
    int count=0;
    for (int j = 0; j < H-Hsyorisuu; j++) {
      if(gyousyoridata.at(j).at(i) == '.'){count++;}
    }
    if (count == H-Hsyorisuu){ 
      width.at(i) = 1;
      Wsyorisuu++;
    }
  }   
  
  //縦の行の消去
  syorisuu=0;
  tobasitaNo=0;
  vector<vector<char>> gyouretsusyoridata(H-Hsyorisuu, vector<char>(W-Wsyorisuu));
   for (int i = 0; i < W; i++) {
     if(width.at(i) == 1 ){ 
       tobasitaNo++;
       continue; }
    for (int j = 0; j < H-Hsyorisuu; j++) {
  gyouretsusyoridata.at(j).at(i-tobasitaNo) = gyousyoridata.at(j).at(i);
    }
  }
  
  for (int i = 0; i < H-Hsyorisuu; i++) {
    for (int j = 0; j < W-Wsyorisuu; j++) {
    cout << gyouretsusyoridata.at(i).at(j);
  if (j == W-Wsyorisuu-1) {
    cout << endl; // 末尾なら改行
  }
}
}
//*/
}

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

struct Node {
    vector<pair<int, int> > to;
    int cost;
    bool isDone;
};

const int MAX_N = 20;
Node nodes[MAX_N + 1];
int n;

int Dijkstra(int start, int end) {
    for (int i = 1; i <= n; i++) {
        nodes[i].isDone = false;
        nodes[i].cost = -1;
    }
    nodes[start].cost = 0;
    while (true) {
        int min_idx = -1;
        for (int i = 1; i <= n; i++) {
            if (nodes[i].isDone == true || nodes[i].cost < 0) {
                continue;
            }
            if (min_idx < 0 || nodes[i].cost < nodes[min_idx].cost) {
                min_idx = i;
            }
        }
        if (min_idx < 0) {
            break;
        }
        nodes[min_idx].isDone = true;
        for (vector<pair<int, int> >::iterator it = nodes[min_idx].to.begin(); it != nodes[min_idx].to.end(); it++) {
            int to = it->first;
            int cost = nodes[min_idx].cost + it->second;
            if (nodes[to].cost < 0 || cost < nodes[to].cost) {
                nodes[to].cost = cost;
            }
        }
    }
    return nodes[end].cost;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c, d;
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        nodes[a].to.push_back(make_pair(b, c));
        nodes[b].to.push_back(make_pair(a, d));
    }
    int x1, x2, y1, y2;
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
    cout << y1 - y2 - Dijkstra(x1, x2) - Dijkstra(x2, x1) << endl;
}

Measured memory_bytes: 0
N = int(input())
d = {}
for D in map(int, input().split()):
    d[D] = d.get(D, 0) + 1
M = int(input())
for T in map(int, input().split()):
    if T in d:
        d[T] -= 1
        if d[T] < 0:
            print('NO')
            exit(0)
    else:
        print('NO')
        exit(0)
print('YES')

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

for i in range(n):
  if s[i] == "c":
    print("No")
  elif s[i] == "b" and b:
    print("Yes")
    b -= 1
  elif s[i] == "a" and a:
    print("Yes")
    a -= 1
  elif s[i] == "a" and b:
    print("Yes")
    b -= 1
  else:
    print("No")

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

int main(){
	int n,y;
	cin>>n>>y;
 
	bool ans=false;
 
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int k=n-i-j;
			int maney=i*10000+j*5000+k*1000;
			if(y==maney){
				ans=true;
				cout<<i<<' '<<j<<' '<<k<<endl;
				break;
			}
		}
		if(ans) break;
	}
 
	if(!ans){
		cout<<-1<<' '<<-1<<' '<<-1<<endl;
	}
 
	return 0;
}

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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;

int gcd(int a, int b);
int lcm(int a, int b);



void solve() {
  string n;
  cin >> n;
  bool check = false;
  REP(i, n.length()) {
    string val = {n[i]};
    if (val == "7") check = true;
  }
  cout << (check ? "Yes": "No") << endl;
  
}

int main() {
  solve();
  return 0;
}

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

int lcm(int a, int b){
    return a * b / gcd(a,b);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    
	ios::sync_with_stdio(0);cin.tie(0);
	n=read();m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
/*
Nearly 崩溃！！！做了一天 
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<LL,LL> mp;
typedef pair<mp,mp> superpair;
mp ant[100000+1];
LL n,l,t; 
int main(){
	fastio;
	cin>>n>>l>>t;
	LL cur=0;
	vector<LL> v;
	rb(i,1,n){
		cin>>ant[i].FIR>>ant[i].SEC;
		if(ant[i].SEC==2) ant[i].SEC=-1;
		v.PB(((LL)ant[i].FIR+ant[i].SEC*t+(LL)l*t)%l);
		cur+=(ant[i].FIR+ant[i].SEC*t)/l;
		if((ant[i].FIR+ant[i].SEC*t)%l<0) cur--;
	}
	sort(ALL(v));
	cur=(cur%n+n)%n;
//	cout<<cur<<endl;
	rb(i,cur,v.size()-1) cout<<v[i]<<endl;
	rep(j,cur) cout<<v[j]<<endl;
	return 0;
}


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

using namespace std;

const int N = 1e5 + 100;
const int H = 1e4 + 10;

int h[N];
const int inf = 2e9;

struct SegmentTree {
    vector<int> IT;
    int n;
    
    SegmentTree() {}
    SegmentTree(int n):n(n), IT(n * 4 + 100, inf) {}

    void Up(int u, int val) { Up(1, 1, n, u, val); }
    int Min(int u, int v) { return Min(1, 1, n, u, v); }
private:
    void Up(int k, int l, int r, int u, int val) {
        if (l == r) {
            IT[k] = val;
            return;
        }
        int m = (l + r) >> 1;
        if (u <= m) Up(k << 1, l, m, u, val);
        else Up(k << 1 | 1, m + 1, r, u, val);
        IT[k] = min(IT[k << 1], IT[k << 1 | 1]);
    }
    int Min(int k, int l, int r, int u, int v) {
        if (l > v || r < u) return inf;
        if (u <= l && r <= v) return IT[k];
        int m = (l + r) >> 1;
        return min(Min(k << 1, l, m, u, v), Min(k << 1 | 1, m + 1, r, u, v));
    }
};

int dp[N];
deque<int> deq[H];
SegmentTree ITSmaller(H); // maintain dp[pos] - i
SegmentTree ITLarger(H); // maintain dp[pos] + i

void Add(int h, int pos) {
    while (!deq[h].empty() && dp[deq[h].back()] >= dp[pos]) deq[h].pop_back();
    if (deq[h].empty()) {
        ITSmaller.Up(h, dp[pos] - h);
        ITLarger.Up(h, dp[pos] + h);   
    }
    deq[h].push_back(pos);
}

void Erase(int h, int pos) {
    if (deq[h].front() == pos) {
        deq[h].pop_front();
        if (deq[h].empty()) {
            ITSmaller.Up(h, inf);
            ITLarger.Up(h, inf);
        } else {
            pos = deq[h].front();
            ITSmaller.Up(h, dp[pos] - h);
            ITLarger.Up(h, dp[pos] + h);
        }
    }    
}

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    dp[1] = 0;
    Add(h[1], 1);
    for (int i = 2; i <= n; ++i) {
        dp[i] = min(ITSmaller.Min(1, h[i]) + h[i], ITLarger.Min(h[i] + 1, H) - h[i]);
        Add(h[i], i);
        if (i > k) {
            Erase(h[i - k], i - k);
        }
    }
    cout << dp[n] << '\n';
}

Measured memory_bytes: 8064
import java.io.*;

class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        String[] str1 = br.readLine().split(" ");
        int r = Integer.parseInt(str1[0]);
        int c = Integer.parseInt(str1[1]);
        int[][] data = new int[r][c];
        int[] sumR = new int[r];
        int[] sumC = new int[c];
        int sumX = 0;

        // r x c ????¨??????\????????????????´???????
        for(int i=0; i<r; i++){
            String[] str2 = br.readLine().split(" ");
            for(int k=0; k<c; k++){
                data[i][k] = Integer.parseInt(str2[k]);
            }
        }

        // sumR ??¨ sumX ????¨??????????
        for(int i=0; i<r; i++){
            for(int k=0; k<c; k++){
                sumR[i] += data[i][k];
            }
            sumX += sumR[i];
        }
        // sumC ????¨??????????
        for(int i=0; i<c; i++){
            for(int k=0; k<r; k++){
                sumC[i] += data[k][i];
            }
        }

        // ??????
        for(int i=0; i<r; i++){
            for(int k=0; k<c; k++){
                sb.append(data[i][k]).append(" ");
            }
            sb.append(sumR[i]).append("\n");
        }
        for(int k=0; k<c; k++){
            sb.append(sumC[k]).append(" ");
        }
        sb.append(sumX).append("\n");

        System.out.print(sb);
    }
}

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

typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "


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

  ll n,i;
  cin>>n;
  ll a[n+1];


  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll dp[n+1];
dp[n-1]=0;
dp[n-2] = abs(a[n-1]-a[n-2]);
  for(i=n-3;i>=0;i--)
  {
    dp[i]=min((ll)abs(a[i+1]-a[i])+dp[i+1],(ll)abs(a[i+2]-a[i])+dp[i+2]);
  }

  cout<<dp[0];

  return 0;
 }

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		List<Double> v = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			v.add(sc.nextDouble());
		}
		v.sort(null);
		while (v.size() > 1) {
			double vv = (v.remove(0) + v.remove(0)) / 2;
			v.add(0, vv);
		}
		System.out.println(v.get(0));
	}
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a[3];  cin >> n >> a[0] >> a[1] >> a[2];
	vector<string> q(n);
	for(int i=0;i<n;i++)cin>>q[i];
	vector<char> result;
	for (int i = 0; i < n; ++i)
	{
		string s = q[i];
		int x = s[0] - 'A';
		int y = s[1] - 'A';
		if (!a[x] && !a[y])
		{      
			result.clear();
			break;
		}
	    if (a[x] > a[y])
		{
			--a[x];++a[y];
			result.push_back(s[1]);
			continue;
		}
	    if (a[x] < a[y])
		{
			++a[x]; --a[y];
			result.push_back(s[0]);
			continue;
		}
	    if (i + 1 < n && q[i + 1].find(s[0]) != string::npos)
		{
			++a[x]; --a[y];
			result.push_back(s[0]);
			continue;
		}
	    --a[x]; ++a[y];
		result.push_back(s[1]);
	}
	if (result.empty())
	{
		cout<<"No\n";
		return 0;
	}
	cout << "Yes\n"; 
	for(int i=0;i<result.size();i++)cout<<result[i]<<endl;
}

Measured memory_bytes: 6700
n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])

t=[0]*n
for i in range(n-1):
  if s[i:i+2]=='AC':
    t[i+1]=t[i]+1
  else:
    t[i+1]=t[i]
for i in range(q):
  l=lr[i][0]
  r=lr[i][1]
  print(t[r-1]-t[l-1])


Measured memory_bytes: 22900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n, m, ans=0;
	cin >> n >> m;
	vi a(m), b(m);
	vector<tuple<int, int>> vt;
	rep(i, m) {
		cin >> a[i] >> b[i];
		tuple<int, int> t = tie(a[i], b[i]);
		vt.push_back(t);
	}
	sort(all(vt),compare());
	int tgt = -1;
	rep(i, vt.size()) {
		if (tgt < get<0>(vt[i])) {
			ans++;
			tgt = get<1>(vt[i]) - 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2168
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string str1;
	char mozi[11],ring[101][11];
	int N,ring2=0;
	scanf("%s",mozi);
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%s",ring[i]);
		str1+=ring[i];
		str1+=ring[i];
		std::string::size_type index = str1.find(mozi);
		if(index==std::string::npos){
		}
		else 
			ring2++;
		str1.clear();
	}
	printf("%d\n",ring2);
	return 0;
}

Measured memory_bytes: 1228
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT A.
  ACCEPT B.
  COMPUTE ans = 6 - A - B.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3776
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
int cnt = 0;
int main() {
	int T, temp;
	cin >> T;
	vector<int> arr;
	for (int i = 0; i < T; i++) {
		cin >> temp;
		arr.push_back(temp);
	}
	sort(arr.begin(), arr.end());
	for (int i = 0; i < T-2; i++) {
		for (int j = i + 1; j < T - 1; j++) {
			for (int h = j + 1; h < T; h++) {
				if (arr[h] == arr[j] || arr[j] == arr[i] || arr[h] == arr[i]) continue;
				if (arr[h] < arr[i] + arr[j]) { cnt++; }
				//cout << "h : " << arr[h] << " i : " << arr[i] << " j : " << arr[j] << endl;
			}
		}
	}
	cout << cnt;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	long long A, B, C, K;
	cin >> A >> B >> C >> K;
	if (abs(A - B) > pow(10, 18)) cout << "Unfair" << endl;
	else cout << (K % 2 == 0 ? A - B : B - A) << endl;
}

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

typedef long long ll;

int main() {
	int A , B , K ; cin >> A >> B >> K ;
for ( int i = min (A , B ); i >= 1; --i ) {
if ( A % i == 0 && B % i == 0) {
--K ;
if ( K == 0) {
cout << i << endl ;
return 0;
}
}
}
}



















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

int main(){
    int s, m, h, n;
    //sを秒、mを分、hを時間とするn
    cin >> n;
    
    h = n / ( 60 * 60 );
    m = (n - h * (60 * 60)) / 60;
    s = n - h * 60 * 60 - m * 60;
    cout << h << ":" <<  m <<  ":" << s << endl;
}


Measured memory_bytes: 3096
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
num_count = [0]*(10**5+1)
for x in a:
    num_count[x] += 1
for i in range(10**5+1):
    if i+2<=10**5:
        ans = max(ans,sum(num_count[i:i+3]))
print(ans)


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

string query(int n) {
	cout << n << '\n' << flush;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (true) {
		int m = (l + r) / 2;
		R = query(m);
		if (L == R && m % 2) r = m;
		if (L == R && !(m % 2)) l = m;
		if (L != R && m % 2) l = m;
		if (L != R && !(m % 2)) r = m;
	}
	return 0;
}

Measured memory_bytes: 3820
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let mut n: i32;
    let mut i = 1;
    loop {
        n = read_line().parse().unwrap();
        if n == 0 {
            break;
        }
        println!("Case {}: {}", i, n);
        i = i + 1;
    }
}



Measured memory_bytes: 5044
#include <iostream>
#include <vector>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, k, q;
  cin >> n >> k >> q;
  
  vector<int> player(n + 1, 0);
  
  for(int i = 0; i < q; i++){
    int ki;
    cin >> ki;
    player[ki]++;
  }
  
  for(int i = 1; i < player.size(); i++){
    if(k - q + player[i] > 0) cout << "Yes"<<'\n';
    else	cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    string s;cin>>s;
    if(s[1]=='R')s[1]='B';
    else s[1]='R';
    cout<<s;
    return 0;  
} 





Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int p[10][10];

int main(){
    string p="0123456789543210123456788954321012345678";
    int n;
    cin>>n;
    rep(roop,n){
        int a,b;
        cin>>a>>b;
        int c=0;
        vector<int> ans[2];
        rep(i,p.size()){
            if(p[i]=='0'+a&&c<2){
                for(int j=i;j<p.size();j++){
                    ans[c].pb(p[j]-'0');
                    if(p[j]=='0'+b)break;
                }
                c++;
            }
        }
        vector<int> out;
        if(ans[0].size()<ans[1].size())out=ans[0];
        else out=ans[1];
        
        rep(i,out.size()){
            if(i!=0)cout<<" ";
            cout<<out[i];
        }
        cout<<endl;
    }
    
}

Measured memory_bytes: 1228
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>

int main (){
	int N;
	scanf("%d",&N);
	std::vector<int> x(N);
	std::vector<int> y(N);
	for (int i=0; i<N; i++){
		scanf("%d",&x[i]);
		scanf("%d",&y[i]);
	}
	double ans = 0;
	for (int i=0;i <N; i++){
		for (int j=i; j<N; j++){
			ans += sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))*2;
		}
	}
	ans /= (double)N;
	printf("%lf\n",ans);
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll N, K;

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

    std::cin >> N >> K;

    ll x = N / K;
    ll c;
    
    if(K % 2 == 1){
        c = x * x * x;
    }else{
        ll y = N / (K / 2);
        
        c = (y - x) * (y - x) * (y - x) + x * x * x;
    }

    std::cout << c << std::endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int K = cin.nextInt();

        for (int i = A; i <= B; i++)
        {
            if (i < A + K || B - K < i)
            {
                Console.WriteLine(i);
            }
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define INFLL (long long)1e14
#define Loops(i, n) for(int i = 0; i < (int)n; i++)
#define Loops1(i, n) for(int i = 1; i <= (int)n; i++)
int counter[100010];
int main(void){
	int N;
	std::cin>>N;
	Loops(i,N){
		counter[i]=0;
	}
	Loops(i,N){
		int x;
		std::cin>>x;
		counter[x]++;
	}
	Loops(i,N){
		if(N%2==1){
			if(i==0){
				if(counter[0]!=1){
					std::cout<<"0"<<std::endl;
					return 0;
				}
			}else {
				if(i%2==0 && counter[i]!=2){
					std::cout<<"0"<<std::endl;
					return 0;
				}
			}
		}else {
			if(i==1){
				if(counter[1]!=2){
					std::cout<<"0"<<std::endl;
					return 0;
				}
			}else {
				if(i%2==1 && counter[i]!=2){
					std::cout<<"0"<<std::endl;
					return 0;
				}
			}
		}
	}
	int kakeru=N/2;
	long long int ans=1;
	Loops(i,kakeru){
		ans*=2;
		ans%=1000000007;
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 640