akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long A, long long B, long long C, long long K){
  int xa = min(A, K);
  K -= xa;
  int xb = min(B, K);
  K -= xb;
  int xc = K;
  K -= xc;
  int ans = xa - xc;
  cout << ans << endl;
}

signed main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long K;
  scanf("%lld",&K);
  solve(A, B, C, K);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

char buf[100005];
string s;
int n;

int main() {
    scanf("%s", buf);
    s = string(buf);
    n = int(s.length());
    for (int i = 0; i < n; ) {
        if (i + 5 > n) {
            cout << "NO" << endl;
            return 0;
        }
        string cur = s.substr(i, 5);
        if (cur == "dream") {
            i += 5;
            if (i + 2 <= n && s[i] == 'e' && s[i + 1] == 'r') {
                if (i + 3 > n || s[i + 2] != 'a') {
                    i += 2;
                }
            }
        } else if (cur == "erase") {
            if (i + 6 <= n && s[i + 5] == 'r') {
                i += 6;
            } else {
                i += 5;
            }
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 384
use std::io::{self, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let m: i32 = read();
    let d: i32 = read();
    let mut result = 0i32;
    for i0 in 2..10 {
        for i1 in 2..10 {
            if i1 * 10 + i0 <= d && i1 * i0 <= m {
                result += 1
            }
        }
    }
    println!("{}", result);
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 1e5 + 100;

int N, M;
char S[Maxn], T[Maxn];

inline void Solve ()
{
	LL lcm = (LL) N * M / __gcd (N, M);
	LL n = lcm / N, m = lcm / M;
	LL r = 0;
	for (int i = 0; i < N; ++i)
	{
		while (r * m < n * i) ++r;
		if (r * m == n * i && S[i] != T[r]) { puts("-1"); exit(0); }
	}
	cout << lcm << endl;
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	scanf("%s", S);
	scanf("%s", T);
}

int main()
{

#ifdef hk_cnyali
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 384
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s, t, ans;
	cin >> s >> t;
	ans += t, ans += s;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
    [n, w] <- map read.words <$> getLine :: IO [Int]
    vws <- U.unfoldrN n parseInt2 <$> B.getContents
    print $ solve w vws

type Value = Int
type Weight = Int

solve :: Int -> U.Vector (Value, Weight) -> Value
solve w vws = runST $ do
    dp <- UM.replicate (w + 1) 0

    U.forM_ vws $ \(vi, wi) ->
        rev (UM.length dp) $ \j ->
            when (wi <= j) $ do
                x <- (+vi) <$> UM.unsafeRead dp (j - wi)
                unsafeModify dp j (max x)

    UM.unsafeRead dp w

-------------------------------------------------------------------------------    

rep, rev :: Monad m => Int -> (Int -> m ()) -> m ()
rep !n = U.forM_ $ U.generate n id
rev !n = U.forM_ $ U.iterateN n (subtract 1) (n - 1)
for :: Monad m => Int -> Int -> (Int -> m ()) -> m ()
for !s !t = U.forM_ $ U.generate (t - s) (+s)
{-# INLINE rep #-}
{-# INLINE rev #-}
{-# INLINE for #-}

unsafeModify :: (PrimMonad m, GM.MVector mv a)
             => mv (PrimState m) a -> Int -> (a -> a) -> m ()
unsafeModify v i f = GM.unsafeRead v i >>= GM.unsafeWrite v i . f
{-# INLINE unsafeModify #-}

type Parser a = B.ByteString -> Maybe (a, B.ByteString)

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (B.readInt . B.dropWhile isSpace)
        <*> StateT (B.readInt . B.unsafeTail)

Measured memory_bytes: 3984
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
int main()
{
    ll n,d,i,j;
    ll ci=0;
    ll x,y;
    scanf("%lld%lld",&n,&d);
    for(i=0;i<n;i++)
    {
        scanf("%lld%lld",&x,&y);
        ll k=(x*x)+(y*y);
        double kk=sqrt(k);
        if(kk<=d)
            ci++;
    }
    printf("%lld\n",ci);
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N; cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];
  sort(all(d));
  cout << d[N/2] - d[N/2-1] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000003
using namespace std;

ll power(ll x, ll n){
    if(n==0){
        return 1;
    }else{
        ll temp = power(x,n/2);
        if(n%2==1){
            return (x*(temp*temp)%MOD)%MOD;
        }else{
            return (temp*temp)%MOD;
        }
        
    }
}


ll kaijo[MOD];
ll kaijo_gyaku[MOD];
int main(){
    kaijo[0]=1;
    for(ll i=1; i<MOD; i++){
        kaijo[i] = kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
    
    for(int i=0; i<MOD; i++){
        kaijo_gyaku[i] = power(kaijo[i],MOD-2);
    }
    
    int Q;
    cin >> Q;
    for(int q=0; q<Q; q++){
        ll x,d,n;
        cin >> x >> d >> n;
        
        if(d==0){
            cout<<power(x,n)<<endl;
            continue;
        }
        
        ll ans = power(d,n);
        ll xd = (power(d,MOD-2)*x)%MOD;
        
        if(xd+n-1>=MOD || xd==0){
            cout<<0<<endl;
            continue;
        }
        
        
        ans *= (kaijo[xd+n-1]*kaijo_gyaku[xd-1])%MOD;
        ans%=MOD;
        cout<<ans<<endl;
    
    
        
    }
    return 0;
}





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

signed main() {
	int n,a,ans=0;
	cin>>n>>a;
	vector<int>t(n);
	for(int i=0;i<n;i++)cin>>t[i];
	for(int i=0;i<n;i++){
		if(i!=n-1){
			ans+=min(t[i+1]-t[i],a);
		}
		else{
			ans+=a;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

string s,t;
cin >> s >> t;
int a,b;
cin >> a >> b;
string u;
cin >> u;
u == s ? cout << a-1 << " " << b : cout << a << " " << b-1;

//////////////////////////////////////////////////////
return 0;}

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

int main(){
  int n, ans;
  cin >> n;
  ans = 0;
  while(n >= 500){
    n -= 500;
    ans += 1000;
  }
  while(n >= 5){
    n -= 5;
    ans += 5;
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int sum = 0;
  rep(i, N) sum += A[i];

  vector<int> d;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      d.eb(i);
      if (sum / i != i) {
        d.eb(sum / i);
      }
    }
  }

  sort(rall(d));

  rep(i, sz(d)) {
    int mod = d[i];
    vector<int> a;
    rep(j, sz(A)) if (A[j] % mod) a.eb(A[j] % mod);

    if (sz(a) == 0) {
      cout << mod << endl;
      return 0;
    }

    sort(all(a));
    ll m = 0, p = 0;
    rep(j, sz(a)) p += (mod - a[j]);

    rep(j, sz(a)) {
      m += a[j];
      p -= (mod - a[j]);
      if (m <= K && p <= K) {
        cout << mod << endl;
        return 0;
      }
    }
  }

  cout << "-1" << endl;
}


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


#define int long long 


const int N = 2002, mod = 1e9 + 7;

int dp[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	dp[0] = 1;
	for(int i = 1; i < N; i++) {
		for(int j = 3; j <= i; j++) {
			dp[i] += dp[i - j];
			dp[i] %= mod;
		}
	}

	int x; cin >> x;
	cout << dp[x] << endl;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double a,b,h,m,H,M;
    constexpr double pi=3.14159265358979;
    cin>>a>>b>>h>>m;
    H=h*pi/6+m*pi/360;
    M=m*pi/30;
    H-=M;
    if(H<0) H=-H;
    if(H>=pi) H=2*pi-H;
    cout<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(H))<<'\n';
}

Measured memory_bytes: 4228
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc081/tasks/arc086_b

//ポイント：
//正負の数が混ざっている時は正負どちらかに統一してから考えるといいかも

//参考：
//https://aralmath.hatenablog.com/entry/2019/02/23/231330

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[51];

vector<pair<LL,LL>> ans;

void solve(){
	LL max=0;//絶対値最大のやつ
    int max_index=0;//それの番号
    
    for(int i=1;i<=N;i++){
        if(abs(A[i])>=abs(max)){
            max=A[i];
            max_index=i;
        }
    }
    
    //Step 1:絶対値最大のやつを他に足して符号を揃える
    for(int i=1;i<=N;i++) ans.push_back(pair<LL,LL>(max_index,i));
    
    //Step 2:前or後ろから順に足していく
    //maxが正なら、Step1でAの要素は全部正になる
    if(max>=0){
        for(int i=1;i<=N-1;i++) ans.push_back(pair<LL,LL>(i,i+1));
    }
    //maxが負なら、Step1でAの要素は全部負になる
    else{
        for(int i=N;i>=2;i--) ans.push_back(pair<LL,LL>(i,i-1));
    }
}

int main(){
    cin >> N;
    for(int i=1;i<=N;i++) cin >> A[i];
 
    solve();

	cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if ((A-1)/D >= (C-1)/B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(A: "List[int]"):
    return 'bust' if sum(A) >= 22 else 'win'


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    print(f'{solve(A)}')


if __name__ == '__main__':
    main()


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

int main() {
  int n,t;
  cin >> n >> t;
  vector<pair<int,int>> vec(n);
  for(int i=0; i<n; i++) {
    int x,y;
    pair<int,int> p;
    cin >> x >> y;
    p = make_pair(x,y);
    vec[i] = p;
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<n; i++) {
    if(vec[i].second <= t) {
      cout << vec[i].first << endl;
      break;
    }
    if(i == n-1) cout << "TLE" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
vector<ll>v[100011];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll l,r,d;

    cin>>l>>r>>d;

    ll ans = (r/d)-((l-1)/d);

    cout<<ans;

    return 0;
}

Measured memory_bytes: 5948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n, m;
    cin>>n>>m;
    int ans = 0;
    for(int i = 0; i <n ;++i){
        int x,y;
        cin>>x>>y;
        if(sqrt(pow(x, 2)+pow(y, 2))<= m){
            ans++;
        }
    }
    cout<<ans<<endl;
}



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

int main() {
  int a,b,s=0;
  cin>>a>>b;
  for(int i=a; i<=b; i++){
    if(i%10==i/10000 && (i- (i/10000)*10000)/1000==(i%100-i%10)/10){
      s+=1;
    }
  }
  cout<<s;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
a = list(map(int,input().split()))

a.sort()
num = [0] * n
c = 0
t = 0
for i in range(n-1):
    if a[i] != a[i+1]:
        c += 1
        num[a[i]-1] += c
        t += 1
        c = 0
    else:
        c += 1

s = sum(num)
t += 1
num[a[i+1]-1] = n - s
num.sort()

ans = 0
for i in range(n):
    if num[i] == 0:
        continue
    if t <= k:
        print(ans)
        break
    ans += num[i]
    t -= 1

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

class union_find {
private:
  unordered_map<lli,lli> par;
  unordered_map<lli,lli> rnk;
public:
  // union_find (lli n){
  //   par = new vll(n);
  //   iota(par->begin(),par->end(),0);
  //   rnk = new vll(n,0);
  // }
  lli parent(lli x){
    if(par[x]) return par[x];
    else return par[x] = x;
  }
  lli find(lli x){
    if(parent(x) == x) return x;
    else return par[x] = find(parent(x));
  }
  void unite(lli x,lli y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(rnk[x] < rnk[y]) par[x] = y;
    else {
      par[y] = x;
      if(rnk[x] == rnk[y]) rnk[x]++;
    }
  }
  bool same(lli x,lli y){
    return find(x) == find(y);
  }
};

union_find uf;
lli n,m;
vll p;
lli x,y;
unordered_map<lli,unordered_set<lli>> pos;
lli ans = 0;


int main(){
  cin >> n >> m;
  p = vll(n+1);
  for(lli i = 1;i <= n;i++) cin >> p[i];
  for(lli i = 0;i < m;i++){
    cin >> x >> y;
    uf.unite(x,y);
  }
  for(lli i = 1;i <= n;i++){
    pos[uf.find(i)].insert(i);
  }
  for(lli i = 1;i <= n;i++){
    if(pos[uf.find(i)].count(p[i]) != 0) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 20168
# coding: utf-8
# Your code here!

N = int(input())
h = list(map(int,input().split()))

dp = [-1 for i in range(N)]

dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(N-2):
    dp[i+2] = min(dp[i+1] + abs(h[i+1]-h[i+2]), dp[i] + abs(h[i] - h[i+2]))

print(dp[N-1])

Measured memory_bytes: 13928
#include <stdio.h>

int main(){
  int X,Y,Z;
  
  scanf("%d %d %d",&X,&Y,&Z);
  
  X=Y-X;
  Y=Y-X;
  X=Y+X;
  
  X=Z-X;
  Z=Z-X;
  X=Z+X;
  
  printf("%d %d %d\n",X,Y,Z);
  
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  vi a(n),b(n),c(n-1);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  rep(i,n-1){
    cin >> c[i];
  }
  int ans = 0;
  int pre = -10;
  rep(i,n){
    ans += b[a[i]-1];
    if(pre == a[i]-1){
      ans += c[pre-1];
    }
    pre = a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <set>
#include <utility>
#include <cmath>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <limits>
#include <istream>
#include <ostream>
#include <complex.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define INF 1e16
#define mod 10000000007
#define mmax(x,y)(x>y?x:y);
#define mmin(x,y)(x<y?x:y);
int main()
{
	
	ll n;
	cin>>n;
	vector<ll> a(n+1);
	vector<ll> b(n);
	for(ll i=0;i<n+1;i++)
		cin>>a[i];
	for(ll i=0;i<n;i++)
		cin>>b[i];
	ll cnt=0;
	for(ll i=n;i>=1;i--)
	{
		if(a[i]>=b[i-1])
			{cnt+=b[i-1];
				a[i]-=b[i-1];
				b[i-1]=0;
			}
		else if(a[i]<b[i-1])
		{
			cnt+=a[i];
			b[i-1]-=a[i];
			a[i]=0;
			if(a[i-1]>=b[i-1])
			{
				cnt+=b[i-1];
				a[i-1]-=b[i-1];
				b[i-1]=0;
			}
			else if(a[i-1]<b[i-1])
			{
				cnt+=a[i-1];
				b[i-1]-=a[i-1];
				a[i-1]=0;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1792
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


#a, b, m = map(int, input().split())
#aa = readints()
#bb = readints()
#print(a, b, m)
# print(aa)
# print(bb)
# for i in range(m):
#    xyc = readints()
#    print(xyc)

s = input()
if s == 'hi':
    print("Yes")
    exit()
if s == 'hihi':
    print("Yes")
    exit()
if s == 'hihihi':
    print("Yes")
    exit()
if s == 'hihihihi':
    print("Yes")
    exit()
if s == 'hihihihihi':
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3832
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
    }
    println!("{} {}", a*b, (a+b)*2);
}



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


int main(){
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  for(int i=0;i<t;++i) cin >> a[i];

  sort(a.rbegin(),a.rend());
  int cal=a[0];
  for(int i=1;i<t;++i){
    if(cal-a[i]>=0) cal-=a[i];
    else{
      int tmp=a[i]-cal;
      cal=tmp;
    }
  }
  if(cal>0)cal--;
  cout << cal << endl;
  return 0;

}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  ll m = 0;
  ll ans = 0;

  for (int i = 0; i < n; i++){
    if (m <= a[i]){
      m = a[i];
    }
    else {
      ans += m - a[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4784
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int inf=1e8+9;
ll mem[1009][(1<<12)+9],n,m,co[1009],M[1009];
ll solve(int id,int msk){

    if(id==m){
        if(msk==(1<<n)-1){
            return 0;
        }
        return inf;
    }
    ll &ret=mem[id][msk];
    if(ret!=-1)
        return ret;
    ll ans=inf;
    ans=min(ans,solve(id+1,msk));
    ans=min(ans,co[id]+solve(id+1,msk|M[id]));
    return ret=ans;
}
int main(){
    GO();

    cin>>n>>m;
    for(int i=0;i<m;i++){
        int num;
        cin>>co[i]>>num;
        int msk=0;
        for(int j=0;j<num;j++){
            int no;
            cin>>no;
            no--;
            msk=setBit1(msk,no);
        }
        M[i]=msk;
    }
    clr(mem,-1);
    int res=solve(0,0);
    cout<<(res>=inf?-1:res)<<endl;
}




Measured memory_bytes: 32640
#include<iostream>
using namespace std;
string s[100];
int h,w,a[100],b[100];
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++)
	{
		int f=1;
		for(int j=0;j<w;j++)f&=s[i][j]=='.';
		a[i]=f;
	}
	for(int j=0;j<w;j++)
	{
		int f=1;
		for(int i=0;i<h;i++)f&=s[i][j]=='.';
		b[j]=f;
	}
	for(int i=0;i<h;i++)
	{
		if(a[i])continue;
		for(int j=0;j<w;j++)if(!b[j])cout<<s[i][j];
		cout<<endl;
	}
}


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

int main() {
    int N;
    cin >> N;
    int a;
    vector<pair<int, int> > vect;
    for (int i = 0; i < N; i++) {
        cin >> a;
        vect.push_back(make_pair(a, i));
    }
    sort(vect.begin(), vect.end());
    for (int i = 0; i < N; i++) {
        cout << vect[i].second+1 << ' ';
    }
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LLINF = 1LL << 60;
inline ll llabs(ll n) { return (n < 0 ? -n : n); }
ll W, H, N;
ll X[100005], Y[100005];
ll sx[100005], sy[100005];
ll dy[] = {-1, 0, -1, 0};
ll dx[] = {-1, -1, 0, 0};
int main()
{
    ll ansx, ansy, val = LLINF;
    cin >> W >> H >> N;
    for(int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
        sx[i] = X[i], sy[i] = Y[i];
    }
    sort(X, X + N), sort(Y, Y + N);
    for(int p = 0; p < 4; p++) {
        ll x = X[(N + dx[p]) / 2], y = Y[(N + dy[p]) / 2];
        ll maxv = 0, sum = 0;
        for(int i = 0; i < N; i++) {
            ll dist = llabs(x - sx[i]) + llabs(y - sy[i]);
            maxv = max(dist, maxv);
            sum += dist * 2;
        }
        if(val > sum - maxv) {
            val = sum - maxv;
            ansx = x, ansy = y;
        }
    }
    cout << val << endl << ansx << " " << ansy << endl;
    return (0);
}


Measured memory_bytes: 6292
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

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


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

ll gcd(ll x, ll y) { return x % y ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

/*
* 積が負になる数: 負数 * 正数
* 積が正になる数: 正数 * 正数 or 負数 * 負数
* 答えが0になる数: 0 * 何でも
*/

ll repeatSquaring(ll n, ll p, ll mod) {
  if(p == 0) return 1;
  if(p % 2 == 0) {
    ll t = repeatSquaring(n, p / 2, mod);
    return t * t % mod;
  } else {
    return (n * repeatSquaring(n, p - 1, mod)) % mod;
  }
}

ll comb(ll n, ll k, ll mod) {
  //分子
  ll res = 1;
  rep(i, k) res = res * (n - i) % mod;
  
  //分母（逆数にする前）
  ll bunbo = 1;
  rep(i, k) bunbo = bunbo * (k - i) % mod;
  
  res = (res * repeatSquaring(bunbo, mod - 2, mod)) % mod;
  return res;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll all = repeatSquaring(2, n, MOD) - 1;
  
  ll anum = comb(n, a, MOD);
  ll bnum = comb(n, b, MOD);
  
  cout << (all - anum - bnum + MOD + MOD + MOD) % MOD << endl;
  
}

/*
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  
  //まず，正，0，負になるペアの個数を数える
  int posct = 0;
  int zeroct = 0;
  int negct = 0;
  rep(i, N) {
    if(A[i] < 0)  ++negct;
    if(A[i] == 0) ++zeroct;
    if(A[i] > 0)  ++posct;
  }
  
  //各符号の組
  int pos_pairct = (posct * posct - posct) / 2 + (negct * negct - negct) / 2;
  int neg_pairct = negct * posct;
  int zero_pairct = (zeroct * zeroct - zeroct) / 2 + (posct * zeroct + negct * zeroct);
  
  sort(A.begin(), A.end());
  
  //順番を区別していったん数えることにする
  //同じインデックス同士は掛けないが，別のインデックスで同じ数なら掛ける
  if(K <= neg_pairct) {
    //負の領域
    //負 * 正 で二分探索
    //負を全部正にして，全部ソートすれば良いのか．筆はなくて生徒みなせばよい．順番が逆になるくらいか
    // int mid = neg_pairct / 2;
    // while(true) {
    //   if(A) 
    // }
  } else if(K <= neg_pairct + zero_pairct) {
    //ゼロの領域
    cout << 0 << endl;
    return 0;
  } else {
    //正の領域
    //昇順
    
    //二分探索で解いてみる    
    int beginIndex = -1;
    rep(i, N) {
      if(A[i] > 0) beginIndex = i;
    }
    int endIndex = N - 1;
    
    int mid = (endIndex - beginIndex) / 2 + beginIndex;
    while(true) {
       
    }
    
  }
}
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int solve(string S){
    int ans = 0, tmp = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            tmp++;
            ans = max(ans, tmp);
        } else {
            tmp = 0;
        }
    }
    return ans;
}

int main(){
  string S;
  cin >> S;
  int ans = solve(S);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI =vector<VI>;
using PII = pair<int,int>;
 
#define FOR(i,a,n) for(ll i = (ll)a; i<(ll)n;++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define PB push_back
 
signed main(void){
 
	cin.tie();
  	ios::sync_with_stdio(false);
  
  	int n;
  	cin >> n;
  	VI a(n);
  	REP(i,n) cin >> a[i];
  	
  	VI b(n);
  	b[0] = a[0];
  	FOR(i,1,n) b[i]=a[i]+b[i-1];
  	
  	int ret=0;
  	map<int,int> mp;
  	for(int i = n-1; i>=0;i--){
    	ret += mp[b[i]];
      	mp[b[i]]++;
    }
  	
  	cout << ret + mp[0] << endl;
  	
  	return 0; 
    
}

Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n); rep (i, n) cin >> a[i];
    ll ansM = 2, ansm = 2;
    reprev (i, n) {
        ansM = (ll)((ansM / a[i]) + 1) * a[i] - 1;
        ansm = (ll)(((ansm - 1) / a[i]) + 1) * a[i];
        eprintf("min:%lld max:%lld\n", ansm, ansM);
        if (ansm > ansM) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ansm << " " << ansM << "\n";
    return 0;
}

Measured memory_bytes: 640
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N = int(input())
divs = make_divisors(N)
ans = float('inf')
for i in divs:
    j = N//i
    ans = min(ans, i+j-2)
print(ans)


Measured memory_bytes: 3268
#include <iostream>
using namespace std;
const int MAX = 1e6;
typedef long long ll;
 
bool prime[MAX+1];
ll dp[MAX+1];
 
void is_prime(){
    fill(prime,prime+MAX+1,true);
 
    prime[0] = prime[1] = false;
    for(int i = 2 ; i*i <= MAX ; i++){
	if(prime[i]){
	    for(int j = i*i ; j <= MAX ; j+=i){
		prime[j] = false;
	    }
	}
    }
 
}
 
int eulerPhi(int n){
    int res = n;
 
    for(int i = 2 ; i*i <= n ; i++){
	if(n % i == 0){
	    res -= res / i;
	    while(n % i == 0) n /= i;
	}
    }
 
    if(n > 1) res -= res / n;
 
    return res;
}
 
void init(){
    is_prime();
 
    dp[1] = 2; // 0/1 , 1/1
 
    for(int i = 2 ; i <= MAX ; i++){
	if(prime[i]){
	    dp[i] = dp[i-1] + (i-1);
	}
	else{
	    dp[i] = dp[i-1] + eulerPhi(i);
	}
    }
 
}
 
int main(){
    int T,in;
 
    init();
 
    cin >> T;
    while(T--){
	cin >> in;
	cout << dp[in] << endl;
    }
    return 0;
}

Measured memory_bytes: 11860
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let rec dig n k = if n=0 then 0 else (dig (n/k) k)+1
    let N,K=R2 int int
    dig N K|>outl
    0
    

Measured memory_bytes: 11348
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <deque>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31) - 1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;

//#define _DEB 0

int main(){
	int n; cin >> n;
	ll ans = 0LL;
	ll per[5] = {};
	for (int i = 0; i < n; i++) {
		string name;
		cin >> name;
		switch (name[0]) {
		case 'M':
			per[0]++;
			break;
		case 'A':
			per[1]++;
			break;
		case 'R':
			per[2]++;
			break;
		case 'C':
			per[3]++; break;
		case 'H':
			per[4]++; break;
		default:
			break;
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += per[i] * per[j] * per[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, val, i;

	while (scanf("%d %d", &a, &b) != EOF) {

		val = a + b;
		for (i = 0; val >= 1; i++) {
			val = val / 10;
		}
		printf("%d\n", i);
	}
	return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define mod 1000000007
#define i2 500000004ll
using namespace std;
int read();
void Add(int &x, int y) { (x += y) >= mod ? x -= mod : x; }

int n, m;
int a[3003], f[3003][3003];
int main() {
    n = read(), m = read();
    for (int i = 1; i <= n; ++i) {
        a[i] = read();
        for (int j = 1; j < i; ++j)
            f[j][i] = a[j] > a[i], f[i][j] = a[i] > a[j];
    }

    for (int i = 1, x, y; i <= m; ++i) {
        x = read(), y = read();
        for (int j = 1; j <= n; ++j) {
            if (j == x || j == y) continue;
            f[j][x] = f[j][y] = i2 * (f[j][x] + f[j][y]) % mod;
            f[x][j] = f[y][j] = i2 * (f[x][j] + f[y][j]) % mod;
        }
        f[x][y] = f[y][x] = i2 * (f[x][y] + f[y][x]) % mod, swap(f, f);
    }

    int res = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j < i; ++j) Add(res, f[j][i]);

    for (int i = 1; i <= m; ++i) Add(res, res);
    printf("%d\n", res);
    return 0;
}
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Measured memory_bytes: 35456
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 1e6 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll n, a[N];
ll ans;
int main(){
	IOS;
	cin >> n;
	cin >> ans;
	for (int i = 1; i < n; i++){
		ll v;
		cin >> v;
		ans = __gcd(ans, v);
	}
	cout << ans;
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long a  = sc.nextLong();
		long b  = sc.nextLong();
		long k  = sc.nextLong();
		long takahashi = a;
		long aoki = b;
		
		if(a <= k) {
			takahashi = 0;
		}else {
			takahashi = a - k;
		}
		
		if(0 < k - a) {
			aoki = Math.max(0, b - (k - a));
		}
		
		System.out.println(takahashi + " " + aoki);
		sc.close();
	}
	
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int ans{};
  int t = min(X, Y);
  if (A + B < C * 2) {
    ans += (A + B) * t;
  } else {
    ans += C * 2 * t;
  }
  int XorY;
  int AorB;
  if (X > Y) {
    XorY = X - t;
    AorB = A;
  } else {
    XorY = Y - t;
    AorB = B;
  }
  if (AorB < C * 2) {
    ans += AorB * XorY;
  } else {
    ans += C * 2 * XorY;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a!=1&&b!=1){
    cout<<"1"<<endl;
  }else if(a!=2&&b!=2){
    cout<<"2"<<endl;
  }else{
    cout<<"3"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int n, x, t;
	cin >> n >> x >> t;

	cout << (n + x - 1) / x * t << endl;

	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
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; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll A;
  cin >> A;
  string tmp;
  cin >> tmp;
  auto iter = tmp.find(".");
  ll Bz = stoll(tmp.substr(0, iter));
  ll Bf = stoll(tmp.substr(iter+1, tmp.size()));
  ll ans = A * Bf;
  ans /= 100;
  ans += A * Bz;
  PRINT(ans);
  return 0;
} 


Measured memory_bytes: 3692
s=input()
n=len(s)
end_1=(n-1)//2
s_1=s[0:end_1]
end_2 = (n+3)//2
s_2=s[end_2-1::]
#print("s_1",s_1)
#print('s_2',s_2)
if s_1 == s_1[::-1] and s_2 == s_2[::-1] and s==s[::-1]:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060