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

int H, W;

signed main() {
  ios::sync_with_stdio( 0 );
  cin >> H >> W;
  long long ans = 1LL << 60;
  for( int _ = 0; _ < 2; ++_ ) {
    for( int i = 1; i <= H - 1; ++i ) {
      ans = min( ans, max( 1LL * i * W - 1LL * W / 2 * ( H - i ), 1LL * ( W + 1 ) / 2 * ( H - i ) - 1LL * i * W ) ) ;
      if( H - i > 1 ) {
        ans = min( ans, max( 1LL * i * W - 1LL * ( H - i ) / 2 * W, 1LL * ( H - i + 1 ) / 2 * W - 1LL * i * W ) );
      }
    }
    swap( H, W );
  }
  cout << ans << endl;
  return 0;
}


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

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

    cout << max(a*b, max(a+b, a-b)) << endl;
    return 0;
}


Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def A_Round_One():
    A = wczytaj_liste()[0]
    B = wczytaj_liste()[0]
    lista_odpowiedzi = [1,2,3]
    for n in lista_odpowiedzi:
        if A != n and B != n: 
            print(n)
            break
            
A_Round_One()

Measured memory_bytes: 38256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

ll n, k;
ll a[100100];

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  solve();

  return 0;
}

void solve() {
  ll cnt = 0;

  sort(a, a+n);

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

  cout << cnt << endl;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

countL2R = [[0 for i in range(w)] for j in range(h)]
countR2L = [[0 for i in range(w)] for j in range(h)]
countU2D = [[0 for i in range(w)] for j in range(h)]
countD2U = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            countL2R[i][j] = -1
            countR2L[i][j] = -1
            countU2D[i][j] = -1
            countD2U[i][j] = -1

for i in range(h):
    for j in range(w):
        if j > 0 and countL2R[i][j] != -1:
                countL2R[i][j] = countL2R[i][j - 1] + 1

        j = w - j - 1
        if j < w - 1 and countR2L[i][j] != -1:
            countR2L[i][j] = countR2L[i][j + 1] + 1

        if i > 0 and countU2D[i][j] != -1:
            countU2D[i][j] = countU2D[i - 1][j] + 1

        I = i
        i = h - i - 1
        if i < h - 1 and countD2U[i][j] != -1:
            countD2U[i][j] = countD2U[i + 1][j] + 1
        i = I

ans = 0
for i in range(h):
    for j in range(w):
        if countD2U[i][j] != -1:
            ans = max(ans, countD2U[i][j] + countU2D[i][j] + countR2L[i][j] + countL2R[i][j])

print(ans + 1)

Measured memory_bytes: 316552
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

long long fac[51000], finv[51000], inv[51000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 51000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
ll H,W;
char maze[105][105];//*%@
const ll dx[] = {1,0,0,-1};
const ll dy[] = {0,1,-1,0};
void dfs(ll x,ll y,char c){
    maze[x][y] = '$';
    rep(i,4){
        ll hx = dx[i] + x,hy = dy[i] + y;
        if(hx >= 0 && hy >= 0 && hx < H && hy < W){
            if(maze[hx][hy] == c){
                dfs(hx,hy,c);
            }
        }
    }
}
int main(){
    while(true){
    cin >> H >> W;
    if(H == 0 && W == 0)break;
    rep(i,H)
    rep(j,W)cin >> maze[i][j];
    ll ans = 0;
    rep(i,H){
        rep(j,W){
            if(maze[i][j] != '$'){
                dfs(i,j,maze[i][j]);
                ans++;
            }
        }
    }
    cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3872
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/



int main()
{
	SPEED;
	ll n,k,t,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string a,b,c;
	while(t--)
	{
		cin>>n>>a>>b>>c;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			if(a[i]==b[i] && b[i]==c[i])
				continue;
			else if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i])
				cs+=1;
			else
				cs+=2;
		}
		
		cout<<cs;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=(1LL<<61)-1;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N,W;
    while((cin>>N>>W,N|W)){
        double res=0.01;
        int ct[11];
        memset(ct,0,sizeof(ct));
        rep(i,N){
            int v;cin>>v;
            ct[v/W]++;
        }
        int f=-1,cnt=0,mx=0;
        rep(i,11)if(ct[i]){cnt=i;if(chmax(mx,ct[i]))f=i;}
        for(int i=0;i<=cnt;i++){
            res+=(double)(cnt-i)/cnt*ct[i]/mx;
        }
        cout<<res<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


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

int dp[101][101];
int dp2[10001];
int dp3[101][101];

void Max(int &a,int b){a=max(a,b);}

int main(){
  int s,t,u,n,o,d,e[101],c[101],h[101],a[101];
  cin>>s>>t>>u>>n>>o>>d;
  for(int i=0;i<t;i++) cin>>e[i]>>c[i];
  for(int i=0;i<n;i++) cin>>h[i]>>a[i];

  memset(dp,-1,sizeof(dp));
  dp[0][0]=0;
  for(int i=0;i<t;i++)
    for(int j=u-1;j>=0;j--)
      for(int k=s-e[i];k>=0;k--)
	if(dp[j][k]>=0) Max(dp[j+1][k+e[i]],dp[j][k]+c[i]);


  for(int i=0;i<n;i++)
    for(int j=0;j<=10000-a[i];j++)Max(dp2[j+a[i]],dp2[j]+h[i]);
  memset(dp3,-1,sizeof(dp3));
  dp3[0][s]=0;
  for(int i=0;i<d;i++)
    for(int j=0;j<=s;j++){
      if(dp3[i][j]==-1)continue;
      for(int k=0;k<=s;k++){
	if(dp[u][k]==-1||j-k<0)continue;
	Max(dp3[i+1][min(s,j-k+o)],dp3[i][j]+dp2[dp[u][k]]);
      }
    }
  
  int ans=-1;
  for(int i=0;i<=s;i++) Max(ans,dp3[d][i]);
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (ll i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    string S;
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>S;
    ll L=S.size();
    REP(Bit,1<<(L-1)){
        ll pos=0;
        REP(i,L-1){
            if(Bit>>i&1){
                string s=S.substr(pos,i-pos+1);
//                DEB(s)END
                ans+=stoll(s);
                pos=i+1;
            }
        }
        if(L!=pos){
            string s=S.substr(pos,L-pos);
//            DEB(s)END
            ans+=stoll(s);
        }

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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k, q int
	_, err := fmt.Scan(&n, &k, &q)
	if err != nil {
		panic("ERROR")
	}
	t := make([]int, q)
	for i := 0; i < q; i++ {
		_, err := fmt.Scan(&t[i])
        if err != nil {
            panic("ERROR")
        }
	}

	num := make([]int, n)
	for i := 0; i < q; i++ {
		num[t[i]-1]++
	}

	for j := 0; j < n; j++ {
		if num[j]+k-q <= 0 {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  ll H, W, A, B; cin >> H >> W >> A >> B;
  ll res = 0;
  prepare_comb_mod(MAX);
  rep(h, 1, H - A + 1){
    res += comb_mod(h + B - 2, h - 1) * comb_mod(H - h + W - B - 1, H - h);
    res %= MOD;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

double arr[3010];
double dp[3010][3010];

int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];}


    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]=0;


    dp[1][0]=1.0-arr[1];
    dp[1][1]=arr[1];

    for(int i=2;i<=n;i++)
    {
        for(int k=0;k<=i-1;k++)
            {
                dp[i][k+1]+=dp[i-1][k]*arr[i];
                dp[i][k]+=dp[i-1][k]*(1.0-arr[i]);
            }

    }



    double ans=0;
    for(int i=n/2+1;i<=n;i++)
        ans+=dp[n][i];

    cout<<setprecision(9)<<fixed<<ans;

    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int C[200005];
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  cin >> S;
  for (int i=N-1; i>=0; i--) {
    C[i] = C[i+1];
    if (S[i] == '#') {
      C[i]++;
    }
  }
  int ans = N;
  int D = 0;
  for (int i=0; i<=N; i++) {
    ans = min(ans, N-i-C[i]+D);
    if (S[i] == '#') D++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1300
INFTY = 1000000001

def merge(A, left, mid, right):
    global cnt

    L = A[left:mid]
    R = A[mid:right]

    L.append(INFTY)
    R.append(INFTY)

    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
          A[k] = L[i]
          i += 1
        else:
          A[k] = R[j]
          j += 1
          cnt += ((mid - left) - i)



def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2

        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)



n = int(input())
S = list(map(int, input().split()))

cnt = 0

merge_sort(S, 0, n)


print(cnt)



Measured memory_bytes: 27468
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    vector<ll> B_{};
    ll N_{};
    explicit C1(vector<ll> B) : B_(move(B)), N_(B_.size()+1){}
    ll resolve() {
        ll sum = 0;
        for (ll i=0; i < N_; ++i) {
            if (i == 0) {
                sum += B_[0];
            } else if (i == N_-1) {
                sum += B_[N_-2];
            } else {
                sum += min(B_[i-1], B_[i]);
            }
        }
        return sum;
    }
};

int main() {
    ll N;
    cin >> N ;
    vector<ll> B{};
    for (int i=0; i < N-1; ++i) {
        ll x;
        cin >> x;
        B.emplace_back(x);
    }
    C1 c{move(B)};
    cout << c.resolve() << endl;
    debug(c.resolve());
    return 0;
}


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

int main()
{
    int h, w;
    while(1)
    {
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int a, b, c, d, e, f;
int tw, ts, answ = 0, anss = 0;
double ma = -1;

set<int> water, sugar;

int main(void){
    // Here your code !
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

    for (int i = 0; i <= f; ++i) for (int j = 0; j <= f; ++j) {
      tw = 100 * (a * i + b * j);
      ts = (c * i + d * j);

      if (tw <= f) water.insert(tw);
      if (ts <= f) sugar.insert(ts);
    }

    for (auto i = water.begin(); i != water.end(); ++i) for (auto j = sugar.begin(); j != sugar.end(); ++j) {
      tw = *i; ts = *j;
      if (((tw + ts) <= f) && (tw != 0 && (ts + tw) != 0)) {
        if (((double)ts / (double)tw) <= ((double)e / (double)100)) {
          if (((double)ts / (double)(tw + ts)) > ma) {
            answ = tw; anss = ts;
            ma = ((double)ts / (double)(tw + ts));
          }
        }
      }
    }

    printf("%d %d\n", answ + anss, anss);
}

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

using namespace std;

const int INF = 1 << 30;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  map<pair<int, int>, vector<pair<pair<int, int>, int>>> G;
  for (int i = 0; i < M; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    u--, v--;
    G[make_pair(u, c)].emplace_back(make_pair(make_pair(v, c), 0));
    G[make_pair(v, c)].emplace_back(make_pair(make_pair(u, c), 0));
    G[make_pair(u, c)].emplace_back(make_pair(make_pair(u, -1), 0));
    G[make_pair(v, c)].emplace_back(make_pair(make_pair(v, -1), 0));
    G[make_pair(u, -1)].emplace_back(make_pair(make_pair(v, c), 1));
    G[make_pair(v, -1)].emplace_back(make_pair(make_pair(u, c), 1));
  }
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  que.push(make_pair(0, make_pair(0, -1)));  // d, u, c
  set<pair<int, int>> st;
  vector<int> dist(N, INF);
  dist[0] = 0;
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int d = q.first, u = q.second.first, a = q.second.second;
    if (st.find(make_pair(u, a)) != st.end()) continue;
    st.insert(make_pair(u, a));
    for (auto g : G[make_pair(u, a)]) {
      int v = g.first.first, b = g.first.second, c = g.second;
      if (st.find(make_pair(v, b)) != st.end()) continue;
      que.push(make_pair(d + c, make_pair(v, b)));
      if (b == -1) chmin(dist[v], d + c);
    }
  }
  if (dist[N - 1] == INF) {
    cout << -1 << '\n';
  } else {
    cout << dist[N - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 87852
def lcs(S,T):
    m = len(S)
    n = len(T)
    dp = [[0]*(n+1) for x in range(m+1)]
    
#計算量はO(MN)、DP表の作成
    for i in range(m):
        for j in range(n):
            if S[i] == T[j]:#同じやったときは+1延ばし斜めに移動
                dp[i+1][j+1] = dp[i][j] + 1
            else:#違うかったら、最長は上と左の大きいほうをもってくる
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
# if I want to know the length of the Lcs, return dp[m][n]
#文字列の復元（複数の場合は、そのうちの一つ）
    ans = ''
    while m!=0 and n!=0:#どっちも0になるまで、後ろから復元
        if dp[m][n] == dp[m-1][n]:#dp表を上に動かす
            m-=1
        elif dp[m][n] == dp[m][n-1]:#dp表を左に動かす
            n-=1
        else:#斜めの移動(S[i]==T[j])のときだけ、LCS伸びているので延ばす
            m-=1
            n-=1
            ans=S[m]+ans#これはT[n]でもいい
    return ans
#----------------------------------------------------------------
S = input()
T = input()
print(lcs(S,T))

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	FOR(i, 1, 10) {
	  FOR(j, 1, 10) {
      if (N == i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
var n,i,h,hmax:int64;
    flag:boolean;
begin
read(n);flag:=true;
read(h);hmax:=h;
for i := 2 to n do
begin
read(h);
if hmax <= h then hmax:=h
else if hmax-h>=2 then flag:=false;
end;
if flag then write('Yes') else write('No');
end.

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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b<=c){
        if(4*a*b<(c-a-b)*(c-a-b)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    if(N%2==0) {
        cout<< double(1)/double(2) << endl;
    } else {
        cout << double(N/2+1) / double(N) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define PBB pair<bool, bool>
#define PII pair<int, int>
#define f first
#define s second

using namespace std;

const int N = 110;

char str[N];
PBB p;
PII q;

int main() {
    scanf("%s", str);
    int length = strlen(str);
    for (int i = 0; i <= length; i++) {
        if (str[i] == 'C') {
            if (q.f == false) {
                p.f = true;
                q.f = i;
            }
            
        } else if (str[i] == 'F') {
            if (q.s == false) {
                p.s = true;
                q.s = i;
            }
        }
    }
    if (p.f == false || p.s == false || q.f > q.s) {
        printf("No");
    } else {
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n, m;
	cin >> n >> m;

	vector<int> v(2*n);
	rep(i, 2*n) v[i] = i + 1;

	rep(i, m) {
		int k;
		cin >> k;

		vector<int> a, b;

		if(k == 0) {
			rep(j, n) {
				a.push_back(v[j]);
				a.push_back(v[j+n]);
			}

			v.clear();
			copy(a.begin(),a.end(),back_inserter(v));
		} else {
			rep(j, k) {
				a.push_back(v[j]);
			}

			REP(j, k, 2*n) {
				b.push_back(v[j]);
			}

			v.clear();
			copy(b.begin(),b.end(),back_inserter(v));
			copy(a.begin(),a.end(),back_inserter(v));
		}

	}

	rep(i, 2*n) {
		cout << v[i] << endl;
	}

	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  rep(i,k) {
    vi b(n+1);
    rep(j,n) {
      int l = max(0,j-a[j]);
      int r = min(n,j+a[j]+1);
      b[l]++;
      b[r]--;
    }
    REP(i,n) b[i] += b[i-1];
    if(a == b) break;
    a = b;
  }
  rep(i,n) cout << a[i] << ' ';
  cout << endl;
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,d,a,dd;
pii x[400010];
int ans,tp;
int cha[400010];
signed main(){
	cin>>n>>d>>a;
	dd=d+d;
	for(int i=1;i<=n;i++)cin>>x[i].F>>x[i].S;
	sort(x+1,x+n+1);
	for(int l=1,r=1,cur=0;l<=n;l++){
		while(r<n&&x[r+1].F-x[l].F<=dd)r++;
		int need=(x[l].S-cha[l]*a+a-1)/a;
		if(need<0)need=0;
		ans+=need;
		
		cha[l]+=need,cha[r+1]-=need;//
		cha[l+1]+=cha[l];
		
				
//		cout<<cur<<endl;
//		for(int i=1;i<=n+1;i++)cout<<cha[i]<<' ';
//		cout<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
/*
200010 1 1
1 
*/

Measured memory_bytes: 7936
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

int main(){
    
    int n;
    int east[350000] = {0};
    int west[350000] = {0};
    int e = 0, w = 0;

    cin >> n;
    for(int i=0; i<n; i++){
        char tmp;
        cin >> tmp;
        if(tmp == 'W') west[i] = 1;
        else east[i] = 1;

    }
    for(int i=0; i<n; i++) west[i] = west[i]? ++w : w;
    for(int i=n-1; i>=0; i--) east[i] = east[i]? ++e : e;

    int min = n;
    for(int i=0; i<n; i++){ // leader
        int count = 0;
        int x, y;

        x = west[i];
        y = east[i];
        count = x+y;

        min = min>count? count : min;
    }

    cout << min-1 << endl;

    return 0;
}

Measured memory_bytes: 2944
s = input()
l = len(s)
i = 0
j = l-1
f = 0
while i<j:
	if s[i] != s[j]:
		f = 1
		break
	i += 1
	j -= 1
if f==0:
	i = 0
	j = (l-2)//2
	while i<j:
		if s[i] != s[j]:
			f = 1
			break
		i += 1
		j -= 1
if f==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
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());
        for(int i=0;i<n;i++){
            String[] str= sc.nextLine().split(" ");
            double[] d = new double[6];
            for(int j=0;j<6;j++){
                d[j]=Double.parseDouble(str[j]);
            }
            double kyori = Math.sqrt((d[0]-d[3])*(d[0]-d[3])+(d[1]-d[4])*(d[1]-d[4]));
            double big = d[2]+d[5];
            int ans=0;
            if(kyori>big){
                ans=0;
            }else{
           
                if(d[2]>d[5]+kyori){
                    ans=2;
                }else if(d[5]>d[2]+kyori){
                    ans=-2;
                }else{
                    ans=1;
                }
                
            }
            System.out.println(ans);
        }
    }
    
}

Measured memory_bytes: 17368
#include<stdio.h>
int main()
{
    long long int a,b,k,c=0,d=0,f,i,j,m,n,r;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0){c=c+i;}
    }
    printf("%lld\n",c);

return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

signed main()
{
    vector <int> in;
    int N;
    cin >> N;
    
    int sum;
    double ave;
    double ave2;
    
    for(int i = 0;i < N; ++i)
    {
        int a;
        cin >> a;
        in.push_back(a);
        sum += a;
    }
    ave = sum/N;
    ave2 = sum%N == 0? sum/N : (sum/N)+1;
    
    int ans=0,ans2=0;
    
    for(auto a : in)
    {
        ans+=(a-ave)*(a-ave);
        ans2+=(a-ave2)*(a-ave2);
    }
    cout<<min(ans,ans2)<<endl;
}

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

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

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = ((n - 1) + k - 2) / (k - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
print(0)
l = input()
if l == "Vacant":
    exit()
print(n-1)
r = input()
if r == "Vacant":
    exit()
s = "none"
l_n = 0
r_n = n-1
while True:
    s_n = (l_n+r_n)//2
    print(s_n)
    diff = s_n - l_n
    s = input()
    if s == "Vacant":
        exit()
    elif s == "Male" and diff % 2 == 0:
        if l == "Male":
            l_n = s_n
        else:
            r = "Male"
            r_n = s_n
    elif s == "Male" and diff % 2 == 1:
        if l == "Male":
            r = "Male"
            r_n = s_n
        else:
            l = "Male"
            l_n = s_n
    elif s == "Female" and diff % 2 == 0:
        if l == "Female":
            l_n = s_n
        else:
            r = "Female"
            r_n = s_n
    elif s == "Female" and diff % 2 == 1:
        if l == "Female":
            r = "Female"
            r_n = s_n
        else:
            l = "Female"
            l_n = s_n



Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,x[N],disc[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]),disc[i]=x[i];
	sort(disc+1,disc+n+1);int hzhz=(n+1)/2;
	for (int i=1;i<=n;i++){
		if (x[i]>disc[hzhz]) printf("%d\n",disc[hzhz]);
		else printf("%d\n",disc[hzhz+1]);
	}
	return 0;
}

Measured memory_bytes: 3712
a, b, C = gets.split.map(&:to_i)
rad = C * Math::PI / 180

h = b * Math.sin(rad)
s = a * h / 2

c =  Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(rad))
l = a + b + c

puts [s, l, h].join(' ')

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int n, m, x, a, left = 0, right = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> x;
    REP(i, m) {
        cin >> a;
        if (a < x) {
            left++;
        } else {
            right++;
        }
    }
    
    cout << min(left, right) << "\n";
    return 0;
}

Measured memory_bytes: 256
p = list(map(int, list(input())))
def add(x,y,s):
    if s == 0: return x+y
    else: return x-y
def bittolist(x):
    ret = []
    for _ in range(3):
        ret.append(x%2)
        x //= 2
    return ret
def pm(s):
    if s == 0:
        return '+'
    else: return '-'
for i in range(8):
    s = bittolist(i)
    res = p[0]
    for j in range(3):
        res = add(res, p[j+1], s[j])
    if res == 7:
        print(p[0], end = '')
        print(pm(s[0]), end = '')
        print(p[1], end = '')
        print(pm(s[1]), end = '')
        print(p[2], end = '')
        print(pm(s[2]), end = '')
        print(p[3], end = '')
        print('=7')
        exit()

Measured memory_bytes: 3064
// x^t = 1 mod m のとき、
// x^(kt) = 1 mod m.
#include<iostream>
using namespace std;

typedef long long ll;

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

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

int main(){
    ll a1, m1, a2, m2, a3, m3;
    
    while(1){
        cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
        if(a1+m1+a2+m2+a3+m3 == 0)  break;
        
        ll x = 1, y = 1, z = 1;

        ll tmp = a1;
        while(tmp != 1){
            x++;
            tmp = (tmp*a1)%m1;
        }
        
        tmp = a2;
        while(tmp != 1){
            y++;
            tmp = (tmp*a2)%m2;
        }

        tmp = a3;
        while(tmp != 1){
            z++;
            tmp = (tmp*a3)%m3;
        }

        ll ans = lcm(lcm(x,y), z);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] pos = new int[n][3];

        for(int i = 0; i < n; i++){
            pos[i][0] = sc.nextInt();
            pos[i][1] = sc.nextInt();
            pos[i][2] = sc.nextInt();
        }
        sc.close();

        int[] curentPos = {0,0,0};
        boolean canTravel = true;
        for(int[] nextPos: pos){
            boolean canMove = false;
            if(nextPos[0] % 2 == (nextPos[1] + nextPos[2]) % 2){
                int timeDiff = nextPos[0] - curentPos[0];
                int xDiff = Math.abs(nextPos[1] - curentPos[1]);
                int yDiff = Math.abs(nextPos[2] - curentPos[2]);
                if(timeDiff >= (xDiff + yDiff)){
                    curentPos = nextPos;
                    canMove = true;
                }
            }

            if(!canMove){
                canTravel = false;
                break;
            }
        }

        if(canTravel){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 94060
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
#include<cstring>

using namespace std;

int main()
{
	int m;
	char st[73];
	int i,j,k,len;
	
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		set<string> T;
		string s;
		cin >> s;
		len = s.length();
		for(j=1;j<len;j++)
		{
			string s1,s2;
			s1 = s.substr(0,j);
			s2 = s.substr(j);
			//puts(s1.c_str());
			//puts(s2.c_str());
			string s1riv,s2riv;
			for (int k=s1.length(); k>0; k--) s1riv+=s1.at(k-1);
			for (int k=s2.length(); k>0; k--) s2riv+=s2.at(k-1);
			//puts(s1riv.c_str());
			//puts(s2riv.c_str());
			T.insert(s1+s2);
			T.insert(s2+s1);
			T.insert(s1+s2riv);
			T.insert(s1riv+s2);
			T.insert(s2+s1riv);
			T.insert(s2riv+s1);
			T.insert(s1riv+s2riv);
			T.insert(s2riv+s1riv);
		}
		k = T.size();
		printf("%d\n",k);
	}
}

Measured memory_bytes: 3388
#include <stdio.h>
#include <string.h>
#define MAX_N 200001

int main(void) {
  int N;
  scanf("%d", &N);
  int A[MAX_N];
  for(int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }

  int B[MAX_N];
  memcpy(B, A, sizeof(int)*(N+1));
  for(int i = N/2; i > 0; i--) {
    for(int j = 2; j <= N; j++) {
      int x = i * j;
      if(x > N) break;
      B[i] += B[x];
    }
    B[i] %= 2;
  }
  //for(int i = 1; i <= N; i++) {
  //printf("B[%d]=%d\n", i, B[i]);
  //}
  int M = 0;
  for(int i = 1; i <= N; i++) {
    if(B[i]) {
      M++;
    }
  }

  if(M == 0) {
    printf("%d\n", M);
    return 0;
  }
  printf("%d\n", M);
  for(int i = 1; i <= N; i++) {
    if(B[i])
      printf("%d ", i);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 2432
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
const int N=1000;
int a[N],b[N];
int32_t main()
{
	int n=in();
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	
	for(int i=0;i<n-2;i++)
	{
		if(a[i]==b[i] and a[i+1]==b[i+1] and a[i+2]==b[i+2]){cout<<"Yes";return 0;}
	}
	puts("No");
	
	
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
int N;
  cin>>N;
  Graph G(N);
  for(int i=0;i<N;i++){
    string s; cin>>s;
    for(int j=0;j<N;j++){
    if(s.at(j)=='1')
      G[i].push_back(j);
   }
}int ans=0;bool y=true;
  for(int i=0;i<N;i++){
    queue<int>que;
      que.push(i);
      vector<int>dist(N,-1);
    dist[i]=0;
    bool x=true;
    int a;
      while(!que.empty()){
      int v=que.front();
        que.pop();
        for(auto u:G[v]){
        if(dist[u]!=-1){
          if(dist[u]==dist[v]){x=false; break;}
        }else{
        dist[u]=dist[v]+1; if(a<dist[u])a=dist[u];
          que.push(u);
        
        }
        
        }  if(x){if(ans<a)ans=a;}else{y=false; break;}
      
      }  if(!y)break;
    
    }if(y)cout<<ans+1<<endl;
  else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  (a,b,c,d) <- (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2, vec VU.! 3)) <$> getIntVector
  let e = a - 1
      underB = b - b `div` c - b `div` d  + b `div` (lcm c d)
      underA = e - e `div` c - e `div` d  + e `div` (lcm c d)

  print $ underB - underA


Measured memory_bytes: 380
#include <iostream>


int main()
{
    int n, m;
    std::cin >> n >> m;
    int res = 0, tmp, cnt;

    for (int i = 0; i < n; i++) {
        cnt = 0;
        for (int j = 0; j < m; j++) {
            std::cin >>tmp;
            cnt += tmp;
        }
        if (cnt > res) res = cnt;
    }
    std::cout << res << std::endl;

    return 0;
}



Measured memory_bytes: 3132
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var a [15][15]int

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()
	x := nextInt()
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = nextInt()
		for j := 0; j < m; j++ {
			a[i][j] = nextInt()
		}
	}

	costmin := 1000000000
	for bit := 0; bit < (1 << n); bit++ {
		nowcost := 0
		nowskill := make([]int, m)
		for j := 0; j < n; j++ {
			if bit&(1<<j) != 0 { // 今回ヒットした場合
				nowcost += c[j]
				for k := 0; k < m; k++ {
					nowskill[k] += a[j][k]
				}
			}
		}
		skilled := true
		for i := 0; i < m; i++ {
			if nowskill[i] < x {
				skilled = false
				if bit == (1<<n)-1 {
					fmt.Println(-1)
					return
				}
			}
		}
		if skilled == true {
			costmin = min(costmin, nowcost)
		}
	}

	fmt.Println(costmin)

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){

	int sum = 0, cost = 0, num = 0, iAve = 0;
	double dAve = 0, count = 0, totalnum = 0; 
	while(scanf("%d,%d", &cost, & num) != EOF){
		sum += cost * num;
		totalnum += num;
		count++;
	}

	dAve = totalnum / count;
	int tmp = dAve * 10;
	iAve = tmp % 10 >= 5 ? dAve + 1 : dAve;

	cout << sum << endl << iAve << endl;

	return 0;
}

Measured memory_bytes: 1204
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
cnt = 0
res = "No"

for i in d:
	if i[0] == i[1]:
		cnt += 1
		if cnt >= 3:
			res = "Yes"
	else:
		cnt = 0
          
print(res)

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

using namespace std;

int main()
{
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n, w; cin >> n >> w;
        int a[n+1], v[n+1];
        for (int i=1; i<=n; i++)
                cin >> a[i] >> v[i];
        long long dp[n+1][w+1];
        memset(dp,0,sizeof(dp));
        for (int i=1; i<=n; i++)
        {
                for (int j=1; j<=w; j++)
                {
                        dp[i][j] = max(dp[i][j], dp[i-1][j]);
                        if (j-a[i]>=0) dp[i][j] = max(dp[i][j], dp[i-1][j-a[i]]+v[i]);
                }
        }
        cout << dp[n][w];
        return 0;
}


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

using namespace std;

int const N = 1234567;

int a[N], b[N];

int query(int x) {
	cout << x << endl;
	cout.flush();
	string s;
	cin >> s;
	if (s == "Vacant") return -1;
	return s == "Male" ? 1 : 0;
}

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int l = 0;
	int r = n;
	int first = query(0);
	if (first < 0) return 0;
	while (l < r - 1) {
		int mid = (l + r) >> 1;
		int got = query(mid);
		if (got < 0) return 0;
		if (got == (first ^ (mid & 1))) {
			l = mid;
		} else {
			r = mid;
		}
	}
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  char x, y;
  cin >> x >> y;

  if (x < y) cout << '<' << endl;
  else if (x == y) cout << '=' << endl;
  else cout << '>' << endl;


  
  return 0;
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);
	
	
	char c;
	cin >> c;

	c = c + 1;
	
	cout << c << endl;
	return 0;
}


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

int main()
{
    long n,d,i,x,y;
    int count=0;
    scanf("%ld %ld",&n,&d);
    for(i=0;i<n;i++)
    {
        scanf("%ld %ld",&x,&y);
        if(sqrt(x*x+y*y)<=d)
            count++;
    }
    printf("%d",count);
    return 0;
}


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

long long N, K;

int main(){
    cin >> N >> K;
    vector<int> a(N, 0);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;
            a[A-1]++;
        }
    }
    cout << count(a.begin(), a.end(), 0) << endl;
    return 0;
}


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

namespace ABC085A
{
	class Program
	{
		static void Main(string[] args)
		{
			String s;

			s = Console.ReadLine();

			Char[] cs = s.ToCharArray();
			cs[3] = '8';
			Console.WriteLine(cs);

			Console.ReadKey();

		}
	}
}

Measured memory_bytes: 11092
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    a = set()
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for Ai in A:
            a.add(Ai)
    print(N-len(a))
if __name__ == "__main__":
    main()

Measured memory_bytes: 67484
#include <chrono>
#include <iostream>
#include <map>

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int val;
    cin >> val;
    ++mp[val];
  }
  int ans = 0;
  for (const pair<const int, int>& it : mp)
    ans += (it.second & 1);
  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep (i, n) cin >> h[i];

	sort(rrng(h));

	int ans = INT_MAX;
	for (int i = 0; i < n - k + 1; i++) chmin(ans, h[i] - h[i + k - 1]); 

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

Measured memory_bytes: 640
import itertools

def main():
  n,k = map(int, input().split())
  xy = [tuple(map(int, input().split())) for i in range(n)]
  INF = 10 ** 20
  ans = INF
  for i in itertools.combinations(xy,2):
    max_x,min_x = -INF,INF
    for x,Y in i:
      max_x = max(max_x,x)
      min_x = min(min_x,x)
    for j in itertools.combinations(xy,2):
      max_y,min_y = -INF,INF
      for X,y in j:
        max_y = max(max_y,y)
        min_y = min(min_y,y)
      inrec = 0
      for xi,yi in xy:
        if  (min_x <= xi <= max_x) and (min_y <= yi <= max_y):
          inrec += 1
      if (inrec >= k):
        ans = min(ans,(max_x-min_x)*(max_y-min_y))
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 45788