akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll n,d,p,dp[100005][105][2];
string arr;

ll dfs(ll x,ll sum,ll f)
{
	ll ans=0,i,l;
	if(x==arr.size())
	{
		if(sum%d==0) 
			return 1;
		return 0;
	}
	if(dp[x][sum][f]!=-1)
		return dp[x][sum][f];
	if(f==1)
	{
		ans=dfs(x+1,(sum+(arr[x]-48))%d,1);
		for(i=0;i<arr[x]-48;i++)
			ans=(ans+dfs(x+1,(sum+i)%d,0))%MOD;
	}
	else
	{
		for(i=0;i<=9;i++)
			ans=(ans+dfs(x+1,(sum+i)%d,0))%MOD;		
	}	
	dp[x][sum][f]=ans%MOD;
	return dp[x][sum][f];
}

int main()
{
	boost
	memset(dp,-1,sizeof(dp));
	cin>>arr>>d;
	dp[0][0][0]=dfs(0,0,1)%MOD;
	cout<<(dp[0][0][0]-1+MOD)%MOD;
	return 0;
}

Measured memory_bytes: 165120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int N, K;
int V[55];
 
int ans = 0 ;
 
int main() {
    ios_base::sync_with_stdio(false);
 
    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> V[i];
 
    for(int l = 0; l <= N; l++) {
        for(int r = 0; l + r <= N && l + r <= K; r++) {
            vector <int> s;
            for(int i = 0; i < l; i++)
                s.push_back(V[i]);
            for(int i = 0; i < r; i++)
                s.push_back(V[N - 1 - i]);
            sort(s.begin(), s.end());
            int sum = accumulate(s.begin(), s.end(), 0);
            for(int i = 0; i < s.size() && i < K - l - r; i++) {
                if (s[i] >= 0)
                    break;
                sum -= s[i];
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
string s; cin >> s;
if(s == "BBB" || s== "AAA"){
	cout <<  "No" << "\n";
}else{
	cout << "Yes" << "\n";
}


}


Measured memory_bytes: 3640
#include <stdio.h>

void check(int x) {
	int i = x;
	while (1) {
		if (i % 10 == 3) {
			printf(" %d", x);
			return;
		}
		if (i / 10 == 0) return;
		i /= 10;
	}
}

int main(void) {
	int s, i;
	scanf("%d", &s);
	for (i = 1; i <= s; i++)
	{
		if (i % 3 == 0) printf(" %d", i);
		else check(i);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main() {
    ll n,a = 0; cin >> n;
    ll sum = 0;

    queue<ll> q;
    while(1){
        a ++;
        sum += a;
        q.push(a);
        if(sum >= n){
            break;
        }

    }

    while(!q.empty()){
        if(!(q.front() == sum - n)) cout << q.front() << endl;
        q.pop();
    }

    return 0;
}


Measured memory_bytes: 3616
#import sys
#input = sys.stdin.readline
from collections import defaultdict
from bisect import bisect_left
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    A.sort()
    aaa = [0]*(10**5+1)
    d = defaultdict(int)
    appA = [0]*(N+1)
    for i in range(N,0,-1):
        appA[i-1] = A[i-1] + appA[i]
#    print(appA)
    for a in A:
        aaa[a] += 1
        d[a] += 1
    for i in range(10**5, 0, -1):
        aaa[i-1] += aaa[i]
    l = 0
    r = 2*10**5+1
    while r - l > 1:
        m = (l+r)//2
        check = True
        cnt = 0
        for k, v in d.items():
            if m - k > 10**5:
                continue
            cnt += v*aaa[max(m-k, 0)]
#        print(m, cnt, l ,r)
        if cnt >= M:
            l = m
        else:
            r = m
    ans = 0
    m = 0
    for k, v in d.items():
        if l - k > 10**5:
            continue
        if k + A[-1] < l:
            continue
        ans += k*v*(N - bisect_left(A, l-k))+appA[ bisect_left(A, l-k)]*v

        m += v*(N - bisect_left(A, l-k))
    if m > M:
        ans -= l*(m-M)
    print(ans)
if __name__ == '__main__':
    main()


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

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

  rep(i, S.size()){
    S[i] = 'x';
  }

  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e16;

signed main(){
  int N, K; cin >> N >> K;
  int ans;
  if(K == 1) ans = 0;
  if(N > K){
    int x = N/K;
    N -= x * K;
    ans = min(N, K - N);
  } 
  if(N < K) ans = min(N, K - N);
  if(N == K) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n),gcd1(n),gcd2(n);
	deque<int>b;
	rep(i, n) {
		cin >> a[i];
	}
	int tmp = a[0];
	rep(i, n) {
		tmp = GCD(tmp, a[i]);
		gcd1[i] = tmp;
	}
	tmp = a[a.size() - 1];
	for(int i=a.size()-1; i>0;i--) {
		tmp = GCD(tmp, a[i]);
		gcd2[i] = tmp;
	}
	int ans = 0;
	FOR(i,1, n-1) {
		int tmpa = GCD(gcd1[i - 1], gcd2[i + 1]);
		ans = max(ans, tmpa);
	}
	if (a.size() >= 2) {
		ans = max(ans, gcd1[a.size() - 2]);
	}
	if (a.size() > 1) {
		ans = max(ans, gcd2[1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
function Main(input){
  
  input = input.split(" ");
  const A = parseInt(input[0],10);
  const B = parseInt(input[1],10);
  let K = parseInt(input[3],10);
  
  if( A >= K ){
  	console.log(K);
  }else if( A + B >= K){
  	console.log(A);
  }else{
  	K = K - A - B;
    console.log(A - K);
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  int a, b;
  char op;
  vector<int> vec;

  while (true)
  {
    cin >> a >> op >> b;
    if (op == '?')
    {
      break;
    }

    int num;

    if (op == '+')
    {
      num = a + b;
    }
    else if (op == '-')
    {
      num = a - b;
    }
    else if (op == '*')
    {
      num = a * b;
    }
    else
    {
      num = a / b;
    }

    vec.push_back(num);
  }

  for (auto &&i : vec)
  {
    printf("%d\n", i);
  }
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF=1e16;
const int MAXN=69,MAXS=25e2+69;
struct vl{
	int x,y,z;
	bool operator<(const vl& oth)const{
		if(x==oth.x&&y==oth.y)return z<oth.z;
		if(x==oth.x)return y<oth.y;
		return x<oth.x;
	}
};
int n,m,S;
vector<vl>g[MAXN];
vl shop[MAXN];
int kc[MAXN][MAXS];
void ditcha(int u){
	for(int i=1;i<=n;i++){
		for(int j=0;j<MAXS;j++)kc[i][j]=INF;
	}
	set<vl>s;
	int i=0;
	while(1){
		int c=S+i*shop[u].x,br=0;
		if(c>=MAXS-1)br=1,c=MAXS-1;
		kc[u][c]=i*shop[u].y;
		s.insert({kc[u][c],u,c});
		i++;
		if(br)break;
	}
	while(!s.empty()){
		int u=(*s.begin()).y;
		int c=(*s.begin()).z;
		s.erase(s.begin());
		for(vl i:g[u]){
			int v=i.x,a=i.y,b=i.z;
			if(c-a<0)continue;
			int j=0;
			while(1){
				int d=c-a+j*shop[v].x,br=0;
				if(d>=MAXS-1)br=1,d=MAXS-1;
				if(kc[v][d]>kc[u][c]+b+j*shop[v].y){
					if(kc[v][d]!=INF)s.erase({kc[v][d],v,d});
					kc[v][d]=kc[u][c]+b+j*shop[v].y;
					s.insert({kc[v][d],v,d});
				}
				j++;
				if(br)break;
			}
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>S;
	for(int i=1,u,v,a,b;i<=m;i++){
		cin>>u>>v>>a>>b;
		g[u].push_back({v,a,b});
		g[v].push_back({u,a,b});
	}
	for(int i=1;i<=n;i++)cin>>shop[i].x>>shop[i].y;
	ditcha(1);
	for(int v=2;v<=n;v++){
		int res=INF;
		for(int i=0;i<MAXS;i++)res=min(res,kc[v][i]);
		cout<<res<<'\n';
	}
}

Measured memory_bytes: 12384
// AOJ 1178 A Broken Door
// 2018.4.24 bal4u

#include <stdio.h>
#include <string.h>

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}
 
#define INF 0xff
typedef unsigned char uchar;

typedef struct { uchar r, c, t; } QUE;
QUE que[905]; int top, end;
uchar hi[30][30], tr[30][30][4], tc[30][30][4];
uchar dist[30][30], cost[30][30], cost2[30][30];

int calc(int h, int w)
{
	int i, r, c, t, nr, nc;
	int ll, rr, mi;

	ll = cost[0][0], rr = INF;
	while (ll+1 < rr) {
		mi = (ll+rr) >> 1;

		memset(dist, INF, sizeof(dist));
		dist[0][0] = 0;
		que[0].r = 0, que[0].c = 0, que[0].t = 0, top = 0, end = 1;
		while (top != end) {
			r = que[top].r, c = que[top].c, t = que[top++].t;
			if (r == h && c == w) break;
			if (dist[r][c] < t) continue;
			for (i = 0; i < hi[r][c]; i++) {
				nr = tr[r][c][i], nc = tc[r][c][i];
				if (cost[nr][nc] + t+1 >= mi) continue;
				if (dist[nr][nc] > t+1)	{
					dist[nr][nc] = t+1;
					que[end].r = nr, que[end].c = nc, que[end++].t = t+1;
				}
			}
		}
		if (dist[h][w] < INF) rr = mi; else ll = mi;
	}
	if (rr == INF) rr = -1;
	return rr;
}

int main()
{
	int h, w, r, c, t, i;
	int r0, c0, nr, nc;

	while (h = in()) {
		w = in();
		memset(hi, 0, sizeof(hi));

		for (r = 0; r < h; r++) {
			for (c = 1; c < w; c++) if (in() == 0) {
				t = hi[r][c-1]++, tr[r][c-1][t] = r, tc[r][c-1][t] = c;
				t = hi[r][c  ]++, tr[r][c  ][t] = r, tc[r][c  ][t] = c-1;
			}
			if (r == h-1) break;
			for (c = 0; c < w; c++) if (in() == 0) {
				t = hi[r  ][c]++, tr[r  ][c][t] = r+1, tc[r  ][c][t] = c;
				t = hi[r+1][c]++, tr[r+1][c][t] = r,   tc[r+1][c][t] = c;
			}
		}

		memset(cost,  INF, sizeof(cost));
		memset(cost2, INF, sizeof(cost2));
		for (r0 = 0; r0 < h; r0++) for (c0 = 0; c0 < w; c0++) {
			memset(dist, INF, sizeof(dist));
			dist[h-1][w-1] = 0;
			que[0].r = h-1, que[0].c = w-1, que[0].t = 0, top = 0, end = 1;
			while (top != end) {
				r = que[top].r, c = que[top].c, t = que[top++].t;
				if (r == r0 && c == c0) continue;
				if (dist[r][c] < t) continue;
				for (i = 0; i < hi[r][c]; i++) {
					nr = tr[r][c][i], nc = tc[r][c][i];
					if (dist[nr][nc] > t+1) {
						dist[nr][nc] = t+1;
						que[end].r = nr, que[end].c = nc, que[end++].t = t+1;
					}
				}
			}
			for (i = 0; i < hi[r0][c0]; i++) {
				nr = tr[r0][c0][i], nc = tc[r0][c0][i];
				if (cost[r0][c0] > dist[nr][nc]) {
					cost[r0][c0] = dist[nr][nc];
					if (cost[r0][c0] < cost2[r0][c0]) {
						t = cost[r0][c0];
						cost[r0][c0] = cost2[r0][c0];
						cost2[r0][c0] = t;
					}
				}
			}
		}
		cost[h-1][w-1] = 0;
		printf("%d\n", calc(h-1, w-1));
	}
	return 0;
}


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

using namespace std;

int main() {
  string n;
  cin >> n;
  
  for (char i : n) {
  	int digit = i - 48;
    
    if (digit == 9)
      cout << "1";
     else if (digit == 1)
       cout << "9";
  }
  
  cout << "\n";
  
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
using namespace std;
long long int gcd(long long int x,long long int  y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
IOS;
ll n;
cin>>n;
ll arr[n],sum=0,cur=0;
for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
}
for(int i=0;i<n-1;i++){
    sum-=arr[i];
    cur+=(arr[i]%1000000007)*(sum%1000000007);
    cur%=1000000007;
}
cout<<cur;
return 0;
}
/*sjleepy*/

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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int h,w;
string s;

int main(){
  cin >>h>>w;
  REP(i,h){
    cin >> s;
    cout << s<<endl<<s<<endl;
  }
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, M;
ll accepted, pen, val;
string S = "";
map<ll, string> mp;
map<ll, ll> mp1;

int main() {
	scanf("%lld %lld", &N, &M);
	for(int i = 0; i < M; i++) {
		scanf("%lld", &val);
		cin >> S;
		if(mp[val] == "WA") {
			mp[val] = S; 
			if(S == "AC") {
				accepted++;
				pen += mp1[val];
			}
			else {
				mp1[val]++;
			}
			// pen++;
		}
		else if(mp[val] == "AC") {
			continue;
		}
		else {
			mp[val] = S;
			if(S == "AC") {
				accepted++;
			}
			else {
				mp1[val]++;
			}
		}
	}
	printf("%lld %lld\n", accepted, pen);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a + b == 15)
    {
        printf("+\n");
    }
    else if(a * b == 15)
    {
        printf("*\n");
    }
    else
    {
        printf("x\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
vector<pair<uint, uint>> d;
// vector<pair<ll, ll>> d;
 
int main(int, char**)
{
	unsigned int n;
	ll t = 0;
	cin >> n;
	d.resize(n);
 
	for (unsigned int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		d[i].first = a + b;
		d[i].second = a;
	}
 
	sort(d.begin(), d.end(), greater<>());
 
	for (unsigned int i = 0; i < n; i++) {
        t += d[i].second;
		if (i % 2 != 0) t -= d[i].first;
	}
 
    cout << t << endl;
	return 0;
}

Measured memory_bytes: 1024
import fractions
n = int(input())
a = list(map(int,input().split()))

def lcm(x,y):
    return (x * y) // fractions.gcd(x, y)

val = a[0]
for i in range(1,n):
    val = lcm(val,a[i])

ans = 0
for i in range(n):
    ans += val // a[i]
print(ans % (10**9+7))

Measured memory_bytes: 6112
//
//  main.cpp
//  ABC159B
//
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    string S;
    cin>>S;
    unsigned long N=S.length();
    if (N==3) { // aba
        if (S.at(0)!=S.at(2)) {
            cout<<"No"<<endl;
            return 0;
        }
            cout<<"Yes"<<endl;
            return 0;
    }
    if (N==5) { // aabaa
        if (S.at(0)!=S.at(1)||S.at(3)!=S.at(4)||S.at(0)!=S.at(4)) {
            cout<<"No"<<endl;
            return 0;
        }
            cout<<"Yes"<<endl;
            return 0;
    }
    // abacaba
    unsigned long first=(N-1)/2;
    unsigned long step=(first-1)/2;
    for (unsigned long i=0; i<step; i++) {
        if(S.at(i)!=S.at(first-1-i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    unsigned long second=(N+3)/2;
    for (unsigned long j=0; j<step; j++) {
        if(S.at(second-1+j)!=S.at(N-1-j)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for (unsigned long k=0; k<first; k++) {
        if (S.at(k)!=S.at(N-1-k)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
        cout<<"Yes"<<endl;
        return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, e int
	fmt.Scan(&n)

	min, max := 1001, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&e)
		if min > e {
			min = e
		}
		if max < e {
			max = e
		}
	}

	fmt.Println(max - min)
}

Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

N, Q = map(int, input().split())
C = list(map(int, input().split()))

by_R = [[] for _ in range(N+1)]
for i in range(Q):
	l, r = map(lambda s: int(s)-1, input().split())
	by_R[r+1].append((l, i))

s = [0] * N
def update(pos, dif):
	while pos < N:
		s[pos] += dif
		pos |= pos + 1

def query(pos):
	res = 0
	while pos > 0:
		res += s[pos-1]
		pos &= pos - 1
	return res

diff = 0
ans = [-1] * Q
last = [-1] * (N+1)

for i, v in enumerate(C):
	if last[v] != -1:
		update(last[v], -1)
	else:
		diff += 1

	update(i, 1)
	last[v] = i

	for l, j in by_R[i+1]:
		ans[j] = diff - query(l)

print('\n'.join(map(str, ans)))


Measured memory_bytes: 208636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(long long A, long long B, long long C){
	ll res = 0;
	res = C-(A-B);
	if (res<0) res = 0;
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOOP(val, times)   for(val = 0; val < (times); val++)
int main(){
  int n;
  cin>>n;
  set<int> nn;
  int i;
  LOOP(i,n){
    int s;
    cin>>s;
    nn.insert(s);
  }
  int m;
  cin>>m;
  vector<int> mm(m);
  LOOP(i,m){
    cin>>mm[i];
  }
  int ans=0;
  LOOP(i,m){
    if(nn.count(mm[i])){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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


int main() {
  int n; cin >> n;
  int sum=0,maxl=0;
  for (int i=0;i < n;i++) {
    int l; cin >> l;
    sum += l;
    maxl = max(maxl,l);
  }

  if (maxl < sum - maxl) cout << "Yes";
  else cout << "No";
  cout << endl;

}


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

int main(){
  int n;
	
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++)
    cin >> p.at(i);
  int count=0;
  for(int i=1;i<n-1;i++){
    if(min(p.at(i-1),p.at(i)) == p.at(i)){
      if(min(p.at(i+1),p.at(i)) == p.at(i+1))
        count ++;
    }
    else{
      if(min(p.at(i+1),p.at(i)) == p.at(i))
        count ++;
    }    
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
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;}

int n;
string s;
int main(){
	cin >> n >> s;
	vector<ll> a(3, 0);
	rep(i ,0, n) a[s[i]%3]++;
	
	ll U = a[0] * a[1] * a[2];
	ll A = 0;
	rep(j, 0, n) rep(i, 0, j){
		int k = 2*j - i;
		if(k >= n) continue;
		if(s[i] == s[j] || s[i] == s[k] || s[k] == s[j]) continue;
		A++;
	}
	
	cout <<	U-A << endl;
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr ll INF = 1'000'000'007;

typedef std::vector<ll> Row;
typedef std::vector<Row> Table;
Table dp;

ll combination(ui n, ui k)
{
  if (n < k) return 0;
  k = std::min(k, n - k);

  assert(k <= n / 2);
  if (dp[n][k] == -1)
  {
    if (!k || !n)
      dp[n][k] = 1;
    else
      dp[n][k] = (combination(n - 1, k - 1) + combination(n - 1, k)) % INF;
  }
  return dp[n][k];
}

void solve(void)
{
  ui N{}, K{}; std::cin >> N >> K;
  dp = Table(std::max(N - K + 1, K - 1) + 1);
  rep(0, dp.size()) dp[i] = Row(i / 2 + 1, -1);

  rep(1, K + 1)
  {
    auto ans = (combination(N - K + 1, i) * combination(K - 1, i - 1)) % INF;
    std::cout << ans << "\n";
  }

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main(void){
  string w;
  cin >> w;
  vector<int> a(26, 0);
  for(int i = 0; i < w.length(); i++){
    char temp = w[i];
    a[temp - 'a']++;
  }
  bool flag = true;
  for(int i = 0; i < 26; i++){
    if(a[i] % 2 == 1){
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s;
  cin >> s;
  ll bnum = count(s.begin(), s.end(), 'B');
  char cset[bnum] = {};
  ll cnt = 0;

  for(char c: s) {
    if (c == 'B') cnt = max(0ll, cnt-1);
    else {
      cset[cnt] = c;
      cnt++;
    }
  }

  rep(i, cnt) cout << cset[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=998244353,MAX=1e5+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int n;
    cin>>n;
    int a[n];
    lp(i,0,n)
        cin>>a[i];
    int cnt=0;
    lp(i,0,n){
        lp(j,i+1,n){
            lp(k,j+1,n){
                if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])
                    cnt++;
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k; cin >> n >> k;
	vint a(n);
	vint win(k+1, 0);
	
	fori(n) {	
		cin >> a[i];
		win[a[i]] = 1;
	}	

	fori(k+1) {
		if (!win[i]) {
			forj(n) {
				if (i-a[j] >= 0) win[i] |= (!win[i-a[j]]);
			}
		}
	}
	if (win[k]) {
		cout << "First" << nl;
	} else {
		cout << "Second" << nl;
	}
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let mut ls = read_vec::<usize>();

    ls.sort();
    ls.reverse();



    let mut count = 0;

    for i in 0..n {
        let a = ls[i];
        for j in i+1..n {
            let b = ls[j];
            let mut lo = j+1;
            let mut hi = n-1;
            let threshold = a - b;
            let mut cur = n;

            while lo <= hi {
                let mid = (hi+lo) / 2;
                let c = ls[mid];
                match c {
                    c if threshold < c => {
                        cur = mid;
                        lo = mid+1;
                    },
                    _ => {
                        hi = mid-1;
                    }
                }

            }

            if cur != n {
                count += cur - j;
            }

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



Measured memory_bytes: 4352
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    cout << (v[0] * v[1])/2;
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
const int MOD=1e9+7;
typedef long long LL;
int f[N],n,a[N],inv[N];
LL ans;

int ksm(int a,int b)
{
	int ret=1;
	for (;b;b>>=1,a=(LL)a*a%MOD)
		if (b&1) ret=(LL)ret*a%MOD;
	return ret;	
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	inv[1]=1;
	for (int i=2;i<=n+1;i++) inv[i]=(LL)(MOD-MOD/i)*inv[MOD%i]%MOD;
	for (int i=1;i<=n;i++) f[i]=(f[i-1]+inv[i+1])%MOD;
	for (int i=1;i<=n;i++) ans=(ans+(LL)a[i]*(f[i-1]+f[n-i]+1LL))%MOD;
	for (int i=1;i<=n;i++) ans=ans*i%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
    cin>>a;
    if(a[i]=='S')
    {
        cout<<"Cloudy"<<endl;
    }
    else if(a[i]=='C')
    {
       cout<<"Rainy"<<endl; 
    }
    else
    {
        cout<<"Sunny"<<endl; 
    }

    return 0;
}


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

vector<int> KaoRou;//烤肉串上的烤肉
priority_queue<int,vector<int>,greater<int> > Pan;//盘中的烤肉

int QuKaoRou(int A,int B,int C){
    int sum=0;
    int n=KaoRou.size();
    for(int i=0;i<A;i++){
        sum+=KaoRou[i];
        Pan.push(KaoRou[i]);
    }
    for(int j=0;j<B;j++){
        sum+=KaoRou[n-1-j];
        Pan.push(KaoRou[n-1-j]);
    }
    if(Pan.size()==0)//如果没取烤肉下来
        return 0;
    for(int i=0;i<C;i++){
        int reminder=Pan.top();
        Pan.pop();
        if(reminder>=0 || Pan.size()==0)//如果盘中最小值大于0，不再取出
            break;
        sum-=reminder;
    }
    return sum;
}

int main()
{  
    int N,K;
    while(cin>>N>>K){
        KaoRou.clear();
        int V;
        for(int i=0;i<N;i++){
            cin>>V;
            KaoRou.push_back(V);
        }
        int sum=0;
        int n=min(N,K);
        for(int A=0;A<=n;A++){//A代表从左边拿烤肉的次数
            for(int B=0;B<=n;B++){//B代表从右边拿烤肉的次数
                if(A+B>n)
                    continue;
                int C=K-A-B;//C表示可以从盘子中取走烤肉的次数
                sum=max(sum,QuKaoRou(A,B,C));
                int n_P=Pan.size();
                for(int i=0;i<n_P;i++){//已经知道最大值了，清空盘子
                    Pan.pop();
                }
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    int a;
    vector<int> score(N,0);
    for(int i=0;i<Q;i++){
        cin >> a;
        score[a-1]++;
    }
    for(int i=0;i<N;i++){
        //cerr << K-Q+score[i] ;
        if(K-Q+score[i]>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 11:33:13 2020

@author: liang
"""

L, R = map(int,input().split())
r = R%2019
l = L%2019
ans = 2018
if R - L >= 2019 - l or l==0:
#if r < l or l == 0:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
print(ans)

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

map<li, li> cnt;

int main() {
    li n;
    cin >> n;
    li sum = 0;
    rin{
        li a;
        cin >> a;
        sum += a;
        cnt[a]++;
    }
    li q;
    cin >> q;
    rep(i, q) {
        li b, c;
        cin >> b >> c;
        if (cnt.count(b) > 0) {
            sum += cnt[b] * (c - b);
            li num = cnt[b];
            cnt.erase(b);
            cnt[c] += num;
        }
        cout << sum << endl;
    }


    return 0;
}

Measured memory_bytes: 7512
#include <bits/stdc++.h>
using namespace std;
 
inline long gcc(int a, int b, int c)
{
	int n = 2;
	int v = 1;
	while(n <= a && n <= b && n <= c){
		if(a % n == 0 && b % n == 0 && c % n == 0){
			a /= n;
			b /= n;
			c /= n;
			v *= n;
		}else{
			n++;
		}
	}
	
	return v;
}
 
int main() 
{
	int K;
	cin >> K;
	
	long sum = 0;
	
	for(int a = 1; a <= K; a++){
      for(int b = 1; b < a; b++){
        for(int c = 1; c < b; c++){
            sum += 6 * gcc(a, b, c);
        }
      }
	}
 
	for(int a = 1; a <= K; a++){
      for(int b = 1; b <= K; b++){
        	if(a==b) continue;
            int c = b;
            sum += 3 * gcc(a, b, c);
      }
	}
 
	for(int a = 1; a <= K; a++){
	  int b = a;
	  int c = b;
      sum += gcc(a, b, c);
	}
 
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3632
s = input()

a = int(s[:2])
b = int(s[2:])

def is_month(value):
    if value != 0 and value <= 12:
        return True
    else:
        return False

if is_month(a) and is_month(b):
    print("AMBIGUOUS")
elif not is_month(a) and not is_month(b):
    print("NA")
else:
    if is_month(a):
        print("MMYY")
    else:
        print("YYMM")

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

int a[50];
int b[50];
int c[50];
int d[50];
int n,m,q;

int ans = 0;

void dfs(vector<int>&vec){


    if(vec.size() == n){
        int tmp = 0;
        for(int i=0;i<q;i++){
            if(vec[b[i]-1] - vec[a[i]-1] == c[i])tmp+=d[i];            
        }
        ans = max(ans,tmp);
    }else if(vec.size() > 0){
        for(int i=vec[vec.size()-1];i<=m;i++){
            vec.push_back(i);
            dfs(vec);
            vec.pop_back();
        }
    }else{
        for(int i=1;i<=m;i++){
            vec.push_back(i);
            dfs(vec);
            vec.pop_back();
        }
    }

}


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

    for(int i=0;i<q;i++)cin >> a[i] >> b[i] >> c[i] >> d[i];
    
    vector<int>vec;

    dfs(vec);
    

    cout << ans << endl;
    

}

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

int main() {
	
	ll a, b;
	cin >> a >> b;
	
	if(a==1 || b==1){
		puts("1");
		return 0;
	}
	
	if(a < b) swap(a, b);
	
	ll r;
	r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
	
	set<ll> s; 
	ll i = 2LL;
	while(b >= i * i){
		if(b % i == 0){
			s.insert(i);
			b /= i;
		}else{
			i++;
		}
	}
	s.insert(b);
	cout << s.size()+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=12;
char s[maxn];
int N;
long long ans;
void dfs(int x,long long v,long long sum){
	if(x==N+1){
		if(!v)
			ans+=sum+v;
		return;
	}
	dfs(x+1,v*10+s[x]-'0',sum);
	dfs(x+1,0,sum+v*10+s[x]-'0');
}
int main(){
	//freopen("in","r",stdin);
	scanf("%s",s+1);
	N=strlen(s+1);
	dfs(1,0,0);
	printf("%lld\n",ans);
	return 0;
}



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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif*/
	lld h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << ((h2 * 60) + (m2)) - ((h1 * 60) + m1) - k << endl;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
struct Edge {
	int from, to, cost;

	bool operator<(Edge e) {
		return cost < e.cost;
	}
};

int N, M;
vvi s;

bool check(vvi sport, int K) {
	
	//cout << "K: " << K << endl;

	vi cur(N, 0);
	vb ban(M, false);
	int cnt = 0;
	while (cnt < N) {
		vi num(M, 0);

		rep(i, N) {
			num[sport[i][cur[i]]]++;
		}
		rep(i, M) {
			if (num[i] > K) {
				ban[i] = true;
			}
		}
		/*
		cout << "cur: ";
		rep(i, N) {
			cout << cur[i] << " ";
		}
		cout << endl;
		cout << "num: ";
		rep(i, M) {
			cout << num[i] << " ";
		}
		cout << endl;
		*/
		bool flag = true;
		rep(i, N) {
			if (num[sport[i][cur[i]]] > K) {
				flag = false;
				while (cur[i] < M && ban[sport[i][cur[i]]])cur[i]++;
				if (cur[i] >= M)return false;
			}
		}
		if (flag) {
			return true;
		}
	}
	return false;
}

int main() {
	cin >> N >> M;
	s = vvi(N, vi(M));
	rep(i, N) {
		rep(j, M) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	int ok = N, ng = 0;
	while (ok - ng > 1) {
		int m = (ok + ng) / 2;
		if (check(s, m)) {
			ok = m;
		}
		else {
			ng = m;
		}
	}
	cout << ok << endl;
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
		    if( i * j == N){
               cout << "Yes" << endl;
               return 0;
            }
		}
	}				
	cout << "No" << endl;		
	return 0;
}


Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n, d;
    cin >> n >> d;

    vvec<int> positions(n, vec<int>(d));

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

    auto check = [](vector<int> a, vector<int> b) 
    {
        ll sqrDist{};

        for (int i = 0; i < a.size(); ++i)
            sqrDist += (a[i] - b[i]) * (a[i] - b[i]);

        for (int i = 1; i * i <= sqrDist; ++i)
        {
            if (i * i == sqrDist)
                return true;
        }

        return false;
    };

    int ans{};

    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
        {
            if (check(positions[i], positions[j]))
                ++ans;
        }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

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

	ll ans = 1000000000001;
	for (ll i = 1; i <= sqrt(n)+1; i++) {
		if (n % i == 0) {
			ll j = n / i;
			ans = min(ans, i + j - 2);
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)

int main() {
    ll s = 0, n;
    cin >> n;
    rep(i, n) {
        ll t = i + 1;
        if (t % 3 && t % 5)s += t;
    }
    cout << s << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    while (1)
    {
        int h, w;
        cin >> w >> h;
        if (w == 0 && h == 0)
        {
            return 0;
        }
        int grid[h][w][4]; // 1が通行可能
        vector<vector<int>> score(h, vector<int>(w, INF));
        for (int i = 0; i < (2 * h) - 1; i++)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < w - 1; j++)
                {
                    int num;
                    cin >> num;
                    if (num == 0)
                    {
                        grid[i / 2][j][1] = 1;
                        grid[i / 2][j + 1][3] = 1;
                    }
                    else
                    {
                        grid[i / 2][j][1] = 0;
                        grid[i / 2][j + 1][3] = 0;
                    }
                }
            }
            else
            {
                for (int j = 0; j < w; j++)
                {
                    int num;
                    cin >> num;
                    if (num == 0)
                    {
                        grid[i / 2][j][2] = 1;
                        grid[(i / 2) + 1][j][0] = 1;
                    }
                    else
                    {
                        grid[i / 2][j][2] = 0;
                        grid[(i / 2) + 1][j][0] = 0;
                    }
                }
            }
        }

        queue<P> qe;
        qe.push(make_pair(0, 0));
        score[0][0] = 0;
        while (!qe.empty())
        {
            P now = qe.front();
            qe.pop();
            int x = now.first;
            int y = now.second;
            int xs[4] = {0, 1, 0, -1};
            int ys[4] = {-1, 0, 1, 0};
            for (int i = 0; i < 4; i++)
            {
                // 進む権利があるかを確認

                if (grid[y][x][i] == 0)
                {
                    continue;
                }
                int nx = x + xs[i];
                int ny = y + ys[i];
                if (nx < 0 || ny < 0 || ny >= h || nx >= w)
                {
                    continue;
                }
                if (score[ny][nx] <= score[y][x] + 1)
                {
                    continue;
                }
                if (score[ny][nx] != INF)
                {
                    score[ny][nx] = score[y][x] + 1;
                    continue;
                }
                score[ny][nx] = score[y][x] + 1;
                qe.push(make_pair(nx, ny));
            }
        }
        int goal = score[h - 1][w - 1];
        if (goal != INF)
        {
            cout << score[h - 1][w - 1] + 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3088