akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define endl	'\n'
#define MOD 1000000

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = { 0,1,0,-1 };
int dy[] = { -1,0,1,0 };
int dz[] = { 0,0,0,0,1,-1 };
const int INF = 1000000000;

int n, m;

struct tt {
	int days, reward;
};



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> n >> m;
	int a, b;

	vector<vector<int>> v(m);

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (m - a < 0) continue;
		v[m - a].push_back(b);
	}

	priority_queue<int, vector<int>, less<int>> pq;

	ll ans = 0;
	for (int i = m - 1; i >= 0; i--) {
		for (int j : v[i]) pq.push(j);
		if (pq.empty()) continue;
		ans += pq.top();
		pq.pop();
	}

	cout << ans;
}


Measured memory_bytes: 5632
from string import ascii_lowercase

s = input()
k = int(input())

sbst = set()
for char in ascii_lowercase:
    if len(sbst) > 5 :
        break
    for i, c in enumerate(s):
        if c == char :
            for j in range(min(5,len(s)-i)) :
                sbst.add(s[i:i+j+1])

abst = list(sbst)
abst.sort()

print(abst[k-1])

Measured memory_bytes: 3896
#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    long long int a[n],sum=0;
    for(int i=0;n>i;++i)
    a[i]=i+1;
    for(int i=0;n>i;++i){
        if(a[i]%5>0&&a[i]%3>0)
        sum+=a[i];
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 9492
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,c=0,j=0,s=0;
    cin>>N;
    while(j<=N)
    {
        for(int i=j;i!=0;i=i/10)
        {
            i/10;
            c++;
        }
        if(c%2!=0)
            s++;
        c=0;
        j++;
    }
    cout<<s<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int cnt[345678];
signed main() {
	int n; string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	boolean key = true;
    	for (int i = 1; i < S.length(); i++) {
    		if (S.charAt(i) != '9') {
    			key = false;
    		}
    	}
    	int count = 0;
    	if (key) {
    		count = (S.charAt(0) - '0') + (9 * (S.length()-1));
    	} else {
    		count = (S.charAt(0) - '1') + (9 * (S.length()-1));
    	}
    	System.out.println(count);
    }
}

Measured memory_bytes: 23380
import java.util.Scanner;

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

        int n = sc.nextInt();

        int v[] = new int[n];
        int c[] = new int[n];

        int max = 0;

        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();

        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }


        for (int i = 0; i < n; i++) {
            if (v[i] - c[i] > 0) {
                max += v[i] - c[i];
            }
        }

        System.out.println(max);

        sc.close();
    }
}

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

typedef long long ll;
ll a,b,n,ans,r;

int main()
{
	cin >> n >> a >> b;
	if(a+b==0)
	{
		cout << 0;
		return 0;
	}
	ans += n/(a+b)*a;
	r = n%(a+b);
	ans += r>a?a:r;
	cout << ans;
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

bool chk(string &s) {
  if (s[0] != 'A') return 0;
  int c = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == 'C' && i >= 2 && i <= s.size() - 2) {
      if (c) return 0;
      else c = 1;
    }
    if (s[i] != 'C' && s[i] < 'a') return 0;
  }
  return c;
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  if (chk(s)) cout << "AC" << '\n';
  else cout << "WA" << '\n';
}


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

int main() {
  int x, y;
  cin >> x;
  y = (x % 10);
  if(y == 3)
    cout << "bon" << endl;
  if(y == 0 || y == 1 || y == 6 || y == 8)
    cout << "pon" << endl;
  if(y == 2 || y == 4 || y == 5 || y == 7 || y == 9)
    cout << "hon" << endl;
  return 0;
}
      
  


Measured memory_bytes: 3612
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

const ll MAXINDx = 3000;
const ll MAXINDy = 3000;

double dp[MAXINDx][MAXINDy] = {0};

vector<vector<int>> edges;

ll R, B, x, y;

bool check(ll mid)
{
    if (mid > R || mid > B)
        return false;
    ll num = (R - mid) / (x - 1) + (B - mid) / (y - 1);
    return (num >= mid);
}

bool comp(const pair<int, int> a, const pair<int, int> b)
{
    return a.second < b.second;
}

int main()
{
    set<int> list;

    int N;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        list.insert(x);
    }

    cout << list.size() << endl;
    return 0;
}

/*Syakutori
cout << fixed << setprecision(10) << ans << endl;
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;



ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
/*
int rec(int v){
    int res = 0;

    if(dp[v] > -1)return dp[v];

    for(auto nv: edges[v]){
        res = max(res, rec(nv) + 1);
    }
    return dp[v] = res;
}
*/


Measured memory_bytes: 256
S = [int(x) for x in list(input())]
f,b = S[0]*10 + S[1], S[2]*10 + S[3]

if 0 < f <= 12 and 0 < b <= 12 :
    print("AMBIGUOUS")
elif 0 < f <= 12:
    print("MMYY")
elif 0 < b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
a, b = map(int, input().split())

def solve(a, b):
    if (a < 0 and b > 0) or a == 0 or b == 0:
        return 'Zero'
    if a > 0:
        return 'Positive'
    if (b - a) % 2:
        return 'Positive'
    else:
        return 'Negative'

print(solve(a, b))


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

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<pair<ll, ll>> P;
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
        P.push_back(make_pair(A[i], B[i]));
    }
    ll ans = 0;
    ll hon = 0;
    sort(P.begin(), P.end());

    for (ll i = 0; i < N; i++)
    {
        ans += P[i].first * min(M,P[i].second);
        M -= min(M, P[i].second);
        if (M <= 0)
        {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

base = min(a) + min(b)
answer = base

for i in range(M):
    x, y, c = map(int, input().split())
    price = a[x - 1] + b[y - 1] - c
    if answer > price:
        answer = price
print(answer)


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

int n, a;

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a;
        if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

int n;
vector<pair<int, int>> a(MAX_N);

int main() {

  cin >> n;
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = i;
  }

  sort(a.begin(), a.begin()+n);

  rep(i, n) {
    cout << a[i].second + 1;
    if(i==n-1) cout << endl;
    else cout << " ";
  }

  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void) {
	long long a, b, arr[200000], i, sum=0;
	scanf("%lld %lld", &a, &b);
	for(i=0; i<a; i++){
		scanf("%lld", &arr[i]);
	}
	sort(arr, arr+a);
	if(a<=b){
		printf("0");
		return 0;
	}
	else{
		for(i=0; i<a-b; i++)
			sum += arr[i];
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    vector<int > v;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        v.push_back(t);
    }
    int c;
    cin>>c;
    while(c--)
    {
        int b,e,t;cin>>b>>e>>t;
        auto it=v.begin();
        swap_ranges(it+b,it+e,it+t);
    }
    
    cout<<v[0];
    for(int i=1;i<v.size();i++)
    {
        cout<<" "<<v[i];
    }
    cout<<endl;
}


Measured memory_bytes: 3168
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1100031;

int n,m,w[N];

int get(int x){
	if (x==w[x])
		return x;
	return w[x]=get(w[x]);
}

void merge(int a,int b){
	a=get(a);
	b=get(b);
	w[a]=b;
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n>>m;
    for (int i=1;i<=n;i++){
    	w[i]=i;
    }

    for (int i=1;i<=m;i++){
    	int a,b,c;
    	cin>>a>>b>>c;
    	merge(a,b);
    }

    int ans=0;

    for (int i=1;i<=n;i++){
    	if (get(i)==i)
    		++ans;
    }
    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <map>
#include <cstring>

#define MAX_Q (400000)

using namespace std;

typedef long long lint;


int bit[MAX_Q + 1];
lint val[MAX_Q + 1];

void add(int pos, int val)
{
	while (pos <= MAX_Q){
		bit[pos] += val;
		pos += pos & -pos;
	}
}

int sum(int pos)
{
	int ret = 0;
	
	while (pos){
		ret += bit[pos];
		pos &= (pos - 1);
	}
	
	return (ret);
}

void print(int x)
{
	int l = 0, r = MAX_Q;
	
	while (l != r){
		int center = (l + r) / 2;
		
		if (sum(center) < x){
			l = center + 1;
		}
		else {
			r = center;
		}
	}
	
	printf("%lld\n", val[r]);
}

void erase(int x)
{
	int l = 0, r = MAX_Q;
	
	while (l != r){
		int center = (l + r) / 2;
		
		if (sum(center) < x){
			l = center + 1;
		}
		else {
			r = center;
		}
	}
	
	add(r, -1);
}

int main()
{
	int q, lim;
	
	while (scanf("%d %d", &q, &lim), lim){
		memset(bit, 0, sizeof(bit));
		memset(val, 0, sizeof(val));
		
		map<lint, int> pos;
		
		int p = 1;
		
		while (q--){
			int qtype, x;
			scanf("%d %lld", &qtype, &x);
			
			if (qtype == 0){
				add(p, 1);
				pos[x] = p;
				val[p++] = x;
				if (sum(MAX_Q) > lim){
					erase(1);
				}
			}
			if (qtype == 1){
				erase(x);
			}
			if (qtype == 2){
				print(x);
			}
			if (qtype == 3){
				add(pos[x], -1);
			}
		}
		
		printf("end\n");
	}
	
	return (0);
}

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

struct node{
	long long a;
	long long b;
};

long long a, b;
vector <node> vis;

int cmp(node a, node b){
	return a.b < b.b;
}

int main(){
	int n;
	cin >> n;
	long long time_now = 0;
	for (int i = 0; i < n; i++){
		cin >> a >> b;
		vis.push_back({a, b});	
	}
	sort(vis.begin(), vis.end(), cmp);
	for (int i = 0; i < n; i++){
		time_now += vis[i].a;
		if (time_now > vis[i].b) {
			cout << "No";
			return 0;
		}	
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int N, D;
  cin >> N >> D;
  int X[N][D];
  REP(i, N) {
    REP(j, D) { cin >> X[i][j]; }
  }

  int ans = 0;
  REP(i, N) {
    for(int j = i + 1; j < N; j++) {
      double sum = 0;
      REP(k, D) { sum += pow(abs(X[i][k] - X[j][k]), 2.0); }
      double d = sqrt(sum);
      if(ceil(d) == floor(d)) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import heapq

if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = [(-x, x) for x in A]
    heapq.heapify(A)

    for i in range(M):
        tmp = heapq.heappop(A)
        v = tmp[1] // 2
        heapq.heappush(A, (-v, v))
    
    res = 0
    for i in range(len(A)):
        res += A[i][1]
    
    print(res)


Measured memory_bytes: 17348
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n , a=0 , b=0 , s ;
    cin>>n;
    for (int i=1 ; i<=n ; ++i)
    {
        if((i*(i+1))/2>=n)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, x;
  int a[110];
  cin >> N >> x;
  rep(i, 0, N) cin >> a[i];
  sort(a, a+N);
  int ans = 0;
  rep(i, 0, N) {
    if (a[i] <= x) {
      if (i+1 == N && a[i] != x) continue;
      ans++;
      x -= a[i];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

const int MAX_N = 100000;
const int MAX_M = 200000;

std::vector<int> g[MAX_N + 1];

int f[MAX_N + 1];

bool vis[MAX_N + 1];

void bfs(int u) {
  std::queue<int> q;
  q.push(u);
  while (!q.empty()) {
    const int u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (!f[v]) {
        f[v] = u;
      }
      if (!vis[v]) {
        q.push(v);
        vis[v] = true;
      }
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  for (int i = 0, u, v; i < m; ++i) {
    std::cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  bfs(1);
  for (int i = 2; i <= n; ++i) {
    if (!f[i]) {
      std::cout << "No";
      return 0;
    }
  }
  std::cout << "Yes\n";
  for (int i = 2; i <= n; ++i) {
    std::cout << f[i] << '\n';
  }
}

Measured memory_bytes: 10716
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <math.h>
#include <stdio.h>
using namespace std;

double x;
double a;
double y;
double b;

int main() {

	cin >> x >> y >> a >> b;

	double z = sqrt((a - x)*(a - x) + (b - y)*(b - y));

	//cout << z << endl;
	printf("%.5f\n", z);

	return 0;
}


Measured memory_bytes: 3196
N = int(input())
A = [[x - 1 for x in list(map(int, input().split()))] for _ in range(N)]

def can_match(i, A, next_set):
	if not A[i]:
		return
	j = A[i][-1]
	if A[j][-1] == i:
		if i < j:
			next_set.add((i, j))
		else:
			next_set.add((j, i))

next_set = set()
for i in range(N):
	can_match(i, A, next_set)

day = 0
battle = 0
while next_set:
	day += 1
	current_set = next_set.copy()
	next_set = set()
	for match in current_set:
		battle += 1
		del A[match[0]][-1]
		can_match(match[0], A, next_set)
		del A[match[1]][-1]
		can_match(match[1], A, next_set)

if battle == N*(N-1) // 2:
	print(day)
else:
	print(-1)

Measured memory_bytes: 35596
from itertools import combinations
_, l = input(), sorted(int(i) for i in input().split())
if len(l) < 3:
    print(0)
else:
    ans = 0
    for v in combinations(l, 3):
        if v[0] + v[1] > v[2] and len(set(v)) == 3:
            ans += 1
    print(ans)


Measured memory_bytes: 73748
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;

signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, i, max1, max2;
    cin>>n;
    int a[n];
    cin>>a[0];
    cin>>a[1];
    max1=max(a[0], a[1]);
    max2=min(a[0], a[1]);
    for(i=2;i<n;i++){
        cin>>a[i];
        if(a[i]>max1)
        {
            int t=max1;
            max1 = a[i];
            max2 = t;
        }
        else if(a[i]>max2){
            max2=a[i];
        }
    }
    int c=0;
    for(i=0;i<n;i++){
        if(a[i]==max1)
            c++;
    }
    for(i=0;i<n;i++){
        if(a[i]!=max1||c>1)
            cout<<max1<<endl;
        else
            cout<<max2<<endl;
    }

    
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    vector<int> N(3);
    cin >> N[0] >> N[1] >> N[2];
    sort(N.begin(), N.end());
    int d2 = N[1] - N[0];

    int res = 0;
    if (d2 % 2 == 1) {
        N[2]++;
        res += 1;
    }
    int d1 = N[2] - N[1];
    res += d2 / 2;
    res += d1;
    cout << res << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    b = list(map(int, input().split()))

    result = b[0]
    for i in range(n - 2):
        result += min(b[i], b[i + 1])
    result += b[n - 2]

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;

const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll x;
    cin >> x;
    if( x >= 30)
    	cout << "Yes\n";
   	else
   		cout << "No\n";

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#define N 100
int main(){

  int i,n,key,j,k;
  int A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  for(k=0;k<n;k++){
    if (k >0) printf(" ");
    printf("%d",A[k]); 
  }
  printf("\n");
  for( i = 1;i<n;i++){
    key = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > key)
      {
	A[j+1] = A[j];
	j--;
	A[j+1] = key;
      }
    for(k=0;k<n;k++){
      if (k >0) printf(" ");
      printf("%d",A[k]); 
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>

int main()
{
	int n, k;
	std::cin >> n >> k;

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

	std::sort( a, a + n );

	int sum = 0;
	for( int i = n - k; i < n; i++ ) {
		sum += a[ i ];
	}

	std::cout << sum << std::endl;
	return 0;
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,m;
int main()
{
   

    cin>>n>>m;
    if(n%3==0 || m%3==0 || (n+m)%3==0)
        cout<<"Possible";
    else
        cout<<"Impossible";
}




Measured memory_bytes: 256
import math
import collections


def main():
    s, w = input_list()
    if w >= s:
        print('unsafe')
    else:
        print('safe')


def input_list():
    return list(map(int, input().split()))


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65016
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	vector<int>a;
	int n, b;
	bool c = true;
	cin >> n;
	rep(i, n) {
		cin >> b;
		a.push_back(b);
	}
	sort(a.begin(), a.end());
	rep(i, n - 1) {
		if (a[i] == a[i + 1]) {
			c = false;
			break;
		}
	}
	if (c == true)cout << "YES" << endl;
	else cout << "NO" << endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int V,E;
vector<int> board[100010];
// dp[i]:=iを始点とする最大長
int dp[100010];
int dfs(int from){
    if(dp[from]!=-1) return dp[from];
    int rec=-1;
    for(auto to:board[from]){
        rec=max(rec,dfs(to));
    }
    dp[from]=rec+1;
    return dp[from];
}
int main(){
    cin>>V>>E;
    rep(i,V) dp[i]=-1;
    while(E--){
        int s,t; cin>>s>>t;
        board[--s].push_back(--t);
    }
    rep(i,V) dfs(i);
    int ans=0;
    rep(i,V) ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8192
#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 a,b,n;
  cin >> a >> b >> n;
  if(b-1>n){
    cout << a*n/b << endl;
    return 0;
  }
  else{
    cout << a*(b-1)/b << endl;
    return 0;
  } 
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 10e9
#define MOD 1000000007

using namespace std;

// ll dp[200005];

const ll MAX_N = 1000000;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	if ((a % MOD) + (b % MOD) >= c % MOD)
		cout << b+c << endl;
	else {
	    cout << (a + b) * 2 - a + 1 << endl;
	} 
}


Measured memory_bytes: 256
#include <bits/stdc++.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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    while(cin>>n,n){
        int mx=0,mn=1001,s;
        int sum=0;
        rep(i,n){
            cin>>s;
            sum+=s;
            mx=max(mx,s),mn=min(mn,s);
        }
        cout<<(sum-mx-mn)/(n-2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    int n,w;
    cin >> n >> w;
    int dp[w+1];
    int value[n],weight[n];
    for(int i = 0; i < n; i++){
        cin >> value[i] >> weight[i];
    }
    for(int i = 0; i <= w; i++) dp[i] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(j - weight[i] >= 0){
                dp[j] = max(dp[j-weight[i]]+value[i],dp[j]);
            }
        }
    }
    cout << dp[w] << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1e9+7;

ll h, w, k;

ll memo[10];
ll dp[105][10];
ll solve(int y, int x) {
	if(y == h) {
		return (x == k ? 1 : 0);		
	}

	ll& ret = dp[y][x];
	if(ret != -1) return ret;
	ret = 0;

	ret += (solve(y+1,x) * memo[x-1] * memo[w-x] % MOD);
	if(x < w) {
		ll loc = solve(y+1, x+1) * memo[x-1] % MOD;
		loc = loc * memo[w-x-1] % MOD;
		ret += loc;
		ret %= MOD;
	} 
	if(x > 1) {
		ll loc = solve(y+1, x-1) * memo[w-x] % MOD;
		loc = loc * memo[x-2] % MOD;
		ret += loc;
		ret %= MOD;
	}
	return ret;
}

void precal() {
	memo[0] = 1;
	memo[1] = 1;
	rep(i,2,10) {
		memo[i] = memo[i-1] + memo[i-2];
	}
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> h >> w >> k;
	rep(i,0,105) rep(j,0,10) dp[i][j] = -1;
	precal();
	cout << solve(0,1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class C {
	string s, t;
	int n, nkey;
public:
	C()
	{
		cin >> s >> t;
		n = SZ(s);
		nkey = SZ(t);
	}

	void declare(int i)
	{

		REP(j, nkey)
		{
			s[i + j] = t[j];
		}

		replace(ALL(s), '?', 'a');

		cout << s << endl;

	}

	bool check(int i)
	{
		if (n - i < nkey)
			return false;

		REP(j, nkey)
		{
			if (s[i + j] != '?' && s[i + j] != t[j])
				return false;
		}
		return true;
	}

	void solve()
	{

		if (n < nkey)
		{
			cout << "UNRESTORABLE" << endl;
			return;
		}

		RREP(i, n)
		{
			if (check(i))
			{
				declare(i);
				return;
			}
		}

		cout << "UNRESTORABLE" << endl;

	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	vector<int> a(3), b = { 5,5,7 };
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a == b) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define x first
#define y second

int main(){
    int n,K; cin >> n >> K;
    vector<pair<long long,long long> > v(n);
    rep(i,n) cin >> v[i].x >> v[i].y; 
    long long ans = 7999999996000000001;
    rep(i,n) rep(j,n) rep(k,n) rep(l,n){
        long long int upper = v[i].y, lower = v[j].y;
        long long int left = v[k].x, right = v[l].x;
        if(upper < lower || left > right) continue;
        int c = 0;
        rep(m,n){
            if(upper >= v[m].y && lower <= v[m].y && left <= v[m].x && right >= v[m].x) c++;
        }
        if(c >= K){
            ans = min(ans, (upper - lower) * (right - left));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> P(N);
  REP(i, N) cin >> S[i] >> P[i];
  vector<int> p(N);
  REP(i, N) p[i] = i;
  sort(p.begin(), p.end(), [&](int i, int j) {
    if (S[i] != S[j]) return S[i] < S[j];
    return P[i] > P[j];
  });
  for (int x : p) cout << x+1 << '\n';
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
S = input()
K = int(input())

d = sorted(list(S))
x = set(d)
for c in d:
    left = S.index(c)
    while left < len(S):
        if S[left] != c:
            left += 1
            continue
        j = 2
        while j <= K:
            x.add(S[left:left+j])
            j += 1
        left += 1
    if len(x) >= K:
        break
x = sorted(list(x))
print(x[K - 1])

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

int main() {
    long long N;
    cin >> N;
    long long minv = (1LL<<60);
    for (int i = 0; i < 6; i++) {
        long long p;
        cin >> p;
        minv = min(minv, p);
    }
    cout << (N + minv - 1) / minv + 4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;


int main(){
	ll n,x,d; cin >> n >> x >> d;
	if(d == 0){
		if(x == 0) cout << 1 << endl;
		else cout << n + 1 << endl;
		return 0;
	}
	if(d < 0) x = -x, d = -d;
	map<ll,vpl> mp;
	rep(i,n+1){
		ll r = x * i % d;
		if(r < 0) r += d;
		ll q;
		if(x < 0) q = (x * i - d + 1) / d;
		else q = x * i / d;
		mp[r].emplace_back(i*(i-1)/2 + q, (n-1+n-i)*i/2 + q);
	}
	ll ans = 0;
	for(auto &i : mp){
		sort(all(i.second));
		ll now = -linf;
		for(auto j : i.second){
			if(now > j.second) continue;
			ans += j.second - max(j.first, now) + 1;
			now = j.second + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 22144
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int p10[9];
int main()
{
	int num;
	scanf("%d", &num);
	int pt = 0;
	ll rem = 0;
	ll sum = 0;
	ll ans = 0;
	p10[0] = 1;
	for (int i = 1; i < 9; i++)p10[i] = p10[i - 1] * 10;
	for (int i = 1; i <= 8; i++)
	{
		int t = 9 * p10[i - 1];
		for (int j = 0; j < t; j++)
		{
			sum += i;
			for (;;)
			{
				if (sum <= num)break;
				if (rem == 0)
				{
					pt++;
					rem = 9 * p10[pt - 1];
				}
				rem--;
				sum -= pt;
			}
			if (sum == num)ans++;
		}
	}
	ll len = p10[8] * 9;
	for (int i = 9; i <= num; i++)
	{
		if (num%i == 0)ans += len + mod - num / i + 1;
		if (i + i - 1 <= num)
		{
			int t = num - i - i + 1;
			int mini = (i - t % i);
			if (mini == i)mini = 0;
			int ea = (t + mini) / i - mini;
			int ba = t % (i - 1);
			ans += max(0, (ea - ba) / (i - 1) + 1);
		}
		len = len * 10 % mod;
	}
	printf("%lld\n", ans % mod);
}

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

typedef long long ll;

char S[1<<17], T[1<<17];

ll N, M;

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

int main() {
	scanf("%lld%lld", &N, &M);
	scanf("%s%s", S, T);

	ll a = gcd(M, N);
	ll L = N * M / a;

	for (int i = 0; i < a; ++i) if (S[N/a * i] != T[M/a * i]) return printf("-1\n"), 0;
	
	printf("%lld\n", L);
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    int dis[N+1][N+1];
    REP(i, R) {
        cin >> r[i];
    }
    REP(i, N){
        REP(j, N){
            dis[i+1][j+1] = INF;
        }
    }
    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        dis[a][b] = c;
        dis[b][a] = c;
    }


    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                if(dis[i][j] > dis[i][k] + dis[k][j]) dis[i][j] = dis[i][k] + dis[k][j];
            }
        }
    }

    sort(r.begin(), r.end());
    ll ans = INF;
    do {
        ll subAns = 0ll;
        REP(i, R-1){
            subAns += (ll)dis[r[i]][r[i+1]];
        }
        ans = min(ans, subAns);
    } while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    for (int i = 0; i < N; ++i)
    {
        cin >> A[0][i];
    }
    for (int i = 0; i < N; ++i)
    {
        cin >> A[1][i];
    }
    int candy = A[0][0] + accumulate(A[1].begin(), A[1].end(), 0);
    for (int i = 1; i < N; ++i)
    {
        candy = max(candy, accumulate(A[0].begin(), A[0].begin() + i + 1, 0) + accumulate(A[1].begin() + i, A[1].end(), 0));
    }
    cout << candy << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
    llint n, k, ans = 0;
    cin >> n >> k;
    rep(i, n - k + 1) {
        ans = (n-i) * (i + 1) + 1 + ans;
        ans = ans % 1000000007;
    }
    ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3624
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$c=array_count_values($a);
$d=array_count_values($c);
if($d[1]==$n){
  echo str_repeat("0\n",$n);
  exit;
}
$ans=0;
foreach($c as $k => $v){
  $m=$v*($v-1)/2;
  $ans+=$m;
  $map[$k][0]=$m;
  $map[$k][1]=($v-1)*($v-2)/2;
}
$i=0;
while($i<$n){
  echo $ans-$map[$a[$i]][0]+$map[$a[$i]][1]."\n";
  ++$i;
}

Measured memory_bytes: 76144
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
ll	n, k;
struct node{
	ll a, b;
	friend bool operator<(node x, node y){
		return x.a < y.a;
	}	
}num[100005];
int main()
{	
	while (~scanf("%lld%lld", &n, &k))
	{
		ll sum = 0, ans = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%lld%lld", &num[i].a, &num[i].b);
		}
		sort(num, num + n);
		for (int i = 0; i < n; i++)
		{
			sum += num[i].b;
			if (sum >= k)
			{
				ans = num[i].a;
				break;
			}	
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 1920
import math
def gcd(x, y):
  if y == 0:
     return x
  else:
     return gcd(y, x % y)

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 a
    
A, B = map(int, input().split())
gcd_AB = gcd(A, B)
# 素因数分解
p_list = prime_factorize(gcd_AB)
#print(p_list)
print(len(set(p_list))+1)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>

using namespace std;

class sci1
{
private:
   int s[6];
public:
   
   //string hougaku;
   
   void set_scikoro(int* m1);
   void set_up_m(string m2);
   void m_print();
};

void sci1::set_scikoro(int* m1)
{
    int i;

    for ( i = 0; i < 6; ++i){
        s[i]=m1[i];
    }
}

void sci1::set_up_m(string m2)
{
    int i;
    int len_m2;
    int temp1;
    
    len_m2 = m2.length();
    
    for ( i = 0; i < len_m2; ++i){
        if (m2[i]== 'E'){
            temp1 =s[3];
            s[3] = s[5];
            s[5] = s[2];
            s[2] = s[0];
            s[0] = temp1;
            //cout << m2[i] <<endl;
        }else if (m2[i]== 'W'){
            temp1 =s[2];
            s[2] = s[5];
            s[5] = s[3];
            s[3] = s[0];
            s[0] = temp1;
            //cout << m2[i] <<endl;
        }else if (m2[i]== 'S'){
            temp1 =s[0];
            s[0] = s[4];
            s[4] = s[5];
            s[5] = s[1];
            s[1] = temp1;
            //cout << m2[i] <<endl;
        }else if (m2[i]== 'N'){
            temp1 =s[0];
            s[0] = s[1];
            s[1] = s[5];
            s[5] = s[4];
            s[4] = temp1;
            //cout << m2[i] <<endl;
        }
    }
    //cout << s[0] <<endl;
    /*
    for ( i = 0; i < len_m2 ; ++i){
        cout << m2[i] << endl;
    }
    */
    //hougaku = m2[0];
}

void sci1::m_print()
{
    int i;
  
    /*
    for ( i = 0; i < 6 ; ++i){
        cout << s[i] << endl;
    }
    */
    cout << s[0] << endl;
}

int main(){
    int i;
    int m[6];
    string hougaku1;
    
    for ( i = 0; i < 6; ++i){
        cin >> m[i];
    }
    cin >> hougaku1;
   
    sci1 saikoro1;
    
    saikoro1.set_scikoro(m);
    saikoro1.set_up_m(hougaku1);
    saikoro1.m_print();
    
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
long long n, k, have[N];
long long ans;
int main() {
	cin>>n>>k;
	for (int i = 1; i <= n; i++) {
		have[i % k]++;
	}
	for (int i = 0; i < k; i++) {
		if ((k - i) * 2 % k == 0) {
			ans += have[i] * have[(k - i) % k] * have[(k - i) % k];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 1e5+4;

vector<int>g[N];
int n,m,k,used[N],ans[N],j,parent[N],cnt,com[N];

void dfs(int x){
	cnt++;
	used[x]=1;
	parent[x]=j;
	for(auto i:g[x]){
		if(!used[i])
			dfs(i);
	}
}

void solve(){
	cin>>n>>m>>k;
	for(int i=0;i<m;++i){
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	j=1;
	for(int i=1;i<=n;++i){
		if(!used[i]){
			dfs(i);
			com[j]=cnt;
			cnt=0;
			j++;
		}
	}
	for(int i=1;i<=n;++i){
		ans[i]=com[parent[i]]-sz(g[i])-1;
	}
	for(int i=0;i<k;++i){
		int c,d;
		cin>>c>>d;
		if(parent[c]==parent[d]){
			ans[c]--;
			ans[d]--;
		}
	}
	for(int i=1;i<=n;++i){
		cout<<ans[i]<<' ';
	}

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 10692
N = int(input())
A = [input().split() for _ in range(2)]
candies = 0
for j in range(N):
    temp = 0
    for cur1 in range(j+1 if j < N else N):
        temp += int(A[0][cur1])
    for cur2 in range(j,(N if j < N else N+1)):
        temp += int(A[1][cur2])
    if candies < temp:
        candies = temp
print(candies)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>

const int N_MAX = 100;
const int W_MAX = 10000;

// DP table
// dp[i][w] -> [1:i]から重量w以下でとれる最大value
// dp[N][W] -> 解
int dp[N_MAX+1][W_MAX+1]; // グローバル配列の中身は0で初期化されているらしい

int main(){
  int N,W;
  int w[N_MAX+1],v[N_MAX+1];
  scanf("%d %d",&N,&W);
  for(int i=1;i<=N;i++){scanf("%d %d",&v[i],&w[i]);} v[0] = 0; w[0] = 0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=W_MAX;j++){
      if(j<w[i]){
        dp[i][j] = dp[i-1][j];
        continue;
      }
      //dp[i-1][j] ... i番目は取らない場合の最大value
      dp[i][j] = std::max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
  }
  printf("%d\n",dp[N][W]);
}


Measured memory_bytes: 6668
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $x);

$box = $a * $a * $b;

if($box/2 === $x) {
    echo '45.0000000000'.PHP_EOL;
} elseif($box/2 > $x) {//容量が半分より少ない場合
    $long = ($x * 2 / $a / $b);
    echo sprintf("%.10f",rad2deg(atan($b/$long))).PHP_EOL;
} else {
    $long = (($box-$x) * 2 / $a / $a);
    echo sprintf("%.10f",rad2deg(atan($long/$a))).PHP_EOL;
}


Measured memory_bytes: 4604
import java.util.HashMap;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var x = sc.next();
		sc.close();

		var count = (int) IntStream.range(0, n).filter(i -> x.substring(i, i + 1).equals("1")).count();
		var modCalc1 = new Main().new ModCalc(count - 1);
		var modCalc2 = new Main().new ModCalc(count + 1);
		var sum1 = 0;
		var sum2 = 0;
		if (count - 1 > 0) {
			for (var i = x.length() - 1; i >= 0; i--) {
				if (x.substring(i, i + 1).equals("1")) {
					sum1 = modCalc1.add(sum1, (int) modCalc1.pow(2, x.length() - 1 - i));
					sum2 = modCalc2.add(sum2, (int) modCalc2.pow(2, x.length() - 1 - i));
				}
			}
		}

		var map = new HashMap<Integer, Integer>();
		for (var i = 0; i < n; i++) {
			var result = 0;
			var bit = x.substring(i, i + 1).equals("1");
			if (!(bit && count == 1)) {
				var fc = 0;
				if (bit) {
					fc = modCalc1.subtract(sum1, modCalc1.pow(2, x.length() - 1 - i));
				} else {
					fc = modCalc2.add(sum2, modCalc2.pow(2, x.length() - 1 - i));
				}
				result++;
				while (fc > 0) {
					fc = f(fc, map);
					result++;
				}
			}
			System.out.println(result);
		}
	}

	private static int f(int n, HashMap<Integer, Integer> map) {
		if (map.containsKey(n)) {
			return map.get(n);
		}

		var count = 0;
		var bits = new Main().new BitConv().getBits(n);
		for (var i = 0; i < bits.length; i++) {
			if (bits[i]) {
				count++;
			}
		}
		var result = n % count;
		map.put(n, result);
		return result;
	}

	public class ModCalc {
		int mod;

		public ModCalc(int mod) {
			this.mod = mod;
		}

		public int add(int a, int b) {
			return (int) (((long) a + b) % mod);
		}

		public int subtract(int a, int b) {
			return (int) (((long) a - b + mod) % mod);
		}

		public int multiply(int a, int b) {
			return (int) (((long) a * b) % mod);
		}

		public int pow(int n, int k) {
			if (k == 0) {
				return 1;
			} else if (k % 2 == 0) {
				int p = pow(n, k / 2);
				return multiply(p, p);
			} else {
				int p = pow(n, (k - 1) / 2);
				return multiply(multiply(p, p), n);
			}
		}
	}

	public class BitConv {
		public boolean[] getBits(int n) {
			var bits = new boolean[32];
			for (int i = 0; i < 32; i++) {
				bits[i] = getBit(n, i);
			}
			return bits;
		}

		public int getInt(boolean[] bits) {
			var value = 0;
			for (int i = 0; i < 32; i++) {
				value += bits[i] ? Math.pow(2, i) : 0;
			}
			return value;
		}

		public boolean getBit(int n, int d) {
			return ((n % (int) Math.pow(2, d + 1)) / ((int) Math.pow(2, d))) != 0;
		}
	}
}


Measured memory_bytes: 66404
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int main()
{
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        cout << "x";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x, y;
    if(a%d == 0) x = a/d;
    else x = a/d + 1;

    if(c%b == 0) y = c/b;
    else y = c/b + 1;

    if(y <= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    //cout << x << " " << y << endl;
}


Measured memory_bytes: 3508