akhauriyash/Code-Regression huggingface dataset:
import sys
#import fractions
from math import gcd
import itertools

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def gcd_list(numbers):
    return reduce(gcd, numbers)

def euclid(p,q):
    if p%q==0:
        return q
    else:
        return euclid(q,p%q)


N = II()

ans=0

for i in range(1, N+1):
    for j in range(1, N+1):
        x = gcd(i,j)
        for k in range(1, N+1):
            ans+=gcd(x,k)


print(ans)


Measured memory_bytes: 9252
import sys
import numpy as np
from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit('(i8[::1],)', cache=True)
def update(A):
    N = len(A)
    B = np.zeros_like(A)
    for i, x in enumerate(A):
        l = max(0, i - x)
        r = min(N - 1, i + x)
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1
    B = np.cumsum(B)
    return B
 
N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)
 
K = min(K, 100)
for _ in range(K):
    A = update(A)
print(' '.join(A.astype(str)))

Measured memory_bytes: 147652
#include<iostream>
using namespace std;
int main() {
  int N,i,countW[200001],countB[200001],ans=200001;
  char S[200001];
  cin >> N >> S;
  countW[0]=0;countB[0]=0;
  for(i=0;i<N;i++) {
    countW[i+1] = countW[i];
    countB[i+1] = countB[i];
    if(S[i] == '.')countW[i+1]++;
    else countB[i+1]++;
  }
  for(i=0;i<N+1;i++) {
    if(ans > countB[i]+countW[N]-countW[i])ans = countB[i]+countW[N]-countW[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2048
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]

Z = 1000

dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][0] = (1 << Z)

for h in range(H):
    for w in range(W):
        d = dp[h][w]
        k = abs(A[h][w] - B[h][w])

        dp[h + 1][w] |= (d << k) | (d >> k)
        dp[h][w + 1] |= (d << k) | (d >> k)

ans = 10**18
for a in (dp[H][W - 1], dp[H - 1][W]):
    for d in range(Z * 2 + 10):
        if a & (1 << d) != 0:
            ans = min(ans, abs(d - Z))
print(ans)


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

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> v;
  v.push_back(0);
  for(ll i = 1; i*i <= n; i++) {
    v.push_back(i);
    if(i != n/i) v.push_back(n/i);
  }
  sort(v.begin(),v.end());
  vector<ll> p(v.size(),0);
  for(int i = 1; i < v.size(); i++) {
    int s = upper_bound(v.begin(),v.end(),n/v[i]) - v.begin();
    p[i] = s-1;
  }
  vector<vector<ll>> dp(k+1,vector<ll>(v.size(),0));
  for(int i = 1; i < v.size(); i++) dp[0][i] = 1;
  rep(i,k) {
    for(int j = 1; j < v.size(); j++) {
      dp[i+1][j] = (dp[i][p[j]] * (v[j]-v[j-1]) + dp[i+1][j-1]) % mod;
    }
  }
  cout << dp[k][v.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 51960
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

int main (void){  
    int n, m;
    cin >> n;
    if (n % 1000 == 0) {
        cout << n % 1000 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

template<int mod>
struct ModInt{
	int x;
	ModInt () : x(0) {}
	ModInt (int64_t x) : x(x >= 0 ? x % mod : (mod - -x % mod) % mod) {}
	ModInt &operator += (const ModInt &p){
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator -= (const ModInt &p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator *= (const ModInt &p) {
		x = (int64_t) x * p.x % mod;
		return *this;
	}
	ModInt &operator /= (const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt &operator ^= (int64_t p) {
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator - () const { return ModInt(-x); }
	ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
	ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
	ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
	ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
	ModInt operator ^ (int64_t p) const { return ModInt(*this) ^= p; }
	bool operator == (const ModInt &p) const { return x == p.x; }
	bool operator != (const ModInt &p) const { return x != p.x; }
	explicit operator int() const { return x; }
	ModInt &operator = (const int p) { x = p; return *this;}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			a -= t * b;
			std::swap(a, b);
			u -= t * v;
			std::swap(u, v);
		}
		return ModInt(u);
	}
	friend std::ostream & operator << (std::ostream &stream, const ModInt<mod> &p) {
		return stream << p.x;
	}
	friend std::istream & operator >> (std::istream &stream, ModInt<mod> &a) {
		int64_t x;
		stream >> x;
		a = ModInt<mod>(x);
		return stream;
	}
};

template<int mod> struct MComb {
	using mint = ModInt<mod>;
	std::vector<mint> fact;
	std::vector<mint> inv;
	MComb (int n) { // O(n + log(mod))
		fact = std::vector<mint>(n + 1, 1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * mint(i);
		inv.resize(n + 1);
		inv[n] = fact[n] ^ (mod - 2);
		for (int i = n; i--; ) inv[i] = inv[i + 1] * mint(i + 1);
	}
	mint ncr(int n, int r) {
		return fact[n] * inv[r] * inv[n - r];
	}
	mint npr(int n, int r) {
		return fact[n] * inv[n - r];
	}
	mint nhr(int n, int r) {
		assert(n + r - 1 < (int) fact.size());
		return ncr(n + r - 1, r);
	}
};

typedef ModInt<1000000007> mint;


int main() {
	int n = ri();
	int m = ri();
	MComb<1000000007> com(n * 2);
	mint res = 0;
	mint cur = 1;
	for (int i = m; i > m - n; i--) cur *= i;
	for (int i = n; i >= 0; i--) {
		if (i != n) cur *= m - i;
		mint tmp = com.ncr(n, i) * cur;
		if (i & 1) res -= tmp;
		else res += tmp;
	}
	printf("%d\n", res.x);
	return 0;
}


Measured memory_bytes: 11056
#include <iostream>

using namespace std;

int main(){
    long n, m, i, e, j, c, max;
    cin>>n;
    m = 0;
    e = 0;
    long v[n], v2[n], v3[n];
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    for(i=0;i<n;i=i+2){
        if(v[i]>0){
            m = m+v[i];
        }
    }
    
    for(i=1;i<n;i=i+2){
        if(v[i]>0){
            e = e+v[i];
        }
    }
    if((m==0)&&(e==0)){
        max = v[0];
        for(i=0;i<n;i++){
            if(v[i]>max){
                max=v[i];
                j = i;
            }
        }
        cout<<max<<endl;
        cout<<n-1<<endl;
        for(i=n;i>j+1;i--){
            cout<<i<<endl;
        }
        for(i=0;i<j;i++){
            cout<<1<<endl;
        }
    }
    else{
    if(m>e){
        cout<<m;
        c = 0;
        for(i=0;i<n;i++){
            if((v[i]>0)&&(i%2==0)){
                v2[i]=1;
            }
            else{
                v2[i] = 0;
            }
        }
        i = n-1;
        while(v2[i]==0){
            v3[j] = n-j;
            j++;
            i--;
        }
        m = i;
        i = 0;
        while(v2[i]==0){
            v3[j] = 1;
            j++;
            i++;
        }
        n = i;
        for(i=n+1;i<=m;i++){
            if(v2[i]==1){
                e = j;
                while(j<e+(c-1)/2){
                    v3[j] = 3;
                    j++;
                };
                v3[j]=2;
                j++;
                c=0;
            }
            else{
                c++;
            }
        }
    }
    else{
        m = e;
        cout<<m;
        c = 0;
        for(i=0;i<n;i++){
            if((v[i]>0)&&(i%2==1)){
                v2[i]=1;
            }
            else{
                v2[i] = 0;
            }
        }
        i = n-1;
        while(v2[i]==0){
            v3[j] = n-j;
            j++;
            i--;
        }
        m = i;
        i = 0;
        while(v2[i]==0){
            v3[j] = 1;
            j++;
            i++;
        }
        n = i;
        for(i=n+1;i<=m;i++){
            if(v2[i]==1){
                e = j;
                while(j<e+(c-1)/2){
                    v3[j] = 3;
                    j++;
                };
                v3[j]=2;
                j++;
                c=0;
            }
            else{
                c++;
            }
        }
    }
    cout<<"\n"<<j<<"\n";
    for(i=0;i<j;i++){
        cout<<v3[i]<<"\n";
    }
    }
}


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

int main() {
	int		h,a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	cin >> n;
	
	str = "APPROVED";
	for(i=0;i<n;i++) {
		cin >> a;
		if ((a & 1) == 0) {
			if ( (( a % 3 ) != 0 ) && (( a % 5 ) != 0 ) ) {
				str = "DENIED";
			}
		}
	}
	cout << str << endl;

}


Measured memory_bytes: 256
def d_abs():
    N, Z, W = [int(i) for i in input().split()]
    A = [W] + [int(i) for i in input().split()]  # こうすると場合分けが不要
    return max(abs(A[N] - W), abs(A[N] - A[N - 1]))

print(d_abs())

Measured memory_bytes: 3188
mod = 10**9 + 7
H, W = map(int, input().split())
Maze = [[0]*(W+1) for _ in range(H+1)]
Memo = [[0]*(W+1) for _ in range(H+1)]
Memo[H-1][W-1] = 1
for i in range(H):
    S = input()
    for j in range(W):
        Maze[i][j] = S[j]

for a in range(H-1, -1, -1):
    for b in range(W-1, -1, -1):
        if Maze[a][b] == '#':
            Memo[a][b] = 0
        elif (a == H-1) and (b == W-1):
            continue
        else:
            Memo[a][b] = Memo[a+1][b] + Memo[a][b+1]
            Memo[a][b] %= mod
print(Memo[0][0])


Measured memory_bytes: 129368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    deque<int> q;
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (n % 2 == 0) {
            if (i % 2 == 0) {
                q.push_back(a);
            } else {
                q.push_front(a);
            }
        } else {
            if (i % 2 != 0) {
                q.push_back(a);
            } else {
                q.push_front(a);
            }
        }
    }
    rep(i, n) {
        if (i) cout << " ";
        cout << q.front();
        q.pop_front();
    }
    cout << endl;
}



Measured memory_bytes: 2944
#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 SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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

    int main()
    {
        int W, H, N; cin >> W >> H >> N;
        int lx = 0, rx = W, by = 0, uy = H;
        REP(i, N) {
            int x, y, a; cin >> x >> y >> a;
            if (a == 1) lx = max(lx, x);
            else if (a == 2) rx = min(rx, x);
            else if (a == 3) by = max(by, y);
            else uy = min(uy, y);
        }
        int ans = (rx - lx) * (uy - by);
        if ((rx - lx) > 0 && (uy - by) > 0) cout << ans << endl;
        else cout << 0 << endl;
    } //詰めてく



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

int main() {
    long int k, a, b;
    long int x, y, z;
    cin >> k >> a >> b;

    if(a % k == 0)
    {
        cout << "OK" << endl;
    }
    else
    {
        x = a / k;
        y = (x + 1) * k;
        if(y > a && y <= b) cout << "OK" << endl;
        else cout << "NG" << endl;
    }
}



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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  int sum=0;
  sum = 100*r+10*g+b;
  bool ans = sum%4==0;
  if (ans){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
using namespace std;
#define ll long long

int main(){

    int d, g; cin >> d >> g;

    int p[d], c[d];
    for(int i=0; i<d; i++){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;

    for(int bit=0; bit<(1<<d); bit++){
        int score = 0;
        int temp = 0;

        for(int i=0; i<d; i++){
            // cout << bitset<8>(bit) << " " << bitset<8>(1<<i) << endl;
            if(bit & (1<<i)){
                score += (i+1)*100*p[i] + c[i];
                temp  += p[i];
            }
        }

        // cout << score << " ";

        if(score < g){
            for(int i=d-1; i>=0; i--){
                if(bit & (1<<i)) continue;
                int index = 0;
                while(score < g){
                    score += (i+1)*100;
                    index++;
                    temp++;
                    if(index == p[i]){
                        score += c[i];
                        break;
                    }
                }
                break;
            }
        }

        // cout << score << " " << temp << endl;

        if(score >= g){
            ans = min(ans,  temp);
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,i,j,n,q,S[100000],T[50000],c1=0,c2=0;
  int left=0,mid,right,value;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  for(a=0;a<q;a++){
    left=0;
    right=n;
    while(left<=right){
      // value=(left+right) % 2;                                                
      //if(value==0){                                                           
      //mid = (left+right) / 2;}                                                
      //else if(value!=0){                                                      
      mid = (left+right)/2;
      if(S[mid] == T[a]){
        c1++;
        c2++;
        break;
        if(c2>=2){
          c1--;
        }
      }
      else if (S[mid] < T[a]){
        left = mid + 1;
      }
      else{
        right = mid - 1;
      }
    }
  }
  printf("%d\n",c1);
  return 0;
}



Measured memory_bytes: 2324
#include<stdio.h>
main(){

    int x,y,tmp;
    
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0 && y==0)
            break;
        if(x>y){
            tmp = y;
            y = x;
            x = tmp;
        } 
        printf("%d %d\n",x,y);

    }
    return 0;
}        

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
 
int main(void) {
    int N, Q;
    scanf("%d %d", &N, &Q);
    char S[N+1];
    scanf("%s", S);

    int ans[100001];
    int i, j;
    for( i=0; i<N; i++) {
      // 「右隣がCであるようなA」を数える
ans[0]=0;
      ans[i+1] = ans[i];
      if( S[i]=='A' && S[i+1]=='C') {
        ans[i+1]++;
      }
    }

    int ans2[100001];
    int l, r;
    for( i=0; i<Q; i++) {
      scanf("%d %d", &l, &r);
      ans2[i] = ans[r-1]-ans[l-1];
    }

    for( i=0; i<Q; i++) {
      printf("%d\n", ans2[i]);
    }

return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n; cin>>n; int arr[n];
	for(int i = 0; i < n; i++) cin>>arr[i]; 
	double ans = 0.0;
	for(int i = 0; i < n; i++){
		ans += 1.0/(double)arr[i];
	}
	cout<<1.0/ans<<"\n";
	
	
	
	
}

Measured memory_bytes: 256
INF = float("inf") #const

def main():
    n = int(input())
    dp = [INF]*(n+1)
    dp[0] = 0
    h = list(map(int,input().split()))

    for i in range(1,n):
        dp[i] = min(dp[i],dp[i-1] + abs(h[i]-h[i-1]))
        if i > 1:
            dp[i] = min(dp[i],dp[i-2] + abs(h[i]-h[i-2]))

    print(dp[n-1])


if __name__ == "__main__":
    main()


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll n;
  cin >> n;
  if(n%2==1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll div = 10;
  while(n / div > 0) {
    ans += n/div;
    div *= 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
N, L = map(int, input().split())
list = [0]*N
list_abs = [0]*N
for i in range(N):
    list[i] = L+i
    list_abs[i] = abs(L+i)
index = sorted(range(N), key=lambda k: list_abs[k])
list.pop(index[0])
print(sum(list))


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

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3=x2+y1-y2;
  y3=y2-x1+x2;
  x4=x1+y1-y2;
  y4=y1-x1+x2;
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<double> a(n);
	double sum = 0;

	for(int i = 0 ; i < n; i++)
	{
		cin>>a[i];
		sum+=(1.0/(1.0*a[i]));
	}
	double ans = (1.0/sum);
	cout<<fixed<<setprecision(6)<<ans<<endl;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define ld long double
#define re register
#define li inline
const int INF=0x7ffffff;
const int N=100010;
li ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll n;
ll a[N];
bool cmp(ll x,ll y){
    return x>y;
}
int  main(){
    // freopen("1009.in", "r", stdin);
	// freopen("1009.out", "w", stdout);
    n=read();ll p1,p2;
        for(int i=1;i<=n;i++) a[i]=read();
        sort(a+1,a+1+n,cmp);
        for(int i=0;i<=n;i++){
            if(i>=a[i+1]){
                p1=i;
                break;
            }
        }
        for(int i=1;i<=n+1;i++){
            if(a[i]<=p1-1){
                 p2=i-1;
                 break;
            }
        }
        if(((p2-p1)%2)||((a[p1]-p1)%2))  printf("First\n");
        else printf("Second\n");

    // fclose(stdin);
	// fclose(stdout);
    return 0;
}
/*
3
3 2 1
*/


Measured memory_bytes: 4416
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

struct Info{
      int r,c,count;

    };

bool visited[102][102][5001];

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

  int h,w;
  cin>>h>>w;

  for(int i=0;i<102;i++){
    for(int j=0;j<102;j++){
      for(int k=0;k<5001;k++){
        visited[i][j][k]=false;
      }
    }
  }

  vector<string> field(h+2);
  field[0]=string(w+2,'$');
  field[h+1]=string(w+2,'$');
  for(int i=1;i<=h;i++){
    string s;
    cin>>s;
    field[i]='$'+s+'$';
  }

  Info initial;
  initial.r=1;initial.c=1;
  if(field[1][1]=='.'){
    initial.count=0;
  }else{
    initial.count=1;
  }
  queue<Info> q;
  q.push(initial);
  vector<int> vr{0,1};
  vector<int> vc{1,0};
  int result=100000;
  while(!q.empty()){
    Info curr=q.front();
    q.pop();
    for(int vi=0;vi<2;vi++){
      Info next=curr;
      if(field[curr.r+vr[vi]][curr.c+vc[vi]]=='$') continue;

      next.r+=vr[vi];
      next.c+=vc[vi];
      if(field[curr.r+vr[vi]][curr.c+vc[vi]]=='#'&&field[curr.r][curr.c]=='.'){
        next.count++;
      }
      if(next.r==h&&next.c==w){
        UpdateMin(result,next.count);
        continue;
      }
      if(visited[next.r][next.c][next.count]) continue;
      visited[next.r][next.c][next.count]=true;
      q.push(next);
    }
  }
  cout<<result<<endl;




  return 0;
}




Measured memory_bytes: 51200
BIG_NUM = 2000000000

table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

N = int(input())

for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add


x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()


Measured memory_bytes: 5624
#include <iostream>

using namespace std;
typedef long long ll;

ll n, m; 

void solve() {
  ll total = n * m;
  ll reversed = 0;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
  } else if (n == 1 || m == 1) {
    cout << max(reversed, max(n - 2, m - 2)) << endl;
  } else {
    reversed = 2 * n + 2 * m - 4;
    cout << (n * m - 2 * n  - 2 * m + 4) << endl;
  }
}

int main() {
  cin >> n >> m;
  solve();
}


Measured memory_bytes: 256
x,y = map(int,input().split())
grp = [0]*13
grp[2] = 1 # 2 をグループ番号１に
for i in [4,6,9,11]: # 4,6,9,11 をグループ番号２に
  grp[i] = 2
print('Yes' if grp[x] == grp[y] else 'No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

bool dpx[8010][40000];
bool dpy[8010][40000];
int main(){
    string s; cin>>s;
    vector<int> vx,vy;
    int cnt=1,sum=0;
    for(char c:s){
        if(c=='T'){
            if(cnt%2) vx.push_back(sum);
            else vy.push_back(sum);
            cnt++; sum=0;
        }else{
            sum++;
        }
    }
    if(sum>0){
        if(cnt%2) vx.push_back(sum);
        else vy.push_back(sum);
    }
    int nx=vx.size(),ny=vy.size();
    int x,y; cin>>x>>y;
    dpx[0][20000]=dpy[0][20000]=1;
    for(int i=1;i<=nx;i++){
        int d=vx[i-1];
        for(int j=10000;j<=30000;j++){
            if(i==1) dpx[i][j]=dpx[i-1][j-d];
            else dpx[i][j]=(dpx[i-1][j-d]||dpx[i-1][j+d]);
        }
    }
    for(int i=1;i<=ny;i++){
        int d=vy[i-1];
        for(int j=10000;j<=30000;j++){
            dpy[i][j]=(dpy[i-1][j-d]||dpy[i-1][j+d]);
        }
    }
    cout<<(dpx[nx][x+20000]&&dpy[ny][y+20000]?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 312832
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    for (int i = 0; 4 * i <= N; ++i)
    {
        for (int j = 0; 7 * j <= N; ++j)
        {
            if (4 * i + 7 * j == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
using namespace std;

int main()
{
    int N;
    cin >> N;

    long long res = 0;

    rep(i, N) {
        if (i % 15 == 0) {
            continue;
        }
        else if (i % 3 == 0) {
            continue;
        }
        else if (i % 5 == 0) {
            continue;
        }
        else {
            res = res + i;
        }
    }
    cout << res;
}


Measured memory_bytes: 3200
import collections
n=int(input())
v=list(map(int,input().split()))
vo=v[0::2]
ve=v[1::2]
co=collections.Counter(vo)
ce=collections.Counter(ve)
cmo=co.most_common()
cme=ce.most_common()
ans=n-cmo[0][1]-cme[0][1]
if cmo[0][0]==cme[0][0]:
    if cmo[0][1]>cme[0][1]:
       if cmo[0][1]!=n//2:
           ans=n-cmo[0][1]-cme[1][1]
    elif cmo[0][1]<cme[0][1]:
        if cme[0][1]!=n//2:
            ans=n-cmo[1][1]-cme[0][1]
    else:
        if cmo[0][1]==n//2:
            ans=n//2
        else:
            ans=n-cmo[0][1]-max(cmo[1][1],cme[1][1])
print(ans)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  int n;
  cin>>n;
  int f[n][10],p[n][10];
  rep(i,n)rep(j,10)cin>>f[i][j];
  rep(i,n)rep(j,11)cin>>p[i][j];

  int ans=-(1<<31);
  for(int bit=1;bit<(1<<10);++bit){
    int sum=0;
    rep(i,n){
      int cnt=0;
      rep(j,10){
        if(((bit>>j)&1) && f[i][j]){
          cnt++;
        }
      }
      sum+=p[i][cnt];
    }
    chmax(ans,sum);
  }
  out(ans);
      


  
  
  
  
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $){
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int sum = 0;
		for (int i = 0; i < m; i++) {
			sum += sc.nextInt();
		}

		if (n < sum) {
			System.out.println("-1");
		} else {
			System.out.println(n - sum);
		}

		sc.close();
	}
}



Measured memory_bytes: 46436
N = int(input())
d = {}
E = [[] for _ in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
    d[(a-1,b-1)]=i
    d[(b-1,a-1)]=i
    
K = 0
ans = [None]*(N-1)

#queueに(node,par)を入れる．
q = [(0,-1)]

while q:
    node,p = q.pop()
    col = 1
    for to in E[node]:
        if to!=p:
            q.append((to,node))
            if p!=-1:
                if col==ans[d[(node,p)]]:
                    col+=1
            ans[d[(node,to)]]=col
            K=max(K,col)
            col+=1

print(K)
print(*ans,sep="\n")

Measured memory_bytes: 95392
import java.util.ArrayList;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		Dice dice;
		int set;
		int sum;
		ArrayList<Integer> result = new ArrayList<Integer>();

		for (;;)
		{
			set = sc.nextInt();
			if (set == 0)
				break;
			
			sum = 1;
			dice = new Dice();
			for(int i = 0; i<set; ++i)
			{
				dice.operate(sc.next());
				sum += dice.getTop();
			}
			result.add(sum);
		}
		
		for(int item : result)
			System.out.println(item);

	}

}

class Dice
{
	public int[] Array = new int[6];
	private int tmp;

	public Dice()
	{
		for (int i = 0; i < 6; ++i)
			this.Array[i] = i + 1;
	}

	public void operate(String operation)
	{
		switch (operation)
		{
			case "North":
				this.rollNorth();
				break;

			case "South":
				this.rollSouth();
				break;

			case "East":
				this.rollEast();
				break;

			case "West":
				this.rollWest();
				break;

			case "Left":
				this.rotateLeft();
				break;

			case "Right":
				this.rotateRight();
				break;
		}
	}

	public void rollWest()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[2];
		this.Array[2] = this.Array[5];
		this.Array[5] = this.Array[3];
		this.Array[3] = this.tmp;
	}

	public void rollNorth()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[1];
		this.Array[1] = this.Array[5];
		this.Array[5] = this.Array[4];
		this.Array[4] = this.tmp;
	}

	public void rollEast()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[3];
		this.Array[3] = this.Array[5];
		this.Array[5] = this.Array[2];
		this.Array[2] = this.tmp;
	}

	public void rollSouth()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[4];
		this.Array[4] = this.Array[5];
		this.Array[5] = this.Array[1];
		this.Array[1] = this.tmp;
	}

	public void rotateLeft()
	{
		this.tmp = this.Array[1];
		this.Array[1] = this.Array[3];
		this.Array[3] = this.Array[4];
		this.Array[4] = this.Array[2];
		this.Array[2] = this.tmp;
	}

	public void rotateRight()
	{
		this.tmp = this.Array[1];
		this.Array[1] = this.Array[2];
		this.Array[2] = this.Array[4];
		this.Array[4] = this.Array[3];
		this.Array[3] = this.tmp;
	}

	public int getTop()
	{
		return this.Array[0];
	}

}

Measured memory_bytes: 34124
import sys

a,b,k = map(int, input().split())

if a < k:
    k -= a
    a = 0
elif a >= k :
    a -= k
    print(a ,b)
    sys.exit()

if b < k:
    print(0,0)
elif b >= k:
    b -= k
    print(a,b)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
long long ans,n;
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		int l=i,r=n/i*i;
//		cout<<i<<":"<<n/i<<" "<<l+r<<" "<<(((r-l)/i+1))<<endl;
		ans+=1ll*(l+r)*(((r-l)/i+1))/2;
	} cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,n) for(int i=0; i<n; i++)
#define forp(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100005;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        cout<<n+n*n+n*n*n<<nl;
    }
    return 0;
}

Measured memory_bytes: 3168
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	sum := float64(0)
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		sum += float64(1) / float64(v)
	}
	fmt.Println(float64(1) / sum)
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N;
    cin >> N;

    vector<ll> a(N);
    for (auto &i : a) cin >> i;

    ll ma = 0; int mi = 0;
    rep(i, N) {
        if (chmax(ma, abs(a[i]))) mi = i;
    }

    vector<P> ans;
    if (0 < a[mi]) {
        while (a[0] < ma) {
            a[0] += ma;
            ans.emplace_back(mi, 0);
        }
        
        rep(i, N-1) {
            while (a[i+1] < a[i]) {
                a[i+1] += a[i];
                ans.emplace_back(i, i+1);
            }
        }
    } else {
        ma = a[mi];
        while (a[N-1] > ma) {
            a[N-1] += ma;
            ans.emplace_back(mi, N-1);
        }

        repr(i, N-1) {
            while (a[i] > a[i+1]) {
                a[i] += a[i+1];
                ans.emplace_back(i+1, i);
            }
        }
    }

    cout << ans.size() << endl;
    for (auto &i : ans) {
        cout << i.first+1 << " " << i.second+1 << endl;
    }
}

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

int main()
{
	double a, l, x;
	
	while (scanf("%lf %lf %lf", &a, &l, &x) != EOF){
		double A = a * sqrt(l * l - a * a / 4) / 2;
		double B = l * sqrt((l + x) * (l + x) / 4 - l * l / 4) / 2;
		
		printf("%.10lf\n", A + B + B);
	}
	
	return 0;
}

Measured memory_bytes: 1084
#include <stdio.h>

int main(void){
  int h, w, i, k;

  while(1){
    scanf("%d %d", &h, &w);
    if(h==0 && w==0){ break; }
    for(i=0;i<h;i++){
      for(k=0;k<w;k++){
        if(i==0 || i==h-1 || k==0 || k==w-1){
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

void dfs(int now, vector<vector<int> >&g, vector<int>&counter, vector<int>&used){
  used[now] = 1;
  for(int i : g[now]){
    if(!used[i]) counter[i] += counter[now], dfs(i, g, counter, used);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, q; cin >> n >> q;
  vector<int> counter(n, 0);
  vector<vector<int> > g(n);
  vector<int> used(n, 0);
  for(int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i = 0; i < q; i++){
    int p, x; cin >> p >> x;
    p--;
    counter[p] += x;
  }
  dfs(0, g, counter, used);
  for(int x : counter) cout << x << ' ';
  cout << endl;
  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 27392
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
const MAXN=200000
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,m:=IO.ReadInt(),IO.ReadInt()
	var a,b,c [MAXN+10]int
	ans:=n
	for i:=1; i<=n; i++ {
		a[i]=IO.ReadInt()
		c[a[i]]++
		t:=a[i]-c[a[i]]
		if t>=0 {
			b[t]++
			if b[t]==1 {
				ans--
			}
		}
	}
	for i:=1; i<=m; i++ {
		x,y:=IO.ReadInt(),IO.ReadInt()
		t:=a[x]-c[a[x]]
		if t>=0 {
			b[t]--
			if b[t]==0 {
				ans++
			}
		}
		c[a[x]]--
		a[x]=y
		c[y]++
		t=y-c[y]
		if t>=0 {
			b[t]++
			if b[t]==1 {
				ans--
			}
		}
		fmt.Fprintln(cout,ans)
	}
	cout.Flush()
}


Measured memory_bytes: 17536
#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(digit) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

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

#pragma endregion

const int COMB_MAX = 500000;
const int COMB_MOD = 998244353;
long long fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMB_MAX; i++) {
    fac[i] = fac[i - 1] * i % COMB_MOD;
    inv[i] = COMB_MOD - inv[COMB_MOD % i] * (COMB_MOD / i) % COMB_MOD;
    finv[i] = finv[i - 1] * inv[i] % COMB_MOD;
  }
}

long long COM(int n, int k) {
  // need COMinit() before calling COM(n,k)
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % COMB_MOD) % COMB_MOD;
}

ll mod = 998244353;

ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n = n >> 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M, K;
  cin >> N >> M >> K;
  COMinit();

  ll sum = 0;
  rep(i, K + 1) {
    ll comb = COM(N - 1, i);
    ll tmp = (M * modpow(M - 1, N - 1 - i, mod)) % mod;
    tmp = (tmp * comb) % mod;
    sum = (sum + tmp) % mod;
  }

  out(sum);

  return 0;
}

Measured memory_bytes: 15372
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			int ab = b - a;
			int souwa = 0;
			for(int i = 1;i <= ab;i++ ){
				souwa = souwa + i;
			}
			int ans = souwa - b;
       		// 出力
			System.out.println(ans);
			return ;
		}
}


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

using namespace std;
const int INF = 1e9+7;
int dp[10055];
int cost(int j){
	int cost[]={0,2,5,5,4,5,6,3,7,6};
	return cost[j];
}
int main(void){
	int N,M;
	cin >> N >> M;
	vector<int> A(M);
	for(int i=0;i<M;i++){
		cin >> A[i];
	}
	sort(A.rbegin(),A.rend());
	dp[0]=0;
	for(int i=1;i<=N;i++){
		dp[i] = -INF;
		for(int j=0;j<M;j++){
			if(i-cost(A[j])<0)continue;
			dp[i] = max(dp[i-cost(A[j])]+1,dp[i]);
		}
	}
	vector<int>ans;
	while(N>0){
		for(int i=0;i<M;i++){
			if(cost(A[i])>N)continue;
			if(dp[N-cost(A[i])] == dp[N]-1){
				ans.push_back(A[i]);
				N -= cost(A[i]);
				break;
			}
		}
	}
	for(auto x:ans)cout << x;
	cout << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		for (int i=0; i < n; i++){
			sc.nextInt();
		}
		int replaceCount = k;
		int controllCount = 1;
		while (replaceCount < n){
			replaceCount += (k - 1);
			controllCount++;
		}
		System.out.println(controllCount);
	}
}

Measured memory_bytes: 48444
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <deque>
#include <unordered_set>
#include <stack>

using namespace std;

#define int long long
int mas[200][200];
int dp[200][200];
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n = 2;
	int m;
	cin >> m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			cin >> mas[i][j];
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + mas[i][j];
		}
	}
	cout << dp[n][m] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL M = 200020;
LL f[M];
LL exgcd(LL a, LL b, LL& x, LL& y){
    LL d = a;
    if(b != 0){
        d = exgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else{
        x = 1; y = 0;
    }
    return d;
}
LL inv(LL a, LL P){
    LL x, y;
    exgcd(a, P, x, y);
    return (P + x % P) % P;
}
void calc_factorial(int P){
    // 预处理阶乘
    f[1] = 1; // m 为组合数中x的最大值
    for(LL i = 2; i < M; i++){
        f[i] = i* f[i - 1];
        f[i] %= P;
    }
    return ;
}
LL mod_fact(LL x, LL& e, LL P){
    // 计算阶乘逆元
    e = 0;
    if(x == 0) return 1;
    LL res = mod_fact(x / P, e, P);
    e += x / P;
    if(x / P % 2 != 0) return res * (P - f[x % P]) % P;
    return res * f[x % P] % P;
}
LL mod_comb(LL x, LL k, LL P){
    if(x < 0 || k < 0 || x < k) return 0;
    LL e1, e2, e3;
    LL a1 = mod_fact(x, e1, P);
    LL a2 = mod_fact(k, e2, P);
    LL a3 = mod_fact(x - k, e3, P);
    if(e1 > e2 + e3) return 0;
    return a1 * inv(a2 * a3 % P, P) % P;
}
const LL P = 1E9 + 7;
LL n, k;
LL quickpow(LL a, LL b, LL c){
    LL ans = 1LL;
    while(b > 0){
        if(b & 1LL) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1LL;
    }
    return ans;
}
void solve(){
    calc_factorial(P);
    LL ans = 1LL;
    for(LL i = 1; i <= k; i++){
        ans = (ans + mod_comb(n - 1, n - i - 1, P) * mod_comb(n, i, P)) % P;
    }
    cout<<ans<<endl;
    return ;
}
int main(){
    
    cin>>n>>k;
    k = min(n - 1, k);
    solve();
    return 0;
}

Measured memory_bytes: 5128
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iomanip>
#define pi 3.14159265358979323846
using namespace std;

int main()
{
	int a,b,C;
	double C_,S,L,h,c;
	cin>>a>>b>>C;
	C_ = double(C*pi/180);
	S = double( (a*b*sin(C_))/2 );
	c = double(sqrt(a*a+b*b-2*a*b*cos(C_)));
	L = double(a+b+c);
	h = double( (2*S)/a );
	cout<<setprecision(9)<<fixed<<S<<endl;
	cout<<setprecision(9)<<fixed<<L<<endl;
	cout<<setprecision(9)<<fixed<<h<<endl;
}



Measured memory_bytes: 3652