akhauriyash/Code-Regression huggingface dataset:
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let a=t.n(n)
  let f=false;
  let ans=0;
  while(!f){
    for(let i=0;i<n;i++){
      if(a[i]%2==0)a[i]/=2
      else {
        f=true
        break
      }
    }
    if(!f)ans++;
  }
  t.o(ans)
}
main()

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b<24)
    {
        cout<<a+b;
    }
    else if(a+b>=24)
    {
        cout<<(a+b)-24;
    }



    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  "use strict"
  const s = input.split("\n").shift();
  const division = s.split("LR").map(e => {
    return "R" + e + "L";
  });
  const len = division.length;
  division[0] = division[0].slice(1);
  division[len - 1] = division[len - 1].slice(0 , -1)

  const ans = [];
  division.forEach(e => {
    const len = e.length;
    for(let i = 0; i < len; i++){
      if(i !== 0 && e[i - 1] === "R" && e[i] === "L"){
        ans.pop();
        const rNum = i;
        const lNum = len - i;
        const a = (rNum > lNum) ? 0 : 1;
        const b = (Math.min(rNum, lNum) % 2 == 0) ? 0 : 1;
        const c = a ^ b;
        if(len % 2 === 0){
          ans.push(len / 2);
          ans.push(len / 2);
        }else if(c === 0){
          ans.push((len + 1) / 2);
          ans.push((len - 1) / 2);
        }else{
          ans.push((len - 1) / 2);
          ans.push((len + 1) / 2);
        }
      } else ans.push(0)
    }
  })
  console.log(ans.join(" "))
}
  
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17984
//2018年  3月 21日 水曜日 22:25:44 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N, S;

ll f(ll b, ll n) {
	if(n < b) return n;
	else return f(b, n / b) + n % b;
}

void solve() {
	cin >> N >> S;
	ll sqt = ll(sqrt(N) + eps);
	for(ll i = 2; i <= sqt; i++) {
		if(f(i, N) == S) {
			cout << i << "\n";
			return;
		}
	}
	for(ll a1 = sqt + 1; a1 >= 1; a1--) {
		if(S - a1 < 0) continue;
		ll a0 = S - a1;
		if((N - a0) % a1 == 0) {
			ll b = (N - a0) / a1;
			if(a1 >= b || a0 >= b) continue;
			cout << b << "\n";
			return;
		}
	}
	if(S == N) {
		cout << N + 1 << "\n";
	}
	else cout << -1 << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

typedef long long ll;
typedef int keytype;

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

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    int a, b;

    scanf("%d %d", &a, &b);

    if(a >= 13){
        printf("%d\n", b);
    }else if(a >= 6 && a <= 12){
        printf("%d\n", b / 2);
    }else{
        puts("0");
    }

    return 0;
}


Measured memory_bytes: 1704
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef vector<P> vp;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    vvi c(3, vi(3, 0));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    
    bool ok = true;
    for(int i = 0; i < 2; i++){
        ok = ok && (c[i][1] - c[i][0]) == (c[i+1][1] - c[i+1][0]);
        ok = ok && (c[i][2] - c[i][1]) == (c[i+1][2] - c[i+1][1]);
    }
    
    for(int i = 0; i < 2; i++){
        ok = ok && (c[1][i] - c[0][i]) == (c[1][i+1] - c[0][i+1]);
        ok = ok && (c[2][i] - c[1][i]) == (c[2][i+1] - c[1][i+1]);
    }
    
    cout << ((ok) ? "Yes" : "No") << endstr;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc046/tasks/agc046_a
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod)
            x -= mod;
    }
    ModInt &operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0)
            x += mod;
        return *this;
    }
    ModInt &operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt &operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
    friend ostream &operator<<(ostream &s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream &operator>>(istream &s, ModInt<mod> &a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<998244353>;

mint dp[3011][3011];
int A, B, C, D;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> A >> B >> C >> D;
    dp[A][B] = 1;
    REP(i, C + 1) REP(j, D + 1) if (dp[i][j].x) {
        dp[i + 1][j] += dp[i][j] * j;
        dp[i][j + 1] += dp[i][j] * i;
        dp[i + 1][j + 1] -= dp[i][j] * i * j;
    }
    cout << dp[C][D] << endl;
}


Measured memory_bytes: 39000
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()
 
int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> X(N),C(N);
  vector<vector<P>> D(30,vector<P>(N,P(0,0)));
  rep(i,N){
    cin >> X.at(i);
    X.at(i)--;
  }
  rep(i,N) cin >> C.at(i);
  rep(i,30){
    if(i==0){
      rep(j,N){
        D.at(i).at(j)=P(X.at(j),C.at(X.at(j)));
      }
    }else{
      rep(j,N){
        D.at(i).at(j)=P(D.at(i-1).at(D.at(i-1).at(j).first).first,D.at(i-1).at(j).second+D.at(i-1).at(D.at(i-1).at(j).first).second);
      }
    }
  }
  ll m=-INF;
  if(K>N){
    vector<P> ans(N);
    rep(j,N){
      ll x=0;
      ans.at(j)=P(j,0);
      rep(i,30){
        if(K-N>=x+(ll)pow(2,29-i)){
          x+=(ll)pow(2,29-i);
        
          ans.at(j)=P(D.at(29-i).at(ans.at(j).first).first,ans.at(j).second+D.at(29-i).at(ans.at(j).first).second);
        }
      }
      m=max(m,ans.at(j).second);
      rep(k,N){
        ans.at(j)=P(X.at(ans.at(j).first),ans.at(j).second+C.at(X.at(ans.at(j).first)));
        m=max(m,ans.at(j).second);
      }
    }
  }
  rep(i,N){
    ll x=0,t=i;
    rep(j,min(2*N,K)){
      t=X.at(t);
      x+=C.at(t);
      m=max(m,x);
    }
  }
      
  cout << m << endl;    
      
}

Measured memory_bytes: 6100
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  r,d,x0=LI()
  for i in range(10):
    x=r*x0-d
    print(x)
    x0=x

main()
# print(main())


Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;

  int l=0,r=0;
  rep(i,n){
    if(s[i]=='('){
      r++;
    }else{
      if(r==0) l++;
      else r--;
    }
  }

  // vi d(n,0);
  // int x=INF;
  // rep(i,n){
  //   if(i==0) d[i]=(s[i]=='('?1:-1);
  //   else d[i]=d[i-1]+(s[i]=='('?1:-1);
  //   chmin(x,d[i]);
  // }
  // cout<<x<<endl;
  string res="";
  rep(i,l) res+='(';
  res+=s;
  rep(i,r) res+=')';
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 305

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

ll dp[ARRAY_MAX][ARRAY_MAX];
ll N, D;
vector<ll> d, a, b, c;

ll dfs(ll day,ll num){

	//day日目に服numを着る場合

	if (day == 1)
	{
		//初日まで見た場合はそれ以前の日との差はないので0を返す
		return 0LL;
	}

	if (dp[day][num] != -1)
	{
		//既に調べた
		return dp[day][num];
	}
	ll cnt = 0;

	//day-1日目に何を着るかを調べる
	for (int i = 1; i <= N; i++)
	{
		//i番目の服を着る場合
		if (a[i] <= d[day - 1] && d[day - 1] <= b[i])
		{
			//i番目の服がday-1日目に着られる場合はi番目の服を着るとしてdfs
			//着られる温度条件を満たしている
			cnt = max(cnt, dfs(day - 1, i) + abs(c[num] - c[i]));
		}
	}
	return dp[day][num] = max(dp[day][num], cnt);
}

int main() {

	cin >> D >> N;

	d.push_back(-INF);
	a.push_back(-INF);
	b.push_back(-INF);
	c.push_back(-INF);
	//番兵を最初に埋め込む

	for (int i = 0; i < D; i++)
	{
		//D日
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}

	for (int i = 0; i < N; i++)
	{
		//N種類の服
		int aa, bb, cc;
		cin >> aa >> bb >> cc;
		a.push_back(aa);
		b.push_back(bb);
		c.push_back(cc);
	}

	for (int i = 0; i < ARRAY_MAX; i++)
	{
		for (int j = 0; j < ARRAY_MAX; j++)
		{
			dp[i][j] = -1;
		}
	}

	ll maxi = 0;
	for (int i = 1; i <= N; i++)
	{
		//D日目に服iを着る場合
		if (a[i] <= d[D] && d[D] <= b[i])
		{
			maxi = max(maxi, dfs(D, i));
		}
	}
	cout << maxi << endl;


	return 0;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX =510000;
const int MOD = 1000000007;

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

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

ll COM(int n, int k){
  if(n<k)
    return 0;
  if(n<0 || k<0)
    return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//2 3 1 1
//...
//x..
//DPっぽいなあ
//111
//X12

//.....
//.....
//XX...
//XX...
//XX...

//11111
//12345
//0037-
//00

//10000*10000の処理で4sec。TLE・・・
//0は境界値だけにして、探索も0以外の長方形2つに限るとか
//でも使用メモリと時間が圧倒的にまだ多いっぽ
//DP自体は1行の上書きでいけるからメモリは減らせる
//時間は･･･。
//1 1 1 1 1
//1 2 3 4 5
//1 3 6 10 15
//1 4 10 20 35
//1 5 15 35 70
//なんの法則あるかな ななめで見れば2項係数か
//はなれてる距離nCkを、2*W回でいけるかな
//8回動く。r5d3 8C3
//そう単純でもないっぽい
//. . . . .
//. . . . .
//X X . . .
//X X . . .
//X X . . .
//1 1 1 1 1
//1 2 3 4 5
//0 0 3 7 12
//0 0 3 10 22
//0 0 3 13 35

//5 5 3 2
//0C0 1C0 2C0 3C0 4C0
//1C1 2C1 3C1 4C1 5C1
//2C2 3C2 4C2 5C2 6C2
//3C3 4C3 5C3 6C3 7C3
//3C1*5C2=3*10=30
//3C1*4C2+
//4C1*3C1+
//5C1*2C0 = 18+12+5=35
//これっぽいなあ
int main(){
  COMinit();
  ll H,W,A,B,MOD=1e9+7; cin>>H>>W>>A>>B;
  vector<ll> DP(W-B+1,0);
  ll x=H-A-1, xx=H-A-1+B,y=(A-1)+(W-B-1), ans=0;
  for(int i=0; i<W-B; i++) (DP[i]=COM(xx+i, x))%=MOD;
  for(int i=0; i<W-B; i++) (ans+=COM(y-i,W-B-1-i)*DP[i])%=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 12928
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
long i,j,k,n,m[225];
while(cin>>n,n){
for(i=0;i<n;i++)
for(j=0;j<n;j++)m[i*n+j]=0;
j=(n-1)/2;i=j+1;
for(k=1;k<=n*n;k++){
m[i*n+j]=k;
i++;j++;
L1:
if(i==n&&j==n){i=0;}
else if(j==n){j=0;}
else if(i==n){i=0;}
if(m[i*n+j]>0){i++;j--;goto L1;}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++)printf("%4d",m[i*n+j]);
printf("\n");
}
}
return 0;
}

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

int main(){
  int n;
  cin>>n;
  stack<int> p;
  set<int> q;
  rep(i,n){
    int x;
    cin>>x;
    p.push(x);
    q.insert(x);
  }
  
  int ans = 0;
  int c = 1;
  rep(i,n){
    if(p.top() == c){
      ans++;
    }
    q.erase(p.top());
    p.pop();
    c = *q.begin();    
  }
  cout << ans << endl;
}

Measured memory_bytes: 10496
length = int(input())
string = input()

possible_pins = list()
for pin in [str(num) for num in range(0, 1000)]:
    if len(pin) == 1:
        pin = "00" + pin
    elif len(pin) == 2:
        pin = "0" + pin
    possible_pins.append(pin)


count = 0
for pin in possible_pins:
    start = 0
    for letter in pin:
        try:
            index = string.index(letter, start)
            start = index + 1
        except ValueError:
            break
    else:
        count += 1
print(count)


Measured memory_bytes: 3188
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if (abs(float(x - a)) < abs(float(x - b))) printf("A\n");
    else printf("B\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define X 100000
 
int main(){
 
	int N;
	int M;	
	int ary[X]={0};
	int bucket_1[2*X+1]={0};
	int margin[X-1]={0};
	int bucket_2[2*X]={0};  
	int i,j,k;
	int notpass=0;
	
	
	scanf("%d %d",&N,&M);
	for(i=0;i<M;i++)
		scanf("%d",&ary[i]);
	
	
	if(M<=N){
	   printf("%d\n",0);
	   return 0;
	}
	
	
	///////// BucketSort_1 //////////
	for(i=0;i<M;i++)
		bucket_1[ary[i]+100000]=1;
	for(i=0,j=0;i<M;j++)
		if(bucket_1[j]!=0){
			ary[i]=j-100000;
			i++;
		}
	
	
	for(i=0;i<M-1;i++)
	    margin[i]=ary[i+1]-ary[i];
	
		
	///////// BucketSort_2 //////////
	for(i=0;i<M-1;i++)
		bucket_2[margin[i]-1]+=1;	
	for(i=0,j=0;i<M-1;j++)
		if(bucket_2[j]!=0){
			for(k=0;k<bucket_2[j];k++){
				margin[i]=j+1;
				i++;
			}
		}
	
		
	
	for(i=M-2;M-N-1<i;i--)
	   notpass+=margin[i];
	
	
	printf("%d\n",ary[M-1]-ary[0]-notpass);
	
	
	return 0;
	
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

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

	ll sum = 0;
	map<ll,ll> bs;
	bs[sum] ++;

	rep(i ,n) {
		int a;
		cin >> a;
		sum += a;
		bs[sum] ++;
	}
	ll ans = 0;
	for (auto b : bs) {
		ans += max(0LL, (b.second - 1) * b.second / 2);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int main(){
    a[0]=1;
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    a[i]=min(a[i-1]+k,a[i-1]*2);
    cout<<a[n];
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab(n);
    for (auto& e : ab) cin >> e.first >> e.second;
    vector<pair<int, int>> cd(m);
    for (auto& e : cd) cin >> e.first >> e.second;
    for (auto& e : ab) {
        int can = -1, tmp = 1e9;
        for (int i = 0; i < m; i++) {
            int dist = abs(e.first - cd[i].first) + abs(e.second - cd[i].second);
            if (dist < tmp) tmp = dist, can = i + 1;
        }
        cout << can << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))

p_ = sorted(p)

cnt_ = 0
for i, j in zip(p, p_):
    if i != j:
        cnt_ += 1

if cnt_ == 0 or cnt_ == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
int const N = 101;
int n , m ;
char g[N][N];
int main(){
   // freopen("input.txt","r",stdin);
   scanf("%d%d",&n,&m);
   for(int i=0;i<n;++i){
       cin>>g[i];
   }
  // vector<int>row , col ;
   bool row[N] = {} , col[N]={};
   int x = 0 ;
   for(int i=0;i<n;++i){
       int cnt=0;
       for(int j=0;j<m;++j){
           if(g[i][j]=='.')++cnt;
       }
       if(cnt==m){row[i]=true;++x;}
   }
   for(int j=0;j<m;++j){
       int cnt=0;
       for(int i=0;i<n;++i){
           if(!row[i]){
               if(g[i][j]=='.')++cnt;
           }
           else if(row[i])continue ;
       }
     //  cout<<cnt<<"\n";
       if(cnt>=n-x)col[j]=true;
   }

   for(int i=0;i<n;++i){
       if(!row[i]){
       for(int j=0;j<m;++j){
           if(!col[j])
             cout<<g[i][j];
       }
       cout<<endl;
   }
   }
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, j, k;
	int h, w;
	char a[100][101];
	int cnt[256] = {0};

	scanf("%d %d", &h, &w);
	for (i = 0; i < h; i++)
		scanf("%s", a[i]);

	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			cnt[a[i][j]]++;

	for (i = 0; i < h / 2; i++)
		for (j = 0; j < w / 2; j++) {
			for (k = 'a'; k <= 'z'; k++)
				if (cnt[k] >= 4) {
					cnt[k] -= 4;
					break;
				}
			if (k > 'z') {
				puts("No");
				return 0;
			}
		}

	for (i = h / 2; i < (h + 1) / 2; i++)
		for (j = 0; j < w / 2; j++) {
			for (k = 'a'; k <= 'z'; k++)
				if (cnt[k] >= 2) {
					cnt[k] -= 2;
					break;
				}
			if (k > 'z') {
				puts("No");
				return 0;
			}
		}

	for (i = 0; i < h / 2; i++)
		for (j = w / 2; j < (w + 1) / 2; j++) {
			for (k = 'a'; k <= 'z'; k++)
				if (cnt[k] >= 2) {
					cnt[k] -= 2;
					break;
				}
			if (k > 'z') {
				puts("No");
				return 0;
			}
		}

	for (i = h / 2; i < (h + 1) / 2; i++)
		for (j = w / 2; j < (w + 1) / 2; j++) {
			for (k = 'a'; k <= 'z'; k++)
				if (cnt[k] >= 1) {
					cnt[k]--;
					break;
				}
			if (k > 'z') {
				puts("No");
				return 0;
			}
		}

	puts("Yes");

	return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N;

int n;
int h[N], e[M], ne[M], w[M], idx;
int dist[N];

void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int fa, int d)
{
	dist[u] = d;
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (j == fa) continue;
		
		dfs(j, u, d + w[i]);
	}
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d", &n);
	
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b, c), add(b, a, c);
	}
	
	dfs(1, -1, 0);
	
	for (int i = 1; i <= n; i ++ ) printf("%d\n", dist[i] & 1);
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

long long lld_abs(long long x) {
    if(x > 0)   return x;
    else        return -x;
}

int main(void) {
    long long X;
    long long K;
    long long D;

    scanf("%lld %lld %lld", &X, &K, &D);

    long long kai = lld_abs(X) / D;
    if( kai >= K ) {
        printf("%lld\n", lld_abs(X) - (K * D));
        return 0;
    }

    X = lld_abs(X) - (D * kai);
    if((K - kai) % 2 == 1) {
        X = lld_abs(X - D);
    }

    printf("%lld\n", X);
    return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

int E[99][99];
int main(){
	int H,W;
	for(;~scanf("%d%d",&H,&W)&&H&&W;){
		int R=0;
		for(int h=0;h<H;h++)for(int w=0;w<W;w++){
			scanf("%d",E[h]+w);
		}
		for(int h0=0;h0<H-2;h0++)for(int h1=h0+2;h1<H;h1++)for(int w0=0;w0<W-2;w0++)for(int w1=w0+2;w1<W;w1++){
			int X=99,R0=0;
			for(int w=w0;w<=w1;w++)X=min(X,min(E[h0][w],E[h1][w]));
			for(int h=h0;h<=h1;h++)X=min(X,min(E[h][w0],E[h][w1]));
			for(int w=w0+1;w<w1;w++)for(int h=h0+1;h<h1;h++){
				if(E[h][w]>=X)R0=-1;
				if(R0>=0)R0+=X-E[h][w];
			}
			if(R0>0)R=max(R,R0);
		}
		printf("%d\n",R);
	}
}

Measured memory_bytes: 2732
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

#define MAX_V 100000
#define INF 2147483647

struct edge {
    int to, cost;
};
//to,cost
typedef pair<int, int> P;//first:Minimum distance/second:Vertex number


int main() {
    int V, E, s;
    cin >> V >> E >> s;

    vector<edge> edges[MAX_V];

    for (int i = 0; i < E; ++i) {
        int a, b, f;
        cin >> a >> b >>f;
        edge ed = {b, f};
        edges[a].push_back(ed);
    }

    // ??????????????????
    priority_queue<P, vector<P>, greater<P> > queue;
    int distance[MAX_V];
    fill(distance, distance + V, INF);
    distance[s] = 0;
    queue.push(P(0, s));

    while (!queue.empty()) {
        P p = queue.top();
        queue.pop();
        int e1_target = p.second;
        if (distance[e1_target] < p.first) {
            continue;
        }
        for (int i = 0; i < edges[e1_target].size(); i++) {
            edge e2 = edges[e1_target][i];
            if (distance[e2.to] > distance[e1_target] + e2.cost) {
                distance[e2.to] = distance[e1_target] + e2.cost;
                queue.push(P(distance[e2.to], e2.to));
            }
        }
    }

    for (int i = 0; i < V; ++i) {
        if (distance[i] >= INF) {
            cout << "INF" << endl;
        } else {
            cout << distance[i] << endl;

        }
    }
    return 0;
}

Measured memory_bytes: 11304
# include <bits/stdc++.h>
using namespace std;
int n,m,x,y,A[200005],B[200005],k,t,f[200005];
vector <int>v[200005];
string s;
queue<int>q;
int main (){
	cin>>n>>m>>s;
	for (int i=0; i<m; i++){
		cin>>x>>y; x--; y--;
		if (x==y)if(s[x]=='A')A[x]=1000000;else B[x]=1000000;
		else{
			if (s[x]=='A') A[y]++; else B[y]++;
			if (s[y]=='A') A[x]++; else B[x]++;
			v[x].push_back(y);
			v[y].push_back(x);
		}
	}
	for (int i=0; i<n; i++)if (A[i]*B[i]==0)q.push(i),f[i]=1;
	
	while(q.size()){
		k=q.front();
		q.pop();
		if (s[k]=='A') 
			for (int i=0; i<v[k].size(); i++){
				A[v[k][i]]--; 
				if (A[v[k][i]]<=0 && f[v[k][i]]==0)q.push(v[k][i]),f[v[k][i]]=1;
				}
		else	
			for (int i=0; i<v[k].size(); i++){
				B[v[k][i]]--; 
				if (B[v[k][i]]<=0 && f[v[k][i]]==0)q.push(v[k][i]),f[v[k][i]]=1;
				}	
	}
	for (int i=0; i<n; i++)if(A[i]>0 && B[i]>0){cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 13188
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    H, W, N = map(int, input().split())
    sh, sw = map(int, input().split())
    S = input()
    T = input()
    count_S = defaultdict(int)
    count_T = defaultdict(int)

    for i in range(N):
        s = S[i]
        t = T[i]

        left = min(sw - (count_S["L"] - count_T["R"]), sw)
        right = max(sw + count_S["R"] - count_T["L"], sw)
        top = min(sh - (count_S["U"] - count_T["D"]), sh)
        bottom = max(sh + count_S["D"] - count_T["U"], sh)

        if s == "L":
            if left - 1 == 0:
                print("NO")
                return
        elif s == "R":
            if right == W:
                print("NO")
                return
        elif s == "U":
            if top - 1 == 0:
                print("NO")
                return
        elif s == "D":
            if bottom == H:
                print("NO")
                return

        count_S[s] += 1

        right = max(sw - (count_S["L"] - count_T["R"]), sw)
        left = min(sw + count_S["R"] - count_T["L"], sw)
        bottom = max(sh - (count_S["U"] - count_T["D"]), sh)
        top = min(sh + count_S["D"] - count_T["U"], sh)

        if t == "L":
            if left - 1 == 0:
                continue
        elif t == "R":
            if right == W:
                continue
        elif t == "U":
            if top - 1 == 0:
                continue
        elif t == "D":
            if bottom == H:
                continue

        count_T[t] += 1

    print("YES")


if __name__ == "__main__":
    main()


Measured memory_bytes: 10024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<double> x(n),y(n);
	rep(i,n){
		cin>>x[i]>>y[i];
	}
	auto g=[&](double rx,double ry){
		double ret=0;
		rep(i,n){
			chmax(ret,(rx-x[i])*(rx-x[i])+(ry-y[i])*(ry-y[i]));
		}
		return ret;
	};
	auto f=[&](double rx){
		double l=-2000,r=2000,mid1,mid2;
		rep(i,100){
			mid1=(l+2*r)/3.0,mid2=(2*l+r)/3.0;
			if(g(rx,mid1)<g(rx,mid2)) l=mid2; 
			else r=mid1;
		}
		return g(rx,l);
	};
	double l=-2000,r=2000,mid1,mid2;
	rep(i,100){
		mid1=(l+2*r)/3.0,mid2=(2*l+r)/3.0;
		if(f(mid1)<f(mid2)) l=mid2; 
		else r=mid1;
	}
	cout<<setprecision(15)<<sqrt(f(l))<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int gcd(ll a, ll b) {
	if (a == 0)return b;
	if (b == 0)return a;
	if (a < b) swap(a, b);
	ll r;
	while ((r = a % b)) {
		a = b; b = r;
	}
	return b;
}


void solve() {
	ll n, ans = 0; cin >> n;
	vector<ll>a(n), l(n + 1, 0), r(n + 1, 0);
	for (ll i = 0; i < n; i++)cin >> a[i];
	for (ll i = 1; i <= n; i++) {
		l[i] = gcd(l[i - 1], a[i - 1]);
		r[n - i] = gcd(r[n - i + 1], a[n - i]);
	}
	for (ll i = 0; i < n; i++) {
		if (ans < gcd(l[i] , r[i + 1]))ans = gcd(l[i] , r[i + 1]);
	}
	cout << ans << endl;
}

int main() {
	solve();
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll A, B, C;
    ll answer;

    cin >> A >> B >> C;

    cout << A * B / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int solve(long long x, bitset<3> bs, int n)
{
    if(x > n)
        return 0;

    int ans = 0;
    if(bs.all())
        ++ ans;
    for(int i=0; i<3; ++i){
        long long y = x * 10 + vector<int>{3, 5, 7}[i];
        bitset<3> bs2 = bs;
        bs2[i] = true;
        ans += solve(y, bs2, n);
    }
    return ans;
}

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

    int ans = solve(0, 0, n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro with-buffered-stdout (&body body)
  "Buffers all outputs to *STANDARD-OUTPUT* in BODY and flushes them to
*STANDARD-OUTPUT* after BODY has been done (without error). Note that only
BASE-CHAR is allowed."
  (let ((out (gensym)))
    `(let ((,out (make-string-output-stream :element-type 'base-char)))
       (let ((*standard-output* ,out))
         ,@body)
       (write-string (get-output-stream-string ,out)))))

(declaim (ftype (function * (values fixnum &optional)) read-digit))
(defun read-digit (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (loop (let ((byte (%read-byte)))
            (cond ((<= 48 byte 57)
                   (return (- byte 48)))
                  ((zerop byte) ; #\Nul
                   (error "Read EOF or #\Nul.")))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (res (make-array (+ 1 n) :element-type 'bit :initial-element 0)))
    (declare (uint31 n))
    (loop for i from 1 to n do (setf (aref res i) (read-digit)))
    (loop for i from n downto 1
          do (loop for j from (* 2 i) to n by i
                   do (setf (aref res i)
                            (logxor (aref res i) (aref res j)))))
    (let ((count (count 1 res)))
      (with-buffered-stdout
        (println count)
        (loop for i from 1 to n
              when (= (aref res i) 1)
              do (println i))))))

#-swank (main)


Measured memory_bytes: 17640
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=b;i<=c;i++)if(i%a==0)return puts("OK"),0;
	puts("NG");
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int n,m,a[200200],cnt[200200],res,vis[200200];
int main()
{
    memset(vis,0,sizeof(vis));
    scanf("%d%d",&n,&m);res=n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
        int pos=a[i]-cnt[a[i]];
        if(pos>=0)
        {
            if(!vis[pos])res--;
            vis[pos]++;
        }
    }
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        int pos=a[x]-cnt[a[x]];
        if(pos>=0)
        {
            if(vis[pos]==1)res++;
            vis[pos]--;
        }
        cnt[a[x]]--;
        a[x]=y;
        cnt[y]++;
        pos=a[x]-cnt[a[x]];
        if(pos>=0)
        {
            if(!vis[pos])res--;
            vis[pos]++;
        }
        printf("%d\n",res);
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

inline vector<pair<ll,int>> sieve(ll n){
	vector<pair<ll,int>> sosuu;
	for(ll i = 2; i*i <= n; i++){
		int x = 0;
		while(n % i == 0){
			n /= i;
			x++;
		}
		sosuu.push_back(make_pair(i,x));
	}
	if(n != 1) sosuu.push_back(make_pair(n,1));
	return sosuu;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  auto res = sieve(n);
  int ans = 0;
  for(auto x : res){
    int a = x.second, b = 1;
    while(b <= a){
      a -= b;
      b++;
      ans++;
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 19680
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = ReadLine();
			var f = false;
			for (int i = 0; i < n.Length; i++)
			{
				if (n[i].Equals('7'))
				{
					f = true;
					break;
				}
			}
			if (f) Console.WriteLine("Yes");
			else Console.WriteLine("No");
		}

		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n - 1, m - 1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s = ' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 17440
import java.util.Scanner;



public class Main {

	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int intNum = sc.nextInt();

		if(intNum<1200)
		{
			System.out.println("ABC");

			return;
		}

		if(intNum<2800)
		{
			System.out.println("ARC");

			return;
		}

		System.out.println("AGC");


	}

}


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

int main(){
  int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K){
    cout << S << endl;
    return 0;
  }
  string T=S.substr(0,K);
  T+="...";
  cout << T << endl;
}
  
  

Measured memory_bytes: 3584
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S
main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    as<-unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine
    putStrLn $ if S.member k $ f k as then "First" else "Second"

f k as = foldl' p S.empty [0..k] where
    p s i | S.member i s = s
          | otherwise = S.union s $ S.fromAscList $ filter (<=k) $ map (+i) as


Measured memory_bytes: 2044
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>
 
#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

 
using namespace std;

#define max_n 100005

int mod = 1e9 + 7;
lint ans = 1;

int main() {
	make(n);
	makev(v, n);
	sort(all(v));
	int jest = 0;
	FOR(i,0,n) {
		int maxi = v[i];
		jest++;
		if (jest > (maxi+1)/2 ) {
			ans = (ans * 1LL * jest) % mod;
			jest--;
		}  
	}
	FOR(i,1,jest+1) {
		ans = (ans * 1LL * i) % mod;
	}
	printf("%lld\n", ans);
}

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

ll n,a[21][21],dp[3000000];

int solve(int mask)
{
    ll i=__builtin_popcount(mask);
    if(i==n)return 1;
    if(dp[mask]!=-1)return dp[mask];
    ll ans=0;
    for(int j=0;j<n;j++)
    {
        if(a[i][j]==1 && (!(mask&(1<<j))))
        ans=(ans+solve(mask|(1<<j)))%mod;
    }
    return dp[mask]=ans;
}

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0)<<"\n";
}

Measured memory_bytes: 23680
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		if (n % 10 == 9 || n / 10 == 9) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(){
  int x,HarshadNum = 0;
  cin >> x;
  int n = x;
  while(n > 0){
    int r = n % 10;
    HarshadNum = HarshadNum + r;
    n = n / 10;
  }
  //cout << HarshadNum << endl;
  //cout << x << endl;
  if(x % HarshadNum == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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



int main(){
  int64_t N;
  cin>>N;
  
  vector<int64_t> vec(N+2);
  for(int i=1;i<=N;i++){
    cin>>vec.at(i);
  }
  vector<int64_t> dis(N+1);
  for(int i=1;i<=N+1;i++){
    dis.at(i-1)=abs(vec.at(i)-vec.at(i-1));
  }
  int64_t sum=0;
  for(int i=0;i<=N;i++){
    sum+=dis.at(i);
  }
  for(int i=0;i<N;i++){
    int64_t hik=dis.at(i)+dis.at(i+1);
    int64_t tas=abs(vec.at(i+2)-vec.at(i));
    cout<<sum-hik+tas<<endl;
  }
    
  
}
  

Measured memory_bytes: 4820
#include<stdio.h>
int main(void)
{
    int i,n,a;
    int min=1000000;
    int max=-1000000;
    long sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }
        sum+=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 1028
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATaskSchedulingProblem solver = new ATaskSchedulingProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATaskSchedulingProblem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(3);
            Arrays.sort(a);
            out.println(a[2] - a[0]);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

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

    }
}



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

int main() {
  int n, c;
  cin >> n >> c;
  vector<vector<int>> d(c, vector<int>(c));
  for (auto &r : d) {
    for (auto &e : r) {
      cin >> e;
    }
  }
  vector<vector<int>> a(3, vector<int>(c));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int e;
      cin >> e;
      a[(i + j) % 3][e - 1]++;
    }
  }

  int m = 1e9;
  vector<int> k(3);
  for (k[0] = 0; k[0] < c; k[0]++) {
    for (k[1] = 0; k[1] < c; k[1]++) {
      if (k[1] == k[0]) {
        continue;
      }
      for (k[2] = 0; k[2] < c; k[2]++) {
        if (k[2] == k[0] || k[2] == k[1]) {
          continue;
        }
        int s = 0;
        for (int i = 0; i < 3; i++) {
          for (int j = 0; j < c; j++) {
            s += a[i][j] * d[j][k[i]];
          }
        }
        m = min(m, s);
      }
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mx 10000010
typedef long long ll;
ll dv[mx];
void divisors(){
    ll i,j,c;
    for(i=1;i<=mx;i++)
    	for(j=i;j<=mx;j+=i)dv[j]++;
}
int main(){
    ll n,sum=0;
    divisors();
    cin>>n;
    for(ll i=1;i<=n;i++)sum+=i*dv[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 81736