akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    for i in range(100):
        for j in range(100):
            if i*4 + 7*j == N:
                print('Yes')
                return
    print('No')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
int f[N],pop[N];
int a[N],n;
ll qmi(ll a,ll b,ll p)
{
    ll res=1%p;
    a%=p;
    while(b)
    {
        if(b&1) res=res*a%p;
        b>>=1;
        a=a*a%p;
    }
    return res;
}
int calc(ll x)
{
    int res=0;
    while(x)
    {
        x-=x&-x;
        res++;
    }
    return res;
}
int init()
{
    for(int i=1;i<N;i++) pop[i]=calc(i);
    f[1]=1,f[2]=1;
    for(int i=3;i<N;i++) f[i]=f[i%pop[i]]+1;
}
ll md(ll x,ll y)
{
    return (x%y+y)%y;
}
int main()
{
    cin>>n;
    int s=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%1d",&a[i]);
        s+=a[i];
    }
    if(s>1)
    {
        ll x=0,y=0;
        //init();
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0) continue;
            x=md(x+qmi(2,n-i,s-1),s-1);
            y=md(y+qmi(2,n-i,s+1),s+1);
        }
        for(int i=1;i<=n;i++)
        {
            /*
            if(a[i]==0) cout<<f[md(y+qmi(2,n-i,s+1),s+1)]+1<<endl;
            else cout<<f[md(x-qmi(2,n-i,s-1),s-1)]+1<<endl;*/
            ll ans=0;
            int cnt=1;
            if(a[i]==0) ans=md(y+qmi(2,n-i,s+1),s+1);
            else ans=md(x-qmi(2,n-i,s-1),s-1);
            while(ans)
            {
                ans%=calc(ans);
                cnt++;
            }
            cout<<cnt<<endl;

        }
    }
    else if(s==0) 
        for(int i=1;i<=n;i++) cout<<1<<endl;
    else
    {
        for(int i=1;i<=n;i++)
        {
            if(a[i]==1) cout<<0<<endl;
            else
            {
                if(a[n]==1||i==n) cout<<2<<endl;
				else cout<<1<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4544
#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() {
    int N = input(), M = input();
    vector< int > H(N);
    cin >> H;

    vector< int > ans(N, 1);
    range(i, 0, M) {
        int a = input() - 1, b = input() - 1;
        if (H[a] <= H[b]) {
            ans[a] = false;
        }
        if (H[b] <= H[a]) {
            ans[b] = false;
        }
    }

    cout << whole(accumulate, ans, 0ll) << endl;
}

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


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

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

    if (a <= 0 and b >= 0) {
        cout << "Zero" << endl;
        return 0;
    }

    if (a > 0) cout << "Positive" << endl;

    if (a <= 0 and b < 0) {
        long long c = b - a + 1;
        if (c % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256
/*input
6 6
..#..#
......
#..#..
......
.#....
....#.
*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 1005;
int dist[N][N];
vector < pair < int, int > > dir;

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

  dir.push_back({1, 0});
  dir.push_back({-1, 0});
  dir.push_back({0, 1});
  dir.push_back({0, -1});

  for(int i = 0; i < n; i ++) {
    for(int j = 0; j < m; j ++) {
      dist[i][j] = SINF;
    }
  }

  queue < pair < int, int > > q;
  for(int i = 0; i < n; i ++) {
    for(int j = 0; j < m; j ++) {
      char c;
      cin >> c;
      if(c == '#') {
        dist[i][j] = 0;
        q.push({i, j}); 
      }
    }
  }

  while(!q.empty()) {
    int x, y;
    tie(x, y) = q.front();
    q.pop();
    for(auto p: dir) {
      int x1 = x + p.first;
      int y1 = y + p.second;
      if(x1 >= 0 and x1 < n and y1 >= 0 and y1 < m and dist[x1][y1] > dist[x][y] + 1) {
        dist[x1][y1] = dist[x][y] + 1;
        q.push({x1, y1});
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i ++) {
    for(int j = 0; j < m; j ++) {
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 12432
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;

int main(){
    int N,M;cin>>N>>M;
    cout<<100*pow(2,M)*(18*M+N)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by labuser on 2016/04/19.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }


    private void run() {

        int i = 1;

        Scanner sc = new Scanner(System.in);

        while (true) {
            int a = sc.nextInt();
            if (a == 0) break;
        else {
                System.out.println("Case" + " " + i + ":" + " " + a);
                i = i + 1;
            }


        }
    }
}

Measured memory_bytes: 42640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int n;
    cin >> n;
    vi dp(n, INF), a(n);
    for (auto &i: a) {
        cin >> i;
    }
    dp[0] = 0;
    rep(i,0,n) {
        dp[i + 1] = min(dp[i+1], dp[i] + abs(a[i] - a[i+1]));
        dp[i + 2] = min(dp[i+2], dp[i] + abs(a[i] - a[i+2]));
    }
    cout << dp[n-1] << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3992
w,h,ｎ = map(int, input().split())
ans = [[0]*(w) for i in range(h)]
for i in range(n):
  x,y,a = map(int, input().split())
  if a == 1:
    for i in range(x):
      for j in range(h):
        ans[j][i] = 1
  elif a == 2:
    for i in range(x,w):
      for j in range(h):
        ans[j][i] = 1
  elif a == 3:
    for i in range(w):
      for j in range(y):
        ans[j][i] = 1
  elif a == 4:
    for i in range(w):
      for j in range(y,h):
        ans[j][i] = 1

cnt = 0
for i in ans:
  cnt += sum(i)
print(h*w - cnt)
    

Measured memory_bytes: 9436
(a, b) = gets.chomp.split(' ').map(&:to_i)

def palindromic?(n)
  s = n.to_s
  
  (0..(s.size / 2)).each do |i|
    if s[i] != s[(s.size - 1) - i] then
      return false
    end
  end
  
  return true
end

c = 0

(a..b).each do |n|
  if palindromic?(n) then
    c += 1
  end
end

puts c.to_s

Measured memory_bytes: 1788
num = int(input())
item = input().split()
res = 0

for i in range(num):
  if i == 0:
    continue
  b = int(item[i - 1])
  t = int(item[i])
  
  if b > t:
    res += (b - t)
    item[i] = b
    
      
print(res)

Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> p(n*n),m(n*n);
    vector<bool> v(n*n);
    for(auto&i:p) cin>>i,--i;
    fr(i,n) fr(j,n) m[i*n+j]=min({i,j,n-1-i,n-1-j});
    int ans{};
    for(auto l:p){
        ans+=m[l];
        queue<int> q;
        q.emplace(l);
        v[l]=true;
        while(!q.empty()){
            int i=q.front();q.pop();
            int D=m[i];
            if(!v[i]) ++D;
            if(i/n and m[i-n]>D) m[i-n]=D,q.push(i-n);
            if(i%n and m[i-1]>D) m[i-1]=D,q.push(i-1);
            if(i<n*n-n and m[i+n]>D) m[i+n]=D,q.push(i+n);
            if(i%n<n-1 and m[i+1]>D) m[i+1]=D,q.push(i+1);
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 5312
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

int main(){
    int r;
    cin>>r;
    cout<<r*r<<endl;
    return 0;
}




Measured memory_bytes: 256
import numpy as np
h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(map(int, list(input()))))
s = np.array(s)

def count(li):
    if np.max(li) > k:
        return -1
    tmp = np.zeros(len(li), dtype=int)
    cnt = len(li)-1
    for i in range(w):
        tmp += li[:, i]
        if np.max(tmp) > k:
            cnt += 1
            if cnt >= ans:
                return -1
            tmp = li[:, i]
    return cnt

ans = 1000000
for i in range(2**(h-1)):
    r = 0
    l = []
    for j in range(h-1):
        if (i>>j)&1:
            l.append(np.sum(s[r:j+1, :], axis=0))
            r = j+1
    l.append(np.sum(s[r:, :], axis=0))
    if ans <= len(l)-1:
        continue
    cnt = count(np.vstack(l))
    if cnt>=0:
        ans = min(ans, cnt)
print(ans)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;

    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    #endif // _DEBUG

    string s;
    cin >> s;
    string x(s.size(), 'x');
    cout << x;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c,n,cou;
    while(scanf("%d%d%d",&a,&b,&c),a + b + c)
    {
        scanf("%d",&n);
        int str[4][2000] = {0};
        int check[400] = {0};
        for(int i = 0; i < n; i++)
        {
            scanf("%d%d%d%d",&str[0][i],&str[1][i],&str[2][i],&str[3][i]);
            if(str[3][i] == 1)for(int j = 0; j < 3; j++)check[str[j][i]] = 1;
        }
        for(int i = 0; i < n; i++)
        {
            if(str[3][i] == 0)
            {
                cou = 0;
                for(int j = 0; j < 3; j++)if(check[str[j][i]] == 1)cou++;
                if(cou == 2)for(int j = 0; j < 3; j++)if(check[str[j][i]] == 0)check[str[j][i]] = 2;
            }
        }
        for(int i = 1; i < a + b + c + 1; i++)
        {
            if(check[i] == 1)printf("1\n");
            else if(check[i] == 0)printf("2\n");
            else printf("0\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2640
#include<stdio.h>
#include<math.h>

#define N 501000

int merge(int *,int,int,int);
int mergeSort(int *,int,int);

int main(void){
  int n,cnt,S[N];
  int i;
  
  scanf(" %d",&n);
  for(i = 0; i < n; i++){
    scanf(" %d",&S[i]);
  }

  cnt = mergeSort(S,0,n);

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

int merge(int *A, int left, int mid, int right){
  int n1,n2,cnt=0,L[N/2],R[N/2];
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = A[left+i];
  }
  /*
  if(A[left] == 0) printf("left: %d\n",left);
  if(A[mid] == 0) printf("mid: %d\n",mid);
  if(A[right] == 0) printf("right: %d\n",right);
  */
  /*  
  for(i = 0; i < n1; i++){
    printf("L[%d]:",i);
    printf("%d ",L[i]);
  }
  printf("\n");
  */
  for(i = 0; i < n2; i++){
    R[i] = A[mid+i];
  }
  /*
  for(i = 0; i < n2; i++){
    printf("R[%d]:",i);
    printf("%d ",R[i]);
  }
  printf("\n");
  */
  L[n1] = (int)INFINITY;
  R[n2] = (int)INFINITY;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      cnt++;
    }
    else{
      A[k] = R[j];
      j++;
      cnt++;
    }
    //if(A[k] == 0) printf("k: %d\n",k);
  }
  //printf("right.500000: %d\n",A[500000]);
  return cnt;
}

int mergeSort(int *A, int left, int right){
  int mid,cnt=0;
  int i;
  if(left+1 < right){
    mid = (left+right)/2;
    cnt += mergeSort(A,left,mid);
    cnt += mergeSort(A,mid,right);
    cnt += merge(A,left,mid,right);
  }
  return cnt;
}



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


int main(){
  int K;
  cin >> K;
  vector <int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << a.at(K-1);
  
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())

*parent, = range(n)
def root(x):
    if x != parent[x]:
        x = parent[x] = root(parent[x])
    return x

def unite(x, y):
    px = root(x)
    py = root(y)

    if px < py:
        parent[py] = px
    else:
        parent[px] = py

def same(x, y):
    return root(x) == root(y)

for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        unite(x, y)
    else:
        print(int(same(x, y)))

Measured memory_bytes: 7992
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;

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

  int cnt = 0;
  int max = 0;
  for (int i = 0; i < 3; i++) {
    if (str[i] == 'R') {
      cnt++;
    } else {
      if (cnt > max) {
        max = cnt;
        cnt = 0;
      }
    }
  }

  if (cnt > max) {
    max = cnt;
    cnt = 0;
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n; cin>>n;
  vi x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  vi a(n),b(n);
  rep(i,n) a[i]=x[i]+y[i];
  rep(i,n) b[i]=y[i]-x[i];
  sort(all(a)); sort(all(b));
  out(max(a[n-1]-a[0],b[n-1]-b[0]));
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 9516
#include <stdio.h>
#define a 100
#define swap(a,b) a^=b^=a^=b

int main(){
    
    int N, i, j, A[a], minj, cnt=0;
    
    scanf("%d", &N);
    for(i=0; i<N; i++)
        scanf("%d", &A[i]);
    
    for(i=0; i<N; i++){
        minj = i;
        for(j=i+1; j<N ; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[i]>A[minj]){
        swap(A[i], A[minj]);
        cnt++;
        }
    }
    
    for(i=0; i<N; i++){
        printf("%d", A[i]);
        if(i != N-1){
            printf(" ");
        }
    }
    printf("\n%d\n", cnt);
    return 0;
}

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

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	bool ans = false;
	for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) {
		if (i * (m-j) + j * (n-i) == k) {ans = true; break;}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define ll long long
#define endl "\n"
#define int ll

signed main ()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int r, g, b;
	cin >> r >> g >> b;
	int k;
	cin >> k;

	for (int i = 0; i < k; i++) {
		if (g <= r) {
			g *= 2;
		}
		else b *= 2;
	}

	if (b > g and g > r) {
		cout << "Yes" << endl;
	}

	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 3644
#include<iostream>
#define rep(i,n) for(int i=1;i<=n;i++)

using namespace std;

unsigned int GetDigit(unsigned int num){
    unsigned int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main()
{
  unsigned int n;
  int count=0;
  cin>>n;
  rep(i,n)
  {
    int keta=GetDigit(i);
    if(keta%2==1)count++;
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N];
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
    	for (int i = 1; i <= 5; i ++) {
    		cin >> a[i];
    		if (!a[i]) {
    			return cout << i, 0;
		    }
	    }
    	
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
int main(){
	std::string input;
	std::cin>>input;
	std::string output;

	if(input == "Sunny"){
	output = "Cloudy";

	}else if(input == "Cloudy"){
	output = "Rainy";

	}else if(input == "Rainy"){
	output = "Sunny";

	}
	std::cout<<output;
}

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

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  
  vector<int> aa(a);
  for(int i = 0; i < a; i++) {
    cin >> aa.at(i);
  }
  
  vector<int> bb(b);
  for(int i = 0; i < b; i++) {
    cin >> bb.at(i);
  }
  
  int min = 1000000;
  
  for(int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    int temp = aa.at(x - 1) + bb.at(y - 1) - c;
    if(temp < min) {
      min = temp;
    }
  }

  sort(aa.begin(), aa.end());
  sort(bb.begin(), bb.end());
  
  int mm = aa.at(0) + bb.at(0);
  if(mm < min) {
    min = mm;
  }
  
  cout << min << endl;
}


Measured memory_bytes: 1024
// copied by Nurstan Duisengaliev
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int n;
	cin >> n;
	double x = n;
	double y = (n / 2 + (n % 2 == 1));
	cout << fixed << setprecision (6) << y / x;	
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

typedef struct {
    char name;
    int Val;
    int index;
}Dat;


void swap(Dat *Card, int i, int j){
    
    Dat temp = Card[i];
    Card[i] = Card[j];
    Card[j] = temp;
}

int Partition(Dat *Card, int p, int r){
    
    int x = Card[r].Val;
    int i = p-1;
    for(int j = p; j < r; j++){
        if (Card[j].Val <= x){
        i+=1;
        swap(Card, i , j);
        }
    }
 swap(Card, i+1, r);
 return i + 1;
 }

void QuickSort(Dat *Card, int p, int r){
    
    if (p < r){
        int q = Partition(Card, p, r);
        QuickSort(Card, p, q-1);
        QuickSort(Card, q+1, r);
    }
}
/*
 * 
 */
int main(int argc, char** argv) {
    
    int Num;
    scanf("%d",&Num);
    Dat *Card = (Dat*)malloc(Num * sizeof(Dat));
    
    for(int a = 0; a < Num; a++){
        
        scanf(" %c %d",&Card[a].name,&Card[a].Val);
        Card[a].index = a;
    }

    QuickSort(Card,0,Num-1);
    

    int stable = 1;
    for(int a = 0; a < Num - 1; a++){
        if(Card[a].Val == Card[a + 1].Val){
           if(Card[a].index > Card[a + 1].index){
               stable = 0;
               break;
           }
        }
    }
    
    if(stable == 1)printf("Stable\n");
    if(stable == 0)printf("Not stable\n");

    
    for(int a = 0; a < Num; a++){
        
            printf("%c %d\n",Card[a].name,Card[a].Val);
    }

    return (0);
}



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

int main() {

	string s; cin>>s;
	int n=s.length();
	int i=0, j=n-1;
	int c=0;
	while(i<j)
	{
		if(s[i]!=s[j])
		{c++;}
		i++; j--;
	}
	cout<<c<<endl;
	
}

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

int main()
{
	int n;
	cin >> n;
	switch (n % 10) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			puts("hon");
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			puts("pon");
			break;
		case 3:
			puts("bon");
			break;
	}
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int ans;
int N;

void dfs(int depth, bool flag3, bool flag5, bool flag7, int n);

int main(){
    ans = 0;
    cin >> N;
    dfs(0, false, false, false, 0);
    cout << ans << endl;
}

void dfs(int depth, bool flag3, bool flag5, bool flag7, int n){
    if(flag3 && flag5 && flag7 && n <= N){ 
            ans++;
    }
    if(depth == 9){
            return;
    }else{
        dfs(depth + 1, true, flag5, flag7, n*10+3);
        dfs(depth + 1, flag3, true, flag7, n*10+5);
        dfs(depth + 1, flag3, flag5, true, n*10+7);
    }
    return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

struct segment{
    vector <ll> tree;
    int n;
    void resize(int _n){
        n = _n;
        tree.resize(4 * n);
    }
    void update(int l, int r, int node, int left, int right, ll val){
        if(l > r) return;
        if(l > right || r < left) return;
        if(l >= left && r <= right){
            tree[node] = val;
            return;
        }
        int mid = (l + r) >> 1;
        update(l, mid, node << 1, left, right, val);
        update(mid+1, r, node << 1 | 1, left, right, val);
        tree[node] = max(tree[node << 1], tree[node << 1 | 1]);
    }
    ll query(int l, int r, int node, int left, int right){
        if(l > r) return 0;
        if(l > right || r < left) return 0;
        if(l >= left && r <= right) return tree[node];
        int mid = (l + r) >> 1;
        return max(query(l, mid, node << 1, left, right), query(mid + 1, r, node << 1 | 1, left, right));
    }
};

int n;
vector <int> h, a;
segment tree;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    tree.resize(n);
    h.resize(n);
    a.resize(n);
    for(auto &i : h) cin >> i;
    for(auto &i : a) cin >> i;
    ll ans = 0;
    for(int i = 0 ; i < n ; i++){
        ll cur = a[i] + tree.query(0, n, 1, 0, h[i] - 1);
        ans = max(ans, cur);
        tree.update(0, n, 1, h[i], h[i], cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;++i) {
    cin>>a[i];
    a[i]--;
  }
  int now = 0;
  int ans = -1;
  for(int i=0;i<N;++i) {
    now = a[now];
    if(now==1) {
      ans = i+1;
      break;
    }
  }
  cout<<ans<<endl;
}



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

int gcd(int a, int b) {
    int c=a%b;
    while (c>0) {
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

int main() {
    int n,y;
    cin >> n >> y;
    vector<int> x(n+1);
    for (int i=0;i<n;i++) cin >> x[i];
    x[n]=y;
    sort(x.begin(),x.end());
    for (int i=1;i<n+1;i++) x[i]-=x[0];
    int ans=x[1];
    for (int i=2;i<n+1;i++) {
        ans=gcd(ans,x[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
int n;
vector<int> dp,a;

int solve(int u) {
    if(dp[u] != -INF) return dp[u];
    if(u == n)        return 0;
    int cost = INF;
    if(u <= n-1) {
        cost = min(cost, solve(u+1) + abs(a[u]-a[u+1]));
    }
    if(u <= n-2) {
        cost = min(cost, solve(u+2) + abs(a[u]-a[u+2]));
    }
    return dp[u] = cost;
}

int main() {
    cin >> n;
    dp.resize(n+1, -INF);
    a.resize(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    cout << solve(1);
    return 0;
}

Measured memory_bytes: 5760
n = int(input())
score = 0
i = 0
ans_list = []

while score < n:
    i += 1
    score += i
    ans_list.append(i)

if score == n:
    for k in range(len(ans_list)):
        print(ans_list[k])
else:
    ans_list.remove(score - n)
    for k in range(len(ans_list)):
        print(ans_list[k])

Measured memory_bytes: 9300
#include<bits/stdc++.h>
using namespace std;
#define maxn 1010
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize(2)
#define ll long long
#define makefa(n) for(int i=1;i<=(n);i++)f[i]=i;
#define hh puts("");
int main(){
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

string s[100000];
int v[100000];

void work() {
	cout << " is working hard now.\n";
}

void idol() {
	cout << " is not working now.\n";
}

void Use(set<pair<int, int>>&used, set<pair<int, int>>&unused) {
	auto it = prev(unused.end());
	used.insert(*it);
	cout << s[it->second];
	work();
	unused.erase(it);
}

void Unuse(set<pair<int, int>>&used, set<pair<int, int>>&unused) {
	auto it = used.begin();
	unused.insert(*it);
	cout << s[it->second];
	idol();
	used.erase(it);
}

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

	cin >> N;
	map<string, int>mp;
	set<pair<int, int>>used;
	set<pair<int, int>>unused;
	int num = 0;
	for (int i = 0; i < N; i++) {
		cin >> s[i] >> v[i];
		mp[s[i]] = i;
		num++;
		used.insert({ v[i],i });
	}
	while (used.size() > num / 5) {
		unused.insert(*used.begin());
		used.erase(used.begin());
	}
	cin >> M;
	for (int i = N; i < N + M; i++) {
		char c;
		string t;
		cin >> c >> t;
		if (c == '+') {
			cin >> K;
			s[i] = t;
			v[i] = K;
			mp[s[i]] = i;
			num++;
			if (!used.empty() && *used.begin() < make_pair(v[i], i)) {
				cout << s[i];
				work();
				used.insert({ v[i],i });
			}
			else if (num % 5 == 0 && *unused.rbegin() < make_pair(v[i], i)) {
				cout << s[i];
				work();
				used.insert({ v[i],i });
			}
			else {
				cout << s[i];
				idol();
				unused.insert({ v[i],i });
			}
		}
		else {
			auto p = make_pair(v[mp[t]], mp[t]);
			num--;
			if (used.find(p) == used.end()) {
				unused.erase(p);
			}
			else {
				used.erase(p);
			}
		}
		while (used.size() < num / 5) {
			Use(used, unused);
		}
		while (used.size() > num / 5) {
			Unuse(used, unused);
		}
		//cout << num << " " << used.size() << " " << unused.size() << endl;
	}
}


Measured memory_bytes: 12900
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI mq;
map<in,in> qc;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,q;
  cin>>n>>q;
  mq.resize(q+1);
  mq[0]=n;
  forn(i,q)
    cin>>mq[i+1];
  reverse(all(mq));
  in rr=1;
  for(in i=1;i<=q;++i){
    if(mq[i]<mq[rr-1])
      mq[rr++]=mq[i];
  }
  mq.resize(rr);
  reverse(all(mq));
  qc[-mq.back()]=1;
  map<in,in>::iterator it;
  in id;
  while(1){
    it=qc.begin();
    if(-it->first<=mq[0])
      break;
    id=lower_bound(all(mq),-it->first)-mq.begin();
    --id;
    qc[-mq[id]]+=(-it->first)/mq[id]*it->second;
    qc[-((-it->first)%mq[id])]+=it->second;
    qc.erase(it);
  }
  in tt=0;
  fors(i,qc)
    tt+=i->second;
  tt-=qc[0];
  for(in i=1;i<=n;++i){
    cout<<tt<<"\n";
    tt-=qc[-i];
  }
  return 0;
}


Measured memory_bytes: 8704
T = [
  [nil, 300, 500, 600, 700, 1350, 1650],
  [300, nil, 350, 450, 600, 1150, 1500],
  [500, 350, nil, 250, 400, 1000, 1350],
  [600, 450, 250, nil, 250, 850, 1300],
  [700, 600, 400, 250, nil, 600, 1150],
  [1350, 1150, 1000, 850, 600, nil, 500],
  [1650, 1500, 1350, 1300, 1150, 500, nil]
].freeze
S = [0, 6, 13, 18, 23, 43, 58].freeze
s, f = 17 * 60 + 30, 19 * 60 + 30
loop do
  e = false
  d = gets.to_i
  break if d.zero?
  d -= 1
  h, m = gets.split.map(&:to_i)
  m += 60 * h
  e = true if s <= m && m <= f
  a = gets.to_i - 1
  h, m = gets.split.map(&:to_i)
  m += 60 * h
  e = true if s <= m && m <= f
  d, a = a, d if d > a
  e = false if S[a] - S[d] > 40
  c = T[d][a]
  if e
    c /= 2
    c += 25 if c % 10 == 5
  end
  p c
end

Measured memory_bytes: 8652
N,M = map(int, input().split())
list_point = ["NN"] * (N + 1)
list_wa = [0] * (N + 1)
for x in range(M):
    point,state = input().split()
    point = int(point)
    if(list_point[point]!='AC' and state == 'AC'):
        list_point[point]=state
    elif(list_point[point]!='AC' and state == 'WA'):
        list_wa[point] += 1
#print(list_point)
#print(list_wa)
sum_wa =0
for x in range(N+1):
    if(list_point[x] == "AC"):
        sum_wa += list_wa[x]
print(list_point.count('AC'),sum_wa)
#print(' ',sum(list_wa))


Measured memory_bytes: 10100
#include<stdio.h>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  long long perm_n = 1;
  long long perm_m = 1;
  for (long long i=1 ; i<=n ; i++) {
    perm_n = (perm_n*i)%1000000007LL;
  }
  for (long long i=1 ; i<=m ; i++) {
    perm_m = (perm_m*i)%1000000007LL;
  }
  if (n == m) {
    printf("%lld\n", 2*perm_n*perm_m%1000000007LL);
  } else if (abs(n-m) == 1) {
    printf("%lld\n", perm_m*perm_n%1000000007LL);
  } else {
    printf("%d\n", 0);
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  sort(v.begin(), v.end(), greater<int>());
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) alice += v[i];
    else bob += v[i];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc076/tasks/abc076_c

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

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string ans = "~";
    REP(i, S.length()-T.length()+1) {
        string sub = S.substr(i, T.length());
        bool can = true;
        REP(j, T.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }

        if (!can) continue;

        string P = S;
        REP(j, T.length()) {
            P[i+j] = T[j];
        }

        REP(j, P.length()) {
            if (P[j] == '?') P[j] = 'a';
        }

        ans = min(ans, P);
    }

    if (ans == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << ans << "\n";
    }

    return 0;
}


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

int n,k,q,dude,a[100001],b[100001];

int main(){
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++){
		a[i]=k;
	}
	for(int i=1;i<=q;i++){
		cin>>dude;
		b[dude]++;
	}
	for(int i=1;i<=n;i++){
		if((a[i]+b[i]-q)>0){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
}


Measured memory_bytes: 4388
#include<stdio.h>

int main(void){
    int p, q, r;

    scanf("%d %d %d",&p,&q,&r);

    int max = p;

    if(p >= q && p >= r){
        max = p;
    } 
    if(q >= r && q >= p){
        max = q;
    }
    if(r >= p && r >= q){
        max = r;
    }
    printf("%d",p + q + r - max);
    return 0;
}

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

capacity = 0
f_capacity = 0

for c in s:
    if c == 'a':
        if capacity < a+b:
            capacity += 1
            print('Yes')
        else:
            print('No')
    elif c == 'b':
        if capacity < a+b and f_capacity < b:
            capacity += 1
            f_capacity += 1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int c = sc.nextInt();
        long k = sc.nextInt();
        long[] arr = sc.nextLongArray(n);
        Arrays.sort(arr);
        long limit = arr[0]+k;
        int nowOn = 1;
        int ans = 1;
        for(int i = 1; i < n; i++){
            long now = arr[i];
            if(nowOn >= c || limit < now){
                limit = now + k;
                nowOn = 1;
                ans++;
            }else{
                nowOn++;
            }
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 41984
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  vector<int> a(3);
  rep(i,3)cin>>a[i];
  sort(a.begin(),a.end());
  int ans=(a[2]-a[1])+(a[1]-a[0]);
  cout<<ans<<endl;
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int s;
    cin>>s;
    set<int> viz;
    for (int i=1;;i++) {
	if (viz.count(s)) {
	    out(i);
	}
	viz.insert(s);
	if (s%2) {
	    s=3*s+1;
	} else {
	    s /= 2;
	}
    }
    
    
    return 0;
}


Measured memory_bytes: 3656
N=int(input())
H=list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(H[0]-H[1])

for i in range(2,N):
    before_2=dp[i-2]+abs(H[i-2]-H[i])
    before_1=dp[i-1]+abs(H[i-1]-H[i])
    dp[i]=min(before_2,before_1)
print(dp[N-1])

Measured memory_bytes: 13928
n=int(input())
v=[]
name=[]
ans=0
for i in range(n):
    x,y=input().split()
    v.append(float(x))
    name.append(y)
for j in range(n):
    if name[j]=='JPY':
        ans+=v[j]
    else:
        ans+=380000.0*v[j]
print(ans)
    

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; 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.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

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

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(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); }
// clang-format on

signed main(int argc, char *argv[]) {
  int64_t n = in(), m = in(), d = in();

  if (d)
    cout << (double)(2 * (n - d)) / (n * n) * (m - 1) << endl;
  else
    cout << (double)(n - d) / (n * n) * (m - 1) << endl;
}


Measured memory_bytes: 256