akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 20:50 on 2020-04-04.
 */
#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, m;
    cin >> n >> m;
    vl a(n);
    cin >> a;
    sort(all(a));
    reverse(all(a));
    ll sum = accumulate(all(a), 0LL);
    rep(i, m) {
        if (a[i] * 4 * m < sum) {
            cout << "No" << '\n';
            return;
        }
    }
    cout << "Yes" << '\n';
}

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

Measured memory_bytes: 256
#include<stdlib.h>
#define D 0.006
int main(void){
  int i,n,t,a,h[1000];
  double d[1000],min_n=0,min_d=1000000;
  scanf("%d%d%d",&n,&t,&a);
  for(i=0;i<n;i++)scanf("%d",&h[i]);
  for(i=0;i<n;i++)d[i]=fabs((double)(a-(t-D*h[i])));
  for(i=0;i<n;i++){
    if(d[i]<min_d){
      min_n=(i+1);
      min_d=d[i];
    }
  }
  printf("%.0lf",min_n);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {

    ll n;
    cin >> n;
    for (ll i = sqrt(n); i > 0; --i) {
        if (n%i==0) {
            cout << i + n/i - 2 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var KN = Sarray();
            var K = KN[0];
            var N = KN[1];
            var Ai = Sarray();
            var dst = new List<long>();
            for (var i = 1; i < N; ++i)
                dst.Add(Ai[i] - Ai[i - 1]);
            dst.Add(Ai[0] + K - Ai[N - 1]);
            dst.Sort();
            var ans = K - dst[(int)N - 1];
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 40468
eval'N,K,*A='+`dd`.split*?,
A.sort!
b=s=K%2<1?1:A.pop
(K/2).times{x,y=A
s*=x*y*b>b*A[-1]*A[-2]?(A.shift 2
x*y):A.pop*A.pop
s%=10**9+7}
p s

Measured memory_bytes: 54944
//
// Created by yamunaku on 2020/06/20.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    int k;
    cin >> k;
    s.push_back('0');
    int n = s.size();
    int one = 0;
    rep(i, n) if(s[i] == '1') one++;
    one = min(one + 1, k + 1);
    mtl dp(one, vl(one)), tmp(one, vl(one));
    dp[0][0] = 1;
    vi nx(n);
    nx[n - 1] = n - 1;
    per(i, n - 1) nx[i] = (s[i] == '0' ? i : nx[i + 1]);
    rep(x, n){
        if(s[x] == '0'){
            rep(i, one - 1){
                rep(j, one){
                    dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
                }
            }
            rep(i, one){
                rep(j, one){
                    dp[i][j] = (dp[i][j] + tmp[i][j]) % MOD;
                    tmp[i][j] = 0;
                }
            }
        }else{
            k = nx[x] - x;
            rep(i, one){
                rep(j, one){
                    if(i < k || one <= j + k) continue;
                    tmp[i - k][j + k] = (tmp[i - k][j + k] + dp[i][j]) % MOD;
                }
            }
        }
    }
    ll ans = 0;
    rep(i, one){
        ans = (ans + dp[0][i]) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,x) for(int i=0;i<(int)(x);++i)

using Int = long long;
const int mo = 1e9+7;

Int N;
Int counter[65]; // counter[i] := 右からi bit目の1の数

signed main()
{
    cin >> N;

    rep(i, N) {
        Int A; cin >> A;
        rep(j, 61) {
            if ((A >> j) & 1) counter[j]++;
        }
    }

    Int ans = 0, a = 0;

    rep(i, 61) {
        a = (1ll << i) % mo;
        a *= counter[i] * (N - counter[i]) % mo;
        ans += a;
        ans %= mo;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<int>>;
vector<int> nice;
Graph G;
int N, M;
vector<long long> H(N);
vector<bool> visit;


int main()
{
    cin >> N >> M;
    H.reserve(N); visit.assign(N, false);
    for (int i = 0; i < N; ++i) cin >> H[i];
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i)
    {
        int at, bt;
        cin >> at >> bt;
        --at, --bt;
        G[at].push_back(bt);
        G[bt].push_back(at);
    }
    int ans = 0;
    for (int s = 0; s < N; ++s)
    {
        if(G[s].size() == 0)
        {
            ++ans;
            continue;
        }
        bool ok = true;
        for (auto e : G[s])
        {
            if (H[s] <= H[e]) ok = false;
        }
        if (ok) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9336
n,y = map(int,input().split())
for a in range(n+1):
  for b in range(n+1):
    c = n-a-b
    if 10000*a + 5000*b + 1000*c == y and a+b+c == n and c >= 0:
      print(a,b,c)
      exit()
print("-1 -1 -1")

Measured memory_bytes: 40684
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

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

    vector<int> A(N, 0);
    int total = 0;
    for (int i=0; i<N; i++) {
        cin >> A[i];
        total += A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    if ((4 * M * A[M-1]) >= total) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    // for (auto &a: A) cout << a << ' ';
    // cout << endl;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    lint h; cin>>h;
    lint ans = 2*h-1;
    lint i = 2;
    while(h>1){
        if(h%2==1) ans-=i;
        h/=2;
        i*=2;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e7+10;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

struct permutation {
    vector<mint> fact, ifact;
    permutation(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k];
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int n, m; cin >> n >> m;
    permutation pm(500000);
    combination cm(500000);
    mint ans = 0;
    rep(i,n+1) {
        mint tmp = cm(n,i)*pm(m-i,n-i);
        if (i&1) tmp *= -1;
        ans += tmp*pm(m,n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 18840
def main():
  V, E = map(int, input().split())
  INF = float('INF')
  graph = [[] for _ in range(V)]
  for i in range(E):
    s, t, d = map(int, input().split())
    graph[s].append([t, d])
  dp = [[INF] * V for _ in range(1<<V)]
  dp[(1<<V)-1][0] = 0
  for bit in range((1<<V)-2, -1, -1):
    for v in range(V):
      for u, d in graph[v]:
        if not (bit>>u & 1):
          dp[bit][v] = min(dp[bit|1<<u][u]+d, dp[bit][v])

  if(dp[0][0] == INF):
    print(-1)
  else:
    print(dp[0][0])
  
if __name__ == '__main__':
	main()


Measured memory_bytes: 25700
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=b[a[i]-1]
  if a[max(i-1,0)]==a[i]-1:
    ans+=c[a[i]-2]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
            using namespace std;
            int main()
            {
                int n;
                cin>>n;
                int a[n][3];
                for(int i=0;i<n;i++)
                {
                    for(int j=0;j<3;j++)
                        cin>>a[i][j];
                }
                int ans[n][3];
                ans[0][1]=a[0][1];
                ans[0][2]=a[0][2];
                ans[0][0]=a[0][0];
                for(int i=1;i<n;i++)
                {
                    for(int j=0;j<3;j++)
                    {
                        int m=0;
                        for(int k=0;k<3;k++)
                        {
                            if(k!=j)
                                m=max(m,ans[i-1][k]);
                        }
                        ans[i][j]=a[i][j]+m;
                    }
                }

                cout<<*max_element(ans[n-1],ans[n-1]+3);
                return 0;
            }


Measured memory_bytes: 2560
# 解説を見た

def solve(N: int, M: int, V: int, P: int, A: 'list[int]') -> int:
    """
    入れてよい票 < M*V
        M*V投票するとjを超えるスコアを持つ問題数がP以上になり、不可能

    入れてよい票 >= M*V
        可能

        次の条件を満たせば可能といえる
        # 各問題への投票数は許容範囲内
        # すべてのjudgeがV投票
        # すべてのjudgeが同じ問題に2度以上投票していない
        投票してよい問題abc...zを
        許容される投票数だけ連続させた列(最大M=すべてのjudgeが投票した場合)
        aaaabbbcc...z
        仮定より長さMV以上なので,
        冒頭の区間(長さMV)に対し,judgeを0...M-1,0...M-1,...と割り当てることができる
        この割り当ては,3つの条件を満たす
    """

    from itertools import accumulate

    def is_ok(j):
        if j < P:
            return True
            # P位以内にM回加点

        X = A[j] + M  # 加点後のj位のスコアX
        if X < A[P]:
            return False
            # A[j]にM回加点、P位に加点なしでも勝てん

        return (j - P) * X - (acc[j - 1] - acc[P - 1]) >= M * (V - (P + N - j))
        # return (P - 1 + 1 + N - j) * M + sum(X - A[k] for k in range(P, j)) >= M * V
        # (P-1)位以内,j位以降にM回加点
        # P位～(j-1)位は,加点後のj位を超えない範囲で加点
        # X>=A[P]>=A[k]
        # なので,各kに対し,0点以上加点できる
        # 移項して,累積和でオーダーを落とした

    def binary_search():
        ok = 1
        ng = N + 1
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    *A, = sorted(A, reverse=True)
    A = [0] + A  # 0-indexed -> 1-indexed
    acc = tuple(accumulate(A))
    return binary_search()


def main():
    import sys
    input = sys.stdin.readline

    N, M, V, P = map(int, input().split())
    A = map(int, input().split())
    print(solve(N, M, V, P, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14300
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    int x,y;
    cin>>x>>y;
    if(x>9||y>9){cout<<-1;}
    else cout<<x*y;



















return 0;}
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣶⠿⠿⠿⣷⣦⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡟⠁⠀⠀⠀⠀⠹⣷
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⢀⣿⠂
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣦⣀⣀⣀⣤⣾⠏
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡟⠀⢙⣿⣿⡟⠋
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⠏⠀⢀⣾⣿⣿⣿⣦⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⠋⠀⢠⣿⣿⣿⣿⣿⡟⠿⣦⣀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠃⠀⣠⣿⠟⠹⣿⣿⠟⠀⠀⠈⠙⠻⢶⣤⣄⣀⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡿⠁⠀⣰⣿⠏⠀⠀⢙⣏⠀⠀⠀⠀⠀⣠⣿⣿⣿⣿⣿⣿⡿⠿⠿⠷⠶⣶⣶⣤⣄⣀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠁⠀⣼⣿⡇⠀⠀⢀⣾⣿⣿⣦⣄⡀⣴⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣶⣄⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡟⠀⢀⣼⣿⣿⣿⡄⢠⣿⣿⣿⣿⣿⣿⠏⠉⠛⠻⠿⢿⣿⣏⡀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⡿⠁⠙⢿⣦⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⠏⠀⢀⣾⣿⣿⣿⣿⡟⠙⢿⣿⣿⣿⣿⠋⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣷⡶⠛⠿⢿⣿⣿⡟⠁⠀⠀⠀⠙⣷
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⠋⠀⢠⣾⠏⠈⢿⣿⡟⠀⠀⠀⠈⠙⢻⣇⣀⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⠈⣽⣄⡀⠀⠀⢠⡾⠋
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠃⠀⣠⣿⠋⠀⠀⠈⣏⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣷⡶⠛⠛⠻⠿⠿⣿⠏⠀⠀⠀⠀⢀⣼⣿⣿⣿⣦⣰⡟⠁
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡿⠁⠀⣰⣿⣿⣆⠀⢀⣾⣿⣷⣤⣀⠀⣰⣿⣿⣿⣿⣿⣿⡟⠁⠀⠀⠀⠀⢀⣾⣿⣿⣶⣤⣀⣾⣿⣿⣿⣿⣿⠏
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠁⠀⣴⣿⣿⣿⣿⣦⣾⣿⣿⣿⣿⣿⡟⠙⠛⠿⠿⣿⣿⣟⣀⡀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⠃⠉⠻⣿⣿⡿⠃
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡟⠀⢀⣼⣿⣿⣿⣿⡿⠁⠙⠻⣿⣿⣿⠏⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⡶⠛⠻⢿⣿⣿⡿⠁⠀⠀⠀⢹⡿⠁
⠀⠀⠀⠀⠀⠀⢀⣼⠏⠀⢀⣾⠏⠀⠻⣿⡟⠁⠀⠀⠀⠈⢙⣯⣤⣀⡀⠀⠀⢀⣾⣿⣿⣿⣿⣿⡟⠁⠀⠀⠀⠈⣹⣅⡀⠀⠀⣰⡿⠁
⠀⠀⠀⠀⠀⢀⣾⠋⠀⢠⣾⠏⠀⠀⠀⠙⢷⣄⡀⠀⠀⢠⣿⣿⣿⣿⣿⣿⡿⠋⠙⠛⠛⠻⠿⣏⣀⠀⠀⠀⠀⣴⣿⣿⣿⣆⣰⡟
⠀⠀⠀⠀⢠⣿⠃⠀⢠⣿⠃⠀⠀⠀⠀⠀⠀⠉⠛⠷⣶⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⢀⣾⣿⣿⣿⣶⣤⣼⣿⣿⣿⣿⣿⡟
⠀⠀⠀⣠⡿⠁⠀⣰⡿⣷⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⠿⠷⢶⣴⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣶⣿⣿⣿⣿⣿⠆⠀⠀⢰⣶⣶⣶⣶⡶
⠀⠀⣰⡟⠁⠀⣴⡿⣱⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⢠⣿⣿⣿⣿⣿⠃
⠀⣼⡟⠀⠀⣼⡟⢠⣿⣿⣿⣿⣿⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠀⠀⢠⣿⣿⣿⣿⣿⠋⠉⠉⠙⠻⣯⣉⠉⢉⣿⠏⠉⠀⠀⢀⣾⣿⣿⣿⣿⠇
⣾⠏⠀⢀⣾⠟⢀⣿⣿⣿⣿⣿⠃⠀⢠⣶⣶⣶⣶⣶⣶⣶⣶⡦⠀⠀⢀⣾⣿⣿⣿⣿⠇⠀⢠⣶⣶⣶⣾⣿⣶⣾⣷⡶⠀⠀⠀⣼⣿⣿⣿⣿⡏
⢿⣷⣤⣾⠏⢀⣾⣿⣿⣿⣿⠏⠀⠠⠿⠿⠿⣿⣿⣿⣿⣿⣿⠁⠀⠀⣼⣿⣿⣿⣿⡏⠀⠀⠿⠿⠿⢿⣿⣿⣿⣿⣿⠃⠀⠀⠼⠿⠿⠿⠿⠟
⠀⠉⠉⠀⠀⣼⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⠃⠀⠀⣸⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⠇
⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⢠⣿⣿⣿⣿⣿⠃
⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⢀⣾⣿⣿⣿⣿⠇
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;

bool IsPrime(ll 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;
}

void solve(long long A, long long B){
  ll gcdv =0;
  ll cnt =0;
  ll not_prime_cnt =0;
  bool flg=false;
  ll n = 0;
  vector <ll> res;

  gcdv = gcd(A,B);
  // cout << gcdv << "\n";
  n = gcdv;

  double boundary = sqrt(n);
  for (ll i = 1; i <= boundary; i++)
  {
    if(n%i==0){
      res.push_back(i);
      if(i != (n/i) && i*i != n){
        res.push_back(n/i);
      }
    }
  }
  // rep(i, res.size()) cout << res[i] << " ";
  // cout << "\n";

  for (ll i = 0; i < res.size(); i++)
  {
    if(IsPrime(res[i])){
      cnt++;
    }
    // if(res[i]==1 || res[i]==2 || res[i] ==3){
    //   cnt++;
    // }
    // double sqrtnum = sqrt(res[i]);
    // for (ll ij = 3; ij <= sqrtnum; ij+=2)
    // {
    //   if(res[i] % i == 0){
    //     not_prime_cnt++;
    //     break;
    //   }
    // }
  }
  cout << cnt +1 << "\n";

  // for (ll i = 3; i <= gcdv; i+=2)
  // {
  //   flg=false;
  //   for (ll j = 3; j <= sqrt(i); j+=2)
  //   {
  //     if(i%j==0){
  //       flg=true;
  //       break;
  //     }
  //   }
  //   if(!flg) cnt++;
  // }
  // cout << cnt + 1 + (gcdv%2) << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
#define EPS 1e-15
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll n=s.size();
  ll now = 0;
  ll ans = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'R'){
      now++;
      if(now == 4){
	ans++;
	now = 0;
      }
    }else{
      now--;
      if(now == -4)now = 0;
    }
    // cout<<now;
  }
  //cout<<endl;
  cout<<ans<<endl;
  return 0;
}



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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p=0,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>s;
    for (ll i=0; i<s.size(); i++) {
        p=0;
    if (s[i]=='A') {
        o++;
        p++;
    }
    if (s[i]=='T') {
       o++;
         p++;
    }
    if (s[i]=='C') {
        o++;
         p++;
    }
    if (s[i]=='G') {
        o++;
         p++;
    }
        if (p==0) {
            o=0;
        }
        max1=max(max1,o);
    }
    cout<<max1<<endl;
}




Measured memory_bytes: 256
n,m=[int(i) for i in input().split()]

x=[0 for i in range(m)]
y=[0 for i in range(m)]
ans=[0 for i in range(n)]
count=[1 for i in range(n)]
ans[0]=1

for i in range(m):
  x[i],y[i]=[int(i) for i in input().split()]

for i in range(m):
  count[x[i]-1]-=1
  count[y[i]-1]+=1
  
  if ans[x[i]-1]==1:
    ans[y[i]-1]=1
  if count[x[i]-1]==0:
    ans[x[i]-1]=0
    
#print(count)
#print(ans)
print(sum(ans))

Measured memory_bytes: 12584
#include<vector>
using namespace std;
#define BLACK 1
#define WHITE 0
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep(i,n) REP(i,0,n)

class state{
public:
  int num,color;
  state(){};
  state(int tnum,int tcolor){num=tnum;color=tcolor;}
  void change(){color = color==WHITE?BLACK:WHITE;}
};

void solve(vector<state>& A,int flag,int color){
  if ( flag == 0){
    if ( A.size() != 0 && A[A.size()-1].color == color)A[A.size()-1].num++;
    else A.push_back(state(1,color) );
  }else {
    if (  A[A.size()-1].color == color)A[A.size()-1].num++;
    else {
      A[A.size()-1].num++;
      A[A.size()-1].change();
      if ( A.size() <= 1)return;
      if ( A[A.size()-1].color == A[A.size()-2].color){
	A[A.size()-2].num+=A[A.size()-1].num;
	A.erase(A.begin()+A.size()-1);
      }
    }
  }
}

main(){
  int n;
  while(cin>>n&&n){
    vector<state> A;
    rep(i,n){
      int t;
      cin>>t;
      solve(A,i%2,t);
    }
    int cnt=0;
    rep(i,A.size()){
      if ( A[i].color==WHITE)cnt+=A[i].num;
    }
    cout << cnt<<endl;
  }
  return false;
}

Measured memory_bytes: 904
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	s := nextInt()
	w := nextInt()

	if s > w {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}

}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  double l;cin>>l;
  double ans=l/3.0*l/3.0*l/3.0;
  cout<<fixed<<setprecision(8)<<ans<<endl;
}

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

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    int c = min(a, b);
    vector<int> ans = {};
    for(int i=1;i<=c;++i){
        if(a%i == 0 && b%i == 0)ans.push_back(i);
    }
    sort(ans.begin(), ans.end(), greater<int>());
    cout << ans[k-1] << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
if n % 2 == 1:
    print(0)
    exit()
ps = sorted(p)
# print(ps, ps[len(ps)//2-1], ps[len(ps)//2])
print(ps[len(ps)//2] - ps[len(ps)//2-1])

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

int main() {
  double r1, r2;
  double k1[] = {35.5, 37.5, 40., 43., 50., 55., 70.};
  double k2[] = {71., 77., 83., 89., 105., 116., 148.};
  const char *label[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
  double *p1, *p2;
  
  while (cin >> r1 >> r2) {
    p1 = upper_bound(k1, k1+7, r1);
    p2 = upper_bound(k2, k2+7, r2);
    cout << label[max(p1-k1, p2-k2)] << endl;
  }

  return 0;
}

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

int main(){
    char S[10];

    scanf("%s",S);

    if(strcmp("ARC",S) == 0){
        printf("ABC\n");
    }else{
        printf("ARC\n");
    }
    return 0;
}


Measured memory_bytes: 1624
#include<iostream>
using namespace std;int main(){int n,k;while(true){cin>>n;if(n==0)break;cin>>k;int left=k,bef=k;for(int u=1;u<n;u++){cin>>k;if(bef+1!=k){if(left!=bef)cout<<left<<"-"<<bef<<" ";else cout<<left<<" ";left=k;}bef=k;}if(left!=bef)cout<<left<<"-"<<bef<<endl;else cout<<left<<endl;}return 0;}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int ans = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                ans++;
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n)cin>>a[i];
    int ans=0,num=1;
    rep(i,0,n){
        if(a[i]==num)num++;
        else ans++;
    }
    if(ans==n) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    
    bool sw[m][n] = {};

    rep(i, m){
        int k;
        cin >> k;
        rep(j, k){
            int s;
            cin >> s;
            sw[i][s-1] = true;
        }
    }

    bool p[m];
    rep(i, m)cin >> p[i];

    int ans = 0;
    rep(i, (1<<n)){
        bool isODD[m] = {};
        rep(j, n)if(i&(1<<j)){
            rep(k, m)if(sw[k][j])isODD[k] = !isODD[k];
        }

        bool isOK = true;
        rep(j, m)if(isODD[j]!=p[j]){
            isOK = false;
            break;
        }

        if(isOK)ans++;
    }

    cout << ans << endl;
}

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

int main() {
  int a; cin >> a;
  cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n,m;
  int a,b;
  cin>>n>>m;
  vector<bool> va(n,false),vb(n,false);
  r(i,m){
    cin>>a>>b;
    if(a==1)va.at(b-1)=true;
    if(b==n)vb.at(a-1)=true;
  }
  r(i,n){
    if(va.at(i)==true and vb.at(i)==true){cout<<"POSSIBLE"<<endl;return 0;}

  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
typedef long long int ll;
using namespace std;

int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int ans=0;
    if(N<= K){
        ans = X*N;
    }else{
        ans = X*K + Y*(N-K);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*  
    tanuj_johal :: gla_clg_sync_with_CSE(true);
    bonding.tie(true);
    hardwork.tie(true);
    
    ::::::::--------------------::::::::
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vector<pll>> graph;
unordered_map<ll,ll> vis,ans;
const ll mod = 1e9+7;
ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}

void dfs(ll s,ll k)
{
    for(ll i=0;i<graph[s].size();i++)
    {
        if(!vis[graph[s][i].ff])
        {
            vis[graph[s][i].ff]=1;
            k += graph[s][i].ss;
            if(k%2==0)  ans[graph[s][i].ff] = 1;
            dfs(graph[s][i].ff,k);
            k-=graph[s][i].ss;
        }
    }
}

void solve()
{
    ll n;cin>>n;
    ll s=-1;
    for(ll i=0;i<n;i++){
        ll a,b,c;cin>>a>>b>>c;
        // if(s==-1)   s=a;
        
        graph[a].pb({b,c});
        graph[b].pb({a,c});
    }
    
    for(ll s=1;s<=n;s++)
    {
        if(!vis[s]){
            ans[s] = 1;
            vis[s] = 1;
            dfs(s,0);
        }
    }
    
    for(ll i=1;i<=n;i++)    cout<<ans[i]<<" ";
}

int main()
{
    fio
    // int t;cin>>t;while(t--)
    {
        solve();
    }
    
}


Measured memory_bytes: 20260
#include <iostream>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


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

  double P = 0;
  FOR(i, 1, N+1) {
    double p = 1.0 / N;
    int score = i;
    while (score < K) {
      p *= 0.5;
      score *= 2;
    }
    P += p;
  }
  cout << fixed << setprecision(12) << P << endl;

  return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> x(n),y(m);

  rep(i,0,n)std::cin>>x[i];
  rep(i,0,m)std::cin>>y[i];

  ll xlen=0,ylen=0;

  rep(i,1,n)xlen=(xlen+((i*(n-i))%MOD)*((x[i]-x[i-1])%MOD))%MOD;

  rep(i, 1, m) ylen =(ylen + ((i * (m - i)) % MOD) * ((y[i] - y[i - 1]) % MOD)) % MOD;

  std::cout<<(xlen*ylen)%MOD;

  return 0;
}

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

using namespace std;

const int MAXN = 55;

int n, m;
int height[MAXN];
vector<int> g[MAXN];
int lca[MAXN][MAXN];
pair<int, int> b[MAXN];

void dfs_prepare(int v, int p) {
  for(int s : g[v]) if(s != p) {
    height[s] = height[v] + 1;
    dfs_prepare(s, v);
  }
}

void dfs_calc(int v, int p, int root, int w) {
  if(height[v] < height[w]) w = v;
  lca[v][root] = w;
  for(int s : g[v]) if(s != p) {
    dfs_calc(s, v, root, w);
  }
}

int add[MAXN];
long long cur, ans;

void dfs_solve(int v, int p) {
  for(int s : g[v]) if(s != p) {
    dfs_solve(s, v);
    add[v] += add[s];
  }
  if(!add[v] && v) cur <<= 1;
}

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

  cin >> n;
  for(int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v;
    g[--u].push_back(--v);
    g[v].push_back(u);
  }

  dfs_prepare(0, -1);
  for(int i = 0; i < n; ++i) dfs_calc(i, -1, i, i);

  cin >> m;
  for(int i = 0; i < m; ++i) {
    cin >> b[i].first >> b[i].second;
    --b[i].first; --b[i].second;
  }

  for(int mask = 0; mask < (1 << m); ++mask) {
    cur = 1;
    fill(add, add + n, 0);
    for(int i = 0; i < m; ++i) {
      if(mask & (1 << i)) {
        ++add[b[i].first];
        ++add[b[i].second];
        add[lca[b[i].first][b[i].second]] -= 2;
      }
    }
    dfs_solve(0, -1);
    if(__builtin_popcount(mask) % 2 == 0) ans += cur;
    else ans -= cur;
  }

  cout << ans << "\n";

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	int ret=0;
	FOR(i,S.size()) ret+=S[i]!=T[i];
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3824
n = list(map(int, input()))
d = int(input())
l = len(n)
MOD = 10**9+7
dp = [[[0]*d for i in range(l+1)] for j in range(2)]
dp[0][0][0] = 1
for i in range(l):
  for j in range(d):
    for k in range(10):
      if k < n[i]:
        dp[1][i+1][j] += dp[0][i][(j-k)%d] + dp[1][i][(j-k)%d]
      elif k == n[i]:
        dp[0][i+1][j] += dp[0][i][(j-k)%d]
        dp[1][i+1][j] += dp[1][i][(j-k)%d]
      else:
        dp[1][i+1][j] += dp[1][i][(j-k)%d]
    dp[1][i+1][j] %= MOD
ans = dp[0][l][0] + dp[1][l][0] - 1
ans %= MOD
print(ans)

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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n)  \
  ld n;        \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)            \
  vector<lli> a(n), b(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i) >> b.at(i);           \
  };
#define LDV(a, n)            \
  vector<ld> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define sum(n) accumulate(n.begin(), n.end(), 0);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(N) LLI(A) LLI(B) DEFO(ans)
  for(lli i = 1;i <= N;i++) {
    if(KSum(i) <= B && KSum(i) >= A) ans += i;
  }
  OUT(ans)
}


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

int main() {
    int N; cin >> N;
    int L[10]; rep(i, N) cin >> L[i];
    sort(L, L + N);
    int S = 0; rep(i, N - 1) S += L[i];
    if (S > L[N - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N,A,B;
  cin >> N >> A >> B;
  cout << min(N*A, B) << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
bool check(int x)
{
	int s=sqrt(x);
	if(double(sqrt(x))-double(s)<1e-9)
	{
		return 0;
	}
	int n=1;
	for(int i=2;i<=s;i++)
	{
		if(x%i==0)
		{
			n++;
		}
	}
	if(n==4)
	{
		return 1;
	}
	return 0;
}
int main()
{
	int i,j,k,n,m,x,ans=0;
	scanf("%d",&n);
	for(i=105;i<=n;i+=2)
	{
		if(check(i))
		{
			ans++;
		}
	}
	printf("%d",ans);
}


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

int main(void){
  int N;
  double sum;
  cin >> N;
  vector<int> num(N);
  vector<double> out(N);
  for(int i = 0; i < N; i++){
    cin >> num.at(i);
    out.at(i) = (1.00000 / num.at(i));
  }
  for(int j = 0; j < N; j++){
    sum = sum + out.at(j);
  }
  double result;
  result = 1.0 / sum;
  cout << fixed << setprecision(10);
  cout << result;
}

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

using namespace std;



int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int cnt=0;
	for(int i=i;i<n;i=i+2)
	{
		if(arr[i]%2!=0)
		{
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
	
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
struct data{
    int x,w,s;
    bool operator < (const data &c)const{
	return s<c.s;
    }
}w[N];
ll ans;
int main(){
    int n=gi(),l=gi(),t=gi();
    for (int i=0; i<n; ++i){
	w[i]=(data){gi(),gi()};
	if (w[i].w==1)
	    ans+=(w[i].x+t)/l,w[i].s=(w[i].x+t)%l;
	else
	    ans+=(w[i].x-t-l+1)/l,w[i].s=(w[i].x-t)%l;
	(w[i].s+=l)%=l;
    }
    sort(w,w+n);
    int id=(ans%n+n)%n,x=id;
    do
	printf("%d\n",w[id].s),(++id)%=n;
    while(x!=id);
    return 0;
}


Measured memory_bytes: 2304
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void pickV(R,T...)(ref R r,ref T t){foreach(ref v;t)pick(r,v);}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  auto a = new int[](n), op = new string[](n), rd = rdsp;
  pick(rd, a[0]); op[0] = "+";
  foreach (i; 1..n) pickV(rd, op[i], a[i]);

  auto dp = new long[][](n+1, 3);
  foreach (ref dpi; dp) dpi[] = -10L^^17;
  dp[0][0] = 0;

  foreach (i; 0..n) {
    if (op[i] == "+") {
      auto r0 = dp[i][0]+a[i];
      auto r1 = dp[i][1]-a[i];
      auto r2 = dp[i][2]+a[i];
      dp[i+1][0] = max(r0, r1, r2);
      dp[i+1][1] = max(r1, r2);
      dp[i+1][2] = r2;
    } else {
      auto r1 = max(dp[i][0], dp[i][2])-a[i];
      auto r2 = dp[i][1]+a[i];
      dp[i+1][0] = max(r1, r2);
      dp[i+1][1] = max(r1, r2);
      dp[i+1][2] = r2;
    }
  }

  writeln(dp[$-1][0]);
}


Measured memory_bytes: 11504
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(0);
  std::cerr << std::fixed << std::setprecision(6);

  long double A, B;

  std::cin >> A >> B;

  std::cout << floorl(A * B) << std::endl;

  return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

class UnionFindTree {
public:
    explicit UnionFindTree(size_t size = 0) {
        reset(size);
    }

    void reset(size_t size) {
        group.resize(size);
        rep(i, size) group[i] = i;
    }
 
    int getGroupId(int i) {
        int g = group[i];
        if (i != g) {
            group[i] = getGroupId(g);
        }
        return group[i]; 
    }

    bool inSameGroup(int i, int j) {
        return (getGroupId(i) == getGroupId(j));
    }

    void merge(int i, int j) {
        i = getGroupId(i);
        j = getGroupId(j);
        if (i != j) {
            group[i] = j;
        }
    }

private:
    vector<int> group;
};

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

    UnionFindTree uft(N);

    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        --x;
        --y;
        uft.merge(x, y);
    }

    rep(i, N) {
        uft.getGroupId(i);
    }

    set<int> groups;
    rep(i, N) {
        groups.insert(uft.getGroupId(i));
    }

    cout << groups.size() << endl;

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n, id, price, num;
	map<int, ll> tbl;
	vector<int> vi;
	
	while (cin >> n, n)
	{
		tbl.clear();
		vi.clear();
		rep(i, n)
		{
			cin >> id >> price >> num;
			if (tbl.find(id) == tbl.end()) vi.push_back(id);
			tbl[id] += (ll)price * num;
		}
		bool flag = false;
		rep(i, vi.size())
		{
			if (tbl[vi[i]] >= 1000000)
			{
				cout << vi[i] << endl;
				flag = true;
			}
		}
		if (!flag) cout << "NA" << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

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

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(0)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,y;
    cin >> x >> y;
    if(x * 2 == y or x * 4 == y){
		cout<<"Yes";
	}else{
		for(int i = 1; i <= x; i++){
			if(i * 4 + (x - i) * 2 == y){
				cout<<"Yes";
				return 0;
			}
		}
		cout<<"No";
	}
}



Measured memory_bytes: 3648
/* ex3_3
   kohei0713 */

#include <stdio.h>

int main(void){
    
    int number, base;
    int digits = 0;
    
    //input
    scanf("%d %d", &number, &base);

    //numberがbase以上の間繰り返す
    while(number >= base){
        //桁数を1増やす
        digits = digits + 1;
        //numberをbaseで割った商を計算
        number = number / base;
    }

    //最後に桁数を1増やす
    digits = digits + 1;

    //digitsを表示
    printf("%d\n", digits);

    return 0;
}

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

#define X first
#define Y second

using namespace std;

const int MAXN=100005;

pair < int, pair<int, int> > niz[MAXN],rj[MAXN];
int n;

int main () {
	
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>niz[i].X>>niz[i].Y.X>>niz[i].Y.Y;
	}
	rj[0].X=niz[0].X;
	rj[0].Y.X=niz[0].Y.X;
	rj[0].Y.Y=niz[0].Y.Y;
	for(int i=1; i<n; i++){
		rj[i].X=max(rj[i-1].Y.Y,rj[i-1].Y.X)+niz[i].X;
		rj[i].Y.X=max(rj[i-1].X,rj[i-1].Y.Y)+niz[i].Y.X;
		rj[i].Y.Y=max(rj[i-1].X,rj[i-1].Y.X)+niz[i].Y.Y;
	}
	cout<<max(rj[n-1].X,max(rj[n-1].Y.X,rj[n-1].Y.Y));
	
	return 0;
}

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

int main() {
    ll k,a,b;cin >> k >> a >> b;
    if(b-a<2 || k-a<1){
        cout << k+1 << endl;
        return 0;
    }

    k -= a-1;
    int y=0;
    if(k%2==1) y=1;
    ll ans=a;
    ans += k/2*(b-a);
    ans += y;
    cout << ans << endl;
    return 0;
}

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

  int H, W, i, j;
   
  while(1){
    scanf("%d %d", &H, &W);
    if (H == 0 && W ==0) break;
    for (i = 0; i < H; i++){
      for (j = 0; j < W; j++){
    printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1804