akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  double ave = (a + b) / 2.0;
  ll price = 0;
  if (ave > c) {
    if (x != y) {
      if (x > y) {
        if (c * 2 < a) {
          price = c * 2 * x;
        } else {
          price = y * c * 2 + a * (x - y);
        }
      } else {
        if (c * 2 < b) {
          price = c * 2 * y;
        } else {
          price = x * c * 2 + b * (y - x);
        }
      }
    } else {
      price = x * c * 2;
    }
  } else {
    price = a * x + b * y;
  }
  cout << price << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    set<int >s;
    int L,R,d;
    cin>>L>>R>>d;
    if(L%d==0){
        cout<<(R/d)-(L/d)+1;
    }
    else
    cout<<(R/d)-(L/d);
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<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; }
//#define int long long

void solve() {
	int n; cin >> n;
    for(int a = 1; a <= 9; ++a) {
        if(n % a == 0) {
            int b = n / a;
            if(1 <= b && b <= 9) {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
s=list(input())
if s[0]!='A':
  print("WA")
elif s[2:len(s)-1].count("C")!=1:
  print('WA')
else:
  s.remove('A')
  s.remove('C')
  ns=str(s)
  if ns.islower():
    print("AC")
  else:
    print("WA")
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n,x; cin>>n>>x;
    vi l(n);
    rep(i,n)cin>>l[i];
    int d=0,cnt=1;
    rep(i,n)
    {
        d+=l[i];
        if(d>x)break;
        cnt++;
    }
    cout<<cnt<<endl;
}

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

int main()
{
	int64_t n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;

	int64_t bottom = min(min(min(min(a, b), c), d), e);
	int64_t bottolneck;
	bottolneck = n / bottom;
	if (n % bottom != 0) {
		bottolneck++;
	}

	int64_t ans = 5 - 1 + bottolneck;

	cout << ans << endl;
}

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

int main()
{
	string str;
	char in;

	while(scanf("%c",&in) && in != '\n'){
		if('a' <= in && in <= 'z'){
			in += ('A'-'a');
		}
		str.push_back(in);
	}
	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;


int main()
{
  stack<int> S;
  int a, b, x;
  string s;
  while(cin >> s) 
  {
    if(s[0] == '+') {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    }else if (s[0] == '-') {
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    }else if (s[0] == '*') {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    }else {
      S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;
  return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

string s;
ll ans;
vector<ll> ve;

int main()
{
    cin>>s;
    ve.push_back(-1);
    if(s[0] == '<') ve[0] = 0;
    for(ll i = 1; i < s.size(); i++)
    {
        if(s[i - 1] == '>' && s[i] == '<') ve.push_back(0);
        else ve.push_back(-1);
    }
    ve.push_back(-1);
    if(s[s.size() - 1] == '>') ve[ve.size() - 1] = 0;
    for(ll i = 0; i < ve.size(); i++)
    {
        if(ve[i] == 0)
        {
            ll j = i - 1;
            ll x = 1;
            while(j >= 0 && s[j] == '>') ve[j] = max(x, ve[j]), j--, x++;
            x = 1;
            j = i + 1;
            while(j <= s.size() && s[j - 1] == '<') ve[j] = x, j++, x++;
        }
    }
    for(ll i = 0; i< ve.size(); i++) ans += ve[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7032
import numpy as np
N, W = map(int, input().split())
dp = np.zeros((N+1, W+1), dtype=int)

w,v = [],[]
for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

for row in range(N):
    dp[row+1,:w[row]] = dp[row,:w[row]]
    dp[row+1,w[row]:] = np.maximum(dp[row,w[row]:],v[row]+dp[row,:-w[row]])

print(dp[N,-1])

Measured memory_bytes: 92192
import sys
input = sys.stdin.readline

N, Q = [int(x) for x in input().split()]

edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

cost = [0] * N
for _ in range(Q):
    p, x = [int(x) for x in input().split()]
    cost[p - 1] += x

next = [0]
s_next = {0}
for i in next:
    for v in edge[i]:
        if v in s_next:
            continue
        s_next.add(v)
        next.append(v)
        cost[v] += cost[i]

print(" ".join(map(str, cost)))





Measured memory_bytes: 74912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n,k;
	cin >>n>>k;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
		if (i>=k){
			if (a[i]>a[i-k]) cout <<"Yes"<<endl;
			else cout <<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4048
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if (a == 7 && b == 5 && c == 5) ||
		(a == 5 && b == 7 && c == 5) ||
		(a == 5 && b == 5 && c == 7) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 512
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int sum1=0;
		int sum2=0;
		int count=0;
		while(cin.hasNext()){
			count++;
			String str = cin.next();
			String s[] = str.split(",");
			sum1+=Integer.parseInt(s[0])*Integer.parseInt(s[1]);
			sum2+=Integer.parseInt(s[1]);
		}
		System.out.println(sum1);
		
		double ans = (double)sum2/(double)count;
		BigDecimal bi = new BigDecimal(String.valueOf(ans));
		System.out.println(bi.setScale(0,BigDecimal.ROUND_HALF_UP));
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> w(n);
    for(int i = 0; i < n; i++){
        std::cin >> w[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += w[i];
    }
    int sum1 = 0;
    int sum2;
    int ans = 1e9;
    for(int i = 0; i < n-1; i++){
        sum1 += w[i];
        sum2 = sum - sum1;
        int diff = sum1 - sum2;
        if(diff < 0) diff = -diff;
        ans = std::min(ans, diff);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string n;
    int k;
    cin >> n >> k;
    int len = n.size();
    ll dp[len+1][k+1][2];
    fill(dp[0][0], dp[len+1][0], 0);
    dp[0][0][0] = 1;
    for (int i=0; i<len; i++) {
        for (int j=0; j<=k; j++) {
            dp[i+1][j][n[i] != '0'] += dp[i][j][0];
            dp[i+1][j][1] += dp[i][j][1];
            if (j < k) {
                dp[i+1][j+1][1] += dp[i][j][0] * max(n[i] - '1', 0);
                if (n[i] != '0') dp[i+1][j+1][0] += dp[i][j][0];
                dp[i+1][j+1][1] += dp[i][j][1] * 9;
            }
        }
    }
    cout << dp[len][k][0] + dp[len][k][1] << '\n';
    return 0;
}

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

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

  int cnt = 0;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] != s[i + 1]) cnt++;
  }

  cout << cnt << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int N_copy = N;
  int digit_sum = 0;
  while (N > 0) {
    int n = N % 10;
    N /= 10;
    digit_sum += n;
  }
  if (N_copy % digit_sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

const int MAXN = 2e5 + 5;

int N;
int p[MAXN];
pii v[MAXN];
int dad[MAXN];

inline ll inv(int l, int r) {
	return (ll)v[l].first * v[r].second;
}

struct cmp {
	bool operator()(const int &lhs, const int &rhs) const {
		ll diff = inv(lhs, rhs) - inv(rhs, lhs);
		return diff ? diff < 0 : lhs < rhs;
	}
};

set <int, cmp> S;

void load() {
	scanf("%d", &N);
	for (int i = 2; i <= N; i++)
		scanf("%d", p + i);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &v[i].first);
		v[i].second = v[i].first ^ 1;
	}
}

int find(int x) {
	return dad[x] == x ? x : dad[x] = find(dad[x]);
}

void operator +=(pii &lhs, const pii &rhs) {
	lhs.first += rhs.first;
	lhs.second += rhs.second;
}

ll solve() {
	for (int i = 1; i <= N; i++) {
		dad[i] = i;
		if (i > 1)
			S.insert(i);
	}
	
	ll sol = 0;
	for (int i = 1; i < N; i++) {
		int curr = *S.begin();
		S.erase(curr);
		int nxt = find(p[curr]);
		if (nxt > 1)
			S.erase(nxt);
		sol += inv(nxt, curr);
		v[nxt] += v[curr];
		dad[curr] = nxt;
		if (nxt > 1)
			S.insert(nxt);
	}
	
	return sol;
}

int main() {
	load();
	printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 14848
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mr make_pair
#define N 100010
using namespace std;
ll ans;
int n,x,nb,nc;
struct Info{ll x,y;}a[N],b[N],c[N];
int main(){
	cin>>n>>x;
	for (int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
	for (int i=1;i<=n;i++)if (a[i].x>x)b[++nb]=a[i];
	for (int i=n;i>=1;i--)if (a[i].x<x)c[++nc]=a[i];
	while (nc&&nb){
		ans+=b[nb].x-c[nc].x;
		if (b[nb].y>c[nc].y){
			while(b[nb].y>c[nc].y&&nc>0){b[nb].y+=c[nc].y;nc--;}
		}else{
			while(b[nb].y<=c[nc].y&&nb>0){c[nc].y+=b[nb].y;nb--;}
		}
	}
	if (nb) ans+=b[nb].x-x;
	if (nc) ans+=x-c[nc].x;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main(){
  ll N;
  cin >> N;
  ll M,A,R,C,H;
  M=0;
  A=0;
  R=0;
  C=0;
  H=0;
  rep(i, N){
    string S;
    cin >> S;
    
    if(S[0] =='M') M++;   
    if(S[0] =='A') A++;
    if(S[0] =='R') R++;
    if(S[0] =='C') C++;
    if(S[0] =='H') H++;
  }
  
  vector<ll> V = {M, A, R, C, H};
  
  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 += V[i]*V[j]*V[k];
     }
   }
 }
 
  cout << ans << endl;
}




Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

def digit_sum(x):
    return sum(int(y) for y in str(x))

if digit_sum(N) == 1:
    answer = 10
else:
    answer = digit_sum(N)
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

void solve(){
	int n;
	cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9) cout<<"hon"<<endl;
	else if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
	else if(n==3) cout<<"bon"<<endl;
}

int32_t main(){
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = 0;(i) < (n);i++)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) b.begin(),v.end()
#define SHOW1d(v, n) {REP(WW,n)cerr<<v[WW]<<" ";cerr<<endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr<<v[W_][H_]<<" ";cerr<<endl;}cerr<<endl;}
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;

ll mp[55][55];
bool used[55][55];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void bfs(ll x, ll y, ll z){
  REP(ii, 55)REP(jj, 55)used[ii][jj] = false;
  queue<pair<P, ll>> q;
  q.push(MP(MP(x, y), z));

  while(!q.empty()){
    ll nx = q.front().FI.FI;
    ll ny = q.front().FI.SE;
    ll nz = q.front().SE;
    q.pop();
    if(used[nx][ny])continue;
    used[nx][ny] = true;
    mp[nx][ny] = max(mp[nx][ny], nz);

    REP(i, 4){
      ll xx = nx + dx[i];
      ll yy = ny + dy[i];
      if(xx < 0 || yy < 0 || xx >= 55 | yy >= 55)continue;
      if(used[xx][yy])continue;
      q.push(MP(MP(xx, yy), nz - 1));
    }
  }
}

int main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
  REP(i, 55)REP(j, 55)mp[i][j] = -INF;

  ll w, h, n;cin >> w >> h >> n;
  vector<pair<P, ll>> v;

  REP(i, n){
    ll x, y, z;cin >> x >> y >> z;
    v.EB(MP(x, y), z);
    bfs(x, y, z);
  }

  //SHOW2d(mp, 15, 15);

  REP(i, n){
    ll x = v[i].FI.FI;
    ll y = v[i].FI.SE;
    ll z = v[i].SE;
    if(mp[x][y] != z){
      cout << "No" << endl;
      return 0;
    }
  }

  ll ans = 0;
  REP(i, w)REP(j, h)ans += mp[i+1][j+1];
  cout << ans << endl;

  return 0;
}



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

//#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

const int INF = 2e9;

bool chmin(int &a, int b){
    if(a > b){a = b; return true;}
    return false;
}

inline int tetrahedra(int n){
    return n*(n+1)/2*(n+2)/3;
}

signed main(){
    vector<int> tetra_table, tetra_odd;
    
    for(int i = 1; tetrahedra(i) <= 1000000; i++){
        int t = tetrahedra(i);
        tetra_table.emplace_back(t);
        if(t % 2){
            tetra_odd.emplace_back(t);
        }
    }
    
    int dp[1000001], dp_odd[1000001];
    
    for(int &i : dp)     i = INF;
    for(int &i : dp_odd) i = INF;
    dp[0] = dp_odd[0] = 0;
    
    for(int i : tetra_table){
        reps(j,i,1000000){
            chmin(dp[j], dp[j-i] + 1);
        }
    }
    
    for(int i : tetra_odd){
        reps(j,i,1000000){
            chmin(dp_odd[j], dp_odd[j-i] + 1);
        }
    }
    
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        printf("%d %d\n", dp[n], dp_odd[n]);
    }
}


Measured memory_bytes: 10892
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = pair<ll,ll>;

vector<ll> prime_factorization3(ll a){
    if(a<=0) return {0};
    if(a==1) return {1};

    vector<ll> ans;
    ll num = a;
    for(ll i=2;i<=sqrt(a)+1;i++){
        while(num%i ==0){
            ans.push_back(i);
            num = num/i;
        }
        if(num==1) break;
    }
    if(num!=1) ans.push_back(num);
    set<ll> s(ans.begin(),ans.end());
    vector<ll> cnt(s.size(),0);
    auto itr = s.begin();
    rep(i,0,cnt.size()) {
        cnt[i] = count(ans.begin(),ans.end(),*itr);
        itr++;
    }
    return cnt;
}

int main(){
    ll N;
    cin >> N;
    if(N==1) cout << "0" << endl;
    else{
        ll ans = 0;
        vector<ll> cnt = prime_factorization3(N);
        for(ll i=0;i<cnt.size();i++){
            ll tmpN =1;
            while(1){
                if((tmpN+1)*(tmpN+2)>2*cnt[i]) break;
                tmpN ++;
            }
            ans += tmpN;            
        }
        cout << ans << endl;
    }
}

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

int main(){

    ll n;
    cin >> n;
    vector<ll> a(5);

    rep(i,5)cin >> a[i];

    int id=0;

    rep(i,5){
        if(a[id]>a[i]){
            id=i;
        }
    }

    ll ans=id+(5-id)-1;

    if(n%a[id]==0){
        ans+=n/a[id];
    }else{
        ans+=n/a[id]+1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    colors = list(input().rstrip())

    flag = True

    while flag:
        flag = False
        for i in range(len(colors) - 1):
            if colors[i] == colors[i + 1]:
                colors[i] = "$"
                flag = True
        colors = "".join(colors)
        colors = colors.replace("$", "")
        colors = list(colors)

    print(len(colors))


if __name__ == "__main__":
    main()

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Reach {
    int x, y, time;
};

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

    int xa = 0, bx = 0, ba = 0;
    int ans = 0;
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, s.size() - 1) {
            if (s[j] == 'A' && s[j + 1] == 'B') ans++;
        }
        if (s.front() == 'B' && s.back() == 'A') ba++;
        else if (s.front() == 'B') bx++;
        else if (s.back() == 'A') xa++;
    }

    if (ba == 0) {
        int add = min(bx, xa);
        cout << ans + add << endl;
    } else {
        int add = ba - 1;
        if (xa > 0) {
            add++;
            xa--;
        }
        if (bx > 0) {
            add++;
            bx--;
        }
        add += min(bx, xa);
        cout << ans + add << endl;
    }


}

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

using namespace std;

int main() {
int n;
cin>>n;
int sum=0;
int a[n];
int b[n];
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
cin>>b[i];
for(int i=0;i<n;i++)
{
    if(a[i]>b[i])
    sum+=a[i]-b[i];
}

cout<<sum;



return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);

    for (int i=0; i<M; i++) {
        cin >> A.at(i);
    }

    long long total = 0;
    long long ans = 0;
    for(auto a : A) {
        total += a;
    }
    ans = N-total;
    if(ans < 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3640
/**
 *    author:  tourist
 *    created: 24.02.2018 15:49:12       
**/
#include <bits/stdc++.h>

using namespace std;

const double pi = acosl(-1.0);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < n; i++) {
    vector<double> ang;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        ang.push_back(atan2(y[j] - y[i], x[j] - x[i]));
      }
    }
    sort(ang.begin(), ang.end());
    double mx = 0.0;
    for (int j = 0; j < n - 2; j++) {
      mx = max(mx, ang[j + 1] - ang[j]);
    }
    mx = max(mx, ang[0] + 2 * pi - ang[n - 2]);
    double res = (mx > pi ? (mx - pi) / 2 / pi : 0.0);
    cout << fixed << setprecision(17) << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int e;
	int m;
	while( 1 ){
		m = 1000000;
		cin >> e;
		if( e == 0 ) break;
		for( int z = 0; z*z*z <= e ; z++ ){
			for( int y = 0; y*y + z*z*z <= e ; y++ ){
				if( m > y + z + e - y*y - z*z*z){
					m = y + z + e - y*y - z*z*z;
				}
			}
		}
		cout << m << endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#define THU 0
#define FRI 1
#define SAT 2
#define SUN 3
#define MON 4
#define TUE 5
#define WED 6
int getDayFrom1_1(int month, int day){
	int dayFrom1_1 = day - 1;
	if(month >= 2){
		dayFrom1_1 += 31;
	}
	if(month >= 3){
		dayFrom1_1 += 29;
	}
	if(month >= 4){
		dayFrom1_1 += 31;
	}
	if(month >= 5){
		dayFrom1_1 += 30;
	}
	if(month >= 6){
		dayFrom1_1 += 31;
	}
	if(month >= 7){
		dayFrom1_1 += 30;
	}
	if(month >= 8){
		dayFrom1_1 += 31;
	}
	if(month >= 9){
		dayFrom1_1 += 31;
	}
	if(month >= 10){
		dayFrom1_1 += 30;
	}
	if(month >= 11){
		dayFrom1_1 += 31;
	}
	if(month >= 12){
		dayFrom1_1 += 30;
	}
	return dayFrom1_1;
}
int main(void){
	int month, day;
	int day1;
	char y_str[7][10] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while(1){
		scanf("%d%d",&month,&day);
		if(month == 0){break;}
		day1 = getDayFrom1_1(month,day);
		puts(y_str[day1 % 7]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

#define INFTY 2000000000

int count = 0;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    count++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
	int n;
  scanf("%d", &n);
  int S[n];
  for ( int i = 0; i < n; i++ ) scanf("%d", &S[i]);
  mergeSort(S, 0, n);
  for ( int i = 0; i < n-1; i++ ) printf("%d ", S[i]);
  printf("%d\n", S[n-1]);
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 6460
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

class Letter{
public:
  string letter;
  string number;
  Letter() : letter(""),number(""){}
  Letter(string _l,string _n) : letter(_l),number(_n) {}
};

bool matching_letters(int offset, const string& src,const string& dst){
  if(offset + src.size() > dst.size()) return false;

  for(int i=0;i<src.size();i++){
    if(dst[i+offset] != src[i]) return false;
  }
  return true;
}

int main(){
  int buttons[256];
  buttons['a'] = 2;
  buttons['b'] = 2;
  buttons['c'] = 2;

  buttons['d'] = 3;
  buttons['e'] = 3;
  buttons['f'] = 3;

  buttons['g'] = 4;
  buttons['h'] = 4;
  buttons['i'] = 4;

  buttons['j'] = 5;
  buttons['k'] = 5;
  buttons['l'] = 5;

  buttons['m'] = 6;
  buttons['n'] = 6;
  buttons['o'] = 6;

  buttons['p'] = 7;
  buttons['q'] = 7;
  buttons['r'] = 7;
  buttons['s'] = 7;

  buttons['t'] = 8;
  buttons['u'] = 8;
  buttons['v'] = 8;

  buttons['w'] = 9;
  buttons['x'] = 9;
  buttons['y'] = 9;
  buttons['z'] = 9;

  int N;
  while(~scanf("%d",&N)){
    if(N == 0) break;

    Letter dict[128];
    for(int dic_idx=0;dic_idx<N;dic_idx++){
      string str;
      cin >> str;

      string tmp_num = "";
      for(int i=0;i<str.size();i++){
	tmp_num.push_back(buttons[str[i]] + '0');
      }
      dict[dic_idx] = Letter(str,tmp_num);
    }

    vector<string> dp[5001]; //dp[end_pos] := term

    string numbers;
    cin >> numbers;
    
    for(int end_pos = 0; end_pos <= 3000; end_pos++){
      if(end_pos == 0){
	for(int dic_idx=0;dic_idx<N;dic_idx++){
	  if(matching_letters(end_pos,dict[dic_idx].number,numbers)){
	    dp[end_pos + dict[dic_idx].number.size()].push_back(dict[dic_idx].letter);
	  }
	}
      }
      if(dp[end_pos].size() == 0) continue;

      for(int dic_idx=0;dic_idx<N;dic_idx++){
	if(matching_letters(end_pos,dict[dic_idx].number,numbers)){
	  for(int i=0;i<dp[end_pos].size();i++){
	    dp[end_pos + dict[dic_idx].number.size()].push_back(dp[end_pos][i] + " " + dict[dic_idx].letter);
	  }
	}
      }
    }

    for(int i=0;i<dp[numbers.size()].size();i++){
      cout << dp[numbers.size()][i] << "." << endl;
    }
    cout << "--" << endl;
  }
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF LONG_LONG_MAX
using namespace std;

signed main(){
    int a; cin>>a;
    int sum=0;
    while(a>0){
        sum+=a%10;
        a/=10;
    }
    cout<<(sum==1?10:sum)<<endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A == B && A!=C && B!=C){
    cout << "Yes";
  }else if(A==C && A!=B && C!=B){
    cout << "Yes";
  }else if(B==C && B!=A && C!=A){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, a, b, c, d, e, mini;
    cin >> n >> a >> b >> c >> d >> e;
    mini = min(a, min(b, min(c, min(d, e))));
    cout << 4 + (n / mini + (int)(n % mini != 0));

    return 0;
}


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

int main(){
        int n;
        scanf("%d", &n);
        std::vector<int>  p(n), q(n), v(n);
        for(int i=0; i<n; i++) scanf("%d", &p[i]);
        for(int i=0; i<n; i++) scanf("%d", &q[i]);
        for(int i=0; i<n; i++) v[i] = i+1;

        int cnt = 1, a, b;
        do {
                if(p==v) a = cnt;
                if(q==v) b = cnt;
                cnt++;
        }while(std::next_permutation(v.begin(), v.end()));

        printf("%d\n", abs(a-b));
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long int N,A,B;
int main(){
  cin >> N >> A >> B;
  if(A>B){
    cout << "0" << endl;
    return 0;
  }
  if(N==1){
    if(A==B){
      cout << "1" << endl;
      return 0;
    }
    else cout << "0" << endl;
    return 0;
  }
  long long int ans=(B-A)*(N-2)+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e12;
const ll inf=1e18;
const ll ms=10000000;
fast;
ll n;
string s,ss,ans;
void solve()
{
    cin>>n;cin>>s>>ss;
    for(ll i=0;i<n;i++)
    {
        ans.pb(s[i]);ans.pb(ss[i]);
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 





int main(){
  int N, K;
  cin >> N >> K;
  vector<int>h(N);
  REP(i, N){
    cin >> h.at(i);
  }
  int cnt = 0;
  REP(i, N){
    if(h.at(i) >= K) cnt++;
  }
  print(cnt);
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

int	main() {
	long N, D, A;
	cin >>N >>D >>A;
	D +=D;
	vector<vector<long>> X(N, vector<long> (2, 0));
	for (long i=0; i<N; i++) {
		int XX;
		cin >>X.at(i).at(0) >>XX;
		X.at(i).at(1)=(XX+A-1)/A;
	}
	sort(X.begin(), X.end());
	long S=0;
	vector<vector<long>> BB;
	long ixb=0;
	long BBB=0;
	for(long i=0; i<N; i++) {
		long XX=X.at(i).at(0);
		long H=X.at(i).at(1);
		while((ixb<BB.size())&&(BB.at(ixb).at(0)<XX)) {
			BBB -=BB.at(ixb).at(1);
			ixb++;
		}
		H-=BBB;
		if (0>=H)
			continue;
		S +=H;
		BBB +=H;
		long DDD=X.at(i).at(0)+D;
		BB.push_back({DDD, H});
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 23088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9') puts("Yes");
    else puts("No");
    return 0;
}

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

int main() {
    int x, y, z, tmp;
    cin >> x >> y >> z;

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    cout << x << " " << y << " " << z << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;
const double PI=3.14159265359;

int main(){
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int cnt=0;
	for(int i=0;i<=n/r+1;i++){
		for(int j=0;j<=n/g+1;j++){
			int red=r*i;
			int green=g*j;
			if(n-red-green>=0 && (n-red-green)%b==0){
				cnt++;
				//std::cout<<red<<" "<<green<<" "<<n-red-green<<endl;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

int main() {
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H')cout<<"H";
        else cout<<"D";
    }else {
        if(b=='H')cout<<"D";
        else cout<<"H";
    }
}

Measured memory_bytes: 256
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, k = map(int, input().split())

ans = 0

if k%2==0:
    tmp = int(n//k)
    ans += tmp*tmp*tmp

    tmp = int((n+k/2)//k)
    ans += tmp*tmp*tmp
else:
    tmp = int(n//k)
    ans += tmp*tmp*tmp

print(ans)

Measured memory_bytes: 13672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin>>n;
  bool ok = false;
  for (int i=1; i<10; i++) {
    for (int j=1; j<10; j++) {
      if(i*j==n) ok = true;
    }
  }
  puts(ok?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    long long n;
    long long q[5];
    long long m = 10000000000000000;
    
    cin >> n;
    for (int i = 0;i < 5;i++){
        cin >> q[i];
        m = min(m,q[i]);
    }
    if (n >= m && n%m == 0){
        cout << 4+n/m << endl;
    }
    else {
        cout << 5+n/m << endl;
    }
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (W>=x+r && H>=y+r && r<=x && r<=y && x>=0 && y>=0){
        printf("Yes\n");}
        else {
            printf("No\n");}
             
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[15],b,i,p[15]={0};
	for(i=1;i<=9;i++)
		cin>>a[i];
	int n;
	cin>>n;
	for(int j=0;j<n;j++)
	{
		cin>>b;
		for(i=1;i<=9;i++)
			if(b==a[i])
				p[i]=1;
	}
	if(p[5]==1)
	{
		if(p[2]==1&&p[8]==1) cout<<"Yes"<<endl;
		else if(p[1]==1&&p[9]==1) cout<<"Yes"<<endl;
		else if(p[3]==1&&p[7]==1) cout<<"Yes"<<endl;
		else if(p[4]==1&&p[6]==1) cout<<"Yes"<<endl;
		else if(p[1]==1)
		{
			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;
			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;
		}
		else if(p[9]==1)
		{
			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;
			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
	else if(p[1]==1)
		{
			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;
			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;
			else if(p[9]==1)
		{
			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;
			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		}
		else if(p[9]==1)
		{
			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;
			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	else cout<<"No"<<endl;
	 
	return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
A,B=map(int,input().split())
sa, sb = prime_factorize(A),prime_factorize(B)
print(len(sa&sb)+1)
    

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 
ll a[100010],b[100010];
int main() {
	ll n;
	cin>>n;
	vector<pair<ll,ll>>c;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		a[i]=x;
		b[i]=y;
		c.push_back(make_pair(x+y,i));
	}
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=c[i].second;
		if(i%2==0){
			ans+=a[now];
		}
		else{
			ans-=b[now];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()




int c[10][10];
int arr[500];

int cnt[10];

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

   int cnt0 = 0, cnt1 = 0, cnt2 = 0;

   for(int i = 0; i < s.size(); i++){
       if(s[i] == 'a') cnt[0]++;
       if(s[i] == 'b') cnt[1]++;
       if(s[i] == 'c') cnt[2]++;
   }
   sort(cnt, cnt+3);

   cnt[1] -= cnt[0];
   cnt[2] -= cnt[0];

   if(cnt[1] && cnt[2]){
      if(cnt[1]+cnt[2] > 2){
         cout << "NO";
      }
      else cout << "YES";
   }
   else{
      if(cnt[2] > 1){
         cout << "NO";
      }
      else cout << "YES";
   }

}


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

inline int read()
{
	int x=0,f=1,c=getchar();
	while(c<48) c=='-'&&(f=-1),c=getchar();
	while(c>47) x=x*10+c-'0',c=getchar();
	return x*f;
}

const int MAXN = 600005;
const int mod = 924844033;
int fac[MAXN],ifac[MAXN],cnt[MAXN],sz[MAXN];
int f[MAXN],g[MAXN],rev[MAXN];
int n;

inline int qpow(int x,int k)
{
	int res=1;
	for(int i=k; i; i>>=1,x=1ll*x*x%mod)
		if(i&1) res=1ll*res*x%mod;
	return res;
}

struct edge {int v,nxt;} e[MAXN<<1];
int head[MAXN];
inline void addEdge(int u,int v)
{
	static int c=0;
	e[++c]=(edge) {v,head[u]},head[u]=c;
}


inline void init(int n)
{
	for(int i=fac[0]=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=qpow(fac[n],mod-2);
	for(int i=n; i; --i) ifac[i-1]=1ll*ifac[i]*i%mod;
}

inline int C(int n,int m)
{return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}


inline void dfs(int u,int fa)
{
	sz[u]=1;
	for(int i=head[u]; i; i=e[i].nxt)
	{
		int v=e[i].v; if(v==fa) continue;
		dfs(v,u),sz[u]+=sz[v],++cnt[sz[v]];
	}
	++cnt[n-sz[u]];
}

inline void ntt(int *a,int n,int op)
{
	for(int i=0; i<n; ++i) if(i<rev[i]) swap(a[i],a[rev[i]]);
	for(int i=1; i<n; i<<=1)
	{
		int rot=qpow(op==1?5:554906420,(mod-1)/(i<<1));
		for(int j=0; j<n; j+=i<<1)
			for(int k=0,w=1; k<i; ++k,w=1ll*w*rot%mod)
			{
				int x=a[j+k],y=1ll*w*a[j+k+i]%mod;
				a[j+k]=(x+y)%mod,a[j+k+i]=(x-y+mod)%mod;
			}
	}
	if(op==-1)
	{
		int inv=qpow(n,mod-2);
		for(int i=0; i<n; ++i) a[i]=1ll*a[i]*inv%mod;
	}
}

int main()
{
	n=read();
	for(int i=1; i<n; ++i)
	{
		int u=read(),v=read();
		addEdge(u,v),addEdge(v,u);
	}
	dfs(1,0); init(n);
	for(int i=1; i<=n; ++i) f[i]=1ll*cnt[i]*fac[i]%mod;
	reverse(f,f+n+1);
	for(int i=0; i<=n; ++i) g[i]=ifac[i];
	int lim=1,l=0;
	for(; lim<=n<<1; lim<<=1,++l);
	for(int i=0; i<lim; ++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<(l-1));
	ntt(f,lim,1),ntt(g,lim,1);
	for(int i=0; i<lim; ++i) f[i]=1ll*f[i]*g[i]%mod;
	ntt(f,lim,-1);
	reverse(f,f+n+1);
	for(int i=1; i<=n; ++i)
		printf("%lld\n",(1ll*n*C(n,i)%mod
		                 -1ll*ifac[i]*f[i]%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 30156
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> h(n+2),dp(n+2,INT_MAX);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  dp[0]=0;
  for (int i = 0; i < n; i++){
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }
  cout << dp[n-1] << '\n';
  return 0;
}

Measured memory_bytes: 3984
/*
 Atcoder ACL
*/


#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };

const int dy[] = { 0, 1, 0, -1 };

const int N=200005;


void solve()
{

    
    int k;
    cin>>k;
    string s="ACL";
    for(int i=0;i<k;i++)
        cout<<s;
    cout<<endl;
    
    
    
    
}


int32_t main(){
    
    IOS;
    
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}




Measured memory_bytes: 3660
a = list(list(map(int,input().split())) for i in range(3))
n = int(input())
b = [int(input()) for x in range(n)]
d = [[0 for i in range(3)] for j in range(3)]
ans = "No"
for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                d[i][j] = 1
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[i][j]
    if c == 3:
        ans = "Yes"
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[j][i]
    if c == 3:
        ans = "Yes"
c = 0
for j in range(3):
    c+=d[j][j]
    if c == 3:
        ans = "Yes"
        c = 0
for j in range(3):
    c+=d[j][2-j]
    if c == 3:
        ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i += 2){
    if(s[i] == 'L'){
      cout << "No" << endl;
      return 0;
    }
    if(s[i+1] == 'R'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

#define min(X, Y) ((X)<(Y)?(X):(Y))
#define swap(X, Y) { int $=X;X=Y;Y=$; }

int a[20], b[20], c[20], n, m;

int func(int zero)
{
    for(int i=0,k=0;i<m;++i) {
        for(int j=0;j<c[i];++j) b[k++]=zero;
        zero^=1;
    }

    int res=0;
    for(int i=0;i<n;++i) if (a[i]!=b[i]) {
        for(int j=i+1;j<n;++j) if (a[i]==b[j]) {
            res+=j-i;
            for(int k=j;k>i;--k) swap(b[k], b[k-1]);
            break;
        }
    }
    return res;
}

int main()
{
    while (~scanf("%d%d", &n, &m)) {
        int o=0, z=0;
        for(int i=0;i<n;++i) {
            scanf("%d", a+i);
            a[i]?o++:z++;
        }
        int ot=0, zt=0;
        for(int i=0;i<m;++i) {
            scanf("%d", c+i);
            i%2?ot+=c[i]:(zt+=c[i]);
        }
        int res=1<<30;
        if (zt==z) res=func(0);
        if (ot==z) res=min(res, func(1));
        printf("%d\n", res);
    }
}

Measured memory_bytes: 1016