akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

template <typename T> inline bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> inline bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

using Real = long double;
using Point = complex<Real>;
const Real EPS = 1e-12, PI = acos(-1.0L);

inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }

istream &operator>>(istream &is, Point &p) {
    Real a, b;
    is >> a >> b;
    p = Point(a, b);
    return is;
}

struct Circle {
    Point p;
    Real r;

    Circle() = default;

    Circle(Point p, Real r) : p(p), r(r) {}
};

using Points = vector<Point>;
using Circles = vector<Circle>;

bool intersect(Circle c1, Circle c2) {
    if(c1.r < c2.r) swap(c1, c2);
    Real d = abs(c1.p - c2.p);
    if(c1.r + c2.r < d || c1.r - c2.r > d) return false;
    return true;
}

pair<Point, Point> crossPoint(const Circle &c1, const Circle &c2) {
    Real d = abs(c1.p - c2.p);
    Real a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
    Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
    Point p1 = c1.p + Point(cos(t + a) * c1.r, sin(t + a) * c1.r);
    Point p2 = c1.p + Point(cos(t - a) * c1.r, sin(t - a) * c1.r);
    return make_pair(p1, p2);
}

int N, K;
Points P;
vector<int> c;
Circles C;

bool isOk(long double mid) {
    rep(i, N) C[i] = Circle(P[i], mid / c[i]);
    Points Check;
    rep(i, N) {
        Check.push_back(P[i]);
        rep(j, i) if(intersect(C[i], C[j])) {
            pair<Point, Point> tmp = crossPoint(C[i], C[j]);
            Check.push_back(tmp.first);
            Check.push_back(tmp.second);
        }
    }
    for(Point p : Check) {
        int cnt = 0;
        rep(i, N) if(abs(P[i] - p) <= C[i].r + EPS) cnt++;
        if(cnt >= K) return true;
    }
    return false;
}

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

    cin >> N >> K;
    P.resize(N);
    c.resize(N);
    C.resize(N);
    rep(i, N) cin >> P[i] >> c[i];

    long double ok = 1e6, ng = 0;
    while(ok - ng > 1e-6) {
        long double mid = (ng + ok) / 2;
        (isOk(mid) ? ok : ng) = mid;
    }
    cout << fixed << setprecision(20) << ok << endl;
}

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


void solve(long long N, std::vector<long long> a){
    int k=1;
    rep(i,N){
        if(k==a[i])k++;
    }
    k--;
    if(k==0)cout<<-1<<endl;
    else cout<<N-k<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,k,a[200010];
vector<int> v1,v2;

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	int cnt=0ll;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<0ll) v1.push_back(a[i]);
		else if(a[i]>0ll) v2.push_back(a[i]);
		else cnt++;
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	int cnt1=v1.size()*v2.size();
	int cnt2=cnt*(n-cnt)+cnt*(cnt-1ll)/2ll;
	if(k<=cnt1){
		int l=-1000000000000000000ll,r=-1ll,ans=-1ll;
		while(l<=r){
			int mid=(l+r)/2ll;
			int num=0ll;
			for(int i=0;i<v1.size();i++){
				int val=(-mid)/(-v1[i])+((-mid)%(-v1[i])!=0);
				int pos=lower_bound(v2.begin(),v2.end(),val)-v2.begin();
				num+=v2.size()-pos;
			}
			if(num>=k){
				ans=mid;
				r=mid-1ll;
			}
			else l=mid+1ll;
		}
		cout<<ans<<endl;
	}
	else if(k<=cnt1+cnt2){
		cout<<0ll<<endl;
	}
	else{
		int l=1ll,r=1000000000000000000ll,ans=1ll;
		while(l<=r){
			int mid=(l+r)/2ll;
			int num=0ll;
			for(int i=0;i<v1.size();i++) if(v1[i]*v1[i]<=mid) num--;
			for(int i=0;i<v2.size();i++) if(v2[i]*v2[i]<=mid) num--;
			for(int i=0;i<v1.size();i++){
				int val=-(mid/(-v1[i]));
				int pos=lower_bound(v1.begin(),v1.end(),val)-v1.begin();
				num+=v1.size()-pos;
			}
			for(int i=0;i<v2.size();i++){
				int val=mid/v2[i];
				int pos=upper_bound(v2.begin(),v2.end(),val)-v2.begin()-1;
				num+=pos+1ll;
			}
			num/=2ll;
			if(num+cnt1+cnt2>=k){
				ans=mid;
				r=mid-1ll;
			}
			else l=mid+1ll;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3572
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int cnt = 0;
		int same = 1;
		while (same < n) {
			same += k - 1;
			cnt++;
		}
		out.println(cnt);

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

int n, k;
int x[100000];

signed main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) cin >> x[i];
	
	int ans = 1145141919;
	for (i = 0; i < n; i++) {
		if (i + k - 1 >= n) break;
		int l = x[i];
		int r = x[i + k - 1];
		int dist;
		
		if (l >= 0) { dist = r; }
		else if (r <= 0) { dist = -l; }
		else { dist = min(-2 * l + r, 2 * r - l); }
		ans = min(ans, dist);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

dist = [0] * (N + 1)
seen = [False] * (N + 1)
seen[1] = True
node = [1]

for _ in range(Q):
    p, x = map(int, input().split())
    dist[p] += x

while node:
    s = node.pop()
    d = dist[s]
    for t in edge[s]:
        if seen[t]:
            continue
        dist[t] += d
        seen[t] = True
        node.append(t)

print(*dist[1:])

Measured memory_bytes: 55800
#include<stdio.h>

int main(){

  int n,p[101],m[101][101];
  int i,j,k,l,s;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
     scanf("%d %d",&p[i-1],&p[i]);
 }

  for(i=1;i<=n;i++){
     m[i][i] = 0;
   }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = 10000000000;
      for(k=i;k<j;k++){
        s= m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        if(m[i][j]>s){
          m[i][j]=s;
        }
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}



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

int main(void){
    string A,B,C;
    cin>>A>>B>>C;
    if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}


fn main() {
    let (l, r, d) = input_tuple();
    println!("{}", r / d - (l - 1) / d);
}


Measured memory_bytes: 2072
#include<stdio.h>
int main(void)
{
	int a,b,c,g,t,i;
	while(1){
	scanf("%d",&a);
	if(a==0)
	{
		break;
	}
	g=1000-a;
	t=(g/500)+(g%500/100)+(g%500%100/50)+(g%500%100%50/10)+(g%500%100%50%10/5)+(g%500%100%50%10%5);
	printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cstring>
#include <istream>
#include<cmath>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
char a[2][3], b[2][3];	
int flag = 0;
int main()
{
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			b[2 - i - 1][3 - j - 1] = a[i][j];
		}
	}
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (a[i][j] != b[i][j])
			{
				flag = 1;
				break;
			}
		}
	}
	if (flag)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,n,taro=0,hanako=0; 
        String[] str = new String[200];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(in.readLine());
        for(i=0;i<n;i++){
            str = in.readLine().split(" ",-1);
            if(str[0].compareToIgnoreCase(str[1])>0) taro+=3;
            if(str[0].compareToIgnoreCase(str[1])<0) hanako+=3;
            else if(str[0].compareToIgnoreCase(str[1])==0){
                taro+=1;
                hanako+=1;
            }
        }
        System.out.println(taro+" "+hanako);
        System.out.flush();
    }
}

Measured memory_bytes: 25080
#include<iostream>
using namespace std;
int main()
{
	int n, i, j;
	cin >> n;
	int a[n], b[n];
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	int q, m, e, x, k;
	
	cin >> q;
	while (q--)
	{
		cin >> x >> m >> e;
		for (k = 0; k < e-x; k++)
		{
			i = x + k;
			j = x + ((k + (e - m))%(e - x));
			b[j] = a[i];
		}
		for (i = 0; i < n; i++)	
			a[i] = b[i];
	}
	
	for (i = 0; i < n; i++)
	{
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3096
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;

int Query(int ans)
{
    char ret[20];
    printf("%d\n", ans);
	fflush(stdout);
    scanf("%s", ret);
    if(ret[0] == 'V') exit(0);
    return ret[0] == 'M' ? 1 : 0;
}

int main()
{
    scanf("%d",&n);
    int l=0,r=n-1;
    int ss=Query(l);
    while(l<=r)
    {
        int mid=(l+r)>>1;
        int ns=Query(mid);
        if((ss==ns)==((mid+1)%2))
            l=mid+1;
        else
            r=mid-1;
    }
}


Measured memory_bytes: 760
from itertools import combinations

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

combi = list(combinations(range(N), 2))

ans = 0
for Y, Z in combi:
    dist = 0
    for i in range(D):
        dist += (X[Y][i] - X[Z][i])**2
    if dist**0.5 <= int(dist**0.5):
        ans += 1

print(ans)


Measured memory_bytes: 9344
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

ll GCD(ll x,ll y){
	return y==0?x:GCD(y,x%y);
}

int main(void){
	ll A,B,C,D,ans=0;
	scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
	ll c,d,cd;
	ll l=C*D/GCD(C,D);
	
	c = B/C -(A-1)/C;
	d = B/D -(A-1)/D;
	cd = B/l -(A-1)/l;
	ans=(B-A+1)-(c+d-cd);
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <iostream>
#include<algorithm>
#include <queue>
#include <vector>
#include<string>
//******************************************************
#define lrt (rt*2)
#define rrt  (rt*2+1)
#define LL long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define exp 1e-8
const double temp=(1+sqrt(5))/2;
//***************************************************
#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair

#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)
using namespace std;
const int maxn=1e5+10;
int pre[maxn];
void iint()
{
    for(int i=0;i<maxn;i++) pre[i]=i;
}
int find(int x)
{
    return x==pre[x]?x:find(pre[x]);
}
void join(int x,int y)
{
    int fx=find(x),fy=find(y);
    if(fx!=fy)  pre[fx]=fy;
}
int main()
{
    int n,k,num;
    char str[5];
    while(cin>>n>>k)
    {
        LL sum=0;
        if(n+k==0)  break;
        iint();
        for(int i=2;i<=n;i++)
        {
            scanf("%d",&pre[i]);
        }
        while(k--)
        {
            scanf("%s%d",str,&num);
            if(str[0]=='M') pre[num]=num;
            else if(str[0]=='Q')    sum+=find(num);
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3540
package main

import (
	"fmt"
)

var num int

func main() {
	fmt.Scan(&num)
	ans := calc(num)
	fmt.Printf("%d", ans)
}

var can int

func calc(people int) int {
	for i := 0; i <= people; i++ {
		can += i
	}
	return can
}

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

int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  bool b = false;
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  for(int i = 0; i < N; i++) {
    if(S.at(i) == 'Y') {
      b = true;
      break;
    }
  }
  if(b == true) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

ll getDigit(ll n) {
    ll digit = 0;
    while (n > 0) {
        n /= 10;
        digit++;
    }
    return digit;
}

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

    ll Min = 1e13;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i != 0) continue;
        ll big = max(getDigit(i), getDigit(n/i));
        Min = min(Min, big);
    }

    cout << Min << endl;

    return 0;
}

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

using namespace std;

#define LL long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)

inline int Read() {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a,T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a,T const&b) {
	return a<b?a=b,1:0;
}

const int N=15;

char S[5];

int L,R;

int main() {
	L=Read(),R=Read();
	if(L+2018<=R)return !puts("0");
	int Ans=1e9;
	ret(i,L,R)rep(j,i+1,R)Min(Ans,((i%2019)*(j%2019))%2019);
	cout<<Ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int xmin,xmax,ymin,ymax;
int main() {
    int w,h,n,x,y,a,s=0;
   
    cin>>w>>h>>n;
    xmax=w,ymax=h;
    for(int i=1;i<=n;i++)
    {     
    	 cin>>x>>y>>a;
    	 
    	 switch (a){
    	 	case 1:xmin=max(xmin,x);break;
    	 	case 2:xmax=min(xmax,x);break;
    	 	case 3:ymin=max(ymin,y);break;
    	 	case 4:ymax=min(ymax,y);break;
		 }
    }
    if((xmax-xmin)<0||(ymax-ymin)<0)cout<<0;
    else cout<<(xmax-xmin)*(ymax-ymin);
    
}

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

using namespace std;


int main()
{
    string a, b;
    cin >> a >> b;
    long len = a.size();
    vector<int> s_to_t(26);
    vector<int> t_to_s(26);
    for (int j = 0; j < 26; ++j) {
        s_to_t[j] = -1;
        t_to_s[j] = -1;
    }

    bool yes = true;
    for (int i=0;i<len;i++) {
        int num_a = a[i] - 'a';
        int num_b = b[i] - 'a';

        if (s_to_t[num_a] == -1) {
            s_to_t[num_a] = num_b;
        } else {
            if (s_to_t[num_a] != num_b) {
                yes = false;
            }
        }

        if (t_to_s[num_b] == -1) {
            t_to_s[num_b] = num_a;
        } else {
            if (t_to_s[num_b] != num_a) {
                yes = false;
            }
        }
    }
    if (yes) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 776
w, h, n = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]

x_min = 0
y_min = 0
x_max = w
y_max = h

for i in range(n):
    if p[i][2] == 1:
        x_min = max(x_min, p[i][0])
    elif p[i][2] == 2:
        x_max = min(x_max, p[i][0])
    elif p[i][2] == 3:
        y_min = max(y_min, p[i][1])
    else:
        y_max = min(y_max, p[i][1])

w_l = x_max - x_min
h_l = y_max - y_min

if w_l > 0 and h_l > 0:
    print(w_l * h_l)
else:
    print(0)

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

unsigned long long greatestCommonDiviser(unsigned long long x, unsigned long long y) {
	return y == 0 ? x : greatestCommonDiviser(y, x%y);
}

int main()
{
	unsigned long long a, b;
	cin >> a >> b;

	unsigned long long gcd = greatestCommonDiviser(a, b);

	unsigned long long sm = sqrt(gcd);
	++sm;

	unsigned long long ret = 1;
	if (gcd % 2 == 0) {
		++ret;
	}
	while (gcd % 2 == 0) {
		gcd /= 2;
	}

	for (unsigned long long i = 3; i <= sm; i += 2) {
		if (gcd % i == 0) {
			++ret;
		}
		while (gcd % i == 0) {
			gcd /= i;
		}
	}

	if (gcd != 1) {
		++ret;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()        //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;        //P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;
    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }
    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }
    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }
    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }
    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }
    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

int main() {
    ll N,K;
    cin>>N>>K;
    rep1(i,K+1){
/*      cerr<<comb(K-1,i-1)<<endl;
        cerr<<comb(N-K+1,i)<<endl;*/
        ll ans = 1;
        ans *= C(K-1,i-1)%MOD;
        ans *= C(N-K+1,i)%MOD;
        ans %= MOD;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
#include <string>
using namespace std;

#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define debug(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;

ll tf,af;

void change(int ti,int ai){
  ll k=max((ai+af-1)/ai,(ti+tf-1)/ti);//切り上げ計算
  tf=ti*k;
  af=ai*k;
}

int main(void) {
  int n;
  std::cin >> n;
  vector<int> t(n),a(n);
  REP(i,n)  std::cin >> t[i] >> a[i];
  tf=t[0]; af=a[0];
  FOR(i,1,n)  change(t[i],a[i]);
  std::cout << (ll)tf+af << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;
int N;
long S[1<<17],T[2155];
map<long,int>M;
main()
{
	cin>>N;
	for(int i=1;i<=2154;i++)T[i]=1L*i*i*i;
	long Max=0;
	for(int i=0;i<N;i++)
	{
		cin>>S[i];
		for(int j=2;j<=2154&&T[j]<=S[i];j++)
		{
			while(S[i]%T[j]==0)S[i]/=T[j];
		}
		M[S[i]]++;
		Max=max(Max,S[i]);
	}
	int ans=0;
	if(M.find(1)!=M.end())ans=1;
	for(map<long,int>::iterator it=M.begin();it!=M.end();it++)
	{
		if(it->first==1||it->second==0)continue;
		long A=it->first,B=1;
		for(long j=2;j*j*j<=A;j++)
		{
			if(A%j==0)
			{
				if(A/j%j)
				{
					A/=j;
					B*=j*j;
				}
				else
				{
					A/=j*j;
					B*=j;
				}
			}
		}
		if(A>1)
		{
			long T=sqrt(A);
			for(long t=max(1L,T-2);t<=T+2;t++)
			{
				if(A%(t*t)==0)
				{
					B*=t;
					A/=t*t;
				}
			}
			if(A>1)
			{
				if((Max+A-1)/A<B)
				{
					B=Max+1;
				}
				else
				{
					B*=A;
					if((Max+A-1)/A<B)
					{
						B=Max+1;
					}
					else B*=A;
				}
			}
		}
		if(M.find(B)==M.end())
		{
			ans+=it->second;
			it->second=0;
		}
		else
		{
			ans+=max(it->second,M[B]);
			it->second=M[B]=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
void solve()
{
		lli n,x,t;
		cin>>n>>x>>t;
		lli tem=n/x;
		if(n%x!=0)tem++;
		cout<<tem*t;


}
 
int main()
{
/////////////////////////////////////
    fastio;
    
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    m=1;
    while(t--)
    {
    	//cout<<"Case #"<<m<<":"<<endl;
    	solve();  
    	m++;  
    }
}

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

int main() {
	char c[] = "MARCH";
	vector<int> a(5);
	int n;
	cin >> n;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < 5; j++) {
			if (s[0] == c[j])
				a[j]++;
		}
	}
	long long ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += (long long) a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int head,leg;
    cin >> head >> leg;
    if(leg%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    else{//leg%2==0
        if(((leg/2-head)>=0)&&((2*head-leg/2)>=0)){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3636
import math
D, G = [int(i) for i in input().split()]
data_ls = list()
for i in range(D):
    data_ls.append([int(i) for i in input().split()])
ps, cs = zip(*data_ls)

def search(cnt, sum, flg, rest_max):
    if sum >= G:
        return cnt
    if flg == len(data_ls):
        if sum + (ps[rest_max] - 1) * 100 * (rest_max + 1) >= G:
            return cnt + math.ceil((G - sum) / (100 * (rest_max+1)))
        else:
            return 1e9
    cnt = min(search(cnt + ps[flg], sum + (ps[flg] * 100 * (flg+1) + cs[flg]), flg + 1, rest_max),
              search(cnt, sum, flg + 1, flg))
    return cnt

print(search(0,0,0,0))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt();
		System.out.println(a+a*a+a*a*a);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int main(){
  int n,ans=1;string s;cin>>n>>s;
  if(n%2) ans=0;
  else REP(i,n/2) if(s.at(i)!=s.at(i+n/2)) ans=0;
  cout<<(ans?"Yes":"No");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int N, K;
	cin >> N >> K;
	
	vector<int> x(N);
	rep(i, N) cin >> x[i];
	
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += min(2 * x[i], 2 * (abs(K - x[i])));
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  int R = nextInt();
  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    x = 2
    while (x-1)*x//2 < n:
        x += 1
    if (x-1)*x//2 == n:
        print("Yes")
        ans = [[] for _ in range(x)]
        y = 1
        for i in range(x-1):
            for j in range(i+1, x):
                ans[i].append(y)
                ans[j].append(y)
                y += 1
        print(x)
        for i in range(x):
            print(len(ans[i]), end=" ")
            for j in range(len(ans[i])):
                print(ans[i][j], end="")
                if j < len(ans[i])-1:
                    print(" ", end="")
                else:
                    print("")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9772
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
 ll n ; cin>> n ;
 vector<char> A(n) ;
 rep(i,n){
   cin>>A[i] ;
 }
 ll p=0 ; 
 ll q=0 ;
 rep(i,n){
   if(A[i]=='R') q ++ ;
 }
 ll ans= max(p,q) ;


 rep(i,n){
   if(A[i]=='R') q-- ;
   else p++ ;
   chmin(ans,max(p,q)) ;
 }
 cout<<ans<<endl ;
   return 0 ;
 }



Measured memory_bytes: 3612
//Coded by not_surrender
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define MAXN 300003
#define MOD 1000000007
#define oo (1<<20)
#define mid ((a+b)/2)
#define pb push_back
#define sz size()
#define fastCpp() ios_base::sync_with_stdio( false ), cin.tie( NULL ), cout.tie( NULL )

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;

int N, A[MAXN], ans, best[2];
 
int main(){

    #ifndef ONLINE_JUDGE
		//~ freopen( "a.txt", "r", stdin );
    #endif // ONLINE_JUDGE
    
    fastCpp();
    
    scanf( "%d", &N );
    
    N = 1<<N;
    
    for ( int i = 0; i < N; ++i )
		scanf( "%d", &A[i] );
		
	for ( int i = 1; i < N; ++i ){
		best[0] = A[0];
		best[1] = 0;
		for ( int j = i; j; j = (j-1)&i )
			if ( A[j] > best[0] )
				best[1] = best[0], best[0] = A[j];
			else
				if ( A[j] > best[1] )
					best[1] = A[j];
		ans = max( ans, best[0]+best[1] );
		printf( "%d\n", ans );
	}
	
return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  if(n<1200)
  puts("ABC");
  else
  puts("ARC");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (998244353LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    string X;
    cin >> N >> X;
    
    set<int> Div;
    for (int n = 1; n * n <= N; ++n) {
        if (N % n == 0) {
            Div.emplace(n);
            Div.emplace(N/n);
        }
    }
    
    ll Res = 0;
    map<int, ll> mapDivToNum;
    for (int d : Div) {
        int Rep = N/d;
        if (Rep%2 == 0) continue;
        int Score = 2 * d;
        
        ll Temp = 0;
        for (int i = 0; i < d; ++i) {
            (Temp *= 2) %= MOD;
            if (X[i] == '1') (Temp += 1) %= MOD;
        }
        string A = X.substr(0, d);
        string B;
        for (char a : A) {
            if (a == '0') B.push_back('1');
            else B.push_back('0');
        }
        string Y;
        for (int r = 0; r < Rep; ++r) {
            if (r % 2 == 0) {
                Y += A;
            } else {
                Y += B;
            }
        }
        if (Y <= X) {
            (Temp += 1) %= MOD;
        }
        
        (Temp += mapDivToNum[d]) %= MOD;
        
        for (int d2 : Div) {
            if (d2 % d == 0) {
                (mapDivToNum[d2] += (MOD - Temp)) %= MOD;
            }
        }
        
        (Res += Score * Temp) %= MOD;
    }

    cout << Res << endl;
    
    return 0;
}


Measured memory_bytes: 1112
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

  ll n,x,t,cnt=0;
   cin>>n>>x>>t;

   if(n < x){
      cout<<t<<endl;
       return 0; }
  else {
     while(n >x || n>0){
      cnt += t;
      n -= x;
  }

  }

  cout<<cnt<<endl;

 return 0;
 }

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

bool isprime(int x){
	for(int i = 2; i < x; i++){
		if(x%i == 0) return false;
	}
	return true;
}

int main(){
	int n;
	cin>>n;
	
	for(int i = 31; i <= 55555 && n;i+=30){
		if(isprime(i)){
		 cout<<i<<" ";
		n--;
	 }
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
long long c;
long long x[MAXN];
int v[MAXN];
long long ans = 0;
long long l[MAXN], r[MAXN];
long long mxL[MAXN], mxR[MAXN];

int main() { 

  scanf("%d %lld", &n, &c);
  for (int i = 0; i < n; i++) {
    scanf("%lld %d", &x[i], &v[i]);
  }

  long long cur = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      cur -= x[i];
    } else {
      cur -= x[i] - x[i - 1];
    }
    cur += v[i];
    l[i] = cur;
    ans = max(ans, l[i]);
  }

  cur = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      cur -= c - x[i];
    } else {
      cur -= x[i + 1] - x[i];
    }
    cur += v[i];
    r[i] = cur;
    ans = max(ans, cur);
  }

  for (int i = 0; i < n; i++) {
    mxL[i] = l[i];
    if (i > 0) {
      mxL[i] = max(mxL[i - 1], mxL[i]);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    mxR[i] = r[i];
    if (i + 1 < n) {
      mxR[i] = max(mxR[i + 1], mxR[i]);
    }
  }

  for (int i = 0; i < n; i++) {
    long long cur = l[i];
    cur -= x[i];
    if (i + 1 < n) {
      cur += mxR[i + 1];
    }
    ans = max(ans, cur);
  }
  for (int i = n - 1; i >= 0; i--) {
    long long cur = r[i];
    cur -= c - x[i];
    if (i > 0) {
      cur += mxL[i - 1];
    }
    ans = max(ans, cur);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    cout << (ll)pow(floor(sqrt(n)), 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

int main()
{
    int n;
    std::vector<char> s;
    std::cin >> n;
   
    std::string b;
    std::cin.ignore();

    long m[5] = {};
    
    for (int i = 0; i < n; i++) {
        std::getline(std::cin, b);
        if (b[0] == 'M')m[0]++;
        if (b[0] == 'A')m[1]++;
        if (b[0] == 'R')m[2]++;
        if (b[0] == 'C')m[3]++;
        if (b[0] == 'H')m[4]++;
    }

    long ans = 0;

    for (int i = 2; i < 5; i++) {
        for (int j = 1; j < i; j++) {
            for (int k = 0; k < j; k++) {
                ans += m[i] * m[j] * m[k];
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}



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

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

  int A;
  cin >> A;

  if(N >= 500){
    if(N % 500 == 0)cout << "Yes" << endl;
    else{
      if(N % 500 < A)cout << "Yes" << endl;
      else cout << "No" << endl;
    }

  }
  else{
    if(N < A){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c=0;
	for(int i=0;i<n-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
		c++;
	}
	cout<<c;
}

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int d[m][m],c[n][n],memo[3][30]={};
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			cin>>d[i][j];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin>>c[i][j];
			--c[i][j];
			++memo[(i+j)%3][c[i][j]];
		}
	}
	long long ans=1000000000000000LL;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			for (int k = 0; k < m; ++k)
			{
				if (i==j||j==k||k==i)
				{
					continue;
				}
				long long nans=0LL;
				for (int l = 0; l < m; ++l)
				{
					nans+=memo[0][l]*d[l][i];
					nans+=memo[1][l]*d[l][j];
					nans+=memo[2][l]*d[l][k];
				}
				ans=min(ans,nans);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(void){
    
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    long long ans;

        int sheet_Min = min(X, Y);
        int amari_A = X - sheet_Min;
        int amari_B = Y - sheet_Min;
        
        long long piza_AB = (A * X) + (B * Y);
        long long piza_ABC = (amari_A * A) + (amari_B * B) + (sheet_Min * (2 * C));
        long long piza_C = (amari_A * (2 * C)) + (amari_B * (2 * C)) + (sheet_Min * (2 * C));
        
        ans = min({piza_AB, piza_ABC, piza_C});
        
        cout << ans << endl;
}


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

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

    char table[H][W];
    bool H_output[H]={false}, W_output[W]={false};
    int  i, j;
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin >> table[i][j];
            if(table[i][j]=='#')
            {
                H_output[i] = true;
                W_output[j] = true;
            }
        }
    }
  
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            
            if(H_output[i] && W_output[j])
            {
                cout << table[i][j];
            }
        }
       if(H_output[i])
        {
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        getAns(n, q);
    }
    static void swap(ref LinkedList<int> a, ref LinkedList<int> b)
    {
        var temp = a;
        a = b;
        b = temp;
    }
    static void getAns(int n, int q)
    {
        var p = new LinkedList<int>[n];
        for (int i = 0; i < n; i++)
            p[i] = new LinkedList<int>();
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0")
            {
                var t = int.Parse(line[1]);
                var x = int.Parse(line[2]);
                p[t].AddLast(x);
            }
            else if (line[0] == "1")
            {
                var t = int.Parse(line[1]);
                Console.WriteLine(string.Join(" ", p[t]));
            }
            else
            {
                var s = int.Parse(line[1]);
                var t = int.Parse(line[2]);
                if (p[s].Count() < p[t].Count())
                {
                    foreach (var y in p[s])
                        p[t].AddLast(y);
                    p[s].Clear();
                }
                else
                {
                    var y = p[t].Last;
                    while (y != null)
                    {
                        p[s].AddFirst(y.Value);
                        y = y.Previous;
                    }
                    swap(ref p[s], ref p[t]);
                    p[s].Clear();
                }
            }
        }
    }
}



Measured memory_bytes: 66368
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007

def main():

    N, M = map(int, input().split())
    ac = [0 for _ in range(N)]
    wa = [0 for _ in range(N)]

    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            ac[p] = 1
        else:
            if ac[p] == 0:
                wa[p] += 1

    # print(ac)
    # print(wa)

    for i in range(N):
        if ac[i] == 0:
            wa[i] = 0

    print(str(sum(ac)) + " " + str(sum(wa)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 47792