akhauriyash/Code-Regression huggingface dataset:
import sys

MOD = 10 ** 9 + 7

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table(10**5+30)

def comb(n, r, mod=MOD):
    if r > n or r < 0:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

from collections import defaultdict
from math import floor, sqrt
def prime_factorize(n):
    res = defaultdict(int)
    while n % 2 == 0:
        res[2] += 1
        n //= 2
    if n == 1:
        return res
    for i in range(3, floor(sqrt(n))+1, 2):
        while n % i == 0:
            res[i] += 1
            n //= i
        if n == 1:
            return res
    res[n] += 1
    return res

n, m = map(int, sys.stdin.readline().split())

def main():
    pfacts = prime_factorize(m)
    res = 1
    for v in pfacts.values():
        res *= comb(n-1+v, v)
        res %= MOD
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 11252
#include <iostream>
#include <vector>

using namespace std;

const int N = 1000010;
bool isPrime[N];

void sieve(){
    for(int i=2;i<N;i++) isPrime[i] = true;
    for(int i=2;i*i<N;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<N;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    vector<int> C(N);
    sieve();
    C[0] = 0;
    for(int i=1;i<N;i++){
        if(isPrime[i]){
            C[i] = C[i-1] + 1;
        }else{
            C[i] = C[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << C[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 5956
#include<iostream>
using namespace std;
int main(){
	int h,j;
	int k,l;
	int a,b,c,d;
	cin >> h >> j >> k >> l >>a >> b >> c >> d ;
	int H = h*a + j*b + c*(h/10) + d*(j/20);
	int K = k*a + l*b + c*(k/10) + d*(l/20);
	if (H>K) cout << "hiroshi" << endl;
	if (H<K) cout << "kenjiro" << endl;
	if (H==K) cout << "even" << endl;
return 0;
}



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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

struct union_find {
  vi par, rank;
  inline union_find(int n) { par.assign(n, -1); rank.resize(n); }
  inline int find(int x) { return (par[x] < 0) ? x : par[x] = find(par[x]); }
  inline bool same(int x, int y) { return find(x) == find(y); }
  inline int size(int x) { return -par[find(x)]; }
  inline void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    else if (rank[x] == rank[y]) rank[x]++;
    par[x] += par[y];
    par[y] = x;
  }
};

void solve() {
  int N, M, K;
  in(N, M, K);
  union_find uf(N);
  vi ans(N);

  rep(i, M) {
    int a, b;
    in(a, b);
    a--; b--;
    uf.unite(a, b);
    ans[a]--;
    ans[b]--;
  }
  rep(i, K) {
    int c, d;
    in(c, d);
    c--; d--;
    if (uf.same(c, d)) {
      ans[c]--;
      ans[d]--;
    }
  }

  rep(i, N) {
    ans[i] += uf.size(i) - 1;
    cout << (i == 0 ? "" : " ") << ans[i];
  }

  cout << endl;
}


Measured memory_bytes: 2048
n,l=map(int,input().split())
a=[0]*(n)
c=[0]*(n+1)
for i in range(n):
    a[i]=l+i

aas=sum(a)

ans=(10**10)
for i in range(n):
    aji=aas-a[i]
    if ans>abs(aas-aji):
        ans=abs(aas-aji)
        ans2=aji
print(ans2)

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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((x + r <= W && x - r >= 0) && (y + r <= H && y - r >= 0)) {
        cout << "Yes" << endl;
    } 
    else {
        cout << "No" << endl;
    }
    return 0;
    
}


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

int N, L;

void solve() {
  int allapple = 0;
  for (int i = 1; i <= N; i++) {
    allapple += L + i - 1;
  }
  int res = 10000, ans;
  for (int i = 1; i <= N; i++) {
    int eat = allapple - (L + i - 1);
    if (res > abs(allapple - eat)) {
      res = abs(allapple - eat);
      ans = eat;
    }
  }
  cout << ans << '\n';
}

int main() {
  cin >> N >> L;
  solve();
  return 0;
}

Measured memory_bytes: 256
class Student:
    def __init__(self, m, f, r):
        self.m = m
        self.f = f
        self.r = r


    def judge(self):
        if self.m == -1 or self.f == -1:
            return 'F'

        total = self.m + self.f
        if total >= 80:
            return 'A'

        if 65 <= total < 80:
            return 'B'

        if 50 <= total < 65:
            return 'C'

        if 30 <= total < 50:
            if self.r >= 50:
                return 'C'
            else:
                return 'D'

        return 'F'


students = []

while True:
    m, f, r = tuple(map(int, input().split(' ')))
    if m == -1 and f == -1 and r == -1:
        break
    students.append(Student(m, f, r))

for student in students:
    print(student.judge())



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef signed long long sll;

int main(){
	sll n,k;
	cin>>n>>k;
	
	sll m=n/k;
	sll ans1=n-k*m;
	sll ans2=k*(m+1)-n;
	
	cout<<min(ans1,ans2);
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define iter(name) decltype(name)::iterator
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

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

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}



double A,B,H,M;

void input() {
	cin>>A>>B>>H>>M;
}

void solve() {
	double deg=fabs(6*M-0.5*M-30*H);
	if(deg<180) deg=360.-deg;
	cout<<setpr<<sqrt(A*A+B*B-2.*A*B*cos(deg*PI/180.))<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 4196
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	ll X;
	cin >> X;
	int ub=10000000, lb=0;
	while(ub-lb > 1){
		ll med = (ub+lb)/2;
		if(med*(med-1)/2 >= X){
			ub = med;
		}
		else{
			lb = med;
		}
	}

	cout << lb << endl;

	return 0;
}


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

int main(){
  string str;
  
  for(;;){
    int cntA = 0,cntB = 0;
  
    cin >> str;
    if(str == "0") break;
    
    for(int i = 1 ; i < str.size() ; i++){
      if(str[i] == 'A') cntA++;
      else cntB++;    
    }
    
    if(cntA > cntB) cntA++;
    else cntB++;
    
    cout << cntA << ' ' << cntB << endl;
  }

  return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include<iostream>
#include <algorithm>
#include <math.h>

using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int i;
	for(i=0;i<k && a+i<b;i++){
		cout<<a+i<<endl;
	}
	printf("\n");
	for(int j=0;j<k;j++){
		if(b-k+j+1<=a+i){j=a+i-b+k-1;}
		cout<<b-k+j+1<<endl;		
	}
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)


var s []string
var t []string

func main() {
  var N,M int
  var a string
  var target string
  var check int
  var x[]int
  fmt.Scan(&N)

  s = make([]string,N)
  x = make([]int,N)

  for i := 0; i < N; i++ {
    fmt.Scan(&a)
    s[i] = a
  }

  fmt.Scan(&M)
  t = make([]string,M)

  for i := 0; i < M; i++ {
    fmt.Scan(&a)
    t[i] = a
  }

//    for i:= 0; i < N; i++ {
//      fmt.Printf("button[%d]=%d\n",i,button[i])
//    }


    for i := 0; i < N ; i++{
      target = s[i]
      for j := i ; j < N; j++ {
        if s[j] == target {
          x[i]++
        }
      }
      for k := 0; k < M; k++ {
        if t[k] == target {
          x[i]--
        }
      }

    }

    //for i := 0; i < N; i++ {
    //  fmt.Printf("x[%d]=%d\n",i,x[i])
    //}

    check = x[0]
    for i := 0; i < N; i++ {
      if x[i] > check {
        check = x[i]
      }
    }

  if check >= 0 {
    fmt.Println(check)
  } else {
    fmt.Println(0)
  }
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

int N;
vector<int>G[100010];
int dp[100010][2];
int func(int n, int k,int pre) {
	if (dp[n][k] != 0) {
		return dp[n][k];
	}
	if (k == 0) {
		int res = 1;
		bool found = 0;
		for (auto x : G[n]) {
			if (x == pre)continue;
			if (x != pre)found = true;
			int tmp = add(func(x, 0, n), func(x, 1, n));
			//res=mult(res, func(x, 0,n));
			//res=mult(res, func(x, 1,n));
			res = mult(res, tmp);
		}
		if (!found)res = 1;
		dp[n][k] = res;
		return res;
	}
	else {
		int res = 1;
		bool found = 0;
		for (auto x : G[n]) {
			if (x == pre)continue;
			found = true;
			res=mult(res, func(x, 0,n));
		}
		if (!found)res = 1;
		dp[n][k] = res;
		return res;
	}
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	REP(i, N-1) {
		int x, y; cin >> x >> y; x--, y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	int ans = add(func(0, 0, 0), func(0, 1, 0));
	print(ans);
	/*REP(i, N) {
		printf("%lld 1:%lld\n", i, dp[i][1]);
		printf("%lld 0:%lld\n", i, dp[i][0]);
	}*/
}


Measured memory_bytes: 13696
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d =[0] * (10**6+1)
for i in range(1,10**6+1):
  div = collections.Counter(prime_factorize(i))
  index = list(div.values())
  s = 1
  for j in range(len(index)):
    s *= (index[j]+1)
  d[i] = s
  

N = int(input())
sum = 0
for i in range(1,N):
  sum += d[N-i]
  
print(sum)

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
    string S;
    cin>>S;
    int n=S.size();
    bool flag=true;
    REP(i,n){
      if(i%2==0 and S[i]=='L'){
        flag=false;
      }
      if(i%2==1 and S[i]=='R'){
        flag=false;
      }
    }
    if(flag){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}


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

int beki_3(int x){
  int ret;
  ret = x*x*x;
  return ret;
}

int main(){
  int x ;
  int ans;
  
  cin >> x;
  ans = beki_3(x);
  cout << ans << endl;

  return 0;
}
 


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

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> xi(n);
  vector<int> yi(m);
  for(int i=0; i<n; i++) cin >> xi[i];
  for(int i=0; i<m; i++) cin >> yi[i];
  sort(xi.begin(), xi.end());
  sort(yi.begin(), yi.end());
  if(y-x>=1){
    for(int j=x+1; j<=y; j++){
      if(j>xi[n-1]&&j<=yi[0]){
        cout << "No War" << endl;
        return 0;
      }
    }
  }
  cout << "War" << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if (a >= b*2 -1) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CP complex<long double>

#define X real()
#define Y imag()
const long double PI = acos(-1.0L);
const long double EPS = 1e-10;
// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment
long double dot(CP a, CP b) { return (a * conj(b)).X; }
long double cross(CP a, CP b) { return (a * conj(b)).Y; }
long double corner(CP a, CP b) {
  //[0,pi]
  return acos(dot(a, b) / (abs(a) * abs(b)));
}

CP intersection(CP a, CP b, CP c, CP d) {
  return a + (b - a) * (cross(d - c, c - a) /
                        cross(d - c, b - a));
}

bool on_seg(CP a, CP b, CP p) {
  // if not use end point, dot(a - p, b - p) < 0
  return abs(cross(a - p, b - p)) <= 1e-10 &&
         dot(a - p, b - p) <= 0;
}

// crossing lines? (a,b) and (c,d)
bool iscross(CP a, CP b, CP c, CP d) {
  // parallel
  if(abs(cross(a - b, c - d)) <= 1e-10) {
    return on_seg(a, b, c) || on_seg(a, b, d) ||
           on_seg(c, d, a) || on_seg(c, d, b);
  }
  CP isp = intersection(a, b, c, d);
  return on_seg(a, b, isp) && on_seg(c, d, isp);
}

long double distLP(CP a, CP b, CP p) {
  return abs(cross(b - a, p - a) / abs(b - a));
}

// segmentver.
long double distSP(CP a, CP b, CP p) {
  if(dot(b - a, p - a) < 0) return abs(p - a);
  if(dot(a - b, p - b) < 0) return abs(p - b);
  return distLP(a, b, p);
}

// segment and segment
long double distSS(CP a, CP b, CP c, CP d) {
  long double res = 1e18;
  res = min(res, distSP(a, b, c));
  res = min(res, distSP(a, b, d));
  res = min(res, distSP(c, d, a));
  res = min(res, distSP(c, d, b));
  return res;
}

long long q, a, b, c, d;
CP xs, xt, ys, yt;

int main() {
  cout << fixed << setprecision(10);
  cin >> q;
  for(int t = 0; t < q; ++t) {
    cin >> a >> b >> c >> d;
    xs = CP(a, b);
    xt = CP(c, d);
    cin >> a >> b >> c >> d;
    ys = CP(a, b);
    yt = CP(c, d);
    CP res = intersection(xs, xt, ys, yt);
    cout << res.X << " " << res.Y << endl;
  }
  return 0;
}


Measured memory_bytes: 3296
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n,k = map(int, input().split())
    print(min(n%k, abs(n%k-k)))
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

ll dp[3001][3001][2];
ll a[3001];
int n;

ll calc(int l, int r, int p)
{
	if (l == r) return a[l];
	ll &ret = dp[l][r][p];
	if (ret != -1) return ret;
	ret = max(a[l] - calc(l+1, r, p^1), a[r] - calc(l, r-1, p^1));
	return ret;
}

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << calc(0, n-1, 0);
}

Measured memory_bytes: 141184
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

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

    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    if(s.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int e, f, g;
    if ( A <= B )
    {
        e = A;
        f = B;
    }
    else if ( B < A )
    {
        e = B;
        f = A;
    }

    if ( f < C)
    {
        g = C;
    }
    else if ( e < C && C < f)
    {
        g = f;
        f = C;
    }
    else if ( C < e)
    {
        g = f;
        f = e;
        e = C;
    }
    int d1 = g - f;
    int d2 = g - e;
    int d3 = f - e;
    int count = 0;
    if ( (f - e) % 2 == 0)
    {
        count = (f-e) / 2 + (g - f);
    }
    else
    {
        count = (f-e) / 2 + (g - f) + 2;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
p = max(x,y)
q = min(x,y)
ans = 0
if a+b>=2*c:
    if p == x:
        ans += 2*c*q + min(a,2*c)*(p-q)
    else:
        ans += 2*c*q + min(b,2*c)*(p-q)
else:
    if p == x:
        ans += (a+b)*q + min(a,2*c)*(p-q)
    else:
        ans += (a+b)*q + min(b,2*c)*(p-q)
         
print(ans)
# print(a,b,c,x,y)

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

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (a + b + 2 * pow(a*b, (long double)0.5) < c) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  long long f = 5 + (n-1)/min(min(min(a,b),min(c,d)),e);
  cout << f << endl;
}

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


int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S.at(K - 1) == 'A') {
    S.at(K - 1) = 'a';
  }
  if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
  }
  if (S.at(K - 1) == 'C') {
    S.at(K - 1) = 'c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

H, W = list(map(int, sys.stdin.readline().split()))

# 縦3等分、横3等分、縦2・横1、横1・縦2
ans = IINF
# 縦
if H >= 3:
    if H % 3 == 0:
        ans = 0
    else:
        ans = min(ans, W)
# 横
if W >= 3:
    if W % 3 == 0:
        ans = 0
    else:
        ans = min(ans, H)
# 縦2、横1
w = 1
while w < W:
    a = (W - w) * H
    b = w * (H // 2)
    c = w * H - b
    ans = min(ans, max(a, b, c) - min(a, b, c))
    w += 1
# 縦1、横2
h = 1
while h < H:
    a = (H - h) * W
    b = h * (W // 2)
    c = h * W - b
    ans = min(ans, max(a, b, c) - min(a, b, c))
    h += 1
print(ans)


Measured memory_bytes: 13792
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;
typedef long long int64;
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define ford(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define fore(i,a,n) for(int i=(int)(a);i<(int)(n);i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size())-1)
int main()
{
	int n,m;
	cin>>n;
	map<string,int> mp;
	string tmp[200];
	forn(i,n){
		cin>>tmp[i];
		mp[tmp[i]]++;
	}
	cin>>m;
	forn(i,m){
		cin>>tmp[n];
		mp[tmp[n]]--;
	}
    int Max=0;
    forn(i,n){
    	if(mp[tmp[i]]>Max)
    		Max=mp[tmp[i]];
	}
	cout<<Max<<endl;
	return 0;
}

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

const string ans[] = {"Yes", 
"No", "No", "No", "Yes", "No", "No", "Yes", "Yes", "No", "No",
"Yes", "Yes", "No", "Yes", "Yes", "Yes", "No", "Yes", "Yes", "Yes",
"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"};
int main() {
	int N;
	cin >> N;
	if (N >= 28) cout << "Yes";
	else cout << ans[N % 28];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、4と7は互いに素
ここで、最初にドーナツ、次にケーキを買うことにすると、ドーナツを買った枚数をxとしてN-7xが4の倍数なら丁度買える
また、N-7(x+4)とN-7xはどちらもmod4上で同じ値になるので、xは0,1,2,3のみ調べれば良い
x=0……買えるのは0,4,8,12,16,20,24
x=1……買えるのは7,11,15,19,23,27
x=2……買えるのは14,18,22,26
x=3……買えるのは21,25
今の買える値に入らなかったものは1,2,3,5,6,9,10,13,17
つまりこの金額のみ買えず、残りは買える(28ドル以上については全て買える)
*/

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

int main() {
  int N;
  cin >> N;
  int P[100];
  int counter = 0;
  for (int i=0; i < N; i++) {
    cin >> P[i];
    if (P[i] != i+1) counter++;
  }
  if (counter ==0 || counter == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}
  
  
 

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

//-----------------------------------------
int cnt = 0;
void merge(vector<int> &A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int *L, *R;
  L = (int*)malloc(sizeof(int)*(n1+1));
  R = (int*)malloc(sizeof(int)*(n2+1));
  for(int i=0;i<n1;i++){
    L[i] = A[left + i];
  }
  for(int i=0;i<n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = INF+1; // 編集
  R[n2] = INF+1; // 編集
  int i =0,j = 0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
      cnt++;
    }
    else{
      A[k] = R[j];
      j++;
      cnt++;
    }
  }
}
void mergesort(vector<int> &A, int left, int right){
  if(left + 1 < right){
    int mid = (left + right) /2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}

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

  int n;
  cin >> n;
  vector<int> vec(n);
  REP(i,n) cin >> vec[i];
  mergesort(vec,0,n);
  for(int i=0;i<n;i++){
    if(i) cout << " ";
    cout << vec[i];
  }
  cout << endl;
  cout << cnt <<endl;




  return 0;
}




Measured memory_bytes: 65552
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 500000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

char st[maxn];
int a[maxn], l[maxn], r[maxn];

vector<pii> G[maxn];

int main() {
#ifdef Wearry
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n = read<int>();
    scanf("%s", st + 1);

    for(int i = 1; i <= n; ++i) if(st[i] == '1') l[i] = (i > 1 && st[i-1] == '1') ? l[i-1] : i;
    for(int i = n; i >= 1; --i) if(st[i] == '1') r[i] = (i < n && st[i+1] == '1') ? r[i+1] : i;

    for(int i = 2; i < n; ++i) if(st[i] == '0') {
        if(st[i-1] == '1' && st[i+1] == '1') {
            G[l[i-1]].pb(pii(i+1, i - l[i-1]));
            G[i-1].pb(pii(r[i+1], r[i+1] - i));
            G[l[i-1] + 1].pb(pii(i+1, i - l[i-1] - 1));
            G[i-1].pb(pii(r[i+1] - 1, r[i+1] - i - 1));
        }
    }

    static int dp[maxn], ans = 0;

    dp[0] = 0;
    for(int i = 1; i <= n + 1; ++i) {
        chkmax(dp[i], dp[i-1]);
        for(int j = 0; j < int(G[i].size()); ++j) {
            chkmax(dp[G[i][j].fst+1], dp[i] + G[i][j].snd);
        }
        chkmax(ans, dp[i]);
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int A, B;
	cin >> A >> B;

	int n = A * B;
	if (n % 2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    map<string, ll> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

using namespace std;
int main(){
  string S;     //入力
  cin >> S;
  string a,b,c;     //判定に使う文字列
  int n;     //Sの文字長

  while(true) {     //
    n = S.size();     //Sの文字長を先に取得
    if(n == 0) {     //Sの文字長が0、すなわちSが全て4単語でできていたらYES
      cout << "YES" << endl;
      return 0;
    }
    
    a = n>=5 ? S.substr(n-5, 5) : "";
    //5文字以上なら末尾5文字切り取る。5文字に足らなかったら空の文字列とする
    b = n>=6 ? S.substr(n-6, 6) : "";
    c = n>=7 ? S.substr(n-7, 7) : "";
    

    if(a=="dream" || a=="erase"){
      //5文字の末尾がdreamまたはeraseに一致していれば末尾5文字削る
      S.erase(n-5, 5);
    }else if(b=="eraser"){
      S.erase(n-6, 6);
    }else if(c=="dreamer"){
      S.erase(n-7, 7);
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n,x,c=0;

    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>x;

        if(i%2!=0 && x%2!=0)
            c++;
    }

    cout<<c<<endl;




    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <list>
#include <numeric>
#include <algorithm>

int main()
{
	int n;
	std::cin >> n;
	std::list<int> p(n), q(n);
	for (auto &e : p) std::cin >> e;
	for (auto &e : q) std::cin >> e;
	
	if (p > q) std::swap(p, q);
	int diff = 0;
	int k = 1;
	for (int i = 2; i < n; i++) k *= i;
	std::list<int> lsp(n), lsq(n);
	std::iota(lsp.begin(), lsp.end(), 1);
	std::iota(lsq.begin(), lsq.end(), 1);
	int d;
	for (auto itp = p.begin(), itq = q.begin(); *itp != p.back(); itp++, itq++) {
		d = std::distance(lsq.begin(), std::find(lsq.begin(), lsq.end(), *itq))
			- std::distance(lsp.begin(), std::find(lsp.begin(), lsp.end(), *itp));
		diff += d * k;
		lsp.remove(*itp);
		lsq.remove(*itq);
		n--;
		k /= n;
	}
	
	std::cout << diff << std::endl;
	
	return 0;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

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

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    int N;
    string S;
    cin >> N >> S;
    int l = 0;
    int now = 0;
    rep(i, N) {
        if (S[i] == '(') {
            now++;
        } else {
            now--;
        }
        if (now < 0) {
            l++;
            now = 0;
        }
    }
    rep(i, l) {
        cout << "(";
    }
    cout << S;
    rep(i, now) {
        cout << ")";
    }
    cout << endl;
}


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

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

  long long ans=1;
  if(n==m+1){
    long long i=1;
    while(i<=m){
      ans*=i;
      ans%=1000000007;
      ans*=i;
      ans%=1000000007;
      i++;
    }
    ans*=n;
    ans%=1000000007;
  }else if(n==m){
    long long i=1;
    while(i<=m){
      ans*=i;
      ans%=1000000007;
      ans*=i;
      ans%=1000000007;
      i++;
    }
    ans*=2;
    ans%=1000000007;
  }else if(n+1==m){
    long long i=1;
    while(i<=n){
      ans*=i;
      ans%=1000000007;
      ans*=i;
      ans%=1000000007;
      i++;
    }
    ans*=m;
    ans%=1000000007;
  }else{
    ans=0;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 412345
int a[N], b[N], c[N], d[N], e[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	REP(i, n) scanf("%d", b+i);
	REP(i, n) c[i] = c[i+n] = a[i] ^ a[(i+1)%n];
	REP(i, n) d[i] = b[i] ^ b[(i+1)%n];
	d[n] = -1;
	
	REP(i, n*2) DEBUG("%d ", c[i]); DEBUG("\n");
	REP(i, n*2) DEBUG("%d ", d[i]); DEBUG("\n");
	
	{
		e[0] = -1;
		int i = 0, j = 1;
		while(j <= n){
			if(d[i] != d[j] && i > 0){
				i = e[i];
			}else{
				if(d[i] == d[j]) i++;
				j++;
				e[j] = i;
			}
		}
	}
	REP(i, n+1) DEBUG("%d ", e[i]); DEBUG("\n");
	
	{
		int i = 0, j = 0;
		while(i < n*2){
			if(c[i] == d[j]){
				i++;
				j++;
			}else if(j == 0){
				i++;
			}else{
				j = e[j];
			}
			if(j == n && i-n < n){
				printf("%d %d\n", i-n, a[i-n] ^ b[0]);
			}
		}
	}
}


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

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
Graph G;
vector<int> used, ans_front, ans_back;

void dfs_front(int u) {
    used[u] = 1;
    for (auto e : G[u]) {
        if (!used[e.to]) {
            ans_front.push_back(e.to);
            dfs_front(e.to);
            break;
        }
    }
}

void dfs_back(int v) {
    used[v] = 1;
    for (auto e : G[v]) {
        if (!used[e.to]) {
            ans_back.push_back(e.to);
            dfs_back(e.to);
            break;
        }
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    G = Graph(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        G[A].push_back({B});
        G[B].push_back({A});
    }
    
    used = vector<int>(N, 0);
    int u = 0;
    int v = G[0][0].to;
    ans_front.push_back(0);
    ans_back.push_back(v);
    used[0] = used[v] = 1;
    dfs_front(u);
    dfs_back(v);
    reverse(ans_front.begin(), ans_front.end());
    cout << ans_front.size() + ans_back.size() << endl;
    rep(i, ans_front.size()) cout << ans_front[i] + 1 << endl;
    rep(i, ans_back.size()) cout << ans_back[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 11896
w = input().strip()
n = int(input())

for i in range(n):
    s = input().split()

    if s[0] == 'print':
        a,b = int(s[1]),int(s[2])
        print(w[a:b+1])
    elif s[0] == 'reverse':
        a,b = int(s[1]),int(s[2])
        p = w[a:b+1][::-1]
        w = w[:a] + p + w[b+1:]
    elif s[0] == 'replace':
        a,b = int(s[1]),int(s[2])
        w = w[:a] + s[3] + w[b+1:]


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> d(N);
	rep(i,N) cin>>d[i];
	sort(d.bg,d.ed,greater<ll>());
	ll ma=d[0],ans=1;
	rep1(i,N-1){
		if(d[i]<ma){
			ma=d[i];
			ans++;
		}
	}	
	cout<<ans;
}

Measured memory_bytes: 256
H,W,K = list(map(int,input().split()))
s = [list(input()) for i in range(H)]
ans = [[0 for i in range(W)] for j in range(H)]
cut = []
for h in range(H):
    if '#' in s[h]:
        cut.append(h)
count = 1
for j in range(len(cut)):
    cut2 = [0 for i in range(W)]
    for w in range(W):
        if s[cut[j]][w] == '#':
            cut2[w] = count
            count += 1
    for w in range(W-2,-1,-1):
        if cut2[w] == 0:
            cut2[w] = cut2[w+1]
    for w in range(1,W):
        if cut2[w] == 0:
            cut2[w] = cut2[w-1]    
    if j == 0:
        for k in range(cut[0]+1):
            print(*cut2)
    else:
        for k in range(cut[j]-cut[j-1]):
            print(*cut2)
if cut[-1] != H-1:
    for k in range(H-cut[-1]-1):
        print(*cut2)
    

Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[] heights = new int[n];

        String[] ss = sc.nextLine().split(" ");
        for(int i = 0; i < n; i++) {
            heights[i] = Integer.parseInt(ss[i]);
        }

        sc.close();
        System.out.println(frog(n, heights));
    }

    public static int frog(int n, int[] heights) {
        if(n == 0 || n == 1)    return 0;

        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(heights[1] - heights[0]);
        for(int i = 2; i < n; i++) {
            dp[i] = Math.min(Math.abs(heights[i] - heights[i - 2]) + dp[i - 2],
                    Math.abs(heights[i] - heights[i - 1]) + dp[i - 1]);
        }
        return dp[n - 1];
    }
}



Measured memory_bytes: 36048
#include <iostream>

using namespace std;

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

	int ans = 0;
	for (int i = 0; i <= a; i++) {
	for (int j = 0; j <= b; j++) {
	for (int k = 0; k <= c; k++) {
		if (500 * i + 100 * j + 50 * k == x) {
			ans++;
		}
	}}}

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


Measured memory_bytes: 256
H, W = map(int, input().split())
ch, cw = map(int, input().split())
ch -= 1
cw -= 1
dh, dw = map(int, input().split())
dh -= 1
dw -= 1
S = [list(input()) for _ in range(H)]
dist = [[float("inf")] * W for _ in range(H)]

# x = []
# for i in range(5):
#     for j in range(5):
#         if i == 3 and j == 3:
#             continue
#         x.append((i-2, j-2))
# x = set(x)
y = {(0, 1), (1, 0), (-1, 0), (0, -1)}
# x = x - y

from collections import deque
q = deque()
q.append((ch, cw))
dist[ch][cw] = 0
while q:
    h, w = q.popleft()
    for hh, ww in y:
        if 0 <= h+hh < H and 0 <= w+ww < W and S[h+hh][w+ww] == "." and dist[h+hh][w+ww] > dist[h][w]:
            dist[h+hh][w+ww] = dist[h][w]
            q.appendleft((h+hh, w+ww))
    for hh in range(-2, 3):
        for ww in range(-2, 3):
            if 0 <= h+hh < H and 0 <= w+ww < W and S[h+hh][w+ww] == "." and dist[h+hh][w+ww] > dist[h][w] + 1:
                dist[h+hh][w+ww] = dist[h][w] + 1
                q.append((h+hh, w+ww))

if dist[dh][dw] == float("inf"):
    print(-1)
else:
    print(dist[dh][dw])


Measured memory_bytes: 138496
def floor_sum(N, M, A, B):
    ans = 0
    if A >= M:
        ans += (N - 1) * N * (A // M) // 2
        A %= M
    if B >= M:
        ans += N * (B // M)
        B %= M

    y_max = (A * N + B) // M
    if y_max == 0:
        return ans

    x_max = y_max * M - B

    ans += (N + (-x_max // A)) * y_max
    ans += floor_sum(y_max, A, M, (A - x_max % A) % A)

    return ans


T, *NMAB = map(int, open(0).read().split())

for n, m, a, b in zip(*[iter(NMAB)] * 4):
    print(floor_sum(n, m, a, b))

Measured memory_bytes: 41444
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll k,x; cin >> k >> x;
    bool ok = false;
    if(500 * k >= x)ok = true;
    cout << (ok ? "Yes" : "No") << endl;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main(){

    set<int> a;

    int b;
    for(int i=0;i<3;i++){
        cin>>b;
        a.insert(b);
    }
    
    cout<<a.size();
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
    long long r,l;
    int a[100000];
    int n;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    r=2; l=2;
    for(int i=1;i<=n;i++){
        if(l%a[n-i]!=0 && (((l/a[n-i]+1)*a[n-i]) > r)){
            cout << "-1" << endl;
            return 0;
          
        }else{
        l = l%a[n-i]==0 ? l : (l/a[n-i]+1)*a[n-i];
        r = r/a[n-i] * a[n-i] + a[n-i] -1;
       
        }
    }
    cout << l << " " << r << endl;
    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll MOD = 1e9 + 7;
    vector<vector<ll>> dp(S.size() + 1, vector<ll>(4, 0));
    dp.at(S.size()).at(3) = 1;
    for (int i = S.size() - 1; i >= 0; i--)
    {
        ll keisuu = (S.at(i) == '?') ? 3 : 1;
        dp.at(i).at(3) = (dp.at(i + 1).at(3) * keisuu) % MOD;
        vector<char> target = {'A', 'B', 'C'};
        for (int j = 0; j < 3; j++)
        {
            dp.at(i).at(j) = dp.at(i + 1).at(j) * keisuu;
            if (S.at(i) == '?' || S.at(i) == target.at(j))
            {
                dp.at(i).at(j) += dp.at(i + 1).at(j + 1);
            }
            dp.at(i).at(j) = dp.at(i).at(j) % MOD;
        }
    }
    cout << dp.at(0).at(0) << endl;
    return 0;
}


Measured memory_bytes: 7376
N,K=map(int,input().split())
A = [int(x) for x in input().split()]
B = [0]*N

sum_A = sum(A)

for i in range(1,N):
    B[i] = max(0, A[i]+A[i-1]-K)


for i in range(1,N-1):
    t = min(B[i],B[i+1], A[i])
    A[i]-=t
    B[i]-=t
    B[i+1]-=t

print(sum_A - sum(A) + sum(B))


Measured memory_bytes: 14068
# include <stdio.h>

int min(int a,int b, int c){
  int m=a+b;
  if(m>b+c) m=b+c;
  if(m>c+a) m=c+a;
  return m;
}
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  printf("%d\n",min(a,b,c));
  return 0;
}


Measured memory_bytes: 128
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	bb := make([]int, n)

	for i := 0; i < n-1; i++ {
		bb[i] = getNextInt(scanner)
	}
	bb[n-1] = math.MaxInt32
	ans := bb[0]

	for i := n - 2; i >= 0; i-- {
		ans += minint(bb[i], bb[i+1])
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}
func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

char a, b, c;

int main()
{
  cin >> a >> b >> c;
  int res = 700;
  if (a == 'o')
  {
    res += 100;
  }
  if (b == 'o')
  {
    res += 100;
  }
  if (c == 'o')
  {
    res += 100;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;

int main(){

  ll sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;

  ll dx = tx -sx;
  ll dy = ty -sy;

  for(ll i=0;i<dx;i++){
cout<<'R';
  } 
  for(ll i=0;i<dy;i++){
cout<<'U';
  } 
  for(ll i=0;i<dx;i++){
cout<<'L';
  } 
  for(ll i=0;i<dy;i++){
cout<<'D';
  } 
cout<<'D';

   for(ll i=0;i<dx+1;i++){
cout<<'R';

  } 
  for(ll i=0;i<dy+1;i++){
cout<<'U';

  } 
  cout<<'L';
cout<<'U';

  for(ll i=0;i<dx+1;i++){
cout<<'L';

  } 
  for(ll i=0;i<dy+1;i++){
cout<<'D';

  } 
cout<<'R';


}
  


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

void cc_env(){
	#ifndef ONLINE_JUDGE
		freopen("input", "r", stdin);
		freopen("output", "w", stdout);
		// 
	#endif
}



void self_min(int &a, int b){
	a = min(a, b);
}

int main(){
	// cc_env();
	int n;
	cin>>n;
	vector<int> height(n);
	for(int i=0;i<n;i++)
		cin>>height[i];

	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for(int i=0;i<n;i++){
		for(auto j : {i+1, i+2}){
			if(j < n)
				self_min(dp[j], dp[i]+abs(height[j] - height[i]));
		}
	}

	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024