akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

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

   int s=n.size()-1;

   if(n[s]=='3') cout<<"bon"<<endl;
   else if(n[s]=='0'||n[s]=='1'||n[s]=='6'||n[s]=='8') cout<<"pon"<<endl;
   else cout<<"hon"<<endl;
   

return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int plus = a + b;
        int minus = a -b;
        int kakeru = a*b;
        int result = 0; 
        if(plus<minus){
            result = minus;
        }else{
            result = plus;
        }

        if(result<kakeru){
            result = kakeru;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
(let*((s(concatenate 'list(read-line)))(c 0)(a(car s)))
  (dolist(i(cdr s))(if(char< i #\a)(incf c(if(char= i #\C)1 2))))
  (princ(if(or(/= c 1)(char/= a #\A)(char<(nth 1 s)#\a)(char<(car(last s))#\a))"WA""AC")))


Measured memory_bytes: 11236
n = int(input())
a = list(map(int,input().split()))
x = {}
ans = 0
for i in range(n):
    R = i + a[i]
    if not R in x:
        x[R]=1
    else: x[R]+=1
    
for i in range(n):
    L = i - a[i]
    if L in x:
        ans+=x[L]
print(ans)

Measured memory_bytes: 40456
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)
#define chmax(x, a)  do { x = max(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

ull N, A, B, X, S;

const ll M = 50;
ll dp[M][2][2];

int main(void) {
  cin >> N >> A >> B;
  rep(i, N-2) {
    ull x;
    cin >> x;
    X ^= x;
  }
  S = A + B;

  // 初期化
  rep(i, M) rep(j, 2) rep(k, 2) dp[i][j][k] = -1;
  rep(a, 2) {
    ull b = a ^ (X & 1);
    ull carry = a & b;
    ull _sum = a ^ b;
    if (_sum != (S & 1)) continue;
    ull over = a > (A & 1);
    chmax(dp[0][carry][over], a);
  }

  // 配るDP
  rep(i, M-1) rep(j, 2) rep(k, 2) rep(a, 2) {
    if (dp[i][j][k] == -1) continue;
    ull ni = i + 1;
    ull b = a ^ ((X >> ni) & 1);
    ull _sum = (a + b + j) & 1;
    ull _carry = ((a + b + j) & 2) > 0;
    if (_sum != ((S >> ni) & 1)) continue;
    ull over;
    if (a >  ((A >> ni) & 1)) over = 1;
    if (a <  ((A >> ni) & 1)) over = 0;
    if (a == ((A >> ni) & 1)) over = k;
    chmax(dp[i+1][_carry][over], dp[i][j][k] | (a << ni));
  }

  ll a = dp[M-1][0][0];
  if (a == -1 || a == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << (A-a) << endl;

  return 0;
}


Measured memory_bytes: 3608
def partition(A, p, r):
    i = p - 1
    x = A[r]

    for j in range(p,r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i
    
n = int(input())
A = list(map(int, input().split()))

i = partition(A, 0, n-1)

str_A = list(map(str,A))

str_A[i+1] = "[" + str_A[i+1] + "]"

print(" ".join(str_A))


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

string s;

int main() {
    cin >> s;
    int c1 = 0, c2 = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i%2) {
            if (s[i] == '1') {
                c1++;
            }
            else {
                c2++;
            }
        }
        else {
            if (s[i] == '1') {
                c2++;
            }
            else {
                c1++;
            }
        }
    }
    
    cout << min(c1, c2) << '\n';
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	int x,y;
}a[55],p[2510];
int n,cnt=0;
bool cmp(node a,node b) {return a.x==b.x?a.y<b.y:a.x<b.x;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d %d",&a[i].x,&a[i].y);
	if(n==1) {printf("1");return 0;}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) if(i!=j)
		{
			p[++cnt].x=a[j].x-a[i].x;
			p[cnt].y=a[j].y-a[i].y;
			//printf("p:%d %d\n",p[i].x,p[i].y);
		}
	sort(p+1,p+cnt+1,cmp);
	int num=0,ans=0;
	for(int i=1;i<=cnt;i++)
	{
		if(i==1||(p[i].x==p[i-1].x&&p[i].y==p[i-1].y)) num++;
		else num=1;
		//printf("%d %d %d\n",p[i].x,p[i].y,num);
		ans=max(ans,num);
	}
	printf("%d",n-ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000003;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll modadd(ll x, ll y) {
    return ((x + y) % mod + mod) % mod;
}

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll modpower(ll x, ll y) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else if (y % 2 == 0) {
        ll p = modpower(x, y / 2);
        return p * p % mod;
    } else {
        ll p = modpower (x, y / 2);
        return (p * p) % mod * (x % mod) % mod;
    }
}

ll divide(ll x, ll y) {
    return multiply(x, modpower(y, mod - 2));
}

ll frac[1000010];
ll invfrac[1000010];

void fracinvfrac(ll n) {
    frac[0] = 1;
    for (int i = 1; i <= n; i++) {
        frac[i] = multiply(frac[i - 1], i);
    }
    invfrac[n] = divide(1, frac[n]);
    for (int i = n - 1; i >= 0; i--) {
        invfrac[i] = multiply(invfrac[i + 1], i + 1);
    }
}

ll modcombi(ll x, ll y) {
    if (x < y || y < 0) {
        return 0;
    } else if (y == 0) {
        return 1;
    } else {
        return multiply(multiply(frac[x], invfrac[x - y]), invfrac[y]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    fracinvfrac(1000009);
    ll Q;
    cin >> Q;
    REP(i, 0, Q) {
        ll x, d, n;
        cin >> x >> d >> n;
        if (d == 0) {
            cout << modpower(x, n) << endl;
            continue;
        }
        ll num = divide(x, d);
        if (num + n - 1 >= mod) {
            cout << 0 << endl;
            continue;
        }
        ll ans = divide(frac[num + n - 1], frac[num - 1]);
        // cout << num << " " << n << endl;
        cout << multiply(modpower(d, n), ans) << endl;
    }
}


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


int main(void){
    // Your code here!
    int N = 0;
    
    cin >> N;
    
    int a = N / 100;
    if (a == 7) {
        cout << "Yes" << endl;
        return 0;
    }
    N = N - a * 100;
    int b = N / 10;
    if (b == 7) {
        cout << "Yes" << endl;
        return 0;
    }
    N = N - b * 10;
    int c = N;
    if (c == 7) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
    
}


Measured memory_bytes: 3640
H, W, K = map(int, input().split())

ans = [0]*W
buf = [0]*W

fibonacci = [1]*(W+1)

for i in range(2, W+1):
    fibonacci[i] = fibonacci[i-1]+fibonacci[i-2]

ans[0] = 1

if W==1:
    print(1)
else:
    for i in range(H):
        buf[0] = ans[0]*fibonacci[W-1]+ans[1]*fibonacci[W-2]
        buf[W-1] = ans[W-1]*fibonacci[W-1]+ans[W-2]*fibonacci[W-2]
        for j in range(1, W-1):
            buf[j] = ans[j-1]*fibonacci[j-1]*fibonacci[W-j-1] + \
                ans[j]*fibonacci[j] * fibonacci[W-j-1] +\
                ans[j+1]*fibonacci[j]*fibonacci[W-j-2]

        for j in range(W):
            ans[j] = buf[j]%1000000007

    print(ans[K-1])


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

const ll p = 1e9+7;
const int MAXN = 1e5+5;

string s; int n, k;

int main() {
	cin >> s >> k;
	n = s.length();
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'a')
			continue;
		int need = 'a'+26-s[i];
		if (k >= need) {
			k -= need; s[i] = 'a';
		}
	}

	if (k != 0) {
		s[n-1] += (k%26);
		while (s[n-1] > 'z')
			s[n-1] -= 26;
	}

	cout << s << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  int x;cin >> x;
  int a;cin >> a;
  int b;cin >> b;
  cout << (x-a)%b << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool flag = true;
  if (s[a] != '-') flag = false;
  rep(i, s.size()) {
    if (i == a) continue;
    if (!('0' <= s[i] && s[i] <= '9')) flag = false;
  }
  if (flag) puts("Yes");
  else puts("No");
  return 0;
}

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

int n;
string s;
int cnt[10][10] = {0};
int dis[10][10] = {0};
int answer[9] = {0};

void solve();

int main() {
  cin >> n >> s;
  for(int i = 1; i < n; ++i) {
    int a, b;
    a = s[i] - '1';
    b = s[i - 1] - '1';
    if(a > b) swap(a, b);
    ++cnt[a][b];
  }
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j) {
      int a, b;
      a = abs(i % 3 - j % 3);
      b = abs(i / 3 - j / 3);
      dis[i][j] = a + b;
    }
  solve();
  for(int i = 0; i < 9; ++i) {
    cout << answer[i] + 1;
    if(i % 3 == 2) cout << endl;
  }
  return 0;
}

void solve() {
  int ls[9] = {0};
  long long best = 1000000000000l;
  for(int i = 0; i < 9; ++i) ls[i] = i;
  do {
    int now = 0;
    for(int i = 0; i < 9; ++i)
      for(int j = i + 1; j < 9; ++j) {
        int mi = ls[i], ma = ls[j];
        if(mi > ma) swap(mi, ma);
        now += cnt[mi][ma] * dis[i][j];
      }
    if(best > now) {
      best = now;
      for(int i = 0; i < 9; ++i) answer[i] = ls[i];
    }
  } while(next_permutation(ls, ls + 9));
}


Measured memory_bytes: 3312
import sys
import math
import copy
import queue
def LI(): return [int(x) for x in input().split()]
n,p = LI()
s = input()
cnt = 0
if p == 2 or p == 5:
    for i in range(n-1,-1,-1):
       if int(s[i]) % p == 0:
           cnt += (i+1)
else:
    num = 0
    p10 = 1
    p_cnt = [1] + [0 for _ in range(p-1)]
    for i in range(n-1,-1,-1):
        num = (num + p10 * int(s[i])) % p
        p_cnt[num] += 1
        p10 = (p10 * 10) % p
    for i in range(p):
        cnt += p_cnt[i] * (p_cnt[i]-1) // 2
print (cnt)



Measured memory_bytes: 44632
#%%
n = int(input())
a, b = [0] * (n-1), [0] * (n-1)
reach = [[] for _ in range(n)]
for i in range(n-1):
    a[i], b[i] = map(int, input().split())
    reach[a[i]-1].append(b[i]-1)
    reach[b[i]-1].append(a[i]-1)
c = list(map(int, input().split()))
c.sort(reverse=True)
ans_list = [0] * n
check = [0] * n

stack = [0]
j = 0

while len(stack) > 0: 
    tmp = stack.pop(-1)
    check[tmp] = 1
    ans_list[tmp] = str(c[j])
    j += 1
    for i in range(len(reach[tmp])):
        if check[reach[tmp][i]] == 0:
            stack.append(reach[tmp][i])
        else:
            pass
    
print(sum(c) - max(c))
print(' '.join(ans_list))


Measured memory_bytes: 6900
import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MOD = 10 ** 9 + 7

class Matrix(list):

    def mul(self,B,mod = 0):
        C = Matrix([[0] * len(B[0]) for _ in range(len(self))])
        if mod == 0:
            for i in range(len(self)):
                for k in range(len(B)):
                    for j in range(len(B[0])):
                        C[i][j] += self[i][k] * B[k][j]
            
            return C
        else:
            for i in range(len(self)):
                for k in range(len(B)):
                    for j in range(len(B[0])):
                        C[i][j] = (C[i][j] + self[i][k] * B[k][j]) % mod
            
            return C

    
    def pow(self,n,mod = 0):
        if len(self) != len(self[0]):
            raise ValueError('the size of matrix is different')

        if mod == 0:
            B = Matrix([[0] * len(self) for _ in range(len(self))])
            A = self
            for i in range(len(self)):
                B[i][i] = 1
            
            while n > 0:
                if (n&1):
                    B = B.mul(A)
                A = A.mul(A)
                n //= 2
            
            return B

        else:
            B = Matrix([[0] * len(self) for _ in range(len(self))])
            A = self
            for i in range(len(self)):
                B[i][i] = 1
            
            while n > 0:
                if (n&1):
                    B = B.mul(A,mod)
                A = A.mul(A,mod)
                n //= 2
            
            return B

def main():
    N,K = map(int,input().split())
    A = Matrix([list(map(int,input().split())) for _ in range(N)])
    B = A.pow(K,MOD)
    ans = sum(sum(B[i])%MOD for i in range(N))%MOD
    print(ans)
if __name__ == '__main__':
    main()
    


Measured memory_bytes: 42228
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/
Solved on 2019/3/
@author: shinjisu
"""


# ABC 076 C Explanation
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def register(db, word):
    global K
    #d = Debug()
    #d.dmp((db, word),'db, word')
    if word >= db[-1]:
        return -1
    else:
        for i in range(K):
            if word == db[i]:
                return 0
            elif word < db[i]:
                db[i+1:] = db[i:-1]
                db[i] = word
                break
    #d.dmp(db)
    return 0
    
    
def prob():
    global K
    d = Debug()
    d.off()
    S = input()
    d.dmp(S)
    K = getInt()
    d.dmp(K)
    db = ['~' for i in range(K)]  # 'z'より大きい
    for i in range(len(S)):
        for j in range(i, len(S)):
            if register(db, S[i:j+1]):
                break
    return db[-1]


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;
    vector<LL> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<LL> odd,even;

    for(int i = 0; i < n; i += 2){
        odd.push_back(a[i]);
    }
    for(int j = 1; j < n; j += 2){
        even.push_back(a[j]);
    }

    sort(odd.begin(),odd.end());
    sort(even.begin(),even.end());

    vector<pair<LL,LL>> on,en;
    on.push_back(make_pair(0,0));
    en.push_back(make_pair(0,0));

    LL fis = odd[0];
    LL count = 1;
    for(int i = 1; i < odd.size(); i++){
        if(fis == odd[i]){
            count++;
        }else{
            on.push_back(make_pair(count,fis));
            fis = odd[i];
            count = 1;
        }
    }
    on.push_back(make_pair(count,fis));
    
    fis = even[0];
    count = 1;
    for(int i = 1; i < even.size(); i++){
        if(fis == even[i]){
            count++;
        }else{
            en.push_back(make_pair(count,fis));
            fis = even[i];
            count = 1;
        }
    }
    en.push_back(make_pair(count,fis));

    sort(on.begin(),on.end());
    sort(en.begin(),en.end());

    LL ans = INF;

    if(on.back().second == en.back().second){
        LL x = n - on.back().first - en[en.size()-2].first;
        LL y = n - en.back().first - on[on.size()-2].first;
        ans = min(x,y);
    }else{
        ans = n - on.back().first - en.back().first;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4212
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}


#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8

int main() {
  char in;
  cin >> in;
  if (in == 'a' || in == 'e' || in == 'i' || in == 'u' || in == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

ll bin_pow_mod(ll x, ll y) { //x^y mod
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % MOD;
        x = (x * x) % MOD;
        y /= 2;
    }
    return prod % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int) s.length();
    map<ll, ll> cnt_a, cnt_b, cnt_c, cnt_q;

    rep(i, l) {
        cnt_a[i] = cnt_a[i - 1]+(s[i] == 'A' ? 1 : 0);
        cnt_b[i] = cnt_b[i - 1]+(s[i] == 'B' ? 1 : 0);
        cnt_c[i] = cnt_c[i - 1]+(s[i] == 'C' ? 1 : 0);
        cnt_q[i] = cnt_q[i - 1]+(s[i] == '?' ? 1 : 0);
    }
    ll ans = 0;
    ll q_pow = bin_pow_mod(3, cnt_q[l - 1]);
    ll inv3 = bin_pow_mod(3, MOD - 2);

    rep(b_p, l) {
        if (s[b_p] == 'A' || s[b_p] == 'C') continue;
        ll Q = 1;
        if (s[b_p] == '?') Q = inv3;
        //ABC
        ans += cnt_a[b_p - 1] * (cnt_c[l - 1] - cnt_c[b_p]) % MOD * q_pow % MOD * Q % MOD;
        ans %= MOD;

        //?BC
        ans += cnt_q[b_p - 1] * (cnt_c[l - 1] - cnt_c[b_p]) % MOD * inv3 % MOD * q_pow % MOD * Q % MOD;
        ans %= MOD;
        //AB?
        ans += cnt_a[b_p - 1] * (cnt_q[l - 1] - cnt_q[b_p]) % MOD
                * inv3 % MOD * q_pow % MOD * Q % MOD;
        ans %= MOD;
        //?B?
        ans += cnt_q[b_p - 1] * (cnt_q[l - 1] - cnt_q[b_p]) % MOD
                * inv3 % MOD * inv3 % MOD * q_pow % MOD * Q % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 26064
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 nextLine() string {
	sc.Scan()
	return sc.Text()
}

// var end int
// var slice []string

func main() {
	sc.Split(bufio.ScanWords)

	// slice = strings.Split(nextLine(), "")
	// end = len(slice)

	s := nextLine()

	// sum := 0
	// for i := 1; i < len(s); i++ {
	// 	s1 := s[0:i]
	// 	fmt.Printf("s1=%s ", s1)
	// 	a, _ := strconv.Atoi(s1)
	// 	sum += a
	// 	for j := i + 1; j < len(s); j++ {
	// 		s2 := s[i:j]
	// 		fmt.Printf("s2=%s ", s2)
	// 		b, _ := strconv.Atoi(s2)
	// 		sum += b
	// 	}
	// 	fmt.Println()
	// }

	// fmt.Println(sum)

	// fmt.Println(s)
	// fmt.Println(s[0])
	// fmt.Println(s[0:1])
	// fmt.Println(s[0:2])
	// fmt.Println(s[1:len(s)])
	ans := dfs(0, s)
	fmt.Println(ans)
}

func dfs(sum int, s string) int {
	result := sum
	for i := 1; i < len(s); i++ {
		a, _ := strconv.Atoi(s[0:i])
		result += dfs(sum+a, s[i:len(s)])
	}
	a, _ := strconv.Atoi(s)
	return result + a
}

// func dfs(sum int, s string) int {

// 	if len(s) == 0 {
// 		return sum
// 	}

// if i == len(s)+1 {
// 	return sum
// }

// i番目の後ろに+を挿入する場合
// var sum1 int
// s1, _ := strconv.Atoi(s[0:1])

// fmt.Printf("sum+s1=%d sum=%d s1=%d, s[i:len(s)]=%s\n", sum+s1, sum, s1, s[1:len(s)])
// sum1 += dfs(sum+s1, s[1:len(s)])

// i番目の後ろに+を挿入しない場合
// var sum2 int
// // s2, _ := strconv.Atoi(s[0:len(s)])
// fmt.Printf("sum+s2=%d  sum=%d s2=%d, s[0:len(s)]=%s\n", sum+0, sum, 0, s[0:len(s)])
// sum2 += dfs(sum, s[0:len(s)])

// return sum2
// }


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"


int main(){
    int k;cin >> k;
    string s;cin>> s;
    if(s.size()<=k){
        COUT(s);
    }
    else{
        cout << s.substr(0,k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 2e5+5;
typedef pair<int,int> pii;


void TEST_CASES(int cas)
{
    string s,t;
    cin>>s>>t;
    int cnt =0; 
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }
    cout<<cnt<<endl;

}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void cout_join(I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)cout<<d;cout<<*i;}cout<<endl;}

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

  LLI n,k; cin >> n >> k;
  vector<LLI> a(n);
  REP(i,n) cin >> a[i];

  vector<LLI> s(n+1,0);
  REP(i,n) s[i+1] = s[i] + a[i];

  vector<LLI> b;
  REP(i,n){
    FORE(j,i+1,n){
      b.push_back(s[j]-s[i]);
    }
  }

  int cur = 63;

  REP(_,64){
    LLI ans = (1LL<<63); --ans;
  
    map<int,vector<LLI>> count;
  
    REP(i,b.size()){
      REP(j,64){
	if(b[i] & (1LL<<j)) count[j].push_back(b[i]);
      }
    }

    //REP(i,30) cout << count[i].size() << " "; cout << endl;

    for(int i=cur; i>=0; --i){
      if(count[i].size() == k){
	//cout_join(ALL(count[i]));
	for(auto v : count[i]){
	  ans = ans & v;
	}
	cout << ans << endl;
	return 0;
      }else if(count[i].size() > k){
	b = count[i];
	cur = i-1;
	break;
      }
      if(i == 0){
	REP(j,k){
	  ans = ans & b[j];
	}
	cout << ans << endl;
	return 0;
      }
    }
  }
  

  
  return 0;
}


Measured memory_bytes: 89964
/// You just can't beat the person who never gives up
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 3e3+5 ,mod = 998244353 ;

int n ,s ,a[N] ;
int mem[N][N] ;
int build(int i,int rem){
    if(i==n) return rem==0 ;
    int&ret = mem[i][rem] ;
    if(~ret) return ret ;
    ret = build(i+1,rem)*2%mod ;
    if(a[i]<=rem) ret = (ret + build(i+1,rem-a[i]))%mod ;
    return ret;
}
int main(){
    scanf("%d%d",&n,&s);
    for(int i=0;i<n;++i) scanf("%d",a+i);
    memset(mem,-1,sizeof mem);
    cout << build(0,s);
    return 0;
}


Measured memory_bytes: 39232
var a,b:array[1..100] of longint;
    i,n,sum:longint;
begin
	readln(n);
	for i:=1 to n-1 do read(b[i]);
	a[1]:=b[1]; a[2]:=b[1]; sum:=0; a[n]:=b[n-1];
	for i:=2 to n - 1 do 
	  begin
	    if b[i] <= a[i] then 
	      begin
	        a[i]:=b[i];
	        a[i+1]:=b[i];
	      end
	    else a[i+1]:=b[i];
	  end;
	for i:=1 to n do inc(sum,a[i]);
	write(sum);
end.

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int N;
    int ans[101] = {0};
    scanf("%d", &N);
    for(int i = 0; i <= 25; i++){
        for(int j = 0; j <= 12; j++){
            if(4 * i + 7 * j > 100) continue;
            ans[4 * i + 7 * j] += 1;
        }
    }
    printf("%s\n", (ans[N] > 0) ? "Yes" : "No");
    return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int n;cin >> n;
  int sum=0;
  int M=0;
  rep(i,n){
    int t;cin >> t;
    sum+=t;
    M=max(M,t);
  }
  sum-M > M ? cout << "Yes" : cout << "No" ;
  cout << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define inf 1111111116
#define next nxt

int n,x[N],y[N],p[N],next[N],f[N];
priority_queue<pair<int,int> > q;

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n-1;i++){
		x[2*i-1]=y[2*i]=read();
		y[2*i-1]=x[2*i]=read();
		next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1;
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
	}
	fill(f+1,f+n+1,-inf);
	for (int k=read();k;k--){
		int x=read(),y=read();
		f[x]=y;q.push(make_pair(y,x));
	}
	while (!q.empty()){
		int t=p[q.top().second];q.pop();
		for (;t;t=next[t])
			if (f[y[t]]==-inf){
				f[y[t]]=f[x[t]]-1;
				q.push(make_pair(f[y[t]],y[t]));
			}
	}
	for (int i=1;i<=2*n-2;i++)
		if (abs(f[x[i]]-f[y[i]])!=1){
			printf("No\n");return 0;
		}
	printf("Yes\n");
	for (int i=1;i<=n;i++)
		printf("%d\n",f[i]);
	return 0;
}

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

using namespace std;


int main() {
    int N,X,Y; cin >> N >> X >> Y;

    vector<int> dist(N+1,0);

    X--; Y--;
    for(int i=0;i<N;i++) {
        for(int j=i+1;j<N;j++) {
            int d1 = abs(X-i) + 1 + abs(Y-j);
            int d2 = abs(j-i);
            int d = min(d1, d2);
            dist[d]++;
        }
    }

    for(int i=1;i<N;i++) {
        cout << dist[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int MAXN=1005,MAXL=1000005;
const int dir[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
typedef pair<int,int>Point;
typedef pair<Point,Point>Matrix;
int W,H;
int disx[MAXL],disy[MAXL];
int sortx[MAXN*2],sorty[MAXN*2],maxx,maxy;
Matrix mat[MAXN];
bool hided[MAXN][MAXN];
void mark(const Point &s,int W,int H)
{
	queue<Point> Q;
	hided[s.first][s.second]=1;
	Q.push(s);
	while(!Q.empty())
	{
		Point t=Q.front(),tt;
		Q.pop();
		for(int i=0;i<4;i++)
		{
			tt=Point(t.first+dir[i][0],t.second+dir[i][1]);
			if(tt.first<0||tt.first>=W||tt.second<0||tt.second>=H||hided[tt.first][tt.second])
				continue;
			hided[tt.first][tt.second]=1;
			Q.push(tt);
		}
	}
}
int main()
{
	int n;
	while(1)
	{
		scanf("%d%d",&W,&H);
		if(!W&&!H)
			break;
		sortx[1]=W;
		sorty[1]=H;
		scanf("%d",&n);
		for(int i=1,x1,y1,x2,y2;i<=n;i++)
		{
			scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
			sortx[i*2]=x1;sortx[i*2+1]=x2;
			sorty[i*2]=y1;sorty[i*2+1]=y2;
			mat[i]=Matrix(Point(x1,y1),Point(x2,y2));
		}
		sort(sortx+1,sortx+n*2+2);
		sort(sorty+1,sorty+n*2+2);
		maxx=unique(sortx,sortx+n*2+2)-sortx;
		maxy=unique(sorty,sorty+n*2+2)-sorty;
		fill(disx,disx+MAXL,-1);
		fill(disy,disy+MAXL,-1);
		for(int i=0;i<maxx;i++)
			disx[sortx[i]]=i;
		for(int i=0;i<maxy;i++)
			disy[sorty[i]]=i;
		memset(hided,0,sizeof hided);
		for(int i=1;i<=n;i++)
			for(int x=disx[mat[i].first.first];x<disx[mat[i].second.first];x++)
				for(int y=disy[mat[i].first.second];y<disy[mat[i].second.second];y++)
					hided[x][y]=1;
		int ans=0;
		/*puts("");
		for(int y=0;y<disy[H];y++)
		{
			for(int x=0;x<disx[W];x++)
				printf("%d",(int)hided[x][y]);
			puts("");
		}*/
		for(int x=0;x<disx[W];x++)
			for(int y=0;y<disy[H];y++)
				if(!hided[x][y])
				{
					ans++;
					mark(Point(x,y),disx[W],disy[H]);
				}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 11408
#include <iostream>

using namespace std;
int n,a[100010],i,tree[4*100010],x1,x2,maxim,x,y;
inline int cmmdc(int a,int b)
{
    if(a==0)return b;
    if(b==0)return a;
    int r=a%b;
    while(r)
    {
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
inline void build(int st,int dr,int nod)
{
    if(st==dr)tree[nod]=a[st];
    else {
        int mij=(st+dr)/2;
        build(st,mij,nod*2);
        build(mij+1,dr,nod*2+1);
        tree[nod]=cmmdc(tree[nod*2],tree[nod*2+1]);
    }
}
inline int querry(int st,int dr,int nod)
{
    if(x<=st&&dr<=y)return tree[nod];
    else {
        int mij=(st+dr)/2,x1=0,x2=0;
        if(x<=mij)
        x1=querry(st,mij,nod*2);
        if(mij<y)
        x2=querry(mij+1,dr,nod*2+1);
        return cmmdc(x1,x2);
    }
}
int main()
{
  ios_base::sync_with_stdio(0);
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>a[i];
    build(1,n,1);
    for(i=1;i<=n;i++)
    {
        if(i!=1){x=1;y=i-1;x1=querry(1,n,1);}
        else x1=0;
        if(i!=n){x=i+1;y=n;x2=querry(1,n,1);}
        else x2=0;
        if(cmmdc(x1,x2)>maxim)maxim=cmmdc(x1,x2);
    }
    cout<<maxim;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
int x[55],y[55];


int solve(int l,int r){
    vint v;
    rep(i,N){
        if(x[i]<l||r<x[i])continue;
        v.pb(y[i]);
    }

    sort(all(v));

    int ret=LLONG_MAX;
    rep(i,v.size()){
        if(i+K>v.size())break;
        chmin(ret,(r-l)*(v[i+K-1]-v[i]));
    }
    if(ret==0)return (r-l);
    return ret;
}

signed main(){
    cin>>N>>K;
    rep(i,N)cin>>x[i]>>y[i];

    vint xs;
    rep(i,N){
        xs.pb(x[i]);
        xs.pb(x[i]+1);
    }

    sort(all(xs));xs.erase(unique(all(xs)),xs.end());

    int ans=LLONG_MAX;

    for(int i=0;i<xs.size();i++){
        for(int j=i+1;j<xs.size();j++){
            chmin(ans,solve(xs[i],xs[j]));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int divisors = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) divisors++;
    }
    if (divisors == 8) ans++;
  }
  cout << ans << endl;
}

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

int main() {
    ll n,k;
    std::cin >> n>>k;
    vector<ll> a(n);
    vector<string> as(n);
    vector<ll> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i]>> b[i];
        as[i] = bitset<30>(a[i]).to_string();
    }
    string ks = bitset<30>(k).to_string();
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if(a[i]<=k && (a[i] | k) <=k){
            res+=b[i];
        }
    }

    for (int i = 0; i < 30; i++) {
        ll ca = 0;
        ll now = 0;
        if(ks[i]=='1'){
            
            for (int j = 0; j < 30; j++) {
                if(j<i){
                    if(ks[j]=='1')now += (ll)pow(2,29-j);
                }else if(j==i){
                    
                }else{
                    now += (ll)pow(2,29-j);
                }
            }
            
            for (int j = 0; j < n; j++) {
                if(a[j]<=now && (a[j] | now) <= now){
                    ca += b[j];
                }
            }
        }
        res = max(res,ca);
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

//const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int main() {
	int n, k; cin>>n>>k; int z = 1;

	while (z <= k && n > 0) {
		z += z; n--;
	}
	while (n > 0) { z += k; n--; }
	cout<<z<<endl;
}

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

int main(){

  int N;
  cin >> N;

  int a[N];
  for(int i=0 ; i<N; i++){
    cin >> a[i];
  }

  sort(a, a+N);

  cout << a[N-1] - a[0] << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    string s, t = "ACGT";
    cin >> s;

    int res = 0, cnt = 0;
    rep(i, (int)s.size())
    {
        if (t.find(s[i]) != -1)
        {
            cnt++;
            res = max(res, cnt);
        }
        else
        {
            cnt = 0;
        }
    }
    cout << res << endl;
    return (0);
}


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

int main(){
    int n;
    cin >> n;
    int m = n%10;
    if(m == 3){
        cout << "bon" << endl;
    }
    else if(m == 0 || m == 1 || m == 6 || m == 8){
        cout << "pon" << endl;
    }
    else cout << "hon" << endl;
    return 0;
}


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


int main() {
    string S;
    cin >> S;
    long long n = S.size();
    long long res = 0;
    long long num = 0;
    for (long long i = 0; i < n; ++i) {
        if (S[i] == 'W') {
            res += num;
        }
        else {
            ++num;
        }
    }
    cout << res << endl;
}






























Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r+100*(10-n) << endl;
}


Measured memory_bytes: 3636
N, K = map(int, input().split())
X = list(map(int, input().split()))

answer = []
for i in range(N-K+1):
    a, b = X[i], X[i+K-1]
    answer.append(min(abs(a-b) + abs(b), abs(b-a) + abs(a)))
print(min(answer))


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

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

    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        mp[a]++;
    }

    vector<pair<LL, int>> v;
    for(auto i: mp)
        v.Pb({i.X, i.Y});

    int f = -1, L = v.size();
    LL ans = 0;

    for(int i = 0; i < L; i++){
        if(v[i].Y > 3)
            ans = max(ans, v[i].X * v[i].X), f = i;
        else if(f >= 0 && v[i].Y > 1)
            ans = max(ans, v[i].X * v[f].X), f = i;
        else if(v[i].Y > 1)
            f = i;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9872
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::VecDeque;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn calc_shortest_path(maze: &Vec<Vec<char>>, costs: &mut Vec<Vec<usize>>, si: usize, sj: usize){
    let mut queue: VecDeque<(usize, usize, usize)> = VecDeque::new();
    queue.push_back((si, sj, 0));
    let dummy = std::usize::MAX;
    while let Some((i, j, ncost)) = queue.pop_front(){
        //println!("current {}, {}", i, j);
        if maze[i-1][j] == '.' && costs[i-1][j] == dummy{
            costs[i-1][j] = ncost+1;
            queue.push_back((i-1, j, ncost+1));
        }

        if maze[i+1][j] == '.' && costs[i+1][j] == dummy{
            costs[i+1][j] = ncost+1;
            queue.push_back((i+1, j, ncost+1));
        }

        if maze[i][j-1] == '.' && costs[i][j-1] == dummy{
            costs[i][j-1] = ncost+1;
            queue.push_back((i, j-1, ncost+1));
        }

        if maze[i][j+1] == '.' && costs[i][j+1] == dummy{
            costs[i][j+1] = ncost+1;
            queue.push_back((i, j+1, ncost+1));
        }
    }
}


fn calc_longest_path(maze: &Vec<Vec<char>>, si: usize, sj: usize) -> usize{
    let mut costs: Vec<Vec<usize>> = vec![vec![std::usize::MAX;maze[0].len()];maze.len()];
    costs[si][sj] = 0;
    calc_shortest_path(maze, &mut costs, si, sj);
    //println!("------start at {} {}-------", si, sj);
    //print_costs(&costs);
    let mut ans: usize = 0;
    for i in 1..maze.len()-1{
        for j in 1..maze[0].len()-1{
            if maze[i][j] == '.'{
                ans = cmp::max(costs[i][j], ans);
            }
        }
    }
    //println!("When start at({}, {}), longest path = {}", si, sj, ans);
    return ans;
}

fn print_maze(maze: &Vec<Vec<char>>){
    for row in maze{
        println!("{:?}", row);
    }
}

fn print_costs(costs: &Vec<Vec<usize>>){
    for row in costs{
        println!("{:>20?}", row);
    }
}

fn main(){
    let line = read_as_vec::<usize>();
    let (h, w) = (line[0], line[1]);
    let mut maze = vec![];
    maze.push(vec!['#';w+2]);
    for _ in 0..h{
        let mut line = read_as_string().chars().collect::<Vec<char>>();
        line.insert(0, '#');
        line.push('#');
        maze.push(line);
    }
    maze.push(vec!['#';w+2]);

    let (h, w) = (h+2, w+2);
    //print_maze(&maze);
    let mut ans = 0;

    for i in 1..h-1{
        for j in 1..w-1{
            //println!("\n\n\n");
            if maze[i][j] == '.'{
                ans = cmp::max(calc_longest_path(&maze, i, j), ans);
            }

        }
    }


    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        BigInteger a=new BigInteger(str);
        str=sc.next();
        BigInteger b=new BigInteger(str);
        System.out.println(a.multiply(b));
    }
}



Measured memory_bytes: 253840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int x = scan.nextInt();
		int max = a;
		int sum = 0;
		int num1 = b;
		int num2 = c;

		if (a < b) {
			num1 = a;
			num2 = c;
			max = b;
		} else if (a < c) {
			num1 = a;
			num2 = b;
			max = c;
		}

		for (int i=0; i<x; i++) {
			max = max*2;
		}

		sum = num1 + num2 + max;

		System.out.println(sum);

		scan.close();

	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int gcd(int x,int y){
    while(1){
        if(x<y)swap(x,y);
        if(!y)break;
        x%=y;
    }
    return x;
}

int main(void){
    int w,h,c;
    cin>>w>>h>>c;
    int sq=gcd(w,h);
    sq=sq*sq;
    cout<<w*h/sq*c<<endl;
}





Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    ll count[5]={0};
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='M')count[0]++;
        else if(s[0]=='A')count[1]++;
        else if(s[0]=='R')count[2]++;
        else if(s[0]=='C')count[3]++;
        else if(s[0]=='H')count[4]++;
    }
    ll ans=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans+=count[i]*count[j]*count[k];
            }
        }
    }
    fin(ans);
}


Measured memory_bytes: 256