akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int h = Integer.parseInt(sc.next());
    System.out.println((a+b)*h/2);
  }
}

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

void draw(int, int);

int main() {
    int h, w;
    for (;;) {
        cin >> h >> w;
        if (h == 0 && w == 0)
            return 0;
        draw(h, w);
        cout << endl;
    }
}

void draw(int h, int w) {
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            if (y == 0 || y == h - 1
                || x == 0 || x == w - 1)
                cout << '#';
            else
                cout << '.';
        }
        cout << endl;
    }
}



Measured memory_bytes: 3000
import sys
from functools import reduce


def input():
    return sys.stdin.readline()[:-1]

X, Y = map(int, input().split())

bool1 = Y - 2*X >= 0
bool2 = 4*X - Y >= 0

if bool1 and bool2 and Y % 2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 66920
def nCr(n, r):
    return (fact(n) / (fact(r)
                       * fact(n - r)))


# Returns factorial of n
def fact(n):
    res = 1
    if n == 0:
        res == 1
    elif n == 1:
        res == 1
    else:
        for i in range(2, n + 1):
            res = res * i

    return res

inList = list(map(int, input().split()))
N = inList[0]
M = inList[1]
a = nCr(N, 2)
b = nCr(M, 2)
if N == M == 1:
    print(0)
else:
    print(int(a+b))

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

typedef pair<int, int> pii;
const int INF = 1e8;

int H, W; 
vector<vector<char>> S(1010, vector<char>(1010));

int bfs(){
  vector<int> dx = {0, 1, 0, -1};
  vector<int> dy = {1, 0, -1, 0};
  vector<vector<int>> dist(1010, vector<int>(1010, INF));
  
  dist[0][0] = 0;
  queue<pii> Q; Q.push(make_pair(0,0));

  while(!Q.empty()){
    pii cur = Q.front(); Q.pop();

    for(int i=0; i<4; i++){
      int nx = cur.first + dx[i], ny = cur.second+dy[i];

      if(0 <= nx && nx < H && 0 <= ny && ny < W){
        if(S[nx][ny] != '#' && dist[nx][ny] == INF){
          Q.push(make_pair(nx, ny));
          dist[nx][ny] = dist[cur.first][cur.second]+1;
        }
      }
    }
  }

  return dist[H-1][W-1];
}

int main(){ 
  cin >> H >> W;

  int black = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> S[i][j];
      if(S[i][j] == '#') black++;
    }
  }


  int d = bfs();
  if(d ==INF){
    cout << -1 << endl;
  } else {
    cout << H*W-d-black-1 << endl;
  }
}

Measured memory_bytes: 5248
import math
X=list()
Y=list()
s=0
N=int(input())
for i in range(N):
  x,y=map(int,input().split())
  X.append(x)
  Y.append(y)
for i in range(N):
  for j in range(N):
    s+=math.sqrt(((X[i]-X[j])**2)+((Y[i]-Y[j])**2))
print(s*(1/N))

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

int main(void){
    int i,j,k;
    int m;
    
    int N;
    cin>>N;
    
    long long x[N],y[N],h[N];
    for(i=0;i<N;i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]>0)m=i;
    }
    
    long long ans,H=1;
    
    
    
    if(N==1){
        int nx,ny;
        ans=h[0]+abs(x[0]-0)+abs(y[0]-0);
        for(i=0;i<=100;i++){
            for(j=0;j<=100;j++){
                H=h[0]+abs(x[0]-i)+abs(y[0]-j);
                if(H>=ans){
                    ans=H;
                    nx=i;
                    ny=j;
                }
            }
        }
        cout<<nx<<" "<<ny<<" "<<ans<<endl;
        return 0;
    }

    for(i=0;i<=100;i++){
        for(j=0;j<=100;j++){
            ans=h[m]+abs(x[m]-i)+abs(y[m]-j);
            for(k=0;k<N;k++){
                H=h[k]+abs(x[k]-i)+abs(y[k]-j);
                if(h[k]>0&&H!=ans)break;
                if(h[k]==0&&ans>H)break;
                if(k==N-1){
                    cout<<i<<" "<<j<<" "<<ans<<endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
cnt=0
for i in range(n-1):
  if a[i]+a[i+1]<0:
    cnt+=1
if cnt==0:
  print(sum(a))
else:
  for i in range(cnt):
    if i%2==0:
      a[i]=-a[i]
      a[i+1]=-a[i+1]
  print(sum(a))

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
#define ll long long

int gcd(int x, int y) {
    while(1) {
        if(x == 0) {
            return y;
        }
        int tmp = x;
        x = y%x;
        y = tmp;
    }
}

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= n; k++) {
                //cout << i << " " << j << " " << k << " ";
                //cout << gcd(i, gcd(j, k)) << endl;
                sum += gcd(i, gcd(j, k)); 
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 100
#define EPS 1e-9
#define PI 3.14159265358979323846264338327950


bool arr[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, m, k, e;
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		cin >> m;
		for (int j = 0; j < m; ++j) {
			cin >> e;
			arr[e - 1] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += arr[i] == false;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int N,K;
    int x[100001]={};
    cin>>N>>K;
    for(int i=0;i<N;i++) cin>>x[i];
    
    ll s[100000]={};
    for(int i=0;i<N-1;i++) {
        s[i]=abs(x[i]-x[i+1]);
    }
    ll ans=1e9;
    ll sum=0;
    for(int i=0;i<K-1;i++) sum+=s[i];
    if(N!=K){
        for(int i=0;i<N-K+1;i++){
            ans=min(ans,sum+abs(x[i]));
            ans=min(ans,sum+abs(x[K-1+i]));
            sum-=s[i];
            sum+=s[K+i-1];
        }
    }
    if(N==1) cout<<abs(x[0])<<endl;
    else if(N==K){
        if(abs(x[0])>abs(x[K-1])){
            int a=abs(x[K-1]);
            cout<<sum+a<<endl;
        }
        else {
            int a=abs(x[0]);
            cout<<sum+a<<endl;
        }
    }
    else cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1408
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

S = input()
n = len(S)

ans = 0

#消してない要素
left = []

#現在の調査位置
i = 0


for i in range(n):
    if S[i]=='0':
        if left:
            if left[-1] == '1':
                ans += 1
                left.pop()
            else:
                left.append('0')
        else:
            left.append('0')
    else:
        if left:
            if left[-1] == '0':
                ans += 1
                left.pop()
            else:
                left.append('1')
        else:
            left.append('1')
    
print(2*ans)

Measured memory_bytes: 45168
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
costa = 0
costb = 0
for i in range(x, n):
    if i in a:
        costa += 1
for j in range(x, 0, -1):
    if j in a:
        costb += 1
print(min(costa, costb))

Measured memory_bytes: 9124
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define pb push_back
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n, k;
int a[2000], sum;
bool solve(int t) {
	vector<int>v;
	int al = 0;
	for (int i = 0; i < n; i++) {
		v.push_back(a[i] % t);
		al += t - v[i];
	}
	sort(all(v));
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (sum <= k && al <= k) return 1;
		al -= t - v[i];
		sum += v[i];
		if (sum <= k && al <= k) return 1;
	}
	return 0;
}
signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int ans = 1;
	for (int i = 1; i * i <= sum; i++) {
		if (sum % i) continue;
		if (solve(i)) ans = max(ans, i);
		if (solve(sum / i)) ans = max(ans, sum / i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a,b,c;
  	cin>>a>>b>>c;
  	cout<<a+b+c-max(max(a,b),c);
}

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int); 
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fast_power(ll, ll, ll);
ll slow_power(ll, ll, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

const int N = 12;
int DP[1 << N];

int main()
{
    int n = si(), k = si();
    for (int i = 1; i < (1 << n); ++i)
        DP[i] = INF;

    for (int i = 0; i < k; ++i)
    {
        int a = si(), b = si();
        int mask = 0;
        for (int j = 0; j < b; ++j)
            mask |= (1 << (si() - 1));
        for (int m = 0; m < (1 << n); ++m)
            DP[m | mask] = min(DP[m | mask], DP[m] + a);
    }

    if (DP[(1 << n) - 1] == INF)
        pi(-1);
    else
        pi(DP[(1 << n) - 1]);

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fast_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slow_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

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


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

int main() {
int64_t   a,s,ans;
int f;
	cin >>  a ;
double b;
 cin >>  b;
	if (a<10000){
	f=a;
	ans = a*b;
	    cout << ans << endl;
	}
	else{
	f=a%100;
	f=f*b;
	a=a/100;
	b=b*100+0.5;
	s=b;
	ans = a*s +f;
	     cout << ans << endl;
	}
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x *= i;
    return x;
}


int main(){
    ll n,c=1;
    cin>>n;
    ll h=n;
    while(h>1){
        c++;
        h /= 2;
    }
    cout<<(ll)(pow(2,c) - 1)<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int count = 0;
        int target = 1;
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() != target) {
                count++;
            } else {
                target++;
            }
        }

        if (count == n) {
            count = -1;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 63048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll dp[105][1LL<<15];
void solve() {
    ll n, m;
    cin >> n >> m;
    if(n == 0) exit(0);
    vector<ll> s(n), d(m);
    REP(i, n) cin >> s[i];
    REP(i, m) cin >> d[i];
    sort(ALL(d));
    // dump(d);

    FOR(i, 1, m+1) REP(j, 1LL<<n) dp[i][j] = INF;
    REP(j, 1LL<<n) dp[0][j] = 0;
    REP(i, m) REP(j, 1LL<<n) {
        ll sum = 0;
        REP(k, n) if(j&1LL<<k) sum += s[k];
        chmin(dp[i+1][j], dp[i][j] + abs(sum-d[i]));
        // dump(i, j, sum, d[i], dp[i+1][j]);
        REP(k, n) if(j&1LL<<k) {
            ll x = j ^ (1LL<<k);
            chmin(dp[i+1][j], dp[i+1][x]);
        }
    }

    // REP(i, m+1) {
    //     dump(s, i, d[i]);
    //     REP(j, 1LL<<n) dump(bitset<3>(j), dp[i][j]);
    // }
    // ll sum = 0;
    // REP(i, n) sum += s[i];
    // dump(sum);

    ll ret = INF;
    REP(i, 1LL<<n) chmin(ret, dp[m][i]);
    cout << ret << endl;
}

int main(void) {
    while(1) solve();

    return 0;
}


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

#define int long long 

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

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int a[maxn],n,m,v,p,f[maxn];

int gao(int x) {
    while(a[x+1]==a[x]) x++;
    int r=lower_bound(a+1,a+n+2,a[x]+m+1)-a;
    r=n-r+1;int g=v-r-(x-1)-1;
    if(g<=0&&r<=p-1) return 1;
    g*=m;f[x]=0;
    for(int i=x+1;i+r<=n;i++) {
        f[i]=a[x]+m-a[i];
        f[i]+=f[i-1];
    }
    int ans=n-x;
    for(int i=n-r;i>x;i--)
        if((n-r-i)*m+f[i]>=g) ans=min(ans,n-i);
    return ans<=p-1;
}

signed main() {
    read(n),read(m),read(v),read(p);
    for(int i=1;i<=n;i++) read(a[i]);a[n+1]=2e9;
    sort(a+1,a+n+1);
    // for(int i=1;i<=n;i++) printf("%d ",a[i]);
    int l=1,r=n,ans=n;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(gao(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
    write(n-ans+1);
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        double x, y;
        cin >> x >> y;
        double dis = sqrt(x*x + y * y);
        if(dis <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3840
import Data.List

main = interact main'
main' = show . f . head . reverse . lines

first (a, b) = a

f :: String -> Integer
f str =
    first $ foldl' g init str
    where
        g (a, c) n = (a + (if c /= n then 1 else 0), n)
        init = (0, ' ')

Measured memory_bytes: 10620
'''
B - RGB Boxes
'''

r_weight, g_weight, b_weight, N = map(int, input().split())

ans = 0
for r in range(N+1):
    for g in range(N-r*r_weight+1):
        rem = N - r*r_weight - g*g_weight
        if rem % b_weight == 0 and rem >= 0:
            ans += 1

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<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; }
typedef long long ll;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAX = 200002;
ll fact[MAX], invfact[MAX];

#define MAX_V 1000000

ll mod_pow(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 mod_inverse(ll a, ll m) {
	return mod_pow(a, m - 2, m);
}

ll nCr(ll n, ll r) {
	return fact[n] * invfact[r] % mod * invfact[n - r] % mod;
}

void init() {
	fact[0] = invfact[0] = 1;
	rep(i, 1, MAX) {
		fact[i] = (fact[i - 1] * i) % mod;
		invfact[i] = mod_inverse(fact[i], mod);
	}
}

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for(ll i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  init();
  ll N, M;
  cin >> N >> M;
  map<ll, ll> m = prime_factor(M);
  ll rsl = 1;
  for(auto it = m.begin(); it != m.end(); ++it) {
    if(it->first == 1) continue;
    (rsl *= nCr(N + it->second - 1, it->second)) %= mod;
  }
  cout << rsl << endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
int main()
{
    char s[10];
    char t[10];
    char u[10];
    ll a,b,tmp;
    scanf("%s",s);
    scanf("%s",t);
    scanf("%lli %lli",&a,&b);
    scanf("%s",u);
    for (ll i=0;i<10;i++){
        if (s[i]!=t[i]) {
            tmp=i;
            break;
        }
    }
    if (u[tmp]==s[tmp]){
        a-=1;
    } else {
        b-=1;
    }
    printf("%lli %lli",a,b);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, V;
  cin >> A >> V;
  ll B, W;
  cin >> B >> W;
  ll T;
  cin >> T;

  if(abs(A - B) <= T * (V - W))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
# AGC032B - Balanced Neighbors
def main():
    N = int(input())
    if N % 2:
        V = [(i, N - i) for i in range(1, N // 2 + 1)]  # pairs of vertices
        V += [(N,)]
    else:
        V = [(i, N - i + 1) for i in range(1, N // 2 + 1)]
    E, l = [], len(V)  # edges
    for i in range(l - 1):
        E += [(v, u) for v in V[i] for u in V[i + 1]]
    if l >= 3:
        E += [(v, u) for v in V[0] for u in V[-1]]
    print(len(E))
    for v, u in E:
        print(v, u)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define EB emplace_back
#define F first
#define S second


using namespace std;

#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt; //cin>>tt;
	ll n,d;cin>>n>>d;
	ll arr[n][d];
	for(int i=0;i<n;i++) 
		for(int j=0;j<d;j++)
			cin>>arr[i][j];

	int count=0;

	for(int i=0;i<n;i++)
	{
	
	for(int j=i+1;j<n;j++)
	{
	float sum=0;
	for(int k=0;k<d;k++)
	{
		ll temp=abs(arr[i][k]-arr[j][k]);
		temp=temp*temp;
		sum+=temp;
		cerr<<sum<<endl;
	}	
	sum=sqrt(sum);

	if(floor(sum)==sum) count++;
	}

	}
	cout<<count<<endl;
	
	
		

	
	
		////------------------------------------------------------------------////
	// #ifndef ONLINE_JUDGE    
 //    t = clock() - t; 
 //    double time_taken = ((double)t)/CLOCKS_PER_SEC; 
 //    printf("Time: %fs\n", time_taken); 
 //    #endif
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {

  
   char *S = malloc(sizeof(char)*110000);
   
   scanf("%s",S);
   
   int n;
   for(n = 0; S[n] != '\0'; ++n);
   
   char *Moji_A = malloc(sizeof(char)*n);
   char *Moji_B = malloc(sizeof(char)*n);
   
   int i;
   for(i = 0;i < n;i++){
      if(i%2 == 0){
         Moji_A[i] = '0';
         Moji_B[i] = '1';
      }
      else {
         Moji_A[i] = '1';
         Moji_B[i] = '0';
      }
   }
   
   int ans_a = 0;
   int ans_b = 0;
   
   for(i = 0;i < n;i++){
      if(Moji_A[i] != S[i]){
         ans_a++;
      }
      if(Moji_B[i] != S[i]){
         ans_b++;
      }
   }
   
   int ans;
   
   if(ans_a > ans_b){
      ans = ans_b;
   }
   else {
      ans = ans_a;
   }
   
   printf("%d\n",ans);
   
   
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <queue>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

priority_queue <int> q;
int n;
ll a[200010], ans;

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1);
	q.push(a[n]);
	for(int i = n - 1; i >= 1; i--){
		ans += q.top(), q.pop();
		q.push(a[i]), q.push(a[i]);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 5324
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int N,H,W;cin >> N >> H  >>W;

    cout << (N-H+1)*(N-W+1)<<endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            var N = c2i(RL());

            var ret = N + Math.Pow(N, 2) + Math.Pow(N, 3);
            Console.WriteLine(ret);
            Console.ReadLine();

        }

        static IEnumerable<int> RL2IE() { return spr(RL()).Select(x => (int)c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 27692
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	string s;
	cin >> s;
	ll n	 = s.size();
	string a = "", b = "";

	for (int i = 0; i < n; i++) {
		if (i % 2) {
			a = a + '0';
			b = b + '1';
		} else {
			a = a + '1';
			b = b + '0';
		}
	}
	ll tmp1 = 0, tmp2 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != s[i])
			tmp1++;
		else
			tmp2++;
	}
	dump(min(tmp1, tmp2));
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int PrintPoint();

int main()
{
    int i;

    cin >> i;
    for(int c=0; c < i; c++)
        PrintPoint();

    return EXIT_SUCCESS;
}

int PrintPoint()
{
    int iPoint = 0;
    int iRunner = 0;
    string sEvent;
    for(int iOutCount = 0; iOutCount < 3;)
    {
        cin >> sEvent;
        if(sEvent == "HOMERUN")
        {
            iPoint += iRunner + 1;
            iRunner = 0;
        }
        if(sEvent == "HIT")
        {
            iRunner++;
            if(iRunner > 3)
            {
                iRunner -= 1;
                iPoint++;
            }
        }
        if(sEvent == "OUT")
            iOutCount++;
    }
    cout << iPoint << endl;
    return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int64_t a, b, c, d, m, n, o, p, q;
  n=0;
  
  cin>>a>>b>>c>>d;
  m=a*c;
  n=a*d;
  o=b*c;
  p=b*d;
  q=m;
  if (q<n)
  {
    q=n;
  }
  if (q<o)
  {
    q=o;
  }
  if (q<p)
  {
    q=p;
  }
  
  
  cout<<q<<endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int inN = stdin.nextInt();

		int[] inA0 = new int[inN];
		inA0[0] = stdin.nextInt();
		for (int i = 1; i < inN; i++) {
			inA0[i] = inA0[i - 1] + stdin.nextInt();
		}

		int[] inA1 = new int[inN];
		for (int i = 0; i < inN; i++) {
			inA1[i] = stdin.nextInt();
		}

		int max = inA0[inN - 1] + inA1[inN - 1];
		for (int i = (inN - 2); i >= 0; i--) {
			inA1[i] += inA1[i + 1];
			max = Math.max(max, (inA0[i] + inA1[i]));
		}

		System.out.println(max);
	}

}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		string s;
		cin >> s;
		cout << s.insert( 4, " " ) << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,d,i;
  while(scanf("%d %d",&a,&b)!=EOF)
    {
      d=1;
      for(i=0;i<8;i++)
	{
	  if(a+b==0){printf("1\n");break;}
	  if(d<=(a+b) && (d*10)>(a+b)){printf("%d\n",i+1);break;}
	  else d=d*10;
	}
    }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	int count[26] = {};
	char alp[27] = "abcdefghijklmnopqrstuvwxyz";

	char ch;

	int i;

	while (scanf("%c", &ch) != EOF) {
		int num = tolower(ch) - 'a';
		count[num]++;
	}

	for (i = 0; i < 26; i++)
		printf("%c : %d\n", alp[i], count[i]);
	
	return 0;
}

Measured memory_bytes: 544
n = int(input())
m = [i for i in range(3, n + 1, 3)]
s = [str(i) for i in range(1, n+1)]
s = [int(i) for i in s if '3' in i]
a = set(m + s)
b = ' '
for i in a:
    b += str(i) + ' '
print(b[:-1])


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

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

	sort(h.begin(), h.end());
	int ans = 1e9;

	for(int i=k-1; i<n; i++) ans = min(ans,h[i]-h[i-k+1]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cl = 0;
		int fcl = 0;
		String s = sc.next();
		for(int i = 0; i < s.length(); i ++){
			switch(s.charAt(i)){
			case 'a':
				if(cl < a + b){
					System.out.println("Yes");
					cl++;
				}else{
					System.out.println("No");
				}
				break;
			case 'b':
				if(cl < a + b && fcl < b){
					System.out.println("Yes");
					cl++;
					fcl ++;
				}else{
					System.out.println("No");
				}
				break;
			default:
				System.out.println("No");
				break;
			}
		}
	}
}




Measured memory_bytes: 50648
# Aiは1桁の非負の整数
# Ai==0がある
# Ai==9がある

# 10通りある

mod = 10**9+7
N = int(input())
# 全てのパターンから，0がないパターン - 9がないパターン + 0も9もないパターン
# pow(base, exp, mod])  # modはoptional
ans = pow(10, N, mod) - pow(9, N, mod) - pow(9, N, mod) + pow(8, N, mod)
print(ans%mod)


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

int main(){
    int n,m;
    cin >> n >> m;
    
    vector< vector<int> > a;
    vector<int> b;

    a.resize(n);
    for (int i=0;i<n;i++){
        a[i].resize(m);
    }
    b.resize(m);

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

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

    int ans;
    for(int j=0;j<n;j++){
        ans =0;
        for(int i=0;i<m;i++){
            ans+=a[j][i]*b[i];
        }
        cout << ans << endl;
    }
    return 0;
}


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

typedef unsigned long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

ll A,B,N;

ll f(ll x){
	ll a = (A*x);
	a /= B;
	
	ll b = x;
	b /= B;
	b *= A;
	return a - b;
}
int main(){
	fast;
	cin>>A>>B>>N;
	
	ll r = min(B - 1,N);
	
	cout<<f(r);
	
	
}




Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n;
cin>>n;
double s=(double) 2*3.141592653589793238*n;
cout<<s<<endl;

return 0;
}


Measured memory_bytes: 3804
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val words = sc.nextLine().split(" ")

    println(Array(words(0)(0).toUpper,  words(1)(0).toUpper, words(2)(0).toUpper).mkString(",").replaceAll(",", ""))
  }
}

Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    string s1, s2, s3; cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[1]<<s3[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define inf -100000000
#define ordered_set tree<pair<ll int,ll int>, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
int main()
{
    fast;
  //  #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
   // #endif
    ll int x;
    cin>>x;
    ll int i,z,left;
    map<ll int,ll int> mp,mp1;
    for(i=-1000;i<=1000;i++)
    {
    	z=i*i*i*i*i;
    	mp[z]=i;
    	mp1[i]=z;
    }
    for(i=-1000;i<=1000;i++)
    {
    	z=mp1[i];
    	left=z-x;
    	if(mp.find(left)!=mp.end())
    	{
    		cout<<i<<" "<<mp[left]<<endl;
    		exit(0);
    	}
    }
}

Measured memory_bytes: 3904
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List <Integer> list = new ArrayList<>(Arrays.asList(sc.nextInt(),sc.nextInt(),sc.nextInt()));
    Collections.sort(list);
    System.out.println((int)(list.get(0) + list.get(1) + list.get(2) * Math.pow(2, sc.nextInt())));
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  bool A=false;
  bool B=false;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='C'&&A==false)A=true;
    if(S.at(i)=='F'&&A==true){
      cout<<"Yes"<<endl;
      break;
    }
    if(i==S.size()-1)B=true;
  }
  if(B==true)cout<<"No"<<endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C;
    cin >> A >> B >> C;

    ll ans = 0LL;
    while (true) {
        if ((A&1) || (B&1) || (C&1)) break;
        if (A == B && B == C) {
            cout << -1 << endl;
            return 0;
        }

        int nA = (B + C) / 2;
        int nB = (A + C) / 2;
        int nC = (A + B) / 2;
        A = nA;
        B = nB;
        C = nC;
        ans++;
    }

    cout << ans << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vs s(N);
    vi t(N);
    REP(i, N) cin >> s[i] >> t[i];
    string X; cin >> X;
    int ans = 0;
    bool isSleep = false;
    REP(i, N)
    {
        if(isSleep) ans += t[i];
        if(s[i] == X) isSleep = true;
    }
    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    ans = 0
    for i in range(len(S)):
        for j in range(1,len(S)-i+1):
            # 数値S[i]を下からj桁目の数として受け取るパターン数は
            # (1) (残りのSの長さ-1)個の場所に'+'をいれるパターン数 S[:i]
            # (2) (残りのSの長さ-1)個の場所に'+'をいれるパターン数 S[i:]
            # の積に他ならない
            ans += int(S[i])*(10**(j-1)) * (2**i) * (2**max(0,(len(S)-i-j-1)))
    print(ans)
main()


Measured memory_bytes: 2940
using System;
using System.Linq;

class Program
{
 static void Main(string[] args)
 {
   int total = int.Parse(Console.ReadLine());
   string[] buff_1 = Console.ReadLine().Split(' ');
   string[] buff_2 = Console.ReadLine().Split(' ');
   int[] line_1 = new int[total];
   int[] line_2 = new int[total];
   int cnt = 0;
   int maxSum = 0;
   int line_1_sum = 0;
   int line_2_sum = 0;
   
   for( cnt = 0; cnt < total; cnt++ )
   {
     line_1[cnt] = int.Parse(buff_1[cnt]);
     line_2[cnt] = int.Parse(buff_2[cnt]);
   }
   
   line_2_sum = line_2.Sum();
   
   for( cnt = 0; cnt < total; cnt++ )
   {
     line_1_sum += line_1[cnt];
     
     if( maxSum < ( line_1_sum + line_2_sum ) )
     {
       maxSum = ( line_1_sum + line_2_sum );
     }
     
     line_2_sum -= line_2[cnt];
   }
   
   Console.WriteLine(maxSum);
 }
}

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())

#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define vll             vector<ll>
#define vpll            vector<pll>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 1e6 + 10;

ll n, k, m, query;
ll ans;

ll factorize(ll n) {
     ll res = 1;
    for (ll i = 2; i * i <= n; ++i) {
        if(n % i == 0){
            while (n % i == 0) {
                n /= i;
            }
            res++;
        }
    }
    if (n != 1) {
        res++;
    }
    return res;
}
void Solve(){
    cin >> n >> m;
    k =  Gcd(n, m);
    cout << factorize(k);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
}

















Measured memory_bytes: 256
import numpy as np

#  入力
n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

#  方針
#  i番目の足場にいるという状態に対して
#  その足場に最も少ないコストを記録する．

dp = np.zeros(n, dtype=np.int)
for i in range(1, n):
    st = max(0, i - k)
    dp[i] = np.min(dp[st:i] + np.abs(h[i] - h[st:i]))

print(dp[-1])


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


int main(){
    ll A , B,ans = 0;
    cin >> A  >> B;
    for(int i = A; i <= B; i++){
        string tmp = to_string(i);
        if(tmp[0] == tmp[4] && tmp[1] == tmp[3]) ans++;
    }
    cout << ans << endl;
}

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

int main() {
    int x,xmax=0;
    cin>>x;
    for(int i=2; i<=9; i++) {
        xmax = max(xmax, (int)pow((int)pow((float)x, (1/(float)i)), i));
    }
    cout<<xmax<<endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int w_cnt = 0, r_cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			w_cnt++;
		} else {
			r_cnt++;
		}
	}
	int ans = 0;
	for (int i = 0; i < r_cnt; i++) {
		if (s[i] == 'W') {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3772
using System;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    static void Main()
    {
        label:
        var s = ReadLine();
        var k = Parse(ReadLine());
        const char bar = '_';
        char pre = bar;
        long n = 0;
        foreach(char c in s)
        {
            if (c == pre)
            {
                ++n;
                pre = bar;
            }
            else pre = c;
        }
        if (s[0] != s[s.Length - 1] || pre == bar)
        {
            WriteLine(k * n);
        }
        else
        {
            long n2 = 0;
            foreach(var c in s)
            {
                if (c == pre)
                {
                    ++n2;
                    pre = bar;
                }
                else
                {
                    pre = c;
                }
            }
            if (pre == bar)
            {
                WriteLine(((k + 1) / 2) * n + (k / 2) * n2);
            }
            else
            {
                WriteLine(n + (k - 1) * n2);
            }
        }
    }
}


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

typedef long long ll;

int main() {
  ll N;
  cin >> N;

  int mini = 100;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      string s1 = to_string(i);
      string s2 = to_string(N / i);
      mini = min(mini, max((int)s1.size(), (int)s2.size()));
    }
  }

  // 解答
  cout << mini << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>

using namespace std;

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

//ノードのコストを管理
typedef struct {
    int edge_cnt;
} Node;

//辺の長さとその繋いでいるものを管理
typedef struct {
    int from;
    int to;
    int del;
} Edge;


int main()
{
    int N, M, is_updated = 0;
    cin >> N >> M;

    Node nodes[50];
    Edge edges[200];
    REP(i, N) 
    {
        nodes[i].edge_cnt = 0;
    }
    REP(i, M) 
    {
        cin >> edges[i].from >> edges[i].to;
        edges[i].del = 0;
        nodes[edges[i].from - 1].edge_cnt++;
        nodes[edges[i].to - 1].edge_cnt++;
    } 

    int cnt = 0;
    do 
    {
        is_updated = 0;
        REP(i, M) 
        {
            if(edges[i].del == 1) continue;
            if(nodes[edges[i].from - 1].edge_cnt == 1 || nodes[edges[i].to - 1].edge_cnt == 1)
            {
                edges[i].del = 1;
                nodes[edges[i].from - 1].edge_cnt--;
                nodes[edges[i].to - 1].edge_cnt--;
                cnt++;
                is_updated = 1;
            }
        }
    } 
    while(is_updated);

    cout << cnt << endl;

}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;

 public class Main{
	 public static void main(String args[]) throws IOException{
		 BufferedReader bf = new BufferedReader(
				 new InputStreamReader(System.in));
		int n = Integer.parseInt(bf.readLine());
		BigInteger result = new BigInteger("1");
		for(int i = n; i > 1 ; i--){
			String str = String.valueOf(i);
			BigInteger I = new BigInteger(str);
			result = result.multiply(I);
		}
		System.out.println(result.toString());
	}
}

Measured memory_bytes: 24284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお


int main() {
	string s; cin >> s;
	ll cnt = 0 , ans = 0;
	rep(i,s.size()-1) {
		if(s[i]=='A')
			cnt++;
		else if(s[i]=='B' && s[i+1]=='C')
			ans += cnt , i++;
		else
			cnt = 0;
	}
	cout << ans << endl;;
	return 0;
}


Measured memory_bytes: 640
X, Y = list(map(int, input().split()))
pX = [0 for _ in range(206)]
pX[1] = 300000
pX[2] = 200000
pX[3] = 100000

point = pX[X] + pX[Y]
if X == 1 and Y == 1:
    point += 400000

print(point)

Measured memory_bytes: 38384