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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    i64 n = input();
    vector< int > as(n);
    cin >> as;

    vector< i64 > cnt(1000001);
    for (auto a: as) cnt[a]++;

    int ans = 0;
    range(i, 0, cnt.size()) {
        if (cnt[i] == 0) continue;
        if (cnt[i] != 1) cnt[i] = 0;
        for (int j = i * 2; j < cnt.size(); j += i) {
            cnt[j] = 0;
        }
    }
    
    cout << whole(accumulate, cnt, 0ll) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 11908
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  while(true){
  string W;
  cin >> W;
  if(W=="-")
    break;

  int n=0;
  cin >> n;

  for(int i=0; i<n; i++){
    int in;
    cin >> in;
    string left = W.substr(0, in);
    string right = W.substr(in, W.size());
    W = right + left;
  }

  cout << W << endl;
  }
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(void) {
	int i; //??????????????°
	int n; //???????????°
	int x1, x; //1???????????°???????????\????????°
	int minv, maxv; //????°????????????§??????

	scanf("%d", &n);

	scanf("%d", &x1);

	minv = x1;
	maxv = -1000000000;

	for(i = 1; i < n; i++) {
		scanf("%d", &x);
		if(x - minv > maxv) {
			maxv = x - minv;
		}
		if(x < minv) {
			minv = x;
		}
	}

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

	return 0;
}

Measured memory_bytes: 596
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
lc = 0
aonly = 0
bonly = 0
abboth = 0
intab = 0
while l = $stdin.gets do
  if lc == 0
  else
    input = l.chomp
    intab += input.scan("AB").length
    if input[0..0] == "B"
      if input[-1..-1] == "A"
        abboth += 1
      else
        bonly += 1
      end
    elsif input[-1..-1] == "A"
      aonly += 1
    end
  end
  lc += 1
end

print "abboth:" if $debugFlag
pd abboth
print "aonly:" if $debugFlag
pd aonly
print "bonly:" if $debugFlag
pd bonly
print "intab:" if $debugFlag
pd intab

# body

min = [aonly, bonly].min
max = [aonly, bonly].max

delta = 0
if (max - min) < abboth
  delta = abboth - (max - min)
  if max == 0 and min == 0
    delta -= 1
  end
end

puts intab + min + [(max - min), abboth].min + delta


Measured memory_bytes: 1788
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
using namespace std;

#define ll                                      long long
#define pb                                      push_back
#define pf                                      push_front
#define eb                                      emplace_back
#define mp                                      make_pair
#define ff                                      first
#define ss                                      second
#define db                                      long double
#define pll                                     pair<ll, ll>
#define ALL(a)                                  (a).begin(),(a).end()
#define endl                                    "\n"

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define ford1(i, n) for (int i = int(n) - 1; i >= 1; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabd(i, a, b) for(int i = int(a); i >= int(b); i--)

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0)

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define tracen( x , n ){ cerr<<(#x)<<": ";for(int i=0;i<int(n);i++)cerr<<(#x)<<"["<<i<<"]:"<< x[i] << "    "; cerr<<endl;}
#define tracenm( x , n , m ){ cerr<<(#x)<<endl;for(int i=0;i<int(n);i++){ cerr<<"Row #"<<i<<": "; for(int j=0;j<int(m);j++) cerr<<x[i][j]<<"     "; cerr << endl;}}
#define trace(v){ cerr<<#v<<": ";for(auto it=v.begin();it!=v.end();it++)cerr<<*it<<" ";cerr<<endl;}


const ll sz = 1e5 + 2;
const ll mod = 1e9 + 7;
const db PI = acos(-1);
const db eps = 1e-10;
const ll INF = 1e18;



typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;
typedef vector<vector<vector<ll> > > VVVL;



ll power(ll n, ll k, ll m) {
	ll ans = 1;
	while (k) {
		if (k & 1)ans = (ans * n) % m;
		k /= 2;
		n = (n * n) % m;
	}
	return ans;
}

void solver() {
	db a,b;cin>>a>>b;
	cout<<(ll)(a*b)<<endl;
}


int main() {
	IOS;
	ll T = 1; //cin >> T;
	forn1(i, T + 1) {
		clock_t z = clock();
		solver();
		debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	}
	return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>
int main(){
  int n,i,j,p[200001],count=0,min;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  min=p[0];
  for(i=0;i<n;i++){
    if(min>p[i]) min=p[i];
    if(p[i]<=min) count++;
  }
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 896
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>   
#include <functional>

#define lnd '\n'
#define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mkp make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

void solution();

template <class T>
T GCD (T a, T b) {
  if(b == 0) return a;
  return GCD(b, a%b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
        cout << endl;
    }else if(a == b){
        for(int i = 0; i < min(a,b); i++) cout << a;
        cout << endl;
    }else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    if (A == B) {
      System.out.println(C);
    } else if (A == C) {
      System.out.println(B);
    } else {
      System.out.println(A);
    }

  }
}

Measured memory_bytes: 22740
A, B, M = map(int, input().split())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
xyclist = [list(map(int, input().split())) for _ in range(M)]
am, bm = min(alist), min(blist)
ans = am + bm

for x, y, c in xyclist:
    ans = min(ans, alist[x-1]+blist[y-1]-c)
print(ans)


Measured memory_bytes: 80324
#include <stdio.h>

int main(void){
	int i,x,y;
	x = 1;
	y = 1;

	for(i=0;i<3000;i++){
		while(x != 0 || y != 0){
			scanf("%d %d",&x,&y);
			if(x != 0 || y !=0){
			if(x>y){
				printf("%d %d\n",y,x);
			}
			else if(x == y){
				printf("%d %d\n",x,y);
			}
			else if(x<y){
				printf("%d %d\n",x,y);
			}
			}
		}
		if(x == 0 && y == 0)break;
	}
	return 0;
}

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

int main() {
	string w;
	string t;
	int count = 0;
	cin >> w;

	while (1) {
		cin >> t;
		if (t == "END_OF_TEXT") break;
		for (int i = 0; i < t.length(); i++) t[i] = tolower(t[i]);
		if (w == t) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main (){
  string s;
  cin >> s;
  for (int i=0;i<4;i++){
    if(s[i]==s[i+1]){
      cout <<"Bad" << endl; return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets


def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)



n,k=input2()
h=input_array()
count=0
for i in range(n):
	if h[i]>=k:
		count+=1
print(count)



Measured memory_bytes: 23240
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;

ll dp[11][1111][111];

ll solve(int a,int b,int pre)
{
  if(a<0||b<0)return 0;
  if(a==0 && b==0)return 1;
  if(dp[a][b][pre]>=0)return dp[a][b][pre];
  ll res = 0;
  for(int i = pre; i <= 100; i++) {
    res += solve(a-1,b-i,i+1);
  }
  return dp[a][b][pre] = res;
}

int main(void)
{
  int n,s;
  memset(dp,-1,sizeof(dp));
  for(;;) {
    scanf("%d%d",&n,&s); if(!n)break;
    printf("%lld\n",solve(n,s,0));
  }
  return 0;
}

Measured memory_bytes: 11632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <limits.h>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i];
    }
    int ans=0;
    int i=0;
    while(i<n){
        if(da[i]%2){
            i++;
        }
        else{
            ans++;
            da[i]/=2;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    stringstream ss;
    // 入力
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int price=0;
    if(2*C>A+B) {
        price=X*A+Y*B;
    }
    else if (X>Y)
    {
        if(2*C<A){
            price=2*C*X;

        }
        else{
            price=2*C*Y+(X-Y)*A;
        /* code */
        }
    }
    else if(Y>=X)
    {
        if(2*C<B){
            price=2*C*Y;
        } else{
            price=2*C*X+(Y-X)*B;
        }

    }
    cout<<price<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){

  int n, i, x, k;
  vector<int> h;

  cin >> n >> k;
  for ( int i = 0; i < n; i++ ){
    cin >> x;
    h.push_back(x);
  }

  vector <int> rasp (n + 1);

  rasp[n - 1] = 0;
  for ( int i = n - 2; i >= 0; i-- ){
    if ( i + k >=  n ){
      rasp [i] = rasp[i + 1] + abs(h[i + 1] - h[i]);
      for ( int j = 2; i + j < n ; j++ )
      rasp [i] =  min ( rasp[i + j] + abs(h[i + j] - h[i]), rasp[i]);
    }
    else {
      rasp [i] = rasp[i + 1] + abs(h[i + 1] - h[i]);
      for ( int j = 2; j <= k; j++ )
      rasp [i] =  min ( rasp[i + j] + abs(h[i + j] - h[i]), rasp[i]);
    }
  }
  cout << rasp[0];

  return 0;
}


Measured memory_bytes: 1144
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

int n;
Vi v[100001];
int col[100001];
void dfs(int N,int p)
{
	int c=0;
	for(int next:v[N])
	{
		if(next==p)continue;
		dfs(next,N);
		if(col[next]==0)col[N]=1;
	}
}
int main(){
	scanf("%d",&n);
	if(n&1)return !printf("First");
	fup(i,1,n-1,1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1,-1);
	int cnt=0;
	fup(i,1,n,1)if(col[i])cnt++;
	puts(cnt==n/2?"Second":"First");
}

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

int main() {
    string S,T;
    cin >> S;
    cin >> T;
    for (int i=0; i<S.size(); i++) {
        if (S.at(i) != T.at(i)) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3572
class String
  def to_sorted_array
    self.each_char.sort
  end
end

def comparea_arr(arr1, arr2)
  arr1Size = arr1.size
  arr2Size = arr2.size

  arr1.each_with_index do |s, i|
    if i == arr2Size
      return 'No'
    end
  
    if s < arr2[i]
      return 'Yes'
    elsif s > arr2[i]
      return 'No'
    end
  end

  # eachループを抜けたということは、arr2はarr1の全ての文字+数文字。またはまったく同じ
  # つまり まったく同じでなければarr1 < arr2が成り立つ
  return arr1Size == arr2Size ? 'No' : 'Yes'
end

arr1 = gets.chomp.to_sorted_array
arr2 = gets.chomp.to_sorted_array.reverse

puts comparea_arr(arr1, arr2)

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

void solve() {
  string s;
  int q;
  cin >> s >> q;

  bool reversed = false;
  string left;
  string right;

  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      reversed = !reversed;
    } else {
      int f;
      char c;
      cin >> f >> c;
      auto to_left = f == 1;
      if (reversed) {
        to_left = !to_left;
      }
      if (to_left) {
        left.push_back(c);
      } else {
        right.push_back(c);
      }
    }
  }
  if (reversed) {
    reverse(right.begin(), right.end());
    reverse(s.begin(), s.end());
    cout << right << s << left << endl;
  } else {
    reverse(left.begin(), left.end());
    cout << left << s << right << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 1040
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 1024
#define maxK 5011

const int lim = 5001;

int n, i, x[maxN], aux;
vector<int> list[maxN];
int alt[maxN];

int ss, dd;
bool dp[2][maxK];

void dfs(int node) {
    int i;
    ll sum = 0;

    for (auto to : list[node])
        dfs(to);

    memset(dp, 0, sizeof(dp));
    ss = 0; dd = 1;
    dp[ss][0] = true;

    for (auto to : list[node]) {
        memset(dp[dd], 0, sizeof(dp[dd]));

        for (i = 0; i + alt[to] <= x[node]; i++)
            dp[dd][i + alt[to]] |= dp[ss][i];

        for (i = 0; i + x[to] <= x[node]; i++)
            dp[dd][i + x[to]] |= dp[ss][i];

        sum += alt[to] + x[to];
        swap(ss, dd);
    }

    for (i = x[node]; i >= 0; i--)
        if (dp[ss][i])
            break;

    if (i < 0) {
        cout << "IMPOSSIBLE";
        exit(0);
    }

    alt[node] = sum - i;

}

int main()
{
 //   freopen("test.in","r",stdin);

    cin >> n;
    for (i = 2; i <= n; i++) {
        scanf("%d", &aux);
        list[aux].pb(i);
    }

    for (i = 1; i <= n; i++) cin >> x[i];
    dfs(1);


    cout << "POSSIBLE";

    return 0;
}


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

int main() {
    double n, k;
    cin >> n >> k;

    int ans = ceil((n - 1) / (k - 1));

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


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

map<pair<string, string> , long long> mp;
long long ans;
string tmp;
int n;

int main() {
	cin >> n >> tmp;
	for (int i = 0; i < (1 << n); i++) {
		string r1, r2;
		for (int j = 0; j < n; j++)
			if ((i & (1 << j)) != 0)
				r1.push_back(tmp[n + j]);
			else
				r2.push_back(tmp[n + j]);
		reverse(r2.begin(), r2.end());
		mp[{r1, r2}]++;
	}
	for (int i = 0; i < (1 << n); i++) {
		string r1, r2;
		for (int j = 0; j < n; j++)
			if ((i & (1 << j)) != 0)
				r1.push_back(tmp[j]);
			else
				r2.push_back(tmp[j]);
		reverse(r2.begin(), r2.end());
		ans += mp[{r2, r1}];
	}
	cout << ans;
}

Measured memory_bytes: 87040
import java.util.Scanner;

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

	private void run() {
		Scanner sc = new Scanner(System.in);
		String exp = sc.next();
		int res = sc.nextInt();
		boolean m = multiple(exp, res);
		boolean l = left(exp, res);
		if (m && l)
			System.out.println('U');
		else if (m)
			System.out.println('M');
		else if (l)
			System.out.println('L');
		else
			System.out.println('I');
		sc.close();
	}

	private boolean left(String exp, int res) {
		int result = 0;
		char op = '+';
		for (char c : exp.toCharArray()) {
			if (Character.isDigit(c))
				if (op == '+')
					result += c - '0';
				else
					result *= c - '0';
			else
				op = c;
		}
		return result == res;
	}

	private boolean multiple(String exp, int res) {
		String[] terms = exp.split("\\+");
		int sum = 0;
		for (String term : terms) {
			String[] factors = term.split("\\*");
			int fact = 1;
			for (String factor : factors) {
				fact *= Integer.parseInt(factor);
			}
			sum += fact;
		}
		return res == sum;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n),y(n),sa(n);
  double a=0,b=0,c=0,d=0;
  for (int i=0; i<n; i++) {
      cin >> x.at(i);
  }
  for (int i=0; i<n; i++) {
      cin >> y.at(i);
  }
  for (int i=0; i<n; i++) {
      if (x.at(i)>y.at(i)) sa.at(i)=x.at(i)-y.at(i);
      else sa.at(i)=y.at(i)-x.at(i);
      a+=sa.at(i);
      b+=sa.at(i)*sa.at(i);
      c+=sa.at(i)*sa.at(i)*sa.at(i);
      if (d<sa.at(i)) d=sa.at(i);
  }
  b=sqrt(b);
  c=cbrt(c);
  cout << fixed << setprecision(5);
  cout << a << endl;
  cout << b << endl;
  cout << c << endl;
  cout << d << endl;
}


Measured memory_bytes: 3476
# ABC 071
def db(x): 
    global debug
    if debug: print(x)
debug = False
S = input()
alpha = [chr(ord('a')+i) for i in range(26)]
for c in S: 
    if c in alpha: alpha.remove(c)
db(alpha)
if alpha==[]: ans = 'None'
else: ans = alpha[0]
print(ans)


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
#include<unordered_map>
#include<set>
using namespace std;

vector<int>rinsetu[105];
bool S[105];
int MAX;
void saiki(int a,int b) {
	MAX = max(MAX, b);
	for (int i : rinsetu[a]) {
		if (!S[i]) {
			S[i] = true;
			saiki(i, b + 1);
			S[i] = false;
		}
	}
}
signed main() {
	int a; 
	while (cin >> a,a) {
		MAX = 0;
		for (int i = 0; i < 105; i++)rinsetu[i].clear();
		memset(S, false, sizeof(S));
		for (int b = 0; b < a; b++) {
			int c, d; scanf("%d%d", &c, &d); c--; d--;
			rinsetu[c].push_back(d);
			rinsetu[d].push_back(c);
		}
		for (int b = 0; b < 105; b++) {
			S[b] = true;
			saiki(b, 1);
			S[b] = false;
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <stdlib.h>
#define N 2000001
#define A 10000

int main(){
  int n,i;
  int *a,*b;
  int c[A+1];

  scanf("%d",&n);
  a = (int *)malloc(1 + n * sizeof(int));
  b = (int *)malloc(1 + n * sizeof(int));
  for(i = 0;i <= A;i++){
    c[i] = 0;
  }
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
    c[a[i]]++;
  }
  
  for(i = 1;i <= A;i++) c[i] = c[i] + c[i-1];
  
  for(i = n-1;i >= 0;i--){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }
  for(i = 1;i <= n;i++){
    if(i != 1) printf(" ");
    printf("%d",b[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 17404
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



int main() {
	int n;
	cin >> n;
	int answer = 0;
	for(int a = 1; a <= n; ++a) {
		for(int i = 1; i * a < n; ++i) {
			answer++;
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 3588
import sys
import math
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res

sys.setrecursionlimit(1923780)

ans=0
def cul(a):
	score=0
	for i in range(q):
		if a[arr[i][1]-1]-a[arr[i][0]-1]==arr[i][2]:
			score+=arr[i][3]
	return score

def dfs(a):
	while 1:
		#print(a)
		# cul
		global ans
		ans = max(ans,cul(a))
		# rec
		if a[0]==m:
			break
		a[n-1]+=1
		for i in range(n-1,0,-1):
			if a[i]>m:
				a[i-1]+=1
				a[i]=0
		for i in range(1,n):
			a[i]=max(a[i],max(a[:i]))


n,m,q = readInts()
arr = []
for _i in range(q):
	arr.append(readInts())
dfs([1]*n)
print(ans)

Measured memory_bytes: 9508
def main():
    A, B, C, D = map(int, input().split())
    for i in range(300):
        if i % 2 == 0:
            C -= B
            if C <= 0:
                print("Yes")
                break
        else:
            A -= D
            if A <= 0:
                print("No")
                break
if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
//
//class UnionFind {
//private:
//    int sz;
//    vector<int> par, size_;
//public:
//    UnionFind(){}
//    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
//        iota(par.begin(), par.end(), 0);
//    }
//    int find(int x){
//        if(par[x] == x) return x;
//        else return par[x] = find(par[x]);
//    }
//    void unite(int x, int y){
//        x = find(x); y = find(y);
//        if(x == y) return;
//        if(size_[x] < size_[y]) swap(x,y);
//        par[y] = x;
//        size_[x] += size_[y];
//    }
//    int size(int x){
//        x = find(x);
//        return size_[x];
//    }
//    bool same(int x, int y){
//        return find(x) == find(y);
//    }
//};
//void no(){
//    cout << "Impossible" << endl;
//    exit(0);
//}
//int main(){
//    cin.tie(nullptr);
//    ios::sync_with_stdio(false);
//    int n, m;
//    cin >> n >> m;
//    vector<vector<int>> g(n);
//    vector<int>a(n);
//    rep(i,n)cin >> a[i];
//    rep(i,m){
//        int x, y;
//        cin >> x >> y;
//        x--;y--;
//        g[x].push_back(y);
//        g[y].push_back(x);
//    }
//    if(m == n - 1){
//        cout << 0 << endl;
//        return 0;
//    }
//    if(n / 2 < n - m - 1){
//        no();
//    }
//}
int a[200005];
int main(){
    int n;
    cin >> n;
    rep(i,n-1){
        int x;
        cin >> x;
        a[x]++;
    }
    rep(i,n){
        cout << a[i+1] << "\n";
    }
}


Measured memory_bytes: 4368
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
 
int main(){    
  int N,count=0;
  cin >> N;
  int p[N],q[N];
  
  for(int i=0;i<N;i++){
    cin >> p[i];
    q[i] = p[i];
  }

  sort(q,q+N);
  
  for(int i=0;i<N;i++){
   if(q[i] != p[i]){
      count++;
    }
  }

  if(count == 0 || count == 2){   
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  
}
 

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

const ll MAXN = 200000;

ll N, tmp=0;
vector<ll> C(MAXN, 0), S(MAXN, 0), F(MAXN, 0), ans;

signed main(){
    cin >> N;
    for(int i=0;i<N-1;i++) cin >> C[i] >> S[i] >> F[i];
    ans.push_back(0);
    for(int i=N-2;i>=0;i--) {
        tmp = S[i] + C[i];
        for(int j=i+1;j<=N-2;j++) {
            if(max(tmp, S[j])%F[j]==0) tmp = max(tmp, S[j]) + C[j];
            else tmp = ((max(tmp, S[j])/F[j]+1)*F[j]) + C[j];
        }
        ans.push_back(tmp);
    }
    for(int i=ans.size()-1;i>=0;i--) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  string s;cin >> s;
  ll cnt_w=0;
  ll out =0;
  for(int i=s.size()-1;i>=0;--i){
    string sub = s.substr(i,1);
    if(sub =="W"){
      ++cnt_w;
    } else if(sub =="B"){
      out += cnt_w;
    }
  }
  cout << out << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n;i++){
    cin >> p.at(i);
  }
  int min = p.at(0);
  int ans = 1;
  for (int i = 1; i < n; i++)  {
    if(min>p.at(i)){
      min = p.at(i);
      ans++;
    }
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999

//char型のポインタ(=配列と意味は同じ)をString型と定義
typedef char* String;

//文字列の長さを求める関数
int string_len(String str){
    int len=0;
    while(str[len]!=0){
        len++;
    }
    return len;
}

//文字列を標準入力から読み込み、それをString型のメモリを確保し直してくれる関数
String string_input(void){
    int i,len;
    char buf[200001];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    //ここまでは文字列の長さがわからなかったから、一旦1000個分のメモリを用意しそこに入力させる
    
    len=string_len(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}



int main(void){
    int n;
    String S;
    
    S=string_input();
    n=string_len(S);
    
    int b=0;
    
    unsigned long ans=0;
    
    for(int i=0;i<n;i++){
        if(S[i]=='B'){
            b++;
        }
        if(S[i]=='W'){
            ans += b;
        }
    }
    
    
    printf("%ld\n",ans);
    
    return 0;
    
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vector<pair<pii,int>> A(M);
  rep(i,0,M) cin>>A[i].first.second>>A[i].first.first>>A[i].second;
  sort(ALL(A));
  set<pii> S;
  S.insert(mp(1,0));
  rep(i,0,M){
    auto p=*rbegin(S);
    if(p.first>=A[i].first.second){
      auto q=S.lower_bound(mp(A[i].first.second,0));
      auto r=*q;
      int X=r.second+A[i].second;
      while(S.size()>0){
        auto s=*rbegin(S);
        if(A[i].first.second<=s.first&&s.second>=X) S.erase(s);
        else break;
      }
    S.insert(mp(A[i].first.first,X));
    }
  }
  int ans=INF;
  for(auto p:S){
    if(p.first==N) ans=min(ans,p.second);
  }
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
  }



Measured memory_bytes: 8704
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[ ";
  for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
    os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " ]"; 
  return os; 
}

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int,int>>> u(N);
  for (int i=0; i<N; i++) {
    int A;
    cin >> A;
    for (int j=0; j<A; j++) {
      int x, y;
      cin >> x >> y;
      u[i].push_back(make_pair(x-1, y));
    }
  }

  int best = 0;
  for (int i=0; i<(1<<N); i++) {
    int sho = i;
    int fus = 0;

    for (int j=0; j<N; j++) {
      if (!((i>>j)&1))
        continue;
      for (const auto& pa : u[j])
        if (pa.second == 1)
          sho |= (1<<pa.first);
        else
          fus |= (1<<pa.first);
    }

    if (sho == i) {
      //cerr << i << " " << sho << " " << fus << " " << "xo"[(sho & fus) == 0] << endl;

      if ((sho & fus) == 0) {
        best = max(best, __builtin_popcount(i));
      }
    }
  }

  cout << best << endl;
  return 0;
}


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

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

int main(){
  int n,k;
  cin >> n >> k;
  long long x[n];
  for (int i=0;i<n;i++){
    cin >> x[i];
  }
  long long ans = 1e9;
  long long ansi;
  for (int i=0;i<n-k+1;i++){
    ansi = abs(x[i]-x[i+k-1])+min(abs(x[i]),abs(x[i+k-1]));
    ans = min(ans,ansi);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[A];
    int[] b = new int[B];
    int[] sum = new int[M];
    for(int i = 0; i < A; i++){
      a[i] = sc.nextInt();
    }
    for(int i = 0; i < B; i++){
      b[i] = sc.nextInt();
    }
    for(int i = 0; i < M; i++){
      sum[i] = a[sc.nextInt() - 1] + b[sc.nextInt() - 1] - sc.nextInt();
    }
    Arrays.sort(sum);
    Arrays.sort(a);
    Arrays.sort(b);
    if(a[0] + b[0] < sum[0])sum[0] = a[0] + b[0];
    System.out.println(sum[0]);
  }
}

Measured memory_bytes: 150980
S = input()
max = 0
cnt = 0
for i in range(len(S)):
    if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
        cnt += 1
    else:
        cnt = 0
    if cnt > max:
        max = cnt
print(max)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var M = items[1];
            var X = items[2];
            var books = Enumerable.Range(0, N).Select(i => Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToList()).ToList();

            var answer = int.MaxValue;
            var end = (int)Math.Pow(2, N) - 1;
            for (var bit = 1L; bit <= end; bit++)
            {
                var sum = Enumerable.Range(0, M).Select(elem => 0).ToArray();
                var totalPrice = 0;
                for (var index = 0; index < N; index++)
                {
                    var book = books[index];
                    if ((bit & (long)Math.Pow(2, index)) != 0)
                    {
                        totalPrice += book[0];
                        for (var algo = 0; algo < M; algo++)
                        {
                            sum[algo] += book[algo + 1];
                        }
                    }
                }

                if (sum.All(elem => elem >= X))
                {
                    if (totalPrice < answer)
                    {
                        answer = totalPrice;
                    }
                }
            }

            Console.WriteLine(answer == int.MaxValue ? -1 : answer);
        }
    }
}


Measured memory_bytes: 29292
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF  = 0x3f3f3f3f3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = 200005;
const int M = 1000005;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

void run() {
    int h,w,k;
    cin >> h >> w >> k;
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    vector<vector<char>> mat(h+1,vector<char>(w+1));
    vector<vector<int>> dis(h+1,vector<int>(w+1,-1));
    string s;
    for(int i=1;i<=h;i++) {
        cin >> s;
        for(int j=1;j<=w;j++) mat[i][j] = s[j-1];
    }
    if(mat[x1][y1]=='@' || mat[x2][y2]=='@') { cout << -1 << endl; return; } 
    queue<PII> q;
    q.emplace(x1,y1);
    dis[x1][y1]=0;
    while(!q.empty()) {
        int x = q.front().fi, y = q.front().se;
        q.pop();
        for(int p=0;p<4;p++) {
            for(int j=1;j<=k;j++) {
                int xx = x + j*dir[p][0], yy = y + j*dir[p][1];
                if(1<=xx && xx<=h && 1<=yy && yy<=w) {
                    if(mat[xx][yy]=='@') break;
                    if(dis[xx][yy]!=-1) {
                        if(dis[xx][yy]>dis[x][y]) continue;
                        else break;
                    }
                    q.emplace(xx,yy);
                    dis[xx][yy] = dis[x][y]+1;
                    if(xx==x2 && yy==y2) {
                        cout << dis[xx][yy] << endl;
                        return;
                    }
                } else {
                    break;
                }
            }
        }
    }
    cout << -1 << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

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

using namespace std;

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

	int a, b;

	cin >> a >> b;

	int tmp = a + b;
	if (tmp % 2 == 0) {
		cout << tmp / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

ll solve(vector<vector<ll>>& dp, const vector<ll>& a, int i, int j) {
    if (i == j)
        return a[i];
    ll& res = dp[i][j];
    if (res != -1)
        return res;
    res = max(a[i] - solve(dp, a, i + 1, j), a[j] - solve(dp, a, i, j - 1));
    return res;
}

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

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

    vector<vector<ll>> dp(n, vector<ll>(n, -1));
    cout << solve(dp, a, 0, n - 1);
    
    return 0;
}


Measured memory_bytes: 72960
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 3e5 + 10;

int a[N],n;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-') ch = getchar();
	if(ch == '-') flag = -1,ch = getchar();
	while(isdigit(ch)) x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline bool check(int val) {
	int sum = 0;
	for(int i = 1;i <= n;i += 2) {
		if(sum >= val) sum = max(sum + a[i] - a[i - 1],a[i]);
		else sum += a[i] - a[i - 1];
	}
	return sum >= val;
}

int main() {

	n = read(); int black = 0,white = 0;
	For(i,1,n) {
		a[i] = read();
		if(i & 1) black += a[i];
		else white += a[i];
	}
	if(!(n & 1)) {
		printf("%d %d\n",max(black,white),min(black,white));
	} else {
		int l = 0,r = black;
		while(l < r) {
			int mid = (l + r + 1) >> 1;
			if(check(mid)) l = mid;
			else r = mid - 1;
		}
		printf("%d %d\n",max(black,white + l),min(white,black - l));
	}
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void)
{
  int x,i,j,temp;
  scanf("%d",&x);
  for(i=1;i<=x;i++)
    {
      temp = x;
      for(j=i;j>0;j--)
	{
	  if(temp-j >= 0)
	    {
	      temp -= j;
	      if(temp == 0)
		{
		  printf("%d\n",i);
		  return 0;
		}
	    }
	}
    }
}


Measured memory_bytes: 128
//#include<iostream>
#include<cstring>
#include<cstdio>
//#include<time.h>
//#include<complex>
//#include<set>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int n;
#define maxn 200011
struct Node{int v,id;}a[maxn];
bool cmp(const Node &a,const Node &b) {return a.v<b.v;}
int ans[maxn];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[a[i].id=i].v);
	sort(a+1,a+1+n,cmp);
	for (int i=1,to=n>>1;i<=to;i++) ans[a[i].id]=a[to+1].v;
	for (int i=n,to=n>>1;i>to;i--) ans[a[i].id]=a[to].v;
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

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

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

Measured memory_bytes: 3592
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;
template<typename ARR>
inline void add_full(ARR& v1, ARR& v2)
{
	v1 += v2;
}
template<typename ARR, size_t N>
inline void add_full(ARR(&v1)[N], ARR(&v2)[N])
{
	auto iter1 = v1, iter2 = v2, iter1end = v1 + N;
	while (iter1 != iter1end) {
		add_full(*iter1++, *iter2++);
	}
}
//1-indexed累積和
template<size_t N>void CuSum(int64_t (&arr)[N])
{
	for (size_t i = 2; i < N; i++)
	{
		arr[i] += arr[i-1];
	}
}
template<typename ARR, size_t N>void CuSum(ARR(&arr)[N])
{
	for (auto& arr2 : arr) {
		CuSum(arr2);
	}
	for (size_t i = 2; i < N; i++)
	{
		add_full(arr[i], arr[i - 1]);
	}
}
template<size_t N, size_t M>void CuSum(int64_t(&arr)[N][M])
{
	for (auto& arr2 : arr) {
		CuSum(arr2);
	}

	for (size_t i = 2; i < N; i++)
	{
		add_full(arr[i], arr[i - 1]);
	}
}
template<size_t N, size_t M, size_t O>void CuSum(int64_t(&arr)[N][M][O])
{
	for (auto& arr2 : arr) {
		CuSum(arr2);
	}

	for (size_t i = 2; i < N; i++)
	{
		add_full(arr[i], arr[i - 1]);
	}
}

int32_t N, M, Q;
int64_t map[2001][2010];
int64_t edgex[2010][2001];
int64_t edgey[2010][2001];


int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>M>>Q;

	for (size_t i = 1; i <= N; i++)
	{
		char buf[3000];
		in >> buf;
		for (size_t j = 1; j <= M; j++)
		{
			map[i][j] = buf[j-1]-'0';
		}
	}

/*
	for (size_t i = 1; i <= N; i++)
		for (size_t j = 2; j <= M; j++)
		{
			edge[i][j] += edge[i][j - 1] + (map[i][j-1] - '0' +map[i][j - 1] - '0')/2;
		}
	for (size_t i = 2; i <= N; i++)
		for (size_t j = 1; j <= M; j++)
	{
		edge[i][j] += edge[i - 1][j] + (map[i - 1][j] - '0' + map[i - 1][j] - '0') / 2;
	}
*/

	for (size_t i = 1; i <= N; i++)
		for (size_t j = 1; j <= M; j++)
		{
			edgex[i][j] += (map[i][j] + map[i][j - 1]) / 2;
			edgey[i][j] += (map[i][j] + map[i - 1][j]) / 2;
		}
	CuSum(map);
	CuSum(edgex);
	CuSum(edgey);


	for (size_t i = 0; i < Q; i++)
	{
		int x, y, x2, y2;
		in >> x >> y >> x2 >> y2;
		--x; --y;
		std::swap(x, y); std::swap(x2, y2);

		auto v = (map[y2][x2] - map[y][x2] - map[y2][x] + map[y][x]);
		auto e = (edgex[y2][x2] - edgex[y][x2] - edgex[y2][x+1] + edgex[y][x+1])+ (edgey[y2][x2] - edgey[y+1][x2] - edgey[y2][x] + edgey[y+1][x]);
		std::cout << v-e<<endl;
	}



	return 0;
}
#endif


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

int main() {
int a[5];
char q,w,e,r;
while(cin>>a[0]>>q>>a[1]>>w>>a[2]>>e>>a[3]>>r>>a[4]){
	for(int kk=0;kk<=3;kk++){
		for(int ll=kk+1;ll<=4;ll++){
			if(a[kk]>a[ll]){
				int t;
				t=a[ll];
				a[ll]=a[kk];
				a[kk]=t;
			}
		}
	}
	if(a[0]==a[3]||a[1]==a[4]){
		cout<<"four card"<<endl;
	}
	else{
		if((a[0]==a[2]&&a[3]==a[4])||(a[0]==a[1]&&a[2]==a[4])){
			cout<<"full house"<<endl;
		}
		else{
			if(((a[0]+1==a[1])&&(a[1]+1==a[2])&&(a[2]+1==a[3])&&(a[3]+1==a[4]))||(a[0]==1&&a[1]==10&&a[2]==11&&a[3]==12&&a[4]==13)){
				cout<<"straight"<<endl;
			}
			else{
				if(a[0]==a[2]||a[1]==a[3]||a[2]==a[4]){
					cout<<"three card"<<endl;
				}
				else{
					if((a[0]==a[1]&&a[2]==a[3])||(a[0]==a[1]&&a[3]==a[4])||(a[1]==a[2]&&a[3]==a[4])){
						cout<<"two pair"<<endl;
					}
					else{
						if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]||a[3]==a[4]){
							cout<<"one pair"<<endl;
						}
						else{
							cout<<"null"<<endl;
						}
					}
				}
			}
		}
	}
}
	return 0;
}

Measured memory_bytes: 1156