akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
    long int a,sum,i,n,max=0;
    scanf("%ld",&n);
    max=0;
    sum=0;
    for(i=0;i<n;i++)
    {
        scanf("%ld",&a);
        sum+=a;
        if(a>max)
        {
            max=a;
        }
        
    }
    sum-=max/2;
    printf("%ld",sum);
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    ll res = 0;
    int cnt = 0;
    while(true) {
        ll min_num = *min_element(A.begin(), A.end(), [](int a, int b) {
            return (a == 0) ? false : (b == 0) || a < b;
        });
        cnt = 0;
        res = 0;
        bool flag = false;
        for(int i = 0; i < N; ++i) {
            if(A[i] == 0) {
                cnt++;
            } else {
                res = A[i];
                if(min_num == A[i] && flag == false) {
                    flag = true;
                    continue;
                }
                A[i] = A[i] % min_num;
            }
        }

        if(cnt == N - 1) break;
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    map<ll,ll> cnt;
    for(ll i=0,x;i<n;i++)cin>>x,cnt[x]++;
    vector<ll> a;
    for(auto &ele:cnt)a.push_back(ele.second);
    sort(a.rbegin(),a.rend());
    ll ans = 0;
    while(a.size()>k)ans+=a.back(),a.pop_back();
    cout<<ans;
}

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

int main()
{
  long long N,M;
  cin>>N>>M;
  vector<pair<long long,long long>> vec;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    vec.push_back(make_pair(a,-b));
  }
  sort(vec.begin(),vec.end());
  
  long long sum=0;
  auto itr = vec.begin();
  while(M!=0){    
    if(M>=(-1*(*itr).second)){
      sum+=(*itr).first*(-1*(*itr).second);
      M-=(-1)*(*itr).second;
      itr++;
    }
    else{
      sum+=(*itr).first*M;
      M=0;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 2420
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;
typedef long long ll;
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 long long INF = 1LL << 60;
typedef pair<int, int> P;

/*
奇数の時0
偶数
素因数5の方が明らかに少ないので
5の数を数えて出力すればよい
それは10の数と等価
各桁について通過する10の数
例えば100000000の時、
1桁目は100000000 / 10

134の時、
10の位は
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130
50 は 50
100の位は
100

1000
10,20,30,...1000  100回
100, 200, 300, ..., 1000  10回


そうか,50のカウント忘れ

50, 150, 250, ... ,950 10回
->(N+50)/100

500, 1500, 2500, 3500, ..., 
->(N+500)/1000

5000, 15000, 
-> 

250, 500, 750 
(N+250)/


10 

50

10000 が含む250の倍数だが 100を
*/

/*
i桁目まで見たとき、j...ぎりぎりの値かどうか 
そこまで決定した数字の内でのそれ以下のあり得る5の数
dp[i][j]
*/
/*
ll dp[20][2];
ll po(ll a, ll b) {for (int i = 0; i < b-1; i++) a*=a; return a;}

ll rec(vector<ll> &digits, ll i, bool flag, ll L) {
    if (i == L-1) return 1;
    if (dp[i][flag] != 0) return dp[i][flag];
    ll d = digits[i], res = 0, D = po(10,(L-i-1));
    if (flag) {
        if (i != 0) {
            if (d == 0) res += rec(digits, i+1, true, L) + D;
            else res += rec(digits, i+1, false, L) + D;
        }
        for (int i = 1; i < d; i++) {
            res += rec(digits,i+1,false,L)+D;
        }
        res += rec(digits,i+1,true,L)+D;
    } else {
        for (int i = 0; i <= 9; i++) {
            res += rec(digits,i+1,false,L)+D;
        }
    }
    dp[i][flag] = res;
    return res;

    1250 
}*/

int main() {
    ll N; 
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl; return 0;
    } 
    /*
    ll res = 0, D = 10;
    while (D <= N) {
        res += N / D;
        if (N + 5 * D > 0) {
            res += (N+5*D) / (10 * D);
        }
        D *= 10;
    }
    cout << res << endl;*/

    ll res = 0, A = 1, D = 10;
    /*while (D <= N) {
        res += N / D;
        D *= 10;
    }*/
    /*
    while (A <= N) {
        D = 10;
        if (A == 1) {
            while (A*D <= N) {
                res += N/(10*D);
                D *= 10;
            }
            A *= 5;
            continue;
        }
        if (A == 5) {
            while (A*D <= N) {
                res += (N+5*D)/(10*D);
                D *= 10;
            }
            A *= 5;
            continue;
        }
        
        while (A*D <= N) {
            res += (N+A*D)/(10*D);
            D *= 10;
        }
        A *= 5;
    }*/
    while (A <= N) {
        res += N / (A*D);
        A *= 5;
    }

    cout << res << endl;
    

/*
    vector<ll> digits;
    ll D = 10, M = N;
    while (M > 0) {
        digits.push_back(M % 10);
        M /= 10;
    }
    reverse(digits.begin(), digits.end()); 
    ll L = digits.size();

    ll res = rec(digits,0,true,L);

    cout << res << endl;
    
*/

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

def mapper(x): 
    if x >= 3200:
        return -1;
    else:
        return x // 400

n = input()

# n行x列の配列を取得
stage = np.array(list(map(int, input().split())))

#-1の個数
r = np.count_nonzero(np.vectorize(mapper)(stage) == -1)

#-1以外の重複個数
s = len(set(np.vectorize(mapper)(stage).tolist())-set([-1]))

print(max(s,1), s+r)


Measured memory_bytes: 13616
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

h_sum=sum(h)

ok=10**9
ng=0
while abs(ok-ng)>1:
 mid=(ok+ng)//2

 l=[i-(mid*b) for i in h]
 cnt=0
 for j in l:

  if j<=0:
   continue

  if j%(a-b)==0:
   cnt+=j//(a-b)
  else:
   cnt+=j//(a-b)+1

 if cnt<=mid:
  ok=mid
 else:
  ng=mid

print(ok)

Measured memory_bytes: 15100
import bisect
import itertools
 
n = int(input())
s = input()
 
RGB = [[], [], []]
for i in range(n):
    if s[i] == 'R':
        RGB[0].append(i)
    elif s[i] == 'G':
        RGB[1].append(i)
    else:
        RGB[2].append(i)
total = len(RGB[0]) * len(RGB[1]) * len(RGB[2])
RGB.sort(key=lambda x:len(x))
len_B=len(RGB[2])
max_B=max(RGB[2])
min_B=min(RGB[2])
#for r in RGB[0]:
#    for g in RGB[1]:
for rg in itertools.product(RGB[0],RGB[1]):
    r=rg[0]
    g=rg[1]
    dif = abs(r - g)
 
    up = max(r,g)+dif
    down = min(r,g)-dif
    if max_B >=up:
        if RGB[2][bisect.bisect_left(RGB[2],up)]==up:
            total-=1
    if min_B <= down and max_B >= down:
        if RGB[2][bisect.bisect_left(RGB[2],down)]==down:
            total-=1
    if dif % 2 == 0:
        center = (r+g)/2
        center_posi=bisect.bisect_left(RGB[2], center)
        if center_posi < len_B:
            if RGB[2][center_posi]==center:
                total-=1
print(total)

Measured memory_bytes: 76724
#include<stdio.h>

int n;
int a[50];

solve(int i, int m){
   if(m == 0)
     return 1;
   if(i >= n)
     return 0;
   int res = solve(i + 1, m) || solve(i + 1, m - a[i]);
   return res;
}

int main(){

int q, m, i;


    scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

    scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &m);
    
    if(solve(0, m))
      printf("yes\n");
    else
      printf("no\n");

    
  }
  return 0;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,i,j,k,x,d,y,z,a,b;
    cin>>x>>k>>d;
    if(abs(x)/d>=k){
     cout<<min(abs(x+k*d),abs(x-k*d));
    }
    else{
        y=abs(x%d);
        z=d-y;
        if(y<z){
            if((k-abs(x)/d)%2==0)
                cout<<y;
            else
                cout<<z;
        }
        else{
            if((k-abs(x)/d-1)%2==0)
                cout<<z;
            else
                cout<<y;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

pair<ll, ll> func(ll A, ll B, ll C, ll D, ll sugerPerWater, ll weightMax) {
    vector<ll> waters;
    for (ll a = 0;; ++a) {
        if (a * A > weightMax) break;
        for (ll b = 0;; ++b) {
            ll tmp = a * A + b * B;
            if (tmp <= weightMax) {
                if (tmp != 0) {
                    waters.push_back(tmp);
                }
            } else {
                break;
            }
        }
    }

    vector<ll> sugers;
    for (ll c = 0;; ++c) {
        if (c * C > weightMax) break;
        for (ll d = 0;; ++d) {
            ll tmp = c * C + d * D;
            if (tmp <= weightMax) {
                sugers.push_back(tmp);
            } else {
                break;
            }
        }
    }

    sort(waters.begin(), waters.end());
    waters.erase(std::unique(waters.begin(), waters.end()), waters.end());

    sort(sugers.begin(), sugers.end());
    sugers.erase(std::unique(sugers.begin(), sugers.end()), sugers.end());

    float percent    = -1;
    pair<ll, ll> res = {A, 0};
    for (auto w : waters) {
        ll sugerMax   = w / 100 * sugerPerWater;
        auto valueItr = lower_bound(sugers.begin(), sugers.end(), sugerMax);
        if (*valueItr > sugerMax) valueItr--;
        while (w + *valueItr > weightMax) {
            valueItr--;
        }

        float p = (float)(*valueItr) / (float)(*valueItr + w);
        if (percent < p) {
            percent = p;
            res     = {w + *valueItr, *valueItr};
        }
#ifdef SOURCE_TEST
        cout << sugerMax << " " << *valueItr << " " << w << endl;
#endif
    }
#ifdef SOURCE_TEST
    for (auto w : waters) {
        cout << w << " ";
    }
    cout << endl;

    for (auto w : sugers) {
        cout << w << " ";
    }
    cout << endl;
#endif

    return res;
}
int main() {
    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    A *= 100;
    B *= 100;

    auto pair = func(A, B, C, D, E, F);
    cout << pair.first << " " << pair.second << endl;

    return 0;
}

Measured memory_bytes: 5124
#include<bits/stdc++.h>
//#define test
#ifdef test
#define IOS()
#define time() cout<<double(end-start)/CLOCKS_PER_SEC<<"S\n"
#else
#define IOS() ios::sync_with_stdio(0)
#define time()
#endif
typedef long long ll;
using namespace std;
int main()
{
	int n,x,t;
	while(cin>>n>>x>>t)
	{
		int k=n/x+bool(n%x);
		cout<<k*t<<"\n";
	}
} 

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    int n = sz(s);
    s = s.substr(0, n-8);
    cout << s << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll n, a, b;cin >> n >> a >> b;
  ll sho = n/(a+b);
  ll amari = n%(a+b);
  ll ans = sho*a;
  if(amari >= a){
    ans += a;
  }else{
    ans += amari;
  }

  say(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 5;


int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		lli n,m;
		cin>>n>>m;
		lli a[n],s = 0;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			s+=a[i];
		}
		int count = 0;
		lli kk = 4ll*m;
		for(int i=0;i<n;i++)
		{
			if(a[i]*kk >= s) count++;
		}
		if(count >= m) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n; cin>>n;
	ll ans =0;
	rep(i,n){
		int tmp=0;
		cin>>tmp;

		ans +=tmp-1;
	}

	writeln(ans);
;



}


Measured memory_bytes: 256
def examA():
    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(N)]
    ans = [0]*D

    for v in ans:
        print(v)
    return

def examB():
    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()for _ in range(D)]
    ans = [0]*D
    used = [0]*N
    for i,t in enumerate(T):
        ans[i] += ans[i-1]
        t -= 1
        ans[i] += S[i][t]
        used[t] = i+1
        for j in range(N):
            ans[i] -= C[j]*(i+1-used[j])
    for v in ans:
        print(v)
    return

def examC():
    def calc_start():
        rep = [0] * D
        used = [0] * N
        for i, t in enumerate(T):
            rep[i] += rep[i - 1]
            rep[i] += S[i][t]
            used[t] = i + 1
            for j in range(N):
                rep[i] -= C[j] * (i + 1 - used[j])
        return rep

    def search(d,k):
        l = 0; r = D
        for i in range(d+1,D):
            if T[i]==k:
                r = i
                break
        for i in range(0,d)[::-1]:
            if T[i]==k:
                l = i + 1
                break
        return l, r

    def calc_cost(d,k):
        return C[k]*(d+1)*d//2

    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()-1 for _ in range(D)]

    ans = calc_start()[D-1]

    #print(ans)

    M = I()
    for i in range(M):
        #d, q = random.randint(0,D-1), random.randint(0,N-1)
        d, q = LI()
        d -= 1; q -= 1
        old = deepcopy(T[d])
        T[d] = q
        #print(q,old)

        old_l, old_r = search(d,old)
        new_l, new_r = search(d,q)

        #print(old_l, old_r)
        #print(new_l, new_r)

        change = S[d][q] - S[d][old] \
                 - (calc_cost(old_r - old_l, old) - calc_cost(d-old_l, old) - calc_cost(old_r-d - 1, old))\
                 + (calc_cost(new_r - new_l, q) - calc_cost(d - new_l, q) - calc_cost(new_r - d - 1, q))

        ans += change

        print(ans)

    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 84716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    int c = (d + s - 1) / s;
    if (c <= t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Thursday August 13, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof arr)
#define ll    int64_t

#define pii   pair<int, int>
#define piii  tuple<int, int, int>
#define pll   pair<ll, ll>
#define plll  tuple<ll, ll, ll>

#define F  first
#define S  second

const int oo  = (int)(1e9);
const ll lloo  = (ll)(1e18);

const int N = int(1e5) + 10;

class Task {
public:

    int n;
    vector<piii> A;

    ll dp[N][4];


    ll go(int index, int last) {
        if(index > n) return 0LL;
        ll &ans = dp[index][last];
        if(ans != -1) return ans;
        ll x=0, y=0;
        if(last == 1) {
            x = get<1>(A[index]) + go(index+1, 2);
            y = get<2>(A[index]) + go(index+1, 3);
        } else if(last == 2) {
            x = get<0>(A[index]) + go(index+1, 1);
            y = get<2>(A[index]) + go(index+1, 3);
        } else if(last == 3) {
            x = get<0>(A[index]) + go(index+1, 1);
            y = get<1>(A[index]) + go(index+1, 2);
        } else {
            ll z = 0;
            x = get<0>(A[index]) + go(index+1, 1);
            y = get<1>(A[index]) + go(index+1, 2);
            z = get<2>(A[index]) + go(index+1, 3);
            x = max(x, z);
        }
        ans = max(x, y);
        return ans;
    }

    ll solveOne(istream &in, ostream &out) {
        int a, b, c;
        in >> n;
        A.resize(n+1);
        for(int i = 1; i <= n; ++i){
            in >> a >> b >> c;
            A[i] = {a, b, c};
        }
        memset(dp, -1, sizeof dp);
        ll ans = go(1, -1);
        return ans;  
    }
    
    void solve(istream &in, ostream &out) {
        int t = 1;
        while(t--) {
            out << solveOne(in, out) << endl;
        }
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 13764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int h, w, a, b; cin >> h >> w >> a >> b;
	a = h % a; b = w % b;
	cout << a * w + b * h - a * b << endl;
}


Measured memory_bytes: 3112
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        abcd: chars
    }
    let v = abcd .into_iter()
        .map(|c| (c as u8 - b'0') as i64)
        .collect::<Vec<_>>();
    let mut ans = vec![];
    for i in 0..2 {
        for j in 0..2 {
            for k in 0..2 {
                let mut ret = v[0];
                if i % 2 == 0 {
                    ret += v[1];
                } else {
                    ret -= v[1];
                }
                if j % 2 == 0 {
                    ret += v[2];
                } else {
                    ret -= v[2];
                }
                if k % 2 == 0 {
                    ret += v[3];
                } else {
                    ret -= v[3];
                }
                if ret == 7 {
                    ans = vec![i,j,k];
                    break;
                }
            }
        }
    }

    println!("{}{}{}{}{}{}{}=7", v[0],op(ans[0]),v[1],op(ans[1]),v[2],op(ans[2]),v[3]);
}

fn op(i: usize) -> char {
    if i % 2 == 0 {
        '+'
    } else {
        '-'
    }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String input = br.readLine();
            List<String> weathers = Arrays.asList("Sunny", "Cloudy", "Rainy");
            Map<String, Integer> weatherPrediction = new HashMap<>();
            weatherPrediction.put("Sunny", 1);
            weatherPrediction.put("Cloudy", 2);
            weatherPrediction.put("Rainy", 0);

            
            System.out.println(weathers.get(weatherPrediction.get(input).intValue()));
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

signed main(){
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    int a = y + z;
    int ans = (x-z) / a;
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
int tot;
ll val[105];

il int count(ll x){
	int ans=0;
	while(x) ++ans,x/=10;
	return ans;
}

il ll dfs(ll num,int id,bool first){
	if(id==tot){
		if(!val[id]){
			if(!num) return first?9:10;
			return 0;
		}else{
			if(num%val[id]) return 0;
			if(num>=0) return qmax(0ll,10-num/val[id]-first);
			else return qmax(0ll,10-(-num/val[id])-(first&&!num));
		}
	}
	if(num<0){
		num=-num;
		ll tmp=num/val[id];
		if(tmp>9) return 0;
		ll ans=dfs(-num+tmp*val[id],id+1,false)*qmax(0ll,10-tmp-(first&&!tmp));
		if(num%val[id]&&tmp<9) ans+=dfs(-num+(tmp+1)*val[id],id+1,false)*qmax(0ll,9-tmp);
		return ans;
	}else{
		ll tmp=num/val[id];
		if(tmp>9) return 0;
		ll ans=dfs(num-tmp*val[id],id+1,false)*(10-tmp-first);
		if(tmp<9) ans+=dfs(num-(tmp+1)*val[id],id+1,false)*(10-tmp-1-first);
		return ans;
	}
}

il ll getans(ll n,int w){
	tot=0;
	if(!--w) return 0;
	for(int i=w;i>=0;i-=2){
		ll cur=0;
		rep0(j,i) cur=cur*10+9;
		rep0(j,w-i>>1) cur*=10;
		val[++tot]=cur;
	}
//	rep(i,1,tot) cerr<<val[i]<<endl;
//	cerr<<"end"<<endl;
	return dfs(n,1,true);
}

int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	rep(i,count(n),18) ans+=getans(n,i);
	printf("%lld\n",ans); 
	return 0;
}


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

int main(){
  int h,n;
  cin >> h;
  cin >> n;
  int s = 0;
  int a = 0;
  for (int i=0; i<n; i++){
    cin >> a;
    h -= a;
  }
  if(h <= 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static int[][] point;
	public static int m;

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		m = in.nextInt();

		int[][] stud = new int[n][2];
		for(int i=0; i<n; i++){
			stud[i][0] = in.nextInt();
			stud[i][1] = in.nextInt();
		}

		point = new int[m][2];
		for(int i=0; i<m; i++){
			point[i][0] = in.nextInt();
			point[i][1] = in.nextInt();
		}

		for(int i=0; i<n; i++){
			Manhattan(stud[i][0], stud[i][1]);
		}
	}

	static void Manhattan(int a, int b) {
		HashMap<Integer, Integer> man = new HashMap<>();
		for(int i=0; i<m; i++){
			man.put(i, Math.abs(a - point[i][0]) + Math.abs(b - point[i][1]));
		}
		List<Map.Entry<Integer, Integer>> entries = new ArrayList<Map.Entry<Integer, Integer>>(man.entrySet());
		Collections.sort(entries, new Comparator(){
		    public int compare(Object o1, Object o2){
		        Map.Entry e1 =(Map.Entry)o1;
		        Map.Entry e2 =(Map.Entry)o2;
		        return ((Integer)e1.getValue()).compareTo((Integer)e2.getValue());
		    }
		});

		for (Entry<Integer,Integer> s : entries) {
            System.out.println(s.getKey()+1);
            break;
        }

	}

}



Measured memory_bytes: 21844
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Scan()
	inslice := strings.Split(stdin.Text(), " ")
	N, _ := strconv.Atoi(inslice[0])
	A, _ := strconv.Atoi(inslice[1])
	B, _ := strconv.Atoi(inslice[2])
	if N*A > B {
		fmt.Println(B)
		return
	}
	fmt.Println(N * A)

}

Measured memory_bytes: 640
/* Coding start  time 10/06 19:32 */
/* Coding finish time 10/06 19: */
#include <iostream>
using namespace std;

int main(void)
{
    int inputSecond  = -1;
    int tmpSurplus   = -1;
    int outputHour   = -1;
    int outputMinute = -1;
    int outputSecond = -1;
    int result       = -1;
    
    cin >> inputSecond;
    
    if( (0 <= inputSecond) && (inputSecond < 86400) )
    {
        /* calcurate hour */
        outputHour  = inputSecond / 3600;
        /* calcurate minute */
        tmpSurplus  = inputSecond % 3600;
        outputMinute = tmpSurplus / 60;
        /* calcurate second */
        outputSecond  = tmpSurplus % 60;
        
        cout << outputHour << ":" << outputMinute << ":" << outputSecond << endl;
        result = 0;
    }
    
    return result;
}

Measured memory_bytes: 3060
import queue

def func():
    n, m = map(int, input().split())
    m_list = [[] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        m_list[a-1].append(b-1)
        m_list[b-1].append(a-1)
    q = queue.Queue()
    q.put(0)
    ans = [-1 for i in range(n)]
    ans[0] = -2
    while not q.empty():
        before_room = q.get()
        for i in m_list[before_room]:
            if ans[i] != -1:
                continue
            ans[i] = before_room
            q.put(i)
    for i in ans:
        if i == -1:
            print('No')
            return
    print ('Yes')
    for i in ans:
        if i == -2:
            continue
        print (i+1)

if __name__ == '__main__':
    func()


Measured memory_bytes: 34428
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

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

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;

int main()
{
	int N;
	cin >> N;
	vi d(N, 0);
	rep(i, N) cin >> d[i];
	sort(d.begin(), d.end());

	int ans = 1;
	rep(i, N - 1)
	{
		if (d[i] != d[i + 1]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
int main(){
  int x,y;cin>>x>>y;
  int ans=0;
  if(x==1&&y==1)
    ans+=400000;
  if(x==1)
    ans+=300000;
  if(x==2)
    ans+=200000;
  if(x==3)
    ans+=100000;
  if(y==1)
    ans+=300000;
  if(y==2)
    ans+=200000;
  if(y==3)
    ans+=100000;
  cout<<ans;
}
  
    
 
    

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (d, g) = readLine()!!.split(" ").map { it.toInt() }

    // 通常スコアとコンプリートスコアがある
    // 問題を解くことで目標G 以上のスコアを獲得するのに解かなくてはいけない最小問題数は？

    // どのコンプボーナスを取るのか -> d < 10 -> 2^10 パターン
    // 必要なコンプボーナスを取って，後はスコアが高い順に上から埋めていけば OK
    // 2^10 パターンで G 以上となったときの問題数が一番少ないケースを求める

    val p = LongArray(d)
    val c = LongArray(d)
    for (i in 0 until d) {
        val (a, b) = readLine()!!.split(" ").map { it.toLong() }
        p[i] = a
        c[i] = b
    }

    var ans = Long.MAX_VALUE

    // パターンをどうやって表現するか？？
    for (i in 0..(Math.pow(2.0, d.toDouble()).toInt()-1) ) {

        // 0 埋めした２進数表現を取得
        val binaryRep = Integer.toBinaryString(i).toInt()
        val bs = "%0${d}d".format(binaryRep)

        val pTmp = p.clone()
        val cTmp = c.clone()

        var score = 0L
        var cnt = 0L
        // 使い切る問題を使い切る
        for ((j, ch) in bs.withIndex()) {
            if (ch == '1') {
                score += (j + 1) * 100 * pTmp[j] + cTmp[j]
                cnt += pTmp[j]
                pTmp[j] = 0
            }
        }

        // 残った問題を足していく
        // すべて使いきらない問題に対して大きい方から使う
        for (j in bs.lastIndex downTo 0) {
            if (score >= g) break

            if (bs[j] == '0') {
                // 問題を１問残すところまで使い切る
                while (score < g && pTmp[j] != 0L) {
                    score += (j + 1) * 100
                    cnt += 1
                    pTmp[j] -= 1L
                }
            }
        }

        if (score >= g) {
            ans = if (cnt < ans) cnt else ans
        }
    }

    println(ans)
}

Measured memory_bytes: 40996
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>num(N,0);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
  
  int oddcount = 0;
  for(int i=0;i<N;i++){
    if(num[i] % 2 == 1)
      oddcount++;
  }
  
  if(oddcount % 2 == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  ll a, b;
  cin >> n >> a >> b;
  VL x(n);
  REP(i, 0, n) {
    cin >> x[i];
  }
  ll mi = 0;
  REP(i, 0, n - 1) {
    mi += min(b, a * (x[i + 1]- x[i]));
  }
  cout << mi << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int group(int i){
    if (i==2)
        return 2;
    else if (i==4 || i==6 || i==9 || i==11)
        return 1;
    else
        return 0;
}

int main()
{
    int x, y;
    cin >> x >> y;
    int gx = group(x), gy = group(y);
    if (gx==gy)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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



int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    
    for(int i=k;i<n;i++){
        if(a[i] > a[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
   	
  	
    
    
    return 0;
}

Measured memory_bytes: 4060
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

pair<int, int> dp[510][510];
const pair<int, int> INFII(INF, -1);
 
void update(pair<int, int> &A, pair<int, int> B) {
    B.first = B.first + 1;
    if(A.first > B.first) A = B;
    else if(A.first == B.first) {
        (A.second += B.second) %= MOD;
    }
}

struct Elem {
    int x, y, ans, cnt;
};

signed main() {
    int R, C, sx, sy, tx, ty; cin >> R >> C >> sx >> sy >> tx >> ty;
    fill(dp[0], dp[R], INFII);
    dp[sx][sy] = make_pair(0, 1);

    queue<Elem> que;
    que.push(Elem{sx, sy, 0, 1});

    const int ex[] = {-1, 0, -1, R-1};
    const int ey[] = {0, -1, C-1, -1};
    for(int step=0; step<R+C; step++) {
        set< pair<int, int> > checked;
        while(que.size()) {
            Elem cur = que.front(); que.pop();
            // 隣接
            for(int k=0; k<4; k++) {
                int nx = cur.x + dx[k], ny = cur.y + dy[k];
                if(nx < 0 || ny < 0 || nx >= R || ny >= C) continue;
                if(dp[nx][ny].first < dp[cur.x][cur.y].first + 1) continue;
                update(dp[nx][ny], dp[cur.x][cur.y]);
                checked.insert(make_pair(nx, ny));
            }

            // テレポート
            for(int k=0; k<4; k++) {
                int nx = (ex[k] < 0 ? cur.x : ex[k]);
                int ny = (ey[k] < 0 ? cur.y : ey[k]);
                if(dp[nx][ny].first < dp[cur.x][cur.y].first + 1) continue;
                update(dp[nx][ny], dp[cur.x][cur.y]);
                checked.insert(make_pair(nx, ny));
            }
        }
        
        for(auto x : checked) {
            int nx, ny; tie(nx, ny) = x;
            int vl, vr; tie(vl, vr) = dp[nx][ny];
            que.push(Elem{nx, ny, vl, vr});
        }
    }

    int ans1, ans2;
    tie(ans1, ans2) = dp[tx][ty];
    printf("%lld %lld\n", ans1, ans2);
    return 0;
}


Measured memory_bytes: 6976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  string s1, s2;
  cin >> s1;
  cin >> s2;

#if 0
  cout << s1 << endl;
  cout << s2 << endl;
#endif

  int64_t ans;
  int beg = 0;
  if (s1[0] != s1[1]) {
    ans = 3;
    beg = 1;
  } else {
    ans = 6;
    beg = 2;
  }
  for (int i = beg; i < n; i++) {
    if (s1[i] != s2[i]) {
      if (s1[i - 1] != s2[i - 1]) {
	ans *= 3;
      } else {
	ans *= 2;
      }
      i++;
    } else {
      if (s1[i - 1] == s2[i - 1]) {
	ans *= 2;
      }
    }
  }

  cout << ans % 1000000007 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
void add(int &a , int b)
{
	a = a + b < mod ? a + b : a + b - mod;
}
int sub(int a,  int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int mult(int a, int b)
{
	return (a * (LL)b) % mod;
}
int a[405] , b[405];
int dp[405][405];
int sum[405][405];
int s(int a , int b , int step)
{
	return sub(sum[b][step] , sum[a - 1][step]);
}
int main()
{
	//freopen("In.txt" , "r" , stdin);
	for(int i = 1; i <= 400; i++)
	{
		int chislo = 1;
		for(int j = 0; j <= 400; j++)
		{
			add(sum[i][j] , sum[i - 1][j]);
			add(sum[i][j] , chislo);
			chislo = mult(chislo , i);
		}
	}
	int n , c;
	cin >> n >> c;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
	dp[0][0] = 1;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j <= c; j++)
		{
			for(int k = 0; k <= c - j; k++)
			{
				add(dp[i + 1][j + k] , mult(dp[i][j] , s(a[i] , b[i] , k)));
			}
		}
	}
	cout << dp[n][c];
}




Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var k = sc.nextInt();
		var a = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		sc.close();

		var v = search(a, k);
		System.out.println(v);
	}

	private static int search(int[] a, int k) {
		var min = 0;
		var max = 1000000000;
		while (max - min > 1) {
			var mid = min + (max - min) / 2;
			var c = count(a, mid);
			//System.out.printf("%d %d %d %d\r\n", min, max, mid, c);
			if (c > k) {
				min = mid;
			} else {
				max = mid;
			}
		}

		if (max - min == 1 && count(a, min) > k) {
			min++;
		}
		return min;
	}

	private static int count(int[] a, int v) {
		var count = 0;
		for (var av : a) {
			count += Math.ceil((double)av  / v - 1);
		}
		return count;
	}
}


Measured memory_bytes: 60444
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}//#########################################

bool isPrime(ll n){
    for(ll i = 2; i <= n / i; ++i)
        if(n % i == 0)
            return 0;
    return n > 1;
}


vector<ll> getDivisors(ll n){
    vector<ll> ret;
    for(int i = 1; i <= n / i; ++i){
        if(n % i == 0){
            ret.push_back(i);
            if(n / i != i)
                ret.push_back(n / i);
        }
    }
    return ret;
}



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

vector<ll> ret;

vector<ll> getFactors(ll n){
    // vector<ll> ret;
    for(ll i = 2; i <= n / i; ++i)
        while(n % i == 0){
            ret.push_back(i);
            n /= i;
        }

    if(n != 1){
        ret.push_back(n);
    }
    return ret;
}
const int N = 1e6 + 5;
int vst[N], cnt[N];
vector<int> primes;
void seive(){
    for(int i = 2; i < N; ++i){
        if(vst[i])
            continue;
        primes.push_back(i);
        for(ll j = 1LL * i * i; j < N; j +=i)
            vst[j] = 1;
    }
}

// Modified sieve for number of divisors
int cnt1[N];
void modSeive(){
    for(int i = 1; i < N; ++i){
        for(int j = i; j < N; j += i)
            ++cnt1[j];
    }
}

// Modified sieve for number of prime factors
int cnt2[N];
void mod2Sieve(){
    for(int i = 2; i < N; ++i){
        if(vst[i])
            continue;
        for(ll j = i; j < N; j +=i){
            vst[j] = 1;
            int cntP = 0;// calculate the power of i exists in j
            int curr = j;
            while (curr % i == 0) {
                ++cntP;
                curr /= i;
            }
            cnt2[j] += cntP;
        }
    }
}
//####################################################################################################



map<string,int>a;
int main() {

    int n = D();

    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        a[s]++;
    }
    int m=D();
    for (int i = 0; i < m; i++) {
        cin >> s;
        a[s]--;
    }
    int mx=0;
    for (std::map<string,int>::iterator it=a.begin(); it!=a.end(); ++it){
        mx=max(mx,it->second);

}
    cout<<mx;





}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int x, a, b, c;
    cin >> x >> a >> b;
    x = x - a;
    //買える個数cを求める
    c = x / b;
    x = x - b * c ;
    cout << x << '\n';
    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

S = collections.Counter(s)
T = collections.Counter(t)


ans = [0]
for key, cont in S.most_common():
  if cont > T[key]:
    ans.append(cont-T[key])
print(max(ans))
 

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans =  min(B-1, N);
  cout << (ll)((A*ans)/B) - A *(ll)(ans/B);
  
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  string S[N];
  rep(i, N){
    cin >> S[i];
  }
  rep(i, N){
    sort(S[i].begin(), S[i].end());
  }
  long long ans = 0;
  unordered_map<string, long long> X(N);
  rep(i, N){
    X[S[i]]++;
  }
  for (auto x : X){
    long long n = x.second;
    ans += (n * (n-1) / 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 13476